Alarm selection callbackon_select_warning(screen_id, control_id, warning_id, starttime, stoptime, warning_text)(exclusive for customized firmware): This is triggered when the user selects an alarm. The alarm ID, start and end time, and text will be provided to you. The script can make disposal suggestions and display details.in the alarm list
1. Preconditions
- Alarm controlControl ID ≠ 0(like self-drawn controls, control ID 0 does not trigger)
- Alarm control is checkedAllow selection √
2. Callback parameters
| Parameters | Description |
|---|---|
| screen_id | Screen ID |
| control_id | Control ID |
| warning_id | Warning ID |
| starttime | Warning Start Time (timestamp) |
| stoptime | Warning End Time (timestamp) |
| warning_text | Warning Text |
3. Application: Provide disposal suggestions based on the Warning ID
g_Solution = {
[1] = "检查压缩机排气压力",
[2] = "检查冷凝器散热",
[3] = "检查制冷剂是否泄漏",
[100] = "检查水泵运行状态",
}
function make_datetime(ts)
-- 时间戳格式化,按需实现
return os.date("%Y-%m-%d %H:%M:%S", ts)
end
function on_select_warning(screen_id, control_id, warning_id,
starttime, stoptime, warning_text)
local sol = g_Solution[warning_id] or "暂无处置建议"
set_string(VT_LW, 0x1100, "告警ID:"..warning_id)
set_string(VT_LW, 0x1101, make_datetime(starttime))
set_string(VT_LW, 0x1102, sol) -- 处置建议显示到 LW1102
endTypical scenario: Operators open an alert and the screen directly displays "How to handle this alert" - much faster than flipping through a manual.
Compiled from Guangzhou Dacai Technology VisualHMI development documentation (hmi-doc.gz-dc.com) LUA tutorial "Alert Selection", copyright reserved by Dacai Technology.
Leave a Reply