From 9916635e9a1314396010248d13e8050d956a685d Mon Sep 17 00:00:00 2001 From: GuanYuankai Date: Tue, 25 Nov 2025 13:20:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/alarms.json | 38 ++++++++++++++++ config/config.json | 17 +++++++ config/devices.json | 98 ++++++++++++++++++++++++++++++++++++++++ config/video_config.json | 47 +++++++++++++++++++ docker-compose.yml | 13 ++++-- 5 files changed, 208 insertions(+), 5 deletions(-) create mode 100644 config/alarms.json create mode 100644 config/config.json create mode 100644 config/devices.json create mode 100644 config/video_config.json diff --git a/config/alarms.json b/config/alarms.json new file mode 100644 index 0000000..87c2052 --- /dev/null +++ b/config/alarms.json @@ -0,0 +1,38 @@ +[ + { + "rule_id": "RTU_TEMP_HIGH_CRITICAL", + "device_id": "rtu_temp_sensor_lab", + "data_point_name": "temperature", + "compare_type": "GT", + "threshold": 30, + "level": "CRITICAL", + "debounce_seconds": 60, + "alarm_mqtt_topic": "alarms/rtu_lab", + "message_template": "RTU温度传感器'{device_id}' 检测到温度过高 ({value}°C),已达临界值 {threshold}°C!", + "clear_message_template": "RTU温度传感器'{device_id}' 温度已恢复正常 ({value}°C)。" + }, + { + "rule_id": "TEST_TEMP_GT_10_WARNING", + "device_id": "rtu_temp_sensor_lab", + "data_point_name": "temperature", + "compare_type": "GT", + "threshold": 10, + "level": "CRITICAL", + "debounce_seconds": 0, + "alarm_mqtt_topic": "alarms/rtu_temp_sensor_lab", + "message_template": "测试告警 设备 '{device_id}' 温度 ({value}°C) 高于测试阈值 {threshold}°C!", + "clear_message_template": "【测试告警解除】设备 '{device_id}' 温度 ({value}°C) 已恢复正常。" + }, + { + "rule_id": "SYSTEM_MEM_HIGH", + "device_id": "proxy_system", + "data_point_name": "mem_usage_percentage", + "compare_type": "GT", + "threshold": 80, + "level": "WARNING", + "debounce_seconds": 30, + "alarm_mqtt_topic": "alarms/proxy", + "message_template": "代理系统内存使用率 ({value}%) 超过 {threshold}%,请检查!", + "clear_message_template": "代理系统内存使用率已恢复 ({value}%)。" + } +] \ No newline at end of file diff --git a/config/config.json b/config/config.json new file mode 100644 index 0000000..72548e2 --- /dev/null +++ b/config/config.json @@ -0,0 +1,17 @@ +{ + "alarm_rules_path": "alarms.json", + "config_base_path": "/app/config/", + "data_cache_db_path": "edge_data_cache.db", + "data_storage_db_path": "edge_proxy_data.db", + "device_id": "rk3588-proxy-002", + "log_level": "info", + "mqtt_broker": "tcp://localhost:1883", + "mqtt_client_id_prefix": "edge-proxy-", + "piper_executable_path": "/usr/bin/piper", + "piper_model_path": "/app/models/model.onnx", + "tcp_server_ports": [ + 12345 + ], + "video_config_path": "video_config.json", + "web_server_port": 8080 +} \ No newline at end of file diff --git a/config/devices.json b/config/devices.json new file mode 100644 index 0000000..59c9532 --- /dev/null +++ b/config/devices.json @@ -0,0 +1,98 @@ +{ + "modbus_rtu_devices": [ + { + "enabled": false, + "device_id": "rtu_temp_sensor_lab", + "port_path": "/dev/ttyS7", + "baud_rate": 9600, + "slave_id": 1, + "poll_interval_ms": 5000, + "data_points": [ + { + "name": "temperature", + "address": 0, + "type": "INT16", + "scale": 0.1 + }, + { + "name": "humidity", + "address": 1, + "type": "UINT16", + "scale": 0.1 + } + ] + }, + { + "enabled": false, + "device_id": "rotary encoder", + "port_path": "/dev/ttyS7", + "baud_rate": 9600, + "slave_id": 111, + "poll_interval_ms": 5000, + "data_points": [ + { + "name": "count", + "address": 1, + "type": "INT16", + "scale": 1 + }, + { + "name": "total_count", + "address": 2, + "type": "INT16", + "scale": 1 + } + ] + }, + { + "enabled": false, + "device_id": "backup_counter", + "port_path": "/dev/ttyS7", + "baud_rate": 9600, + "slave_id": 10, + "poll_interval_ms": 1000, + "data_points": [ + { + "name": "count", + "address": 32, + "type": "UINT32" + } + ] + } + ], + "modbus_tcp_devices": [ + { + "enabled": false, + "device_id": "plc_workshop1", + "ip_address": "192.168.1.120", + "port": 502, + "slave_id": 1, + "poll_interval_ms": 1000, + "data_points": [ + { + "name": "motor_speed", + "address": 100, + "type": "UINT16", + "scale": 1 + }, + { + "name": "pressure", + "address": 102, + "type": "FLOAT32", + "scale": 0.01 + }, + { + "name": "valve_status", + "address": 104, + "type": "UINT16", + "scale": 1 + } + ] + } + ], + "modbus_rtu_bus_configs": { + "/dev/ttyS7": { + "inter_device_delay_ms": 150 + } + } +} \ No newline at end of file diff --git a/config/video_config.json b/config/video_config.json new file mode 100644 index 0000000..99fd311 --- /dev/null +++ b/config/video_config.json @@ -0,0 +1,47 @@ +{ + "video_service": { + "enabled": true + }, + "video_streams": [ + { + "enabled": true, + "id": "cam_01_intrusion", + "input_url": "rtsp://admin:hzx12345@192.168.1.10:554/Streaming/Channels/1301", + "module_config": { + "class_num": 80, + "intrusion_zone": [ + 100, + 100, + 1820, + 1820 + ], + "label_path": "/app/models/coco_80_labels_list.txt", + "model_path": "/app/models/RK3588/yolov5s-640-640.rknn", + "rknn_thread_num": 3, + "time_threshold_sec": 3 + }, + "module_type": "intrusion_detection", + "output_rtsp": "rtsp://127.0.0.1:8554/ch1301" + }, + { + "enabled": false, + "id": "cam_01_intrusion", + "input_url": "rtsp://admin:hzx12345@192.168.1.10:554/Streaming/Channels/1301", + "module_config": { + "class_num": 3, + "intrusion_zone": [ + 100, + 100, + 1820, + 1820 + ], + "label_path": "/app/models/human.txt", + "model_path": "/app/models/human_detection.rknn", + "rknn_thread_num": 3, + "time_threshold_sec": 3 + }, + "module_type": "human_detection", + "output_rtsp": "rtsp://127.0.0.1:8554/ch1301" + } + ] +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 0860a47..e726891 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,11 +22,12 @@ services: - "110" - "29" volumes: - - prod_config_data:/app/config - + - ./config:/app/config + - ./models:/app/models - /tmp/.X11-unix:/tmp/.X11-unix:rw environment: - DISPLAY=$DISPLAY + - MQTT_HOST=127.0.0.1 dns: - 8.8.8.8 - 114.114.114.114 @@ -52,7 +53,9 @@ services: - ./mosquitto/config:/mosquitto/config - ./mosquitto/data:/mosquitto/data - ./mosquitto/log:/mosquitto/log + healthcheck: + test: ["CMD-SHELL", "mosquitto_sub -t '$SYS/#' -C 1 | grep -v Error || exit 1"] + interval: 10s + timeout: 10s + retries: 3 - -volumes: - prod_config_data: \ No newline at end of file