VisualHMI Warning Selection: on_select_warning displays disposal suggestions

freeFree Technical Resource

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

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

ParametersDescription
screen_idScreen ID
control_idControl ID
warning_idWarning ID
starttimeWarning Start Time (timestamp)
stoptimeWarning End Time (timestamp)
warning_textWarning 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
end

Typical scenario: Operators open an alert and the screen directly displays "How to handle this alert" - much faster than flipping through a manual.

Two pitfalls:① This API is only available in customized firmware, not in regular firmware;② The condition of Control ID≠0 + Allowed to be checked √ must be met simultaneously for, otherwise the selected action will not trigger a callback.

Compiled from Guangzhou Dacai Technology VisualHMI development documentation (hmi-doc.gz-dc.com) LUA tutorial "Alert Selection", copyright reserved by Dacai Technology.

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 address will not be published. Required fields are marked *.