Untitled
unknown
plain_text
a year ago
2.3 kB
2
Indexable
Never
Timer(IN:=Timer.IN,PT:=Timer.PT); ErrorMode := IsClosed AND IsOpen; CASE ValveState OF 0: // Closed state IF OpenValve THEN ValveState := 1; // Start Closing state // Reset the timer Timer.IN := FALSE; Timer.PT := T1; Timer.IN := TRUE; // Start Closing timer T1 END_IF; IF NOT IsClosed THEN ValveState := 1; ManualMode := TRUE; END_IF 1: // Attempting to close IF NOT isClosed THEN IF OpenValve THEN // Check if we commanded it to change state or if it was a forced change (manual) OpenValve := FALSE; IdleMode := FALSE; ManualMode := FALSE; ELSE ManualMode := TRUE; END_IF // Reset the timer Timer.IN := FALSE; Timer.PT := T2; Timer.IN := TRUE; // Start Opening TImer T2 ValveState := 2; // Enter END_IF IF isClosed AND Timer.Q THEN // State never changed, setting to idle mode. IdleMode := TRUE; OpenValve := FALSE; ValveState := 0; END_IF 2: // Just Closed, now Opening IF IsOpen THEN // opening ValveState := 3; SlowTurning := FALSE; END_IF; IF Timer.Q THEN SlowTurning := TRUE; // Reset the timer Timer.IN := FALSE; END_IF 3: // Opened state IF CloseValve THEN ValveState := 4; // Start Opening state // Reset the timer Timer.IN := FALSE; Timer.PT := T1; Timer.IN := TRUE; // Start Opening timer T1 END_IF; IF NOT IsOpen THEN ValveState := 4; ManualMode := TRUE; END_IF 4: // Attempting to open IF NOT IsOpen THEN IF CloseValve THEN // Check if we commanded it to change state or if it was a forced change (manual) CloseValve := FALSE; IdleMode := FALSE; ManualMode := FALSE; ELSE ManualMode := TRUE; END_IF // Reset the timer Timer.IN := FALSE; Timer.PT := T2; Timer.IN := TRUE; // Start Closing TImer T2 ValveState := 5; // Enter END_IF IF IsOpen AND Timer.Q THEN // State never changed, setting to idle mode. IdleMode := TRUE; CloseValve := FALSE; ValveState := 3; END_IF 5: // Just Opened, now Closing IF IsClosed THEN // Closing ValveState := 0; SlowTurning := FALSE; END_IF; IF Timer.Q THEN SlowTurning := TRUE; // Reset the timer Timer.IN := FALSE; END_IF END_CASE