@@ -62,12 +62,11 @@ class MPMBinding(BaseBinding):
6262 "AN" ,
6363 )
6464
65- # Server cache lifetime (60 FPS).
66- CACHE_LIFETIME = 1 / 60
65+ # Server data update rate (30 FPS).
66+ SERVER_DATA_UPDATE_RATE = 1 / 30
6767
6868 # Movement polling preferences.
6969 UNCHANGED_COUNTER_LIMIT = 10
70- POLL_INTERVAL = 0.1
7170
7271 # Speed preferences (mm/s to use coarse mode).
7372 COARSE_SPEED_THRESHOLD = 0.1
@@ -114,7 +113,7 @@ async def get_position(self, manipulator_id: str) -> Vector4:
114113 stage_z : float = manipulator_data ["Stage_Z" ]
115114
116115 # Wait for the stage to stabilize.
117- await sleep (self .POLL_INTERVAL )
116+ await sleep (self .SERVER_DATA_UPDATE_RATE )
118117
119118 return Vector4 (
120119 x = manipulator_data ["Stage_X" ],
@@ -182,7 +181,7 @@ async def set_position(self, manipulator_id: str, position: Vector4, speed: floa
182181 and unchanged_counter < self .UNCHANGED_COUNTER_LIMIT
183182 ):
184183 # Wait for a short time before checking again.
185- await sleep (self .POLL_INTERVAL )
184+ await sleep (self .SERVER_DATA_UPDATE_RATE )
186185
187186 # Update current position.
188187 current_position = await self .get_position (manipulator_id )
@@ -227,7 +226,7 @@ async def set_depth(self, manipulator_id: str, depth: float, speed: float) -> fl
227226 and unchanged_counter < self .UNCHANGED_COUNTER_LIMIT
228227 ):
229228 # Wait for a short time before checking again.
230- await sleep (self .POLL_INTERVAL )
229+ await sleep (self .SERVER_DATA_UPDATE_RATE )
231230
232231 # Get the current depth.
233232 current_depth = (await self .get_position (manipulator_id )).w
@@ -291,7 +290,7 @@ def unified_space_to_platform_space(self, unified_space: Vector4) -> Vector4:
291290 async def _query_data (self ) -> dict [str , Any ]: # pyright: ignore [reportExplicitAny]
292291 try :
293292 # Update cache if it's expired.
294- if get_running_loop ().time () - self .cache_time > self .CACHE_LIFETIME :
293+ if get_running_loop ().time () - self .cache_time > self .SERVER_DATA_UPDATE_RATE :
295294 # noinspection PyTypeChecker
296295 self .cache = (await get_running_loop ().run_in_executor (None , get , self ._url )).json ()
297296 self .cache_time = get_running_loop ().time ()
0 commit comments