28 lines
822 B
Python
28 lines
822 B
Python
|
|
#!/usr/bin/env python
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
import time
|
|||
|
|
from EMV import RelayController # 请根据你的实际模块名修改
|
|||
|
|
|
|||
|
|
def run_real_sensor_monitor():
|
|||
|
|
# 创建控制器实例
|
|||
|
|
controller = RelayController()
|
|||
|
|
|
|||
|
|
try:
|
|||
|
|
print("启动传感器1监听线程...")
|
|||
|
|
controller.start_sensor1_only() # 只启动传感器1的监听线程
|
|||
|
|
|
|||
|
|
print("开始监听真实传感器1信号,按 Ctrl+C 停止...")
|
|||
|
|
|
|||
|
|
# 主线程可以继续做其他事情,或者只是等待
|
|||
|
|
while True:
|
|||
|
|
time.sleep(1) # 保持主线程运行
|
|||
|
|
|
|||
|
|
except KeyboardInterrupt:
|
|||
|
|
print("\n检测到中断信号,正在停止传感器监听...")
|
|||
|
|
finally:
|
|||
|
|
controller.stop()
|
|||
|
|
print("程序已安全退出。")
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == '__main__':
|
|||
|
|
run_real_sensor_monitor()
|