stepper: improve speed

This commit is contained in:
Romain Bazile 2020-12-15 16:44:47 +01:00
parent f801d74c0e
commit dd77155c94

View file

@ -348,7 +348,6 @@ class StepperProcess(multiprocessing.Process):
def treat_command(self): def treat_command(self):
command = "" command = ""
if self.actuator_client.new_message_received():
logger.info("We received a new message") logger.info("We received a new message")
last_message = self.actuator_client.msg["payload"] last_message = self.actuator_client.msg["payload"]
logger.debug(last_message) logger.debug(last_message)
@ -366,7 +365,6 @@ class StepperProcess(multiprocessing.Process):
logger.warning( logger.warning(
f"We did not understand the received request {command} - {last_message}" f"We did not understand the received request {command} - {last_message}"
) )
return
def focus(self, direction, distance, speed=focus_max_speed): def focus(self, direction, distance, speed=focus_max_speed):
"""moves the focus stepper """moves the focus stepper
@ -507,22 +505,26 @@ class StepperProcess(multiprocessing.Process):
self.actuator_client.client.publish("status/focus", '{"status":"Ready"}') self.actuator_client.client.publish("status/focus", '{"status":"Ready"}')
logger.success("Stepper is READY!") logger.success("Stepper is READY!")
delay = 0.001
while not self.stop_event.is_set(): while not self.stop_event.is_set():
# check if a new message has been received if self.actuator_client.new_message_received():
self.treat_command() self.treat_command()
if self.pump_stepper.move(): if self.pump_stepper.move():
delay = 0.0001
planktoscope.light.ready() planktoscope.light.ready()
self.actuator_client.client.publish( self.actuator_client.client.publish(
"status/pump", "status/pump",
'{"status":"Done"}', '{"status":"Done"}',
) )
if self.focus_stepper.move(): if self.focus_stepper.move():
delay = 0.0001
planktoscope.light.ready() planktoscope.light.ready()
self.actuator_client.client.publish( self.actuator_client.client.publish(
"status/focus", "status/focus",
'{"status":"Done"}', '{"status":"Done"}',
) )
time.sleep(0.0001) time.sleep(delay)
delay = 0.001
logger.info("Shutting down the stepper process") logger.info("Shutting down the stepper process")
self.actuator_client.client.publish("status/pump", '{"status":"Dead"}') self.actuator_client.client.publish("status/pump", '{"status":"Dead"}')
self.actuator_client.client.publish("status/focus", '{"status":"Dead"}') self.actuator_client.client.publish("status/focus", '{"status":"Dead"}')