<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.0.26">
  <POU Name="FB_IsEStopActiveChannel" Id="{038022b4-d67d-423c-a061-6462aaf35c50}">
    <Declaration><![CDATA[FUNCTION_BLOCK FB_IsEStopActiveChannel
VAR_INPUT
	bExec: 						BOOL;
	nChan: 						UINT;
END_VAR
VAR_OUTPUT
	bBusy: 						BOOL;
	bIsEstop:					BOOL;
	nErrId: 						UDINT;
	bErr: 						BOOL;
END_VAR
VAR
	fbRTrig: 					R_TRIG;
	nState: 						UINT;
	fbADSREAD: 					ADSREAD;
	nGroup: 						UDINT := 0;
	fbItpIsEStop: ItpIsEStop;
END_VAR]]></Declaration>
    <Implementation>
      <ST><![CDATA[(* ==========================================================*)
(*     FB: FB_IsEStopActiveChannel                           *)
(* ----------------------------------------------------------*)
(*   Desc: is EStop in Channel nChan active?                 *)
(*   Auth: MiB                                               *)
(*   Date: 30.01.2006                                        *)
(*   Rev.: 1.0                                               *)
(* ==========================================================*)

fbRTrig(Clk := bExec);

CASE nState OF
0: (* init *)
		IF fbRTrig.Q THEN
			bBusy	:= TRUE;
			bErr	:= FALSE;
			nErrId	:= 0;
			nState := 10;
		END_IF

10: (* Read Group ID only if aktual Group ID = 0*)
		IF nGroup = 0 THEN
			fbADSREAD(
				NETID:= ,
				PORT:= 	501,  			(* NCI Channel *)
				IDXGRP:= 16#2000+nChan, (* Spezifikation f黵 Kanal-Parameter *)
				IDXOFFS:=16#21 ,			(* 0x00000021  Read  every  UINT32  1   Gruppen-ID (nur eindeutig f黵 3D- und FIFO-Kanal   *)
				LEN:= SIZEOF(nGroup),
				DESTADDR:=ADR(nGroup) ,
				READ:= TRUE,
				TMOUT:= T#200ms,
				BUSY=> ,
				ERR=> ,
				ERRID=> );
			IF NOT fbADSREAD.BUSY THEN
				fbADSREAD(READ := FALSE);
				IF fbADSREAD.ERR THEN
					fbADSREAD(READ := FALSE);
					bErr := TRUE;
					nErrId := fbADSREAD.ERRID;
					nState := 999;
				ELSE
					fbItpIsEStop(bExecute:= FALSE);
					nState := 20;
				END_IF
			END_IF
	ELSE   (* von if nGroup = 0 *)
		fbItpIsEStop(bExecute:= FALSE);
		nState := 20;
	END_IF

20: (* get information about eStop *)
		fbItpIsEStop(
				bExecute:= TRUE,
				nGrpId:= nGroup,
				tTimeOut:=  t#250ms);
		IF NOT fbItpIsEStop.bBusy THEN
			fbItpIsEStop(bExecute := FALSE);
			IF fbItpIsEStop.bErr THEN
					nErrId := fbItpIsEStop.nErrId;
					bErr := TRUE;
					bIsEstop := FALSE;
					nState := 999;
			ELSE   (* All ok -> got the information *)
				bIsEstop := fbItpIsEStop.bEStop;
				bBusy := FALSE;
				nState := 0;
			END_IF
		END_IF

999:	(* Error *)
		bBusy := FALSE;
		nState := 0;

END_CASE]]></ST>
    </Implementation>
    <ObjectProperties />
  </POU>
</TcPlcObject>