写不NG流程:添加传送带运行、步进电机移动、线条个数方便后续夹爪的抓取、气动夹爪控制流程
This commit is contained in:
@ -100,6 +100,7 @@ class RelayController:
|
||||
|
||||
self.press_sensors_thread = None # 保存按压开关线程对象
|
||||
self.press_sensors_monitor_running = False # 按压传感器监听线程运行标志
|
||||
self.last_press_sensor_status = False # 记录传感器上一次状态,初始为无信号(用于上升沿检测)
|
||||
|
||||
def send_command(self, command):
|
||||
"""
|
||||
@ -291,12 +292,16 @@ class RelayController:
|
||||
# 检测两个传感器任意一个是否触发
|
||||
press_sensor1_status = self.get_device_status(PRESS_SENSOR1, 'sensors')
|
||||
press_sensor2_status = self.get_device_status(PRESS_SENSOR2, 'sensors')
|
||||
if press_sensor1_status or press_sensor2_status:
|
||||
current_sensor_state = press_sensor1_status or press_sensor2_status
|
||||
|
||||
# 上升沿触发(仅从无信号-->有信号时,才触发事件)
|
||||
if current_sensor_state and not self.last_press_sensor_status:
|
||||
press_sensors_triggered.set() # 触发事件,通知主线程
|
||||
logging.info("双压传感器触发:线条已落到传送带")
|
||||
# 重置事件(等待下一次触发)
|
||||
time.sleep(0.1) # 防重复触发
|
||||
press_sensors_triggered.clear()
|
||||
|
||||
# 更新上一次传感器状态,为下一次上升沿检测做准备
|
||||
self.last_press_sensor_status = current_sensor_state
|
||||
# 传感器检测间隔
|
||||
time.sleep(check_interval)
|
||||
except Exception as e:
|
||||
logging.info(f"双压传感器监听异常: {e}")
|
||||
|
||||
Reference in New Issue
Block a user