返回列表 发布新帖

TC系列HMI如何将用户权限更改为动态密码?

184 0
发表于 2024-7-10 18:16:53 | 查看全部 阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
<p>1、客户为了便于维护现场设备,但同时又避免终端客户随意修改设备参数,故采用动态密码赋予终端客户临时权限,动态密码每小时自动更新一次;</p><p><img src="/upload/article/20230131/1675144983896523.jpg" title="1675144983896523.jpg" alt="用户权限.jpg"/></p><p>2、如上图所示,此用户等级为不同级别的保护,但是密码均为固定不可自动变更的;</p><p><br/></p><p><img src="/upload/article/20230131/1675145105710814.jpg" title="1675145105710814.jpg" alt="权限设置.jpg"/></p><p>3、如上图所示,对数值输入对话框进行保护,并赋予密码6等级;</p><p><br/></p><p><img src="/upload/article/20230131/1675145191701780.jpg" title="1675145191701780.jpg" alt="动态密码宏.jpg"/></p><p>4、如上图所示,通过系统寄存器的运算和赋值,将用户等级更改为动态密码,此动态密码与时间相关,并赋予计算公式,得到密码赋给SRW10118,每次需要赋予终端客户临时权限时,只需根据计算公式算出密码,并将此密码告知终端用户即可。</p><p><br/></p><p>5、代码如下:</p><p><span style="color: #008000; ">#include &lt;macro.h&gt;</span><br/><br/><span style="color: #0000ff; font-weight: bold; ">int</span> <span style="color: #191970; font-weight: bold; ">MacroMain</span><span style="color: #006400; ">()</span><br/><span style="color: #006400; ">{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">// Here to add macro code.</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">unsigned</span> <span style="color: #ff0000; ">short</span> data<span style="color: #006400; ">[</span><span style="color: #00008b; ">4</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">{</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">};</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">unsigned</span> <span style="color: #ff0000; ">short</span> p1 <span style="color: #006400; ">=</span> <span style="color: #00008b; ">0</span><span style="color: #006400; ">;</span><span style="color: #008000; ">//年</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">unsigned</span> <span style="color: #ff0000; ">short</span> p2 <span style="color: #006400; ">=</span> <span style="color: #00008b; ">0</span><span style="color: #006400; ">;</span><span style="color: #008000; ">//月</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">unsigned</span> <span style="color: #ff0000; ">short</span> p3 <span style="color: #006400; ">=</span> <span style="color: #00008b; ">0</span><span style="color: #006400; ">;</span><span style="color: #008000; ">//日</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">unsigned</span> <span style="color: #ff0000; ">short</span> p4 <span style="color: #006400; ">=</span> <span style="color: #00008b; ">0</span><span style="color: #006400; ">;</span><span style="color: #008000; ">//时</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">unsigned</span> <span style="color: #0000ff; font-weight: bold; ">int</span> p5<span style="color: #006400; ">,</span>p6<span style="color: #006400; ">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">char</span> mima1<span style="color: #006400; ">[</span><span style="color: #00008b; ">8</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">{</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">};</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #ff0000; ">char</span> mima2<span style="color: #006400; ">[</span><span style="color: #00008b; ">8</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">{</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">};</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #191970; font-weight: bold; ">GetMem</span><span style="color: #006400; ">(</span>data<span style="color: #006400; ">,</span>@时间@<span style="color: #006400; ">,</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">,</span><span style="color: #00008b; ">4</span><span style="color: #006400; ">*</span><span style="color: #0000ff; font-weight: bold; ">sizeof</span><span style="color: #006400; ">(</span><span style="color: #ff0000; ">unsigned</span> <span style="color: #ff0000; ">short</span><span style="color: #006400; ">));</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;p1 <span style="color: #006400; ">=</span> data<span style="color: #006400; ">[</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;p2 <span style="color: #006400; ">=</span> data<span style="color: #006400; ">[</span><span style="color: #00008b; ">1</span><span style="color: #006400; ">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;p3 <span style="color: #006400; ">=</span> data<span style="color: #006400; ">[</span><span style="color: #00008b; ">2</span><span style="color: #006400; ">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;p4 <span style="color: #006400; ">=</span> data<span style="color: #006400; ">[</span><span style="color: #00008b; ">3</span><span style="color: #006400; ">];</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;p5<span style="color: #006400; ">=</span>p1<span style="color: #006400; ">*</span>p2<span style="color: #006400; ">+</span>p3<span style="color: #006400; ">*</span>p4<span style="color: #006400; ">;</span><span style="color: #008000; ">//计算公式</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;p6<span style="color: #006400; ">=</span>p4<span style="color: #006400; ">*</span><span style="color: #00008b; ">3600</span><span style="color: #006400; ">+</span>p2<span style="color: #006400; ">*</span><span style="color: #00008b; ">30</span><span style="color: #006400; ">;</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima1<span style="color: #006400; ">[</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">(</span>p5<span style="color: #006400; ">/</span><span style="color: #00008b; ">10000</span><span style="color: #006400; ">+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima1<span style="color: #006400; ">[</span><span style="color: #00008b; ">1</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p5<span style="color: #006400; ">%</span><span style="color: #00008b; ">10000</span><span style="color: #006400; ">/</span><span style="color: #00008b; ">1000</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima1<span style="color: #006400; ">[</span><span style="color: #00008b; ">2</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p5<span style="color: #006400; ">%</span><span style="color: #00008b; ">1000</span><span style="color: #006400; ">/</span><span style="color: #00008b; ">100</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima1<span style="color: #006400; ">[</span><span style="color: #00008b; ">3</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p5<span style="color: #006400; ">%</span><span style="color: #00008b; ">100</span><span style="color: #006400; ">/</span><span style="color: #00008b; ">10</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima1<span style="color: #006400; ">[</span><span style="color: #00008b; ">4</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p5<span style="color: #006400; ">%</span><span style="color: #00008b; ">10</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima2<span style="color: #006400; ">[</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">(</span>p6<span style="color: #006400; ">/</span><span style="color: #00008b; ">10000</span><span style="color: #006400; ">+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima2<span style="color: #006400; ">[</span><span style="color: #00008b; ">1</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p6<span style="color: #006400; ">%</span><span style="color: #00008b; ">10000</span><span style="color: #006400; ">/</span><span style="color: #00008b; ">1000</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima2<span style="color: #006400; ">[</span><span style="color: #00008b; ">2</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p6<span style="color: #006400; ">%</span><span style="color: #00008b; ">1000</span><span style="color: #006400; ">/</span><span style="color: #00008b; ">100</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima2<span style="color: #006400; ">[</span><span style="color: #00008b; ">3</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p6<span style="color: #006400; ">%</span><span style="color: #00008b; ">100</span><span style="color: #006400; ">/</span><span style="color: #00008b; ">10</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;mima2<span style="color: #006400; ">[</span><span style="color: #00008b; ">4</span><span style="color: #006400; ">]</span> <span style="color: #006400; ">=</span> <span style="color: #006400; ">((</span>p6<span style="color: #006400; ">%</span><span style="color: #00008b; ">10</span><span style="color: #006400; ">)+</span><span style="color: #00008b; ">0x30</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #191970; font-weight: bold; ">SetMem</span><span style="color: #006400; ">(</span>mima1<span style="color: #006400; ">,</span>@密码@<span style="color: #006400; ">,</span><span style="color: #00008b; ">0</span><span style="color: #006400; ">,</span><span style="color: #00008b; ">8</span><span style="color: #006400; ">);</span><br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #191970; font-weight: bold; ">SetMem</span><span style="color: #006400; ">(</span>mima2<span style="color: #006400; ">,</span>@密码@<span style="color: #006400; ">,</span><span style="color: #00008b; ">4</span><span style="color: #006400; ">,</span><span style="color: #00008b; ">8</span><span style="color: #006400; ">);</span>&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000080; ">return</span> <span style="color: #00008b; ">0</span><span style="color: #006400; ">;</span><br/><span style="color: #006400; ">}</span></p>

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright © 2001-2024 英威腾技术论坛 版权所有 All Rights Reserved. 粤ICP备07504406号
关灯 在本版发帖
扫一扫添加微信客服
返回顶部
快速回复 返回顶部 返回列表