VisualHMI 分期应用(system):到期锁定与 set_stage_pwd

freeFree Technical Resource

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

分期(租赁锁机):到约定时间自动锁屏,输パスワード才解锁。适合デバイス试用、分期付款。系统方案是「到期前锁定」,自定义方案(见 04)是「到期才锁」。

1. 設定

工程 → 工程設定 → 分期使用:有効分期、分期数(最大10)、到期锁定画面 ID、每期到期日和パスワード。

VisualHMI 分期应用(system):到期锁定与 set_stage_pwdFigure

2. 锁定界面与システム·レジスタ

锁定画面放2つ数值控件:パスワード入力绑定 $SysStageEnterPwd(LW0205,UINT32)、当前期号绑定 $SysStageTimeLevel(LW0204,UINT16,Zoom1偏移1)。

VisualHMI 分期应用(system):到期锁定与 set_stage_pwdFigure1

3. 分期时间掉电存储(LUA)

改分期时间需写システム·レジスタ SysCfgCtrl(0x011A)/SysCfgOption(0x011B):

function on_update(slave,vtype,addr)
  if vtype == VT_LW then
    if addr >= 0x0210 and addr <= 0x0218 then  -- 5个分期时间アドレス
      set_uint16(VT_LW, 0x011B, (1<<5))  -- 選択分期パスワード
      set_uint16(VT_LW, 0x011A, 0x5501)   -- 保存
    end
  end
end

VisualHMI 分期应用(system):到期锁定与 set_stage_pwdFigure2

4. 分期パスワード(不读只写)

set_stage_pwd(level, pwd):level 0~9 对应分期1~10,pwd 为数字パスワード。首次使用把パスワード写入 RW 区(检测标识位 0x0055 防重复初期化):

function on_init()
  local _val = get_uint16(VT_RW, 0x2000)
  if _val ~= 0x0055 then
    set_uint32(VT_RW, 0x0000, 1111)
    set_uint32(VT_RW, 0x0002, 2222)
    set_uint32(VT_RW, 0x0004, 3333)
    set_uint32(VT_RW, 0x0006, 4444)
    set_uint32(VT_RW, 0x0007, 5555)
    set_uint16(VT_RW, 0x2000, 0x0055)
  end
  set_uint16(VT_LW, 0x011B, (1<<5))
  set_uint16(VT_LW, 0x011A, 0x5502)  -- 从set_stage_pwd后的パスワード加载
end

VisualHMI 分期应用(system):到期锁定与 set_stage_pwdFigure3

5. 恢复与开关

恢复分期写 SysCfgCtrl=0x5503;动态开关経由写 LW0200(分期数 0 或 1)+ 保存実装。すべての涉及分期的写 RW/システム·レジスタ操作都要配合 SysCfgCtrl/SysCfgOption 保存。

VisualHMI 分期应用(system):到期锁定与 set_stage_pwdFigure4

分期パスワード是只写不读的:你想让用户改パスワード或初期化,得自己在 RW 区镜像一份,再用 set_stage_pwd 同步。每次改完记着调 SysCfgCtrl(0x011A)/SysCfgOption(0x011B) 保存,否则掉电丢。

整理自 广州大彩科技 VisualHMI 开发ドキュメント(hmi-doc.gz-dc.com)其他技术チュートリアル「分期应用(system)」,著作権は大彩科技すべての。

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