添加了5个电磁阀+修改了传送带传感器的逻辑

This commit is contained in:
2026-01-29 18:30:22 +08:00
parent 070895f3dd
commit 17df13c08e
10 changed files with 670 additions and 512 deletions

View File

@ -204,8 +204,8 @@ class SingleMotorController:
current_time = time.time()
# 3. 检测到挡板且满足防抖条件
if (not sensor_status) and (not self.sensor_locked) and \
(current_time - self.last_sensor_trigger) > SENSOR_DEBOUNCE_TIME:
if sensor_status and (not self.sensor_locked) and \
(current_time - self.last_sensor_trigger) > SENSOR_DEBOUNCE_TIME:
print(
f"\n[传送带{self.conveyor_id}] [{datetime.now().strftime('%H:%M:%S')}] 检测到挡板!立即停止")
self.last_sensor_trigger = current_time
@ -298,7 +298,7 @@ class MasterConveyorController:
except Exception as e:
raise RuntimeError(f"485串口初始化失败: {e}")
def on_sensor_triggered(self):
def on_sensor_triggered(self, *args):
"""传感器触发回调(同步两个传送带停止)"""
with self.sync_lock:
# 检查是否两个传送带都已触发
@ -319,6 +319,8 @@ class MasterConveyorController:
self.conveyor1.start_motor_once()
self.conveyor2.start_motor_once()
time.sleep(0.5) # 等待挡板过去,后续看还需不需要修改参数
# 2. 启动传感器检测线程
self.conveyor1.start_sensor_thread(self)
self.conveyor2.start_sensor_thread(self)