def force_stop(self): message = PacketFactory.force_stop() response = self.serial_controller.send_request(message) if (response.data): self.set_running(False) self.step_request_lock.acquire() self.step_request_lock.release() return response
def step(self, target_pos=0): if self.is_running(): raise StepperExecutionException("Stepper is already running") self.set_running(True) message = PacketFactory.step_request(target_pos) response = self.serial_controller.send_request(message) if response.status == 10: self.set_running(True) raise StepperExecutionException("Stepper is already running") if response.status == message.status: self.set_running(False) self.position = response.data return response
def get_limit_switch(self, index): message = PacketFactory.get_limit_switch(index) response = self.serial_controller.send_request(message) return response
def set_position(self, position): self.position = position message = PacketFactory.set_position(self.position) self.serial_controller.send_request(message)
def set_switch_time(self, sw_time=None): if sw_time: self.switch_time = sw_time message = PacketFactory.set_step_delay(self.sw_time) self.serial_controller.send_request(message)
def zero_motor(self): message = PacketFactory.zero_motor() return self.serial_controller.send_request(message)
def get_step_delay(self): message = PacketFactory.get_step_delay() return self.serial_controller.send_request(message)
def set_step_delay(self, st_time=None): if (st_time): self.step_time = st_time message = PacketFactory.set_step_delay(self.step_time) return self.serial_controller.send_request(message)
def calibrate(self): message = PacketFactory.calibration_request() return self.serial_controller.send_request(message)
def force_stop(self): message = PacketFactory.force_stop() response = self.serial_controller.send_request(message) if (response.data): self.set_running(False) return response