etisserant@0: FUNCTION_BLOCK FWD_REV_MON
etisserant@0: VAR_INPUT AUTO : BOOL ;(* Enable automated commands *)
etisserant@0:   ACK : BOOL ;         (* Acknowledge/cancel all alarms *)
etisserant@0:   AUTO_FWD : BOOL ;    (* Automated forward command *)
etisserant@0:   MAN_FWD : BOOL ;     (* Manual forward command *)
etisserant@0:   MAN_FWD_CHK : BOOL ; (* Negated MAN_FWD for debouncing *)
etisserant@0:   T_FWD_MAX : TIME ;  (* Maximum time from FWD_CMD to FWD_FDBK *)
etisserant@0:   FWD_FDBK : BOOL ;    (* Confirmation of FWD_CMD completion *)
etisserant@0:                        (*   by operative unit *)
etisserant@0:   AUTO_REV : BOOL ;    (* Automated reverse command *)
etisserant@0:   MAN_REV : BOOL ;     (* Manual reverse command *)
etisserant@0:   MAN_REV_CHK : BOOL ; (* Negated MAN_REV for debouncing *)
etisserant@0:   T_REV_MAX : TIME ;  (* Maximum time from REV_CMD to REV_FDBK *)  
etisserant@0:   REV_FDBK : BOOL ;    (* Confirmation of REV_CMD completion *)
etisserant@0: END_VAR                (*    by operative unit *)
etisserant@0: VAR_OUTPUT KLAXON : BOOL ;      (* Any alarm active *)
etisserant@0:   FWD_REV_ALRM : BOOL; (* Forward/reverse command conflict *)
etisserant@0:   FWD_CMD : BOOL ;     (* "Forward" command to operative unit *)
etisserant@0:   FWD_ALRM : BOOL ;    (* T_FWD_MAX expired without FWD_FDBK *)
etisserant@0:   REV_CMD : BOOL ;     (* "Reverse" command to operative unit *)
etisserant@0:   REV_ALRM : BOOL ;    (* T_REV_MAX expired without REV_FDBK *)
etisserant@0: END_VAR
etisserant@0: VAR FWD_MON : CMD_MONITOR; (* "Forward" command monitor *)
etisserant@0:   REV_MON : CMD_MONITOR;   (* "Reverse" command monitor *)
etisserant@0:   FWD_REV_FF : SR ;      (* Forward/Reverse contention latch *)
etisserant@0: END_VAR
etisserant@0: (* Function Block body *)
etisserant@0: LD	AUTO	(* Load common inputs *)
etisserant@0: ST	FWD_MON.AUTO_MODE	
etisserant@0: ST	REV_MON.AUTO_MODE	
etisserant@0: LD	ACK	
etisserant@0: ST	FWD_MON.ACK	
etisserant@0: ST	REV_MON.ACK	
etisserant@0: ST	FWD_REV_FF.R	
etisserant@0: LD	AUTO_FWD	(* Load inputs to FWD_MON *)
etisserant@0: ST	FWD_MON.AUTO_CMD	
etisserant@0: LD	MAN_FWD	
etisserant@0: ST	FWD_MON.MAN_CMD	
etisserant@0: LD	MAN_FWD_CHK	
etisserant@0: ST	FWD_MON.MAN_CMD_CHK	
etisserant@0: LD	T_FWD_MAX	
etisserant@0: ST	FWD_MON.T_CMD_MAX	
etisserant@0: LD	FWD_FDBK	
etisserant@0: ST	FWD_MON.FDBK	
etisserant@0: CAL	FWD_MON	(* Activate FWD_MON *)
etisserant@0: LD	AUTO_REV	(* Load inputs to REV_MON *)
etisserant@0: ST	REV_MON.AUTO_CMD	
etisserant@0: LD	MAN_REV	
etisserant@0: ST	REV_MON.MAN_CMD	
etisserant@0: LD	MAN_REV_CHK	
etisserant@0: ST	REV_MON.MAN_CMD_CHK	
etisserant@0: LD	T_REV_MAX	
etisserant@0: ST	REV_MON.T_CMD_MAX	
etisserant@0: LD	REV_FDBK	
etisserant@0: ST	REV_MON.FDBK	
etisserant@0: CAL	REV_MON	(* Activate REV_MON *)
etisserant@0: LD	FWD_MON.CMD	(* Check for contention *)
etisserant@0: AND	REV_MON.CMD	
etisserant@0: S1	FWD_REV_FF	(* Latch contention condition *)
etisserant@0: LD	FWD_REV_FF.Q	
etisserant@0: ST	FWD_REV_ALRM	(* Contention alarm *)
etisserant@0: LD	FWD_MON.CMD	(* "Forward" command and alarm *)
etisserant@0: ANDN	FWD_REV_ALRM	
etisserant@0: ST	FWD_CMD	
etisserant@0: LD	FWD_MON.ALRM	
etisserant@0: ST	FWD_ALRM	
etisserant@0: LD	REV_MON.CMD	(* "Reverse" command and alarm *)
etisserant@0: ANDN	FWD_REV_ALRM	
etisserant@0: ST	REV_CMD	
etisserant@0: LD	REV_MON.ALRM	
etisserant@0: ST	REV_ALRM	
etisserant@0: OR	FWD_ALRM	(* OR all alarms *)
etisserant@0: OR	FWD_REV_ALRM	
etisserant@0: ST	KLAXON	
etisserant@0: 
etisserant@0: END_FUNCTION_BLOCK
etisserant@0: