VisualHMI 告警选择:on_select_warning 显示处置建议

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

告警选择回调 on_select_warning(screen_id, control_id, warning_id, 시작time, stoptime, warning_text)(定制固件专属):用户在告警列表里选中某条告警时触发,把告警 ID、起止时间、文本都给你,脚本可以做处置建议、详情展示。

1. 前置条件

  • 告警控件control ID ≠ 0(和自绘控件一样,0 号控件不触发)
  • 告警控件勾选容许选中√

2. 回调参数

parameter说明
screen_id画面 ID
control_idcontrol ID
warning_id告警 ID
시작time告警开始时间(时间戳)
stoptime告警结束时间(时间戳)
warning_text告警文本

3. 应用:按告警 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,
                            시작time, 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(시작time))
  set_string(VT_LW, 0x1102, sol)      -- 处置建议显示到 LW1102
end

典型场景:运维人员点开一条告警,屏幕直接显示「这条告警该怎么处理」——比翻手册快得多。

两个坑:①定制固件才有此 API,普通固件没有;②必须 controlID≠0 + 容许选中√ 同时满足,否则选中动作不触发回调。

整理自 广州大彩科技 VisualHMI 开发文档(hmi-doc.gz-dc.com)LUA Tutorial「告警选择」,版权归大彩科技所有。

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email 주소 will not be published. Required fields are marked *.