VisualHMI 分期应用(Customization):动态パスワード Lua 元表方案

freeFree Technical Resource

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

系统分期是「到期前锁定」,自定义分期是「到期才锁」——更贴合真实租赁场景。这篇用 Lua 元表封装,実装时间正確触发 + 动态パスワード(算法外置,不预存静态パスワード)。

1. 两种方案区别

维度系统方案(前置锁定)自定义方案(到期锁定)
触发时机設定后即生效当前时间 ≥ 截止时间才锁
用户感知提前被锁刚好到期被锁

2. 设计要点

  • 动态パスワード:由外部函数 password_func(date) 实时算(如年+月+日),不预存,防逆向
  • 超级パスワード:单一 uint32,一键全局解锁,现场运维兜底
  • 自チェック热更新:启动检测日期变更,設定修改后自动重写存储
  • ステータス持久化:time/switch/解锁进度存 VT_RW 非易失区,掉电不丢

3. 实例化(main.lua)

Stage.new(base_addr, stage_dates, password_func, super_password):

-- base_addr: VT_RW starting address,连续存储すべての設定
-- stage_dates: 3期截止日期リスト,必须递增
-- password_func: パスワード計算函数
-- super_password: 超级パスワード
dofile("stage.lua")
g_stage = Stage.new(0x1000,
  {{2023,11,1},{2023,12,1},{2024,1,1}},
  function(d) return d[1]+d[2]+d[3] end,
  123456)

モジュール用闭包 + 元表 OO 実装,サポート 1~10 期、ステータス全存 RW 区。核心判定 get_eligible_stage() 严格比对系统时间与截止日,now ≥ deadline 才锁屏。

VisualHMI 分期应用(Customization):动态パスワード Lua 元表方案イラスト

自定义分期比系统分期灵活,代价是要自己写 Lua モジュール(stage.lua)。最关键的动态パスワード不预存——パスワード算出来即弃,即使被人 dump 出 RW 区也只看到某期的结果,逆向不出算法。ステータス必须落 RW 区,否则再起動丢失解锁进度。

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

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