我写的密码修改宏指令:
数值输入LW21并通知LB14,与多状态指示LW20叠合。
LB15选择用户1或用户2;
LB9054是密码变更禁允。
macro_command main() //【UPdataPswd】
unsigned short stepNum
unsigned int PSWD, xxIn
bool ON = true, OFF = false
bool xPWEN, PswSel
GetData(PswSel, "Local HMI", LB, 15, 1)
GetData(xxIn, "Local HMI", LW, 21, 1)
GetData(stepNum, "Local HMI", LW, 20, 1)
//
GetData(xPWEN, "Local HMI", LB, 9054, 1)
//
SetData(OFF, "Local HMI", LB, 9054, 1)
if stepNum == 0 then
SetData(xxIn, "Local HMI", LW, 25, 1)
stepNum = 1
else if stepNum == 1 then
GetData(PSWD, "Local HMI", LW, 25, 1)
if xxIn == PSWD then
SetData(ON, "Local HMI", LB, 9061, 1)
if not(PswSel) then
SetData(PSWD, "Local HMI", LW, 9500, 1)
else
SetData(PSWD, "Local HMI", LW, 9502, 1)
end if
stepNum = 2
else
stepNum = 3
end if
end if
//
xxIn = 0 确认密码已写入指定单元
if not(PswSel) then
GetData(xxIn, "Local HMI", LW, 9500, 1)
else
GetData(xxIn, "Local HMI", LW, 9502, 1)
end if
if (stepNum == 2) and (xxIn <> PSWD) then
stepNum = 3
end if
SetData(stepNum, "Local HMI", LW, 20, 1)
SetData(xxIn, "Local HMI", LW, 21, 1)
SetData(OFF, "Local HMI", LB, 14, 1)
//
SetData(xPWEN, "Local HMI", LB, 9054, 1)
SetData(OFF, "Local HMI", LB, 9061, 1)
if stepNum >= 2 then
DELAY(2100)
stepNum = 0
SetData(stepNum, "Local HMI", LW, 20, 1)
end if
end macro_command |