Untitled

mail@pastecode.io avatar
unknown
plain_text
19 days ago
729 B
1
Indexable
Never
FUNCTION_BLOCK PumpControl
VAR_INPUT
			PStart:BOOL;
			PStop: BOOL;
			PFail:BOOL;
END_VAR

VAR_OUTPUT
			PRun:BOOL;
			PTrip:BOOL;
			ThisObject: POINTER TO PumpControl;
END_VAR

VAR 
	prevPStart:BOOL;
	prevPStop:BOOL;
	prevPtrip: BOOL;
	ready:BOOL;
END_VAR

ThisObject:=THIS;

IF prevPtrip THEN 
    PTrip := FALSE;
END_IF

IF ThisObject^.PStart AND NOT prevPStart THEN
    StartPump();
ELSIF ThisObject^.PFail THEN
    PTrip := TRUE;
END_IF

IF ThisObject^.PStop AND NOT prevPStop THEN
    StopPump();
END_IF

prevPStart := ThisObject^.PStart;
prevPStop := ThisObject^.PStop;
prevPtrip := ThisObject^.PTrip;

#StartPump
ThisObject^.PRun:=TRUE;

#StopPump
ThisObject^.PRun:=FALSE;
Leave a Comment