Initialization

       Set array to empty

       IF data file exist read into array each sensor number and associated pin number


       Foreach entry in array

               read input pin

               set LastReported = input pin

               Set Time to 0


update status

       Foreach entry in array

               Read input pin

               IF input LOW

IF LastReported == HIGH

Set LastReported = LOW

Set Time = 0

Send LastReported


IF input HIGH

IF LastReported == LOW

IF Time == 0

       Set Time = CurrentTime + 4 seconds

IF Time < CurrentTime

       Set LastReported = HIGH

       Send LastReported


NOTE: in the laptop the status of each switch/turnout depends on two sensors, 1 HIGH if the turnout is CLEAR and 1 HIGH if the turnout is THROWN. With the delay above there is a 4-second time when both the CLEAR and THROWN sensors are LOW i.e. status is Unknown.