Visual HMI LUAアラートの集中管理:warning_setバッチトリガと8スレーブParse

freeFree Technical Resource

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

警報の集中管理:warning_set(warning_id, value, count)アラームのアラーム+on_parse_warningアラームテキストをカスタマイズ。典型的なシナリオ:HMIはModbusからスレーブの障害ビットを読み取り、ビットごとにアラームにマップします。8台のスレーブ、各96アラーム、1つのコマンドがトリガーされます。

1. APIの概要

関数の機能説明書は
warning_set_mode(en)グローバルイネーブル1=オン/0=オフ
warning_set(warning_id, value, count)値の下位ビットがwarning_idからのアラートに対応します(ビット0→ warning_id,count 1~16)。
on_parse_warning(id, text, screen_id, control_id, p0, p1, p2, p3)カスタムアラートテキストコールバック、返値文字列、encode、encode 1=UTF-8/0=GBK

2. 8機× 96警報ケース

アーキテクチャ:8 台のスレーブがModbus 4 x 1000から連続した6つのレジスタを読み取る(16ビットx 6=96ビットアラーム)。on_initでcreate_resp_que、on_cmd_respでは、warning_setをレジスタごとに呼び出します。

_warning = {}   -0 x 1000~ 0 x 100 5の各ビットのアラーム名

function on_init
  set__read 0
  create_resp_que
  --アラーム設定に768個(8 台 × 96)をプロビジョニング
End of Endシングル

function on__resp slave vtype count ret wr
  r === 0とr == 0の場合
    --slaveスレーブ,addrから始まり,count個のレジスタを読み込む
    i = 0、5 do
      local val = get_uint16 vtype addr + i
      j = 0,15 doの場合
        local bitv = j 0x01
        local wid =-0x1000 * 16 + j + slave * 100
        warning_set wid bitv 1     --1ビットトリガー
      End of Endシングル
    End of Endシングル
  End of Endシングル
End of Endシングル

function on_parse_warning id text screen_id_id p0 p1 p2 p3
  local slave_no = math.floor id / 96 + 1   --マシン番号から
  ローカルmsg_id = ID % 96                      メッセージID:メッセージID
  local name =_warningTb [0x1000 + math.floor msg_id/ 16]または“不明な警告”
  local msg = "スレーブ".. slave_no.. " : "..名前は
  return msg 1      --1 = UTF-8
End of Endシングル

アラームIDコーディング規約:マシン番号×100 +桁のシーケンス番号から、解析時にプッシュバックします。アラート設定には768個すべてをプロビジョニングする必要があり、テキストはon_parse_warning(スレーブ番号のプレフィックスで)で動的に生成されます。768個のテキストを静的にプロビジョニングするよりもはるかに簡単です。

3つの穴warning_setの値の下位ビットは、warning_idからのアラートに対応します。ビット0→ warning_id、ビット1→ warning_id +1は、コマンドを実行するためのバッチトリガーです。カウントの範囲1 - 1 6何度も破壊する。on_parse_warningの戻り値1つ目はテキスト、2つ目はエンコーディングです。(1=UTF-8/0=GBK)、間違ったコードを使用しないでください。

広州大彩科技Visual HMI開発文書(hmi-doc.gz-dc.com)LUAチュートリアル“アラーム集中管理”より整理され、著作権は大彩科技が所有しています。

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 *.