Files
AutoControlSystem-G/EMV/EMV_test_sensor.py
2025-07-29 13:16:30 +08:00

28 lines
822 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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()