201 lines
3.9 KiB
Plaintext
201 lines
3.9 KiB
Plaintext
modbus {
|
|
# 通信参数
|
|
transport rtu {
|
|
port /dev/ttyUSB0;
|
|
baudrate 9600;
|
|
parity none;
|
|
stopbits 1;
|
|
timeout 1s;
|
|
}
|
|
|
|
# 或TCP配置
|
|
transport tcp {
|
|
host 192.168.1.100;
|
|
port 502;
|
|
timeout 500ms;
|
|
}
|
|
|
|
# 日志设置
|
|
error_log /var/log/modbus_error.log;
|
|
access_log /var/log/modbus_access.log;
|
|
}
|
|
|
|
device boiler_controller {
|
|
# 设备标识
|
|
slave_id 1;
|
|
model "Siemens S7-1200";
|
|
description "Main boiler controller";
|
|
|
|
# 轮询间隔
|
|
poll_interval 5s;
|
|
|
|
# 重试策略
|
|
retries 3;
|
|
retry_timeout 2s;
|
|
|
|
# 数据点定义
|
|
metrics {
|
|
# 温度读取(保持寄存器)
|
|
temperature {
|
|
address 40001; # Modbus地址表示法
|
|
type int16;
|
|
scale 0.1;
|
|
unit "°C";
|
|
poll on;
|
|
}
|
|
|
|
# 压力传感器(输入寄存器)
|
|
pressure {
|
|
address 30001;
|
|
type uint16;
|
|
scale 0.01;
|
|
unit "kPa";
|
|
poll on;
|
|
}
|
|
|
|
# 状态位(线圈)
|
|
#alarm_status {
|
|
# address 00001;
|
|
# type bool;
|
|
# bits {
|
|
# 0 "overheat";
|
|
# 1 "low_pressure";
|
|
# 2 "pump_failure";
|
|
# }
|
|
# poll on;
|
|
#}
|
|
}
|
|
|
|
# 写入控制
|
|
controls {
|
|
# 启停控制
|
|
power_switch {
|
|
address 00010;
|
|
type bool;
|
|
safe_value off;
|
|
}
|
|
|
|
# PID设定值
|
|
pid_setpoint {
|
|
address 40010;
|
|
type float32;
|
|
min 0.0;
|
|
max 100.0;
|
|
precision 0.1;
|
|
}
|
|
}
|
|
}
|
|
|
|
device xyz {
|
|
# 设备标识
|
|
slave_id 1;
|
|
model "Siemens S7-1200";
|
|
description "Main boiler controller";
|
|
|
|
# 轮询间隔
|
|
poll_interval 5s;
|
|
|
|
# 重试策略
|
|
retries 3;
|
|
retry_timeout 2s;
|
|
|
|
# 数据点定义
|
|
metrics {
|
|
# 温度读取(保持寄存器)
|
|
temperature {
|
|
address 40001; # Modbus地址表示法
|
|
type int16;
|
|
scale 0.1;
|
|
unit "° C";
|
|
poll on;
|
|
}
|
|
|
|
# 压力传感器(输入寄存器)
|
|
pressure {
|
|
address 30001;
|
|
type uint16;
|
|
scale 0.01;
|
|
unit "kPa";
|
|
poll on;
|
|
}
|
|
|
|
# 状态位(线圈)
|
|
#alarm_status {
|
|
# address 00001;
|
|
# type bool;
|
|
# bits {
|
|
# 0 "overheat";
|
|
# 1 "low_pressure";
|
|
# 2 "pump_failure";
|
|
# }
|
|
# poll on;
|
|
#}
|
|
}
|
|
|
|
# 写入控制
|
|
controls {
|
|
# 启停控制
|
|
power_switch {
|
|
address 00010;
|
|
type bool;
|
|
safe_value off;
|
|
}
|
|
|
|
# PID设定值
|
|
pid_setpoint {
|
|
address 40010;
|
|
type float32;
|
|
min 0.0;
|
|
max 100.0;
|
|
precision 0.1;
|
|
}
|
|
}
|
|
}
|
|
|
|
processor temperature_processor {
|
|
# 输入源
|
|
input $boiler_controller.temperature;
|
|
|
|
# 数据转换
|
|
transform {
|
|
# 线性转换: raw * 0.1 + 2.5
|
|
linear 0.1 2.5;
|
|
|
|
# 滤波
|
|
moving_average 5;
|
|
|
|
# 范围检查
|
|
validate {
|
|
min -10.0;
|
|
max 150.0;
|
|
action log; # or 'discard', 'replace_with: value'
|
|
}
|
|
}
|
|
|
|
# 输出目标
|
|
#output {
|
|
# mqtt "sensors/boiler/temp";
|
|
# influxdb "plant_metrics" measurement="temperature";
|
|
#}
|
|
}
|
|
|
|
alarm high_temperature {
|
|
# 触发条件
|
|
condition $boiler_controller.temperature > 90.0;
|
|
|
|
# 持续判定
|
|
hold_time 30s;
|
|
|
|
# 动作
|
|
actions {
|
|
log "CRITICAL: Boiler temperature too high!";
|
|
mqtt "alarms/boiler";
|
|
email "ops@example.com";
|
|
exec "/usr/local/bin/shutdown_boiler.sh";
|
|
}
|
|
|
|
# 恢复动作
|
|
recovery_actions {
|
|
log "Boiler temperature back to normal";
|
|
}
|
|
} |