This Calculation Tag example calculates creates flip-flopping tag the oscillates from 0 to 1 to 0.
Tag Type Calculation (discrete)
Tag Name CalcLogicDigital
Description Test if nonzero - flip from 0 to 1 to 0
Evaluate frequency 3 Second
Initial Value 0
State 0 OFF
State 1 ON
State 2 NotUsed
State 3 NotUsed
State 4 NotUsed
State 5 NotUsed
State 6 NotUsed
State 7 NotUsed
Formula A>0?0:1
A CalcLogicDigital
If at least one device is good, radio link says good.
If all devices fail, then the link says bad. If you DISABLE a device, and at least one other device is good, then the RADIOLINK says good. If you DISABLE all devices, then the COMPORT goes to DISABLE and RADIO LINK says FAIL.
The crux for the following is two Calc blocks with which OR the logical NOT each input from a DEVSTS System Tag with the exception being input 20 of the main calc block is input from the secondary calc block which does not use a logical NOT.
Tag Type Calculation (discrete)
Tag Name RadioLink
Description Radio Communication Link still working
Evaluate frequency 1 Second
State 0 RADIO FAIL
State 1 GOOD
State 2 NotUsed
Formula !A||!B||!C||!D||!E||!F||!G||!H||!I||!J||!K||!L||!M||!N||!O||!P||!Q||!R||!S||T
(notice there is no NOT for T)
A Port2Device1
B Port2Device2
C Port2Device3
D Port2Device4
E Port2Device5
F Port2Device6
G Port2Device7
H Port2Device8
I Port2Device9
J Port2Device10
K Port2Device11
L Port2Device12
M Port2Device13
N Port2Device14
O Port2Device15
P Port2Device16
Q Port2Device17
R Port2Device18
S Port2Device19
T RadioLinkd20to25
Tag Type Calculation (discrete)
Tag Name RadioLinkd20to25
Description Radio Communication Link still working devices 20 to 25
Evaluate frequency 1 Second
Keep Previous Value No
Initial Value 0
State 0 RADIO FAIL
State 1 GOOD
State 2 NotUsed
Formula !A||!B||!C||!D||!E||!F
A Port2Device20
B Port2Device21
C Port2Device22
D Port2Device23
E Port2Device24
F Port2Device25
Create 25 of the following DEVSTS system tags
Tag Type System Point (discrete) (really a DEVSTS type system point)
Tag Name Port2Device1
Description Port 2 Device 1 Status
Comport Number, Unit Number 2,1 (1-12,0-255)
Read Only Yes
Keep Previous Value No
Initial Value 0
State 0 OK
State 1 BAD
State 2 Disabled
State 3 NotUsed