<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.0.20">
  <POU Name="FB_StepOnAfterEStop" Id="{351ec210-31b1-4f0e-ae2f-e4492a94b21f}">
    <Declaration><![CDATA[FUNCTION_BLOCK FB_StepOnAfterEStop
VAR_INPUT
	bExec: 						BOOL;
	nChan: 						UINT;
END_VAR
VAR_OUTPUT
	bBusy: 						BOOL;
	nErrId: 						UDINT;
	bErr: 						BOOL;
END_VAR
VAR
	fbRTrig: 					R_TRIG;
	nState: 						UINT;
	fbADSREAD: 					ADSREAD;
	nGroup: 						UDINT;
	fbItpStepOnAfterEStop: 	ItpStepOnAfterEStop;
END_VAR
]]></Declaration>
    <Implementation>
      <ST><![CDATA[(* ==========================================================*)
(*     FB: FB_StepOnAfterEStop	                             *)
(* ----------------------------------------------------------*)
(*   Desc:                                                   *)
(*   Auth: MiB / TV                                          *)
(*   Date: 02.09.2005                                        *)
(*   Last: 02.04.2013                                        *)
(*   Rev.: 1.1                                               *)
(* ==========================================================*)

fbRTrig(Clk := bExec);

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

16#10: (* Read Group ID *)
		fbADSREAD(
			NETID:= ,
			PORT:= 	501,  			(* NCI Channel *)
			IDXGRP:= 16#2000+nChan, (* Spezifikation für Kanal-Parameter *)
			IDXOFFS:=16#21 ,			(* 0x00000021  Read  every  UINT32  1   Gruppen-ID (nur eindeutig für 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 := 16#999;
			ELSE
				nState := 16#20;
			END_IF
		END_IF

16#20: (* initiate Step on after EStop in NCI *)
		fbItpStepOnAfterEStop(
			bExecute:= TRUE,
			nGrpId:= nGroup,
			tTimeOut:= t#250ms);
		IF NOT fbItpStepOnAfterEStop.bBusy THEN
			fbItpStepOnAfterEStop(bExecute := FALSE);
			IF fbItpStepOnAfterEStop.bErr THEN
				nErrId := fbItpStepOnAfterEStop.nErrId;
				bErr := TRUE;
				nState := 16#999;
			ELSE
				nState := 16#0;
				bBusy := FALSE;
			END_IF
		END_IF


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

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