macro_command main()
short A,B,C,Num,Value
short AS[3],BS[3],CS[3]
bool D
unsigned int PW[4]
unsigned int PW_in
int x1=1,x0=0
bool off=0,on=1
int x42=42,x43=43,x10=10,x11=11
GetData(A, "Local HMI", LW, 9022, 1)
GetData(B, "Local HMI", LW, 9021, 1)
GetData(C, "Local HMI", LW, 9020, 1)
GetData(AS[0], "Local HMI", RW, 0, 3)
GetData(BS[0], "Local HMI", RW, 3, 3)
GetData(CS[0], "Local HMI", RW, 6, 3)
GetData(D, "Local HMI", RW_Bit, 30.0, 1)
GetData(Num, "Local HMI", RW, 31, 1)
GetData(PW[0], "Local HMI", RW, 9, 4)
GetData(PW_in, "Local HMI", LW, 8000, 1)
if D==1 then
Value=(AS[Num]-A)*365+(BS[Num]-B)*30+(CS[Num]-C)
SetData(Value, "Local HMI", LW, 401, 1)
else
if Value<1 then
SetData(x43, "Local HMI", LW, 0, 1)
else
end if
if Value<8 and Value>0 then
SetData(x42, "Local HMI", LW, 0, 1)
else
SetData(x10, "Local HMI", LW,0,1)
end if
if PW[Num]==PW_in then
Num=Num+1
SetData(x0, "Local HMI", LW, 8000, 1)
SetData(Num, "Local HMI",RW, 31, 1)
SetData(on, "Local HMI", LB,1,1)
else
SetData(off, "Local HMI",LB,1,1)
end if
if Num>2 or PW[Num]==PW_in then
SetData(off, "Local HMI", RW_Bit, 30.0, 1)
SetData(x0, "Local HMI", RW, 31, 1)
SetData(x0, "Local HMI", LW, 8000, 1)
SetData(x10,"Local HMI", LW,0,1)
end if
end if
end macro_command
想实现日期比较,在允许比较(RW_B30.0=1)时,每次提前7天开始提醒(LW0=42),到期时(LW0=43),这时输入LW8000,和PW[Num]比较,相等时Num加1并写入RW31,同时置LB1=1以及LW8000清零,等待下一次日期比较。当共比较3次,第三次比较完成或输入PW[3]=LW8000后,Lw8000和RW31清零,RW_B30.0置0,LW0=10.
离线模拟时,能实现第一次的7天内提醒,但输入PW[0]没有反应。
请各位老师帮忙指正。谢谢! |