VisualHMI staged application (system): expiration lock and set_stage_pwd

freeFree Technical Resource

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

Installments (Rental Lock): Automatically locks the screen at the agreed time, requiring a password to unlock. Suitable for device trials and installment payments. The system scheme is "Lock before expiration", and the custom scheme (see 04) is "Lock only upon expiration".

1. Configure

Project → Project Settings → Installment Usage: Enable installment, installment number (up to 10), lock screen ID before expiration, due date of each installment, and password.

VisualHMI staged application (system): expiration lock and set_stage_pwd插图

2. Lock Interface and System Registers

Place two numeric controls on the lock screen: password input bound to $SysStageEnterPwd (LW0205, INT32), and current installment number bound to $SysStageTimeLevel (LW0204, INT16, scaled by 1 with offset 1).

VisualHMI staged application (system): expiration lock and set_stage_pwd插图1

3. Installment Time Power-Loss Storage (LUA)

To change the installment time, write to system registers 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 staged application (system): expiration lock and set_stage_pwd插图2

4. Installment Password (Read-Only, Write-Only)

set_stage_pwd(level, pwd): level 0~9 corresponds to installments 1~10, and pwd is a numeric password. Write the password to the RW area for the first use (check flag bit 0x0055 to prevent duplicate initialization):

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 staged application (system): expiration lock and set_stage_pwd插图3

5. Restore and Switch

Restore installment writes SysCfgCtrl=0x5503; dynamic switching is achieved by writing LW0200 (installment number 0 or 1) + save. All operations involving installment writes to RW/system registers must be accompanied by SysCfgCtrl/SysCfgOption saves.

VisualHMI staged application (system): expiration lock and set_stage_pwd插图4

Installment password isFor those that only write and do not read: If you want the user to change the password or initialize, you need to create a mirror copy in the RW area and synchronize it using set_stage_pwd. Remember to save the changes by adjusting SysCfgCtrl(0x011A)/SysCfgOption(0x011B) each time, otherwise they will be lost during power-down.

Compiled from the VisualHMI development documentation of Guangzhou Dacai Technology (hmi-doc.gz-dc.com) and other technical tutorials "Staged Application (System)", the copyright belongs to 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 *.