测试模块

This commit is contained in:
cdeyw
2025-09-29 10:41:17 +08:00
parent bd7820df76
commit cf67e55d2c
7 changed files with 160 additions and 3 deletions

View File

@ -51,6 +51,11 @@ class InverterController:
def control(self, action):
"""控制变频器启停"""
# 先检查动作是否有效
if action not in ['start', 'stop']:
print(f"无效操作: {action}")
return False
try:
if not self.relay_controller.modbus_client.connect():
print("无法连接网络继电器Modbus服务")
@ -70,9 +75,6 @@ class InverterController:
slave=self.config['slave_id']
)
print("停止变频器")
else:
print(f"无效操作: {action}")
return False
if isinstance(result, Exception):
print(f"控制失败: {result}")