hvs2中增加氮气阀门控制
This commit is contained in:
@@ -23,6 +23,7 @@ def main():
|
||||
|
||||
light_state_update_time = 0.0
|
||||
xray_off_time = 0.0
|
||||
last_valve_time = 0.0
|
||||
|
||||
while True:
|
||||
try:
|
||||
@@ -47,8 +48,15 @@ def main():
|
||||
light_state_update_time = time.time()
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
if time.time() - last_valve_time > 10.0:
|
||||
io_module.control_valve(13, True)
|
||||
time.sleep(1)
|
||||
io_module.control_valve(13, False)
|
||||
last_valve_time = time.time()
|
||||
except KeyboardInterrupt:
|
||||
print("程序收到中断信号,正在退出...")
|
||||
io_module.control_valve(13, False)
|
||||
io_module.stop()
|
||||
hv_service.stop()
|
||||
mqtt_client.stop()
|
||||
|
||||
@@ -185,6 +185,13 @@ class TcpIoModule():
|
||||
print(f"写入线圈出错: {e}")
|
||||
self.is_connected = False
|
||||
|
||||
def control_valve(self, index, value):
|
||||
try:
|
||||
self.client.write_coil(index, value)
|
||||
except Exception as e:
|
||||
print(f"写入线圈出错: {e}")
|
||||
self.is_connected = False
|
||||
|
||||
def get_register_value(self, register_address):
|
||||
"""
|
||||
获取指定寄存器的值
|
||||
|
||||
Reference in New Issue
Block a user