@@ -84,6 +84,7 @@ def __init__(
8484 super ().__init__ ("SPAMetadataContext" , acquisition_software , token )
8585 self ._basepath = basepath
8686 self ._machine_config = machine_config
87+ self ._registered_squares : set [int ] = set ()
8788
8889 def post_transfer (
8990 self ,
@@ -243,39 +244,44 @@ def post_transfer(
243244 },
244245 )
245246
246- for fh , fh_data in fh_positions .items ():
247- capture_post (
248- base_url = str (environment .url .geturl ()),
249- router_name = "session_control.spa_router" ,
250- function_name = "register_foil_hole" ,
251- token = self ._token ,
252- instrument_name = environment .instrument_name ,
253- session_id = environment .murfey_session ,
254- gs_name = gs_name ,
255- data = {
256- "name" : fh ,
257- "x_location" : fh_data .x_location ,
258- "y_location" : fh_data .y_location ,
259- "x_stage_position" : fh_data .x_stage_position ,
260- "y_stage_position" : fh_data .y_stage_position ,
261- "readout_area_x" : fh_data .readout_area_x ,
262- "readout_area_y" : fh_data .readout_area_y ,
263- "thumbnail_size_x" : fh_data .thumbnail_size_x ,
264- "thumbnail_size_y" : fh_data .thumbnail_size_y ,
265- "pixel_size" : fh_data .pixel_size ,
266- "diameter" : fh_data .diameter ,
267- "tag" : visitless_source ,
268- "image" : fh_data .image ,
269- },
270- )
271- if fh_positions :
272- capture_post (
273- base_url = str (environment .url .geturl ()),
274- router_name = "session_control.spa_router" ,
275- function_name = "register_square" ,
276- token = self ._token ,
277- instrument_name = environment .instrument_name ,
278- session_id = environment .murfey_session ,
279- gsid = gs_name ,
280- data = {"tag" : visitless_source },
281- )
247+ if gs_name not in self ._registered_squares :
248+ for fh , fh_data in fh_positions .items ():
249+ capture_post (
250+ base_url = str (environment .url .geturl ()),
251+ router_name = "session_control.spa_router" ,
252+ function_name = "register_foil_hole" ,
253+ token = self ._token ,
254+ instrument_name = environment .instrument_name ,
255+ session_id = environment .murfey_session ,
256+ gs_name = gs_name ,
257+ data = {
258+ "name" : fh ,
259+ "x_location" : fh_data .x_location ,
260+ "y_location" : fh_data .y_location ,
261+ "x_stage_position" : fh_data .x_stage_position ,
262+ "y_stage_position" : fh_data .y_stage_position ,
263+ "readout_area_x" : fh_data .readout_area_x ,
264+ "readout_area_y" : fh_data .readout_area_y ,
265+ "thumbnail_size_x" : fh_data .thumbnail_size_x ,
266+ "thumbnail_size_y" : fh_data .thumbnail_size_y ,
267+ "pixel_size" : fh_data .pixel_size ,
268+ "diameter" : fh_data .diameter ,
269+ "tag" : visitless_source ,
270+ "image" : fh_data .image ,
271+ },
272+ )
273+ if fh_positions :
274+ capture_post (
275+ base_url = str (environment .url .geturl ()),
276+ router_name = "session_control.spa_router" ,
277+ function_name = "register_square" ,
278+ token = self ._token ,
279+ instrument_name = environment .instrument_name ,
280+ session_id = environment .murfey_session ,
281+ gsid = gs_name ,
282+ data = {
283+ "tag" : visitless_source ,
284+ "count" : len (self ._registered_squares ) + 1 ,
285+ },
286+ )
287+ self ._registered_squares .add (gs_name )
0 commit comments