etisserant@0: FUNCTION_BLOCK CMD_MONITOR
etisserant@0:  VAR_INPUT AUTO_CMD : BOOL ; (* Automated command *)
etisserant@0:           AUTO_MODE : BOOL ; (* AUTO_CMD enable *)
etisserant@0:             MAN_CMD : BOOL ; (* Manual Command *)
etisserant@0:         MAN_CMD_CHK : BOOL ; (* Negated MAN_CMD to debounce *)  
etisserant@0:           T_CMD_MAX : TIME ; (* Max time from CMD to FDBK *)
etisserant@0:                FDBK : BOOL ; (* Confirmation of CMD completion     
etisserant@0:                                 by operative unit *)               
etisserant@0:                 ACK : BOOL ; (* Acknowledge/cancel ALRM *)         
etisserant@0:  END_VAR
etisserant@0:  VAR_OUTPUT CMD : BOOL ;   (* Command to operative unit *)
etisserant@0:            ALRM : BOOL ;   (* T_CMD_MAX expired without FDBK *)
etisserant@0:  END_VAR
etisserant@0:  VAR CMD_TMR : TON ;    (* CMD-to-FDBK timer *)
etisserant@0:      ALRM_FF : SR ;     (* Note over-riding S input: *)
etisserant@0:  END_VAR                (* Command must be cancelled before
etisserant@0:                               "ACK" can cancel alarm *)
etisserant@0:  (* Function Block Body *)
etisserant@0: LD	T_CMD_MAX	
etisserant@0: ST	CMD_TMR.PT	(* Store an input to the TON FB *)
etisserant@0: LD	AUTO_CMD	
etisserant@0: AND	AUTO_MODE	
etisserant@0: OR(	MAN_CMD	
etisserant@0: ANDN	AUTO_MODE	
etisserant@0: ANDN	MAN_CMD_CHK	
etisserant@0: )		
etisserant@0: ST	CMD	
etisserant@0: IN	CMD_TMR	(* Invoke the TON FB *)
etisserant@0: LD	CMD_TMR.Q	
etisserant@0: ANDN	FDBK	
etisserant@0: ST	ALRM_FF.S1	(* Store an input to the SR FB *)
etisserant@0: LD	ACK	
etisserant@0: R	ALRM_FF	(* Invoke the SR FB *)
etisserant@0: LD	ALRM_FF.Q1	
etisserant@0: ST    	ALRM	
etisserant@0: 
etisserant@0: END_FUNCTION_BLOCK