macro_command main()
bool a,c,d=1,e=0
short plcip0[4]={192,168,0,1} //Assign to an arbitrary IP
short plcip1[4]={192,168,0,95} //PLC1 IP connected to HMI1
short plcip2[4]={192,168,0,96} // PLC2 IP connected to HMI2
bool b = 1
GetData(a,"Local HMI",LB,999,1) //Read HMI1 status for error check
GetData(c,"Local HMI",LB,998,1) //Read HMI2 status for error check
if a==1 and c==0 then //When error occurs on HMI1 but HMI2 stays normal
SetData(plcip1[0],"Local HMI",LW,9600,4) // Write PLC1 IP into the PLC IP
address the redundant HMI connects to
SetData(e, "Local HMI", LB, 10, 1)
else if a==1 and c==1 then //When errors occur on both HMI1 and HMI2
SetData(plcip2[0],"Local HMI",LW,9600,4)
SetData(d, "Local HMI", LB, 10, 1)
else if a==0 and c==1 then //When error occurs on HMI2 but HMI1 stays
normal
SetData(plcip2[0],"Local HMI",LW,9600,4) //Write PLC2 IP into the PLC IP
address the redundant HMI connects to
SetData(e, "Local HMI", LB, 10, 1)
SetData(e, "Local HMI", LB, 20, 1)
else if a==0 and c==0 then //The status of both HMI1 and HMI2 stay normal
SetData(plcip0[0],"Local HMI",LW,9600,4) //Randomly provide an IP for
redundant HMI to connect
SetData(e, "Local HMI", LB, 10, 1)
end if
SetData(b,"Local HMI",LB,10070,1) //forced to reconnect PLC4 when IP
changeed
end macro_command
宏ID 2:
macro_command main()
bool a,c,d=1,e=0
short plcip0[4]={192,168,0,1}
short plcip1[4]={192,168,0,95}
short plcip2[4]={192,168,0,96}
bool b = 1
GetData(a,"Local HMI",LB,998,1)
GetData(c,"Local HMI",LB,999,1)
if a==1 and c==0 then
SetData(plcip2[0],"Local HMI",LW,9600,4)
SetData(e, "Local HMI", LB, 20, 1)
else if a==1 and c==1 then
SetData(plcip1[0],"Local HMI",LW,9600,4)
SetData(d, "Local HMI", LB, 20, 1)
else if a==0 and c==1 then
SetData(plcip1[0],"Local HMI",LW,9600,4) //
SetData(e, "Local HMI", LB, 20, 1) //
SetData(e, "Local HMI", LB, 10, 1) //
else if a==0 and c==0 then //
SetData(plcip0[0],"Local HMI",LW,9600,4) //
SetData(e, "Local HMI", LB, 20, 1) //
end if
SetData(b,"Local HMI",LB,10070,1) //
end macro_command