VisualHMI 安全登录:分级授权与 set_pwd 密码管理

freeFree Technical Resource

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

安全登录:给界面控件分级授权,不同等级用户看/操作不同东西。支持 1~8 级(0 为游客),密码可配、可 Lua 改、可超时自动退出。

1. 配置

工程 → 工程设置 → 安全等级:设等级数、各级密码、保持登录、超时退出(秒)、返回画面、键盘位置(默认/居中)、用户名称。

VisualHMI 安全登录:分级授权与 set_pwd 密码管理插图

2. 超时退出登录

功能按钮切换画面时勾选「用户等级 → 最低要求等级」,等级不够弹键盘输密码。空闲超时自动退登录(保持登录启用才生效)。

VisualHMI 安全登录:分级授权与 set_pwd 密码管理插图1

3. 密码修改(LUA)

set_pwd(level, pwd, len):level 0~7 对应密码等级 1~8,pwd 数字密码,len 选填(前导零填充,如 len=5 则 123 存为 00123)。

密码不支持读取,初始化/修改时同步镜像到 RW 区:

function on_init()
  local _val = get_uint16(VT_RW, 0x2000)
  if _val ~= 0x0055 then
    set_uint32(VT_RW, 0x0000, 111111)
    set_uint32(VT_RW, 0x0002, 222222)
    set_uint32(VT_RW, 0x0004, 333333)
    set_uint32(VT_RW, 0x0006, 444444)
    set_uint32(VT_RW, 0x0008, 555555)
    set_pwd(0, 111111, 6); set_pwd(1, 222222, 6)
    set_pwd(2, 333333, 6); set_pwd(3, 444444, 6)
    set_pwd(4, 555555, 6)
    set_uint16(VT_RW, 0x2000, 0x0055)
    flash_sync()
  else
    set_pwd(0, get_uint32(VT_RW, 0x0000), 6)
    set_pwd(1, get_uint32(VT_RW, 0x0002), 6)
    -- ... 其余等级
  end
end

VisualHMI 安全登录:分级授权与 set_pwd 密码管理插图2

安全登录密码和分期密码一样只写不读,必须自己镜像到 RW 区。前导零是个坑:若用前导零(len=6 则 66 存为 000066),所有等级密码都得统一用前导零,否则匹配不上。改完 flash_sync() 保存。

整理自 广州大彩科技 VisualHMI 开发文档(hmi-doc.gz-dc.com)其他技术教程「安全登录」,版权归大彩科技所有。

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC 검증 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 *.