import time class McuDebug(object): def __init__(self, mcu, is_debug=True, is_deviation=False): self.mcu = mcu self.is_debug = 1 if is_debug else 0 self.is_deviation = 1 if is_deviation else 0 def camera_high_motor(self, value): # 相机电机 self.mcu.to_device_move( device_name="camera_high_motor", value=value, max_speed=1400, up_speed=400, down_speed=100, _is_debug=self.is_debug, is_deviation=self.is_deviation, ) def camera_steering(self, value): # 相机舵机 self.mcu.to_device_move( device_name="camera_steering", value=value, _is_debug=self.is_debug, is_deviation=self.is_deviation, ) def turntable_steering(self, value): # 转盘舵机 self.mcu.to_device_move( device_name="turntable_steering", value=value, _is_debug=self.is_debug, is_deviation=self.is_deviation, ) def turntable_position_motor(self, value): # 转盘舵机 self.mcu.to_device_move( device_name="turntable_position_motor", value=value, max_speed=1400, up_speed=400, down_speed=100, _is_debug=self.is_debug, is_deviation=self.is_deviation, ) def overturn_steering(self, value): # 翻板舵机中位 self.mcu.to_device_move( device_name="overturn_steering", value=value, _is_debug=self.is_debug, is_deviation=self.is_deviation, ) def to_deal_device(self, device_name, value=1, _type=0, times=1): self.mcu.to_deal_device( device_name, value=value, _type=_type, times=times ) def photograph(self, goods_art_no=None): self.mcu.photograph(goods_art_no=goods_art_no) def __move_equipment(self, data): func_class = { "相机电机": self.camera_high_motor, "相机舵机": self.camera_steering, "转盘舵机": self.turntable_steering, "转盘前后电机": self.turntable_position_motor, } for key, value in data.items(): if key in func_class: func_class[key](value=value) time.sleep(0.1)