完成中交三航控制系统

This commit is contained in:
cdeyw
2025-09-26 16:18:17 +08:00
parent 3ebc4c3765
commit 6b882a7e54
3 changed files with 42 additions and 2268 deletions

1153
Fedding.py

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,3 @@
# feeding/process.py
class FeedingProcess:
def __init__(self, relay_controller, inverter_controller,
transmitter_controller, vision_detector,
@ -17,6 +16,11 @@ class FeedingProcess:
print("下料已在进行中")
return
# 检查关键设备是否可连接
if not self._check_device_connectivity():
print("关键设备连接失败,无法开始下料")
return
print("开始分步下料过程")
# 重置计数器
self.state.lower_feeding_cycle = 0
@ -29,6 +33,43 @@ class FeedingProcess:
self.state.lower_feeding_stage = 4
self.wait_for_vehicle_alignment()
def _check_device_connectivity(self):
"""检查关键设备连接状态"""
try:
# 检查网络继电器连接
test_response = self.relay_controller.send_command(self.relay_controller.read_status_command)
if not test_response:
print("网络继电器连接失败")
return False
# 检查变频器连接
if not self.relay_controller.modbus_client.connect():
print("无法连接到网络继电器Modbus服务")
return False
# 尝试读取变频器一个寄存器(测试连接)
test_result = self.relay_controller.modbus_client.read_holding_registers(
address=0x00,
count=1,
slave=self.inverter_controller.config['slave_id']
)
if isinstance(test_result, Exception):
print("变频器连接测试失败")
return False
# 检查下料斗变送器连接
test_weight = self.transmitter_controller.read_data(2)
if test_weight is None:
print("下料斗变送器连接失败")
return False
self.relay_controller.modbus_client.close()
return True
except Exception as e:
print(f"设备连接检查失败: {e}")
return False
def transfer_material_from_upper_to_lower(self):
"""上料斗向下料斗下料"""
print(f"上料斗向下料斗下料 (第 {self.state.upper_feeding_count + 1} 次)")