FUNCTION_BLOCK "FB_Main"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_IN_OUT 
      stInOutControlUnitCabinet : "UDT_MainState";
   END_VAR

   VAR 
      fbCarousel5002 : "FB_Conveyor";
   END_VAR
   VAR RETAIN
      arCognexInterface { S7_SetPoint := 'False'} : Array[1.."cNoScanner"] of "stCognexInterface";
   END_VAR
   VAR 
      stCognexInterfaceDummy : "stCognexInterface";   // Als Platzhalter benutzen für TRO ohne Barcode-Leser
      stBarcodeReaderDummy : "UDT_BarcodeReader";
      TRO500 : "FB_ILS_MTRO_Vario";
      TRO501 : "FB_ILS_MTRO_1Sep";
      TRO502 : "FB_ILS_MTRO_Vario";
      TRO503 : "FB_ILS_MTRO_1Sep";
      TRO504 : "FB_ILS_MTRO_1Sep";
      TRO505 : "FB_ILS_MTRO_1Sep1Swi";
      TRO506 : "FB_ILS_MTRO_Vario";
      TRO507 : "FB_ILS_MTRO_1Sep";
      TRO508 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO509 : "FB_ILS_MTRO_1Sep";
      TRO510 : "FB_ILS_MTRO_1Sep1Swi";
      TRO511 : "FB_ILS_MTRO_1Sep";
      TRO512 : "FB_ILS_MTRO_Vario";
      TRO513 : "FB_ILS_MTRO_1Sep";
      TRO514 : "FB_ILS_MTRO_1Sep1Swi";
      TRO515 : "FB_ILS_MTRO_1Sep";
      TRO516 : "FB_ILS_MTRO_Vario";
      TRO517 : "FB_ILS_MTRO_1Sep";
      TRO518 : "FB_ILS_MTRO_1Sep1Swi";
      TRO519 : "FB_ILS_MTRO_1Sep";
      TRO520 : "FB_ILS_MTRO_Vario";
      TRO521 : "FB_ILS_MTRO_1Sep";
      TRO522 : "FB_ILS_MTRO_1Sep1Swi";
      TRO523 : "FB_ILS_MTRO_1Sep";
      TRO524 : "FB_ILS_MTRO_Vario";
      TRO525 : "FB_ILS_MTRO_1Sep";
      TRO526 : "FB_ILS_MTRO_1Sep";
      TRO527 : "FB_ILS_MTRO_1Sep1Swi";
      TRO528 : "FB_ILS_MTRO_1Sep";
      TRO529 : "FB_ILS_MTRO_1Sep";
      TRO530 : "FB_ILS_MTRO_Vario";
      TRO531 : "FB_ILS_MTRO_Vario";
      xReInit : Bool;
      rTrigReInit {InstructionName := 'R_TRIG'; LibVersion := '1.0'; S7_SetPoint := 'False'} : R_TRIG;
      rTrig_ClarificationButton {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      "rTrig_Workstation1.1" {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      "rTrig_Workstation1.0" {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      "rTrig_Workstation2.0" {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      "rTrig_Workstation3.0" {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      "rTrig_Workstation4.0" {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      xTest : Bool;
      rTrig_LengthMeasurement {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
   END_VAR

   VAR_TEMP 
      nActCar : Int;
      nActNo : Int;
      nNiu : DInt;
      stGenerateCarrier : "stCarrier";
      nCounter1 : DInt;
      xResult1 : Bool;
      nIdx : Int;
      nIdx2 : Int;
      nFound : Int;
      stEmptyCarrier : "stCarrier";
      stEmptyCarrierData : "stJamData";
      arCarrierPlaceHolder : Array[1..1] of "stCarrier";   // Platzhalter
      stJamDataPlaceHolder : "stJamData";
      stHMISwitchPlaceholder : "UDT_HMI_UnloadingStation";
      idx : Int;
      arEmptyStorageLine_1 : Int;
      arEmptyStorageLine : Array[1..1] of "stCarrier";
      t_automatik : Bool;
      arDummyEventCorrectionInfo : Array[0..1] of "stEventCorrectionInfo";
      tmpLaneStatus : Array[0..4] of String;
      tmpPlaceHolderLaneStatus : Array[0..4] of String;
      sLengthInfo : String;
   END_VAR


BEGIN
	REGION Reinitialisieren
	    IF NOT #xReInit THEN
	        #xReInit := TRUE;
	    END_IF;
	    
	    #rTrigReInit(CLK := #xReInit);
	    
	    IF #rTrigReInit.Q THEN
	        
	        #TRO500.nState := "DB_GLOB_TroState".arTroState["cMainTro500"];
	        #TRO501.nState := "DB_GLOB_TroState".arTroState["cMainTro501"];
	        #TRO502.nState := "DB_GLOB_TroState".arTroState["cMainTro502"];
	        #TRO503.nState := "DB_GLOB_TroState".arTroState["cMainTro503"];
	        #TRO504.nState := "DB_GLOB_TroState".arTroState["cMainTro504"];
	        #TRO505.nState := "DB_GLOB_TroState".arTroState["cMainTro505"];
	        #TRO506.nState := "DB_GLOB_TroState".arTroState["cMainTro506"];
	        #TRO507.nState := "DB_GLOB_TroState".arTroState["cMainTro507"];
	        #TRO508.nState := "DB_GLOB_TroState".arTroState["cMainTro508"];
	        #TRO509.nState := "DB_GLOB_TroState".arTroState["cMainTro509"];
	        #TRO510.nState := "DB_GLOB_TroState".arTroState["cMainTro510"];
	        #TRO511.nState := "DB_GLOB_TroState".arTroState["cMainTro511"];
	        #TRO512.nState := "DB_GLOB_TroState".arTroState["cMainTro512"];
	        #TRO513.nState := "DB_GLOB_TroState".arTroState["cMainTro513"];
	        #TRO514.nState := "DB_GLOB_TroState".arTroState["cMainTro514"];
	        #TRO515.nState := "DB_GLOB_TroState".arTroState["cMainTro515"];
	        #TRO516.nState := "DB_GLOB_TroState".arTroState["cMainTro516"];
	        #TRO517.nState := "DB_GLOB_TroState".arTroState["cMainTro517"];
	        #TRO518.nState := "DB_GLOB_TroState".arTroState["cMainTro518"];
	        #TRO519.nState := "DB_GLOB_TroState".arTroState["cMainTro519"];
	        #TRO520.nState := "DB_GLOB_TroState".arTroState["cMainTro520"];
	        #TRO521.nState := "DB_GLOB_TroState".arTroState["cMainTro521"];
	        #TRO522.nState := "DB_GLOB_TroState".arTroState["cMainTro522"];
	        #TRO523.nState := "DB_GLOB_TroState".arTroState["cMainTro523"];
	        #TRO524.nState := "DB_GLOB_TroState".arTroState["cMainTro524"];
	        #TRO525.nState := "DB_GLOB_TroState".arTroState["cMainTro525"];
	        #TRO526.nState := "DB_GLOB_TroState".arTroState["cMainTro526"];
	        #TRO527.nState := "DB_GLOB_TroState".arTroState["cMainTro527"];
	        #TRO528.nState := "DB_GLOB_TroState".arTroState["cMainTro528"];
	        #TRO529.nState := "DB_GLOB_TroState".arTroState["cMainTro529"];
	        #TRO530.nState := "DB_GLOB_TroState".arTroState["cMainTro530"];
	        #TRO531.nState := "DB_GLOB_TroState".arTroState["cMainTro531"];
	    END_IF;
	END_REGION
	
	REGION Automatik
	    #t_automatik := "DB_InterfaceSafety".stFromSafety.stMainContactorsUH05.Q;//#stInOutControlUnitCabinet.xRunning AND NOT #stInOutControlUnitCabinet.xStarting AND "DB_InterfaceSafety".stFromSafety.EStopMain.Q;
	END_REGION
	
	REGION Conveyor
	    REGION Carousel KR-M5002        
	        #fbCarousel5002.Settings.tEnergySafeTime := T#90s;
	        #fbCarousel5002.Settings.tStartingTime := T#50ms;
	        #fbCarousel5002.Settings.xGridActive := TRUE;
	        #fbCarousel5002.Settings.sMotorProtectName := 'FC0062';
	        #fbCarousel5002.Settings.sGridSenName := 'BG3435';
	        #fbCarousel5002(xInRequestRun := (* "fbPreMain_DB".fbStateMain.nConveyorStartUpCounter = 100 OR *)#stInOutControlUnitCabinet.xRestart OR
	                        #TRO501.xOutCarouselReq OR #TRO503.xOutCarouselReq OR #TRO505.xOutCarouselReq1 OR
	                        #TRO504.xOutCarouselReq OR #TRO509.xOutCarouselReq OR
	                        #TRO510.xOutCarouselReq1 OR #TRO513.xOutCarouselReq OR
	                        #TRO514.xOutCarouselReq1 OR #TRO517.xOutCarouselReq OR #TRO518.xOutCarouselReq1 OR #TRO521.xOutCarouselReq
	                        OR #TRO522.xOutCarouselReq1 OR #TRO525.xOutCarouselReq
	                        OR #TRO526.xOutCarouselReq OR #TRO527.xOutCarouselReq1 OR #TRO528.xOutCarouselReq OR #TRO529.xOutCarouselReq,
	                        xInEnabled := "cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3435"].xDirectSensor,
	                        xInGridQuit := "SF0002" OR "SF0041",
	                        xInAutomaticMode := #t_automatik,
	                        xInMotorProtectionMonitoring := "FC0062",
	                        xOutPowerContactor => "MA0062",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar5002);
	    END_REGION
	END_REGION
	
	REGION TROs
	    
	    REGION TRO 500 (Vario) - Stand: Vorbereitet für Umbau!
	        #TRO500.stInSeparator1.Settings.nSeparatorNo := "cSep500.1";
	        #TRO500.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO500.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO500.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO500.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO500.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO500.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO500.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO500.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3333"];
	        
	        #TRO500.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO500.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO500.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO500.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO500.stInVario.Settings.tConvEmpty := t#120s; //IBN neu einstellen!
	        #TRO500.stInVario.Settings.nCountCarrier := 1;
	        #TRO500.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO500.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3334"]; //Finger in Pos
	        #TRO500.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3455"]; // Conveyor full, neue Adresse!
	        #TRO500.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3456"]; // Jam detector, neue Adresse!
	        #TRO500.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3335"]; // MT in Pos
	        
	        #TRO500.stInVario.Settings.xJamSenDelayActive := TRUE; // Langes Gefälle nach Vario, Staureaktion muss nicht "schnell" sein
	        #TRO500.stInVario.Settings.tJamSenDelay := T#750ms;    // Zeit wie lange Stausensor belegt sein muss, damit Vario sofort anhält
	        
	        #TRO500.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO500.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO500.stInSettings.xIsBorner := TRUE;
	        
	        IF "DB_JamArea5001".stJam5001_1.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea5001".stJam5001_1.arCarrier[1].bStatus.%X1 := TRUE; //beladene (provisorium)
	        END_IF;
	        
	        #TRO500(nInMainTroNo := "cMainTro500",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_automatik,
	                xInRelease := "DB_TRO_Test".TRO500,
	                xInMotorProtection := "FC0072",
	                arInOutJamEntr := "DB_JamArea5001".stJam5001_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea5001".stJam5001_1.stData,
	                arInOutJamFinger := "DB_JamArea5001".stJam5001_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea5001".stJam5001_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO500,
	                xOutStopper => "MB3333",
	                xOutVarioMotor => "MA0072",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro500"]);
	    END_REGION
	    
	    REGION TRO 501 (1Sep) + Scanner (BX5101)
	        #TRO501.stInSeparator1.Settings.nSeparatorNo := "cSep501.1";
	        #TRO501.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO501.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO501.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO501.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO501.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO501.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO501.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO501.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3304"];
	        #TRO501.stInSenJam2 := "DB_Inputs".Sensors["cInBG3305"];
	        
	        #TRO501.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO501.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5101"].xInCamTriggerReady := "bx5101-TriggerReady";
	        #arCognexInterface["cScannerBX5101"].xInCamTriggerAck := "bx5101-TriggerAck";
	        #arCognexInterface["cScannerBX5101"].xInCamResultsAvailable := "bx5101-Results Available";
	        #arCognexInterface["cScannerBX5101"].xInCamGeneralFault := "bx5101-General Fault";
	        #arCognexInterface["cScannerBX5101"].hwInCamInspectionResults := "BX5101~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO501(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO501.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO501.TroOut,
	                nInMainTroNo := "cMainTro501",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := NOT "DB_Handshake".str_TROs.udt_TRO501.stCtrl.xStop AND NOT "DB_Interface_HMI".stControl.xEmptyCarrierInsertReq,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5101"],
	                arInOutJamEntr1 := "DB_JamArea5001".stJam5001_3.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5001".stJam5001_3.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_1.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO501,
	                xOutStopper1 => "MB3304",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro501"]);
	        
	        "bx5101-TriggerEnable" := #arCognexInterface["cScannerBX5101"].xOutCamTriggerEnable;
	        "bx5101-Trigger" := #arCognexInterface["cScannerBX5101"].xOutCamTrigger;
	        "bx5101-ResultsAck" := #arCognexInterface["cScannerBX5101"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO501.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO501.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5001".stJam5001_3.arCarrier[1]);
	        END_REGION
	        
	        REGION Loaded MT: Send DReqM to Fortna WCS
	            IF #TRO501.xOutNewScan OR #xTest THEN
	                
	                REGION Provisorium für Test - kommt später per Telegramm
	                    "DB_Handshake".str_TelegramMES.udtIn_DataMES.stPayload.nBarcode := #TRO501.nOutScanResult;
	                    "DB_Handshake".str_TelegramMES.udtIn_DataMES.stPayload.arActions[1] := "DB_Handshake".xLoadedDestinationTest;
	                    
	                    "DB_Handshake".udt_HandshakeMESStorage.str_Ctrl.xNewDataAvaible := TRUE;
	                END_REGION ;
	                
	                IF "DB_MachineGlobal".xActivateWESComms THEN
	                    
	                    #tmpLaneStatus[0] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                             stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[1]);
	                    #tmpLaneStatus[1] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                             stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[2]);
	                    #tmpLaneStatus[2] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                             stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[3]);
	                    #tmpLaneStatus[3] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                             stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[4]);
	                    
	                    "FC_Send_GOHDReqM"(sInPLCID := "cPLCID",
	                                       xInSSCCReq := FALSE,
	                                       xInLengthReq := FALSE,
	                                       xInDockDoorReq := FALSE,
	                                       xInLaneStatusReq := TRUE,
	                                       nInBarcode := #TRO501.nOutScanResult,
	                                       sInSSCC := '',
	                                       sInDecisionPoint := "cDP_GOH_PROC_01",
	                                       sInDockDoor := '',
	                                       sInLengthInfo := '',
	                                       arInLaneStatus := #tmpLaneStatus,
	                                       nInLaneCnt := 4,
	                                       FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                       BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                       nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	                END_IF;
	                #xTest := FALSE;
	            END_IF;
	            
	            IF "DB_Handshake".udt_HandshakeMESStorage.str_Status.xNewDataSaved THEN
	                "DB_Handshake".udt_HandshakeMESStorage.str_Ctrl.xNewDataAvaible := FALSE;
	            END_IF;
	        END_REGION
	        
	        IF "IBN".xDUMMessage THEN
	            "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                             nInBarcode := #TRO501.nOutScanResult,
	                             sInDecisionPoint := 'GOH.Proc.01', //todo
	                             sInActionTaken := '1',
	                             nReasonCode := 1,
	                             FIFO := "DB_LGF_FIFO_CommWCSBL",
	                             BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                             nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	        END_IF;
	        "IBN".xDUMMessage := FALSE;
	        
	    END_REGION ;
	    
	    REGION TRO 502 (Vario) - Stand: Vorbereitet für Umbau!
	        #TRO502.stInSeparator1.Settings.nSeparatorNo := "cSep502.1";
	        #TRO502.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO502.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO502.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO502.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO502.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO502.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO502.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO502.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3330"];
	        
	        #TRO502.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO502.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO502.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO502.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO502.stInVario.Settings.tConvEmpty := t#120s; //IBN!
	        #TRO502.stInVario.Settings.nCountCarrier := 1;
	        #TRO502.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO502.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3331"]; //Finger in Pos
	        #TRO502.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3450"]; // Conveyor full
	        #TRO502.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3451"]; // Jam detector
	        #TRO502.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3332"]; // MT in Pos
	        
	        #TRO502.stInVario.Settings.xJamSenDelayActive := TRUE; // Langes Gefälle nach Vario, Staureaktion muss nicht "schnell" sein
	        #TRO502.stInVario.Settings.tJamSenDelay := T#750ms;    // Zeit wie lange Stausensor belegt sein muss, damit Vario sofort anhält
	        
	        #TRO502.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO502.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO502.stInSettings.xIsBorner := TRUE;
	        
	        #TRO502(nInMainTroNo := "cMainTro502",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInReset := "cTodoFalse",
	                xInAutomatic := #t_automatik,
	                xInRelease := "DB_TRO_Test".TRO502,
	                xInMotorProtection := "FC0071",
	                arInOutJamEntr := "DB_JamArea5000".stJam5000_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea5000".stJam5000_1.stData,
	                arInOutJamFinger := "DB_JamArea5000".stJam5000_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea5000".stJam5000_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO502,
	                xOutStopper => "MB3330",
	                xOutVarioMotor => "MA0071",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro502"]);
	    END_REGION
	    
	    REGION TRO 503 (1Sep)+ Scanner (BX5100)
	        
	        #TRO503.stInSeparator1.Settings.nSeparatorNo := "cSep503.1";
	        #TRO503.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO503.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO503.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO503.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO503.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO503.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO503.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO503.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3301"];
	        #TRO503.stInSenJam2 := "DB_Inputs".Sensors["cInBG3302"];
	        
	        #TRO503.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO503.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #TRO503.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO503.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #arCognexInterface["cScannerBX5100"].xInCamTriggerReady := "bx5100-TriggerReady";
	        #arCognexInterface["cScannerBX5100"].xInCamTriggerAck := "bx5100-TriggerAck";
	        #arCognexInterface["cScannerBX5100"].xInCamResultsAvailable := "bx5100-Results Available";
	        #arCognexInterface["cScannerBX5100"].xInCamGeneralFault := "bx5100-General Fault";
	        #arCognexInterface["cScannerBX5100"].hwInCamInspectionResults := "BX5100~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO503(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO503.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO503.TroOut,
	                nInMainTroNo := "cMainTro503",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                xInRelease := NOT "DB_Handshake".str_TROs.udt_TRO503.stCtrl.xStop AND NOT "DB_Interface_HMI".stControl.xEmptyCarrierInsertReq,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5100"],
	                arInOutJamEntr1 := "DB_JamArea5000".stJam5000_3.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5000".stJam5000_3.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_1.stData,
	                xOutStopper1 => "MB3301",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO503,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro503"]);
	        
	        "bx5100-TriggerEnable" := #arCognexInterface["cScannerBX5100"].xOutCamTriggerEnable;
	        "bx5100-Trigger" := #arCognexInterface["cScannerBX5100"].xOutCamTrigger;
	        "bx5100-ResultsAck" := #arCognexInterface["cScannerBX5100"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO503.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO503.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5000".stJam5000_3.arCarrier[1]);
	        END_REGION
	    END_REGION
	    
	    REGION TRO 504 (1Sep)
	        
	        #TRO504.stInSeparator1.Settings.nSeparatorNo := "cSep504.1";
	        #TRO504.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO504.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO504.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO504.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO504.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO504.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO504.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO504.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3240"];
	        #TRO504.stInSenJam2 := "DB_Inputs".Sensors["cInBG3241"];
	        
	        #TRO504.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        //  "DB_JamArea5002".stJam5002_1.arCarrier[1].nDestination := "cDestLeaveF2H";
	        
	        #TRO504(nInMainTroNo := "cMainTro504",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_Test".TRO504,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_1.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_2.stData,
	                xOutStopper1 => "MB3240",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO504,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro504"]);
	        
	    END_REGION
	    
	    REGION TRO 505 (1Sep1Switch) + Scanner (BX5102)
	        #TRO505.stInSeparator1.Settings.nSeparatorNo := "cSep505.1";
	        #TRO505.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO505.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO505.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO505.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO505.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO505.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO505.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3242"];
	        #TRO505.stInSenJam2 := "DB_Inputs".Sensors["cInBG3243"];
	        #TRO505.stInSenJam3 := "DB_Inputs".Sensors["cInBG3261"];
	        
	        #TRO505.stInSwitch1.Settings.nSwitchNo := "cSwi505.1";
	        #TRO505.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO505.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO505.stInSwitch1.Settings.tTransitEx := T#5s;
	        #TRO505.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO505.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO505.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5102"].xInCamTriggerReady := "bx5102-TriggerReady";
	        #arCognexInterface["cScannerBX5102"].xInCamTriggerAck := "bx5102-TriggerAck";
	        #arCognexInterface["cScannerBX5102"].xInCamResultsAvailable := "bx5102-Results Available";
	        #arCognexInterface["cScannerBX5102"].xInCamGeneralFault := "bx5102-General Fault";
	        #arCognexInterface["cScannerBX5102"].hwInCamInspectionResults := "BX5102~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO505.stInSettings.xPrioDir2 := TRUE;
	        
	        #TRO505(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO505.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO505.TroOut,
	                nInMainTroNo := "cMainTro505",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO505,
	                xInCarouselRun1 := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO505,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5102"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_2.stData,
	                arInOutJamExit2 := "DB_JamArea5003".stJam5003_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5003".stJam5003_1.stData,
	                arInOutJamExit3 := "DB_JamArea5002".stJam5002_3.arCarrier,
	                stInOutJamExit3 := "DB_JamArea5002".stJam5002_3.stData,
	                xOutStopper1 => "MB3242",
	                xOutSw1ExTo3 => "MB3243",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro505"]);
	        
	        "bx5102-TriggerEnable" := #arCognexInterface["cScannerBX5102"].xOutCamTriggerEnable;
	        "bx5102-Trigger" := #arCognexInterface["cScannerBX5102"].xOutCamTrigger;
	        "bx5102-ResultsAck" := #arCognexInterface["cScannerBX5102"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO505.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO505.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_2.arCarrier[1]);
	        END_REGION
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi505.1",
	                           nOutDirection => #TRO505.nInDirection,
	                           InOutCarrier := "DB_JamArea5002".stJam5002_2.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO505.xOutBookedDir1 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO505.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.F2H.01', //todo
	                                 sInActionTaken := '1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 506 (Vario)
	        #TRO506.stInSeparator1.Settings.nSeparatorNo := "cSep506.1";
	        #TRO506.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO506.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO506.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO506.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO506.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO506.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO506.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO506.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3245"];
	        
	        #TRO506.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO506.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO506.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO506.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO506.stInVario.Settings.tConvEmpty := t#20s;//T#8000ms;
	        #TRO506.stInVario.Settings.nCountCarrier := 1;
	        #TRO506.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO506.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3246"]; //Finger in Pos
	        #TRO506.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3247"]; // Conveyor full
	        #TRO506.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3250"]; // Jam detector
	        #TRO506.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3244"]; // MT in Pos
	        
	        #TRO506.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO506(nInMainTroNo := "cMainTro506",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInReset := "cTodoFalse",
	                xInAutomatic := #t_automatik,
	                xInRelease := "DB_TRO_Test".TRO506,
	                xInMotorProtection := "FC0063",
	                arInOutJamEntr := "DB_JamArea5003".stJam5003_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea5003".stJam5003_1.stData,
	                arInOutJamFinger := "DB_JamArea5003".stJam5003_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea5003".stJam5003_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO506,
	                xOutStopper => "MB3245",
	                xOutVarioMotor => "MA0063",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro506"]);
	        
	    END_REGION
	    
	    
	    REGION TRO 507 (1Sep)
	        
	        #TRO507.stInSeparator1.Settings.nSeparatorNo := "cSep507.1";
	        #TRO507.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO507.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO507.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO507.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO507.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO507.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO507.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO507.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3251"];
	        #TRO507.stInSenJam2 := "DB_Inputs".Sensors["cInBG3252"];
	        
	        #TRO507.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO507.stInSeparator1.Settings.tSenFree := t#1200ms;
	        #TRO507.stInSeparator1.Settings.tSenWait := t#1200ms;
	        
	        #TRO507(nInMainTroNo := "cMainTro507",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE, //Gefälle
	                xInRelease := "DB_TRO_Test".TRO507,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5003".stJam5003_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5003".stJam5003_2.stData,
	                arInOutJamExit2 := "DB_JamArea5004".stJam5004_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5004".stJam5004_1.stData,
	                xOutStopper1 => "MB3251",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO507,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro507"]);
	        
	    END_REGION
	    
	    
	    REGION TRO 508 (Vario)+Scanner(BX5103) 
	        #TRO508.stInSeparator1.Settings.nSeparatorNo := "cSep508.1";
	        #TRO508.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO508.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO508.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO508.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO508.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO508.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO508.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO508.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3253"];
	        
	        #TRO508.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO508.stInBarcodeReader.Settings.tTimeout := T#5s;
	        #arCognexInterface["cScannerBX5103"].xInCamTriggerReady := "bx5103-TriggerReady";
	        #arCognexInterface["cScannerBX5103"].xInCamTriggerAck := "bx5103-TriggerAck";
	        #arCognexInterface["cScannerBX5103"].xInCamResultsAvailable := "bx5103-Results Available";
	        #arCognexInterface["cScannerBX5103"].xInCamGeneralFault := "bx5103-General Fault";
	        #arCognexInterface["cScannerBX5103"].hwInCamInspectionResults := "BX5103~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO508.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO508.stInSeparator1.Settings.tSenWait := T#1200ms;
	        
	        #TRO508.stInSettings.bSepType.%X0 := TRUE; //am ersten Bein halten
	        #TRO508.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO508.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO508.stInVario.Settings.tConvEmpty := t#15s;//T#8000ms;
	        #TRO508.stInVario.Settings.nCountCarrier := 1;
	        #TRO508.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO508.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3254"]; //Finger in Pos
	        #TRO508.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3256"]; // Conveyor full
	        #TRO508.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3262"]; // Jam detector
	        #TRO508.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3255"]; // MT in Pos
	        
	        #TRO508.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        IF "DB_JamArea5003".stJam5003_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea5003".stJam5003_2.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_IF;
	        
	        
	        #TRO508(nInMainTroNo := "cMainTro508",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInReset := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO508 AND (#"rTrig_Workstation1.1".Q OR "IBN".xSkipWorkstation1_1),
	                xInMotorProtection := "FC0064",
	                xInAutomatic := #t_automatik,
	                arInOutJamEntr := "DB_JamArea5004".stJam5004_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea5004".stJam5004_1.stData,
	                arInOutJamFinger := "DB_JamArea5004".stJam5004_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea5004".stJam5004_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5103"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO508,
	                xOutStopper => "MB3253",
	                xOutVarioMotor => "MA0064",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro508"]);
	        "bx5103-TriggerEnable" := #arCognexInterface["cScannerBX5103"].xOutCamTriggerEnable;
	        "bx5103-Trigger" := #arCognexInterface["cScannerBX5103"].xOutCamTrigger;
	        "bx5103-ResultsAck" := #arCognexInterface["cScannerBX5103"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO508.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO508.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5004".stJam5004_1.arCarrier[1]);
	        END_REGION
	        
	        REGION Release Button
	            #"rTrig_Workstation1.1"(CLK := "IBN".xTriggerWorkstation1_1 OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[0].xUnloadReq));
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 509 (1Sep)
	        #TRO509.stInSeparator1.Settings.nSeparatorNo := "cSep509.1";
	        #TRO509.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO509.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO509.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO509.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO509.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO509.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO509.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO509.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3257"];
	        #TRO509.stInSenJam2 := "DB_Inputs".Sensors["cInBG3260"];
	        
	        #TRO509.stInSeparator1.Settings.tSenFree := t#1200ms;
	        #TRO509.stInSeparator1.Settings.tSenWait := t#1200ms;
	        
	        #TRO509(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO509.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO509.TroOut,
	                nInMainTroNo := "cMainTro509",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO509,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5004"."stJam5004_2".arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5004".stJam5004_2.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_3.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_3.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO509,
	                xOutStopper1 => "MB3257",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro509"]);
	        
	    END_REGION
	    
	    REGION TRO 510 (1Sep1Switch) + Scanner (BX5104)
	        #TRO510.stInSeparator1.Settings.nSeparatorNo := "cSep510.1";
	        #TRO510.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO510.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO510.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO510.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO510.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO510.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO510.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3312"];
	        #TRO510.stInSenJam2 := "DB_Inputs".Sensors["cInBG3313"];
	        #TRO510.stInSenJam3 := "DB_Inputs".Sensors["cInBG3324"];
	        
	        #TRO510.stInSwitch1.Settings.nSwitchNo := "cSwi510.1";
	        #TRO510.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO510.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO510.stInSwitch1.Settings.tTransitEx := T#5s;
	        #TRO510.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO510.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO510.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5104"].xInCamTriggerReady := "bx5104-TriggerReady";
	        #arCognexInterface["cScannerBX5104"].xInCamTriggerAck := "bx5104-TriggerAck";
	        #arCognexInterface["cScannerBX5104"].xInCamResultsAvailable := "bx5104-Results Available";
	        #arCognexInterface["cScannerBX5104"].xInCamGeneralFault := "bx5104-General Fault";
	        #arCognexInterface["cScannerBX5104"].hwInCamInspectionResults := "BX5104~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO510.stInSettings.xPrioDir2 := TRUE;
	        
	        #TRO510(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO510.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO510.TroOut,
	                nInMainTroNo := "cMainTro510",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO510,
	                xInCarouselRun1 := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5104"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_3.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_3.stData,
	                arInOutJamExit2 := "DB_JamArea5005".stJam5005_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5005".stJam5005_1.stData,
	                arInOutJamExit3 := "DB_JamArea5002".stJam5002_4.arCarrier,
	                stInOutJamExit3 := "DB_JamArea5002".stJam5002_4.stData,
	                xOutStopper1 => "MB3312",
	                xOutSw1ExTo3 => "MB3313",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO510,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro510"]);
	        
	        "bx5104-TriggerEnable" := #arCognexInterface["cScannerBX5104"].xOutCamTriggerEnable;
	        "bx5104-Trigger" := #arCognexInterface["cScannerBX5104"].xOutCamTrigger;
	        "bx5104-ResultsAck" := #arCognexInterface["cScannerBX5104"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO510.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO510.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_3.arCarrier[1]);
	        END_REGION
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi510.1",
	                           nOutDirection => #TRO510.nInDirection,
	                           InOutCarrier := "DB_JamArea5002".stJam5002_3.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO510.xOutBookedDir1 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO510.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.VAS.01', //todo
	                                 sInActionTaken := '1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 511 (1Sep)
	        
	        #TRO511.stInSeparator1.Settings.nSeparatorNo := "cSep511.1";
	        #TRO511.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO511.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO511.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO511.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO511.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO511.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO511.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO511.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3314"];
	        #TRO511.stInSenJam2 := "DB_Inputs".Sensors["cInBG3315"];
	        
	        #TRO511.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO511.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO511.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO511(nInMainTroNo := "cMainTro511",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE, //Gefälle
	                xInRelease := NOT "DB_MachineGlobal".xActivateWESComms OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[1].xIndexReq),
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5005".stJam5005_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5005".stJam5005_1.stData,
	                arInOutJamExit2 := "DB_JamArea5005".stJam5005_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5005".stJam5005_2.stData,
	                xOutStopper1 => "MB3314",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO511,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro511"]);
	    END_REGION
	    
	    REGION TRO 512 (Vario)+Scanner(BX5105) 
	        #TRO512.stInSeparator1.Settings.nSeparatorNo := "cSep512.1";
	        #TRO512.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO512.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO512.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO512.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO512.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO512.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO512.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO512.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3316"];
	        #TRO512.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO512.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5105"].xInCamTriggerReady := "bx5105-TriggerReady";
	        #arCognexInterface["cScannerBX5105"].xInCamTriggerAck := "bx5105-TriggerAck";
	        #arCognexInterface["cScannerBX5105"].xInCamResultsAvailable := "bx5105-Results Available";
	        #arCognexInterface["cScannerBX5105"].xInCamGeneralFault := "bx5105-General Fault";
	        #arCognexInterface["cScannerBX5105"].hwInCamInspectionResults := "BX5105~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO512.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO512.stInSeparator1.Settings.tSenWait := T#1200ms;
	        
	        #TRO512.stInSettings.bSepType.%X0 := TRUE; //am ersten Bein halten
	        #TRO512.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO512.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO512.stInVario.Settings.tConvEmpty := t#20000ms;//T#8000ms;
	        #TRO512.stInVario.Settings.nCountCarrier := 1;
	        #TRO512.stInVario.Settings.tWaitForStop := T#3s;
	        #TRO512.stInVario.Settings.tRasterHigh := t#3s;
	        #TRO512.stInVario.Settings.tRasterLow := t#3s;
	        
	        
	        #TRO512.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3317"]; //Finger in Pos
	        #TRO512.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3321"]; // Conveyor full
	        #TRO512.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3326"]; // Jam detector
	        #TRO512.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3320"]; // MT in Pos
	        #TRO512.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        //Provisorium zum Testen
	        
	        IF "DB_JamArea5005".stJam5005_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea5005".stJam5005_2.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_IF;
	        
	        #TRO512(nInMainTroNo := "cMainTro512",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInReset := "cTodoFalse",
	                xInAutomatic := #t_automatik,
	                xInRelease := "DB_TRO_Test".TRO512 AND (#"rTrig_Workstation1.0".Q OR "IBN".xSkipWorkstation1),
	                xInMotorProtection := "FC0065",
	                arInOutJamEntr := "DB_JamArea5005".stJam5005_2.arCarrier,
	                stInOutJamEntr := "DB_JamArea5005".stJam5005_2.stData,
	                arInOutJamFinger := "DB_JamArea5005".stJam5005_3.arCarrier,
	                stInOutJamFinger := "DB_JamArea5005".stJam5005_3.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5105"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO512,
	                xOutStopper => "MB3316",
	                xOutVarioMotor => "MA0065",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro512"]);
	        
	        "bx5105-TriggerEnable" := #arCognexInterface["cScannerBX5105"].xOutCamTriggerEnable;
	        "bx5105-Trigger" := #arCognexInterface["cScannerBX5105"].xOutCamTrigger;
	        "bx5105-ResultsAck" := #arCognexInterface["cScannerBX5105"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO512.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO512.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5005".stJam5005_2.arCarrier[1]);
	        END_REGION
	        
	        
	        REGION Release Button
	            #"rTrig_Workstation1.0"(CLK := "IBN".xTriggerWorkstation1 OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[1].xUnloadReq)); //Release Button Workstation 1.0 or telegram UPDATE: phys. Button existiert nicht mehr
	        END_REGION
	        REGION Send CTMP to Fortna WES
	            IF #TRO512.xOutNewScan AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_CTMP"(sInPLCID := "cPLCID",
	                               nInBarcode := #TRO512.nOutScanResult,
	                               sInStationName := 'GOH-VAS-01',
	                               sInLaneNumber := '1',
	                               FIFO := "DB_LGF_FIFO_CommWES",
	                               BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                               nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[1].xIndexReq := FALSE;
	            END_IF;
	        END_REGION
	        REGION Send UNLDResp to Fortna WES
	            IF #TRO512.xOutBooked AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_UNLDResp"(sInPLCID := "cPLCID",
	                                   nInBarcode := 0,
	                                   sInStationName := 'GOH-VAS-01',
	                                   sInLaneNumber := '1',
	                                   sInReasonCode := '1',
	                                   FIFO := "DB_LGF_FIFO_CommWES",
	                                   BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                "DB_Prozessdaten".stWorkStations.arWorkStations[1].xUnloadReq := FALSE;
	            END_IF;
	        END_REGION
	    END_REGION
	    
	    REGION TRO 513 (1Sep)
	        #TRO513.stInSeparator1.Settings.nSeparatorNo := "cSep513.1";
	        #TRO513.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO513.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO513.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO513.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO513.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO513.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO513.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO513.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3322"];
	        #TRO513.stInSenJam2 := "DB_Inputs".Sensors["cInBG3323"];
	        
	        #TRO513.stInSeparator1.Settings.tSenFree := t#2000ms;
	        #TRO513.stInSeparator1.Settings.tSenWait := t#2000ms;
	        
	        #TRO513(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO513.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO513.TroOut,
	                nInMainTroNo := "cMainTro513",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO513,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5005"."stJam5005_3".arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5005".stJam5005_3.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_4.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_4.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO513,
	                xOutStopper1 => "MB3322",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro513"]);
	        
	    END_REGION
	    
	    REGION TRO 514 (1Sep1Switch) + Scanner (BX5106)
	        #TRO514.stInSeparator1.Settings.nSeparatorNo := "cSep514.1";
	        #TRO514.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO514.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO514.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO514.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO514.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO514.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO514.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3360"];
	        #TRO514.stInSenJam2 := "DB_Inputs".Sensors["cInBG3361"];
	        #TRO514.stInSenJam3 := "DB_Inputs".Sensors["cInBG3384"];
	        
	        #TRO514.stInSwitch1.Settings.nSwitchNo := "cSwi514.1";
	        #TRO514.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO514.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO514.stInSwitch1.Settings.tTransitEx := T#5s;
	        #TRO514.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO514.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO514.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5106"].xInCamTriggerReady := "bx5106-TriggerReady";
	        #arCognexInterface["cScannerBX5106"].xInCamTriggerAck := "bx5106-TriggerAck";
	        #arCognexInterface["cScannerBX5106"].xInCamResultsAvailable := "bx5106-Results Available";
	        #arCognexInterface["cScannerBX5106"].xInCamGeneralFault := "bx5106-General Fault";
	        #arCognexInterface["cScannerBX5106"].hwInCamInspectionResults := "BX5106~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO514.stInSettings.xPrioDir2 := TRUE;
	        
	        #TRO514(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO514.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO514.TroOut,
	                nInMainTroNo := "cMainTro514",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO514,
	                xInCarouselRun1 := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5106"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_4.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_4.stData,
	                arInOutJamExit2 := "DB_JamArea5006".stJam5006_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5006".stJam5006_1.stData,
	                arInOutJamExit3 := "DB_JamArea5002".stJam5002_5.arCarrier,
	                stInOutJamExit3 := "DB_JamArea5002".stJam5002_5.stData,
	                xOutStopper1 => "MB3360",
	                xOutSw1ExTo3 => "MB3361",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO514,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro514"]);
	        
	        "bx5106-TriggerEnable" := #arCognexInterface["cScannerBX5106"].xOutCamTriggerEnable;
	        "bx5106-Trigger" := #arCognexInterface["cScannerBX5106"].xOutCamTrigger;
	        "bx5106-ResultsAck" := #arCognexInterface["cScannerBX5106"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO514.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO514.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_4.arCarrier[1]);
	        END_REGION
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi514.1",
	                           nOutDirection => #TRO514.nInDirection,
	                           InOutCarrier := "DB_JamArea5002".stJam5002_4.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO514.xOutBookedDir1 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO514.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.F2H.02', //todo
	                                 sInActionTaken := '1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 515 (1Sep)
	        
	        #TRO515.stInSeparator1.Settings.nSeparatorNo := "cSep515.1";
	        #TRO515.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO515.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO515.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO515.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO515.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO515.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO515.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO515.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3362"];
	        #TRO515.stInSenJam2 := "DB_Inputs".Sensors["cInBG3363"];
	        
	        #TRO515.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO515.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO515.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO515(nInMainTroNo := "cMainTro515",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE, //Gefälle
	                xInRelease := NOT "DB_MachineGlobal".xActivateWESComms OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[2].xIndexReq),
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5006".stJam5006_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5006".stJam5006_1.stData,
	                arInOutJamExit2 := "DB_JamArea5006".stJam5006_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5006".stJam5006_2.stData,
	                xOutStopper1 => "MB3362",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO515,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro515"]);
	        
	    END_REGION
	    
	    REGION TRO 516(Vario)+Scanner(BX5107) 
	        #TRO516.stInSeparator1.Settings.nSeparatorNo := "cSep516.1";
	        #TRO516.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO516.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO516.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO516.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO516.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO516.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO516.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO516.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3364"];
	        
	        #TRO516.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO516.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5107"].xInCamTriggerReady := "bx5107-TriggerReady";
	        #arCognexInterface["cScannerBX5107"].xInCamTriggerAck := "bx5107-TriggerAck";
	        #arCognexInterface["cScannerBX5107"].xInCamResultsAvailable := "bx5107-Results Available";
	        #arCognexInterface["cScannerBX5107"].xInCamGeneralFault := "bx5107-General Fault";
	        #arCognexInterface["cScannerBX5107"].hwInCamInspectionResults := "BX5107~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO516.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO516.stInSeparator1.Settings.tSenWait := T#4300ms;
	        #TRO516.stInSettings.bSepType.%X0 := TRUE; //am ersten Bein halten
	        #TRO516.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO516.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO516.stInVario.Settings.tConvEmpty := t#20000ms;//T#8000ms;
	        #TRO516.stInVario.Settings.nCountCarrier := 1;
	        #TRO516.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO516.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3365"]; //Finger in Pos
	        #TRO516.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3367"]; // Conveyor full
	        #TRO516.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3386"]; // Jam detector
	        #TRO516.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3366"]; // MT in Pos
	        #TRO516.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        //Provisorium
	        IF "DB_JamArea5006".stJam5006_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea5006".stJam5006_2.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_IF;
	        
	        #TRO516(nInMainTroNo := "cMainTro516",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_automatik,
	                xInReset := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO516 AND (#"rTrig_Workstation2.0".Q OR "IBN".xSkipWorkstation2),
	                xInMotorProtection := "FC0066",
	                arInOutJamEntr := "DB_JamArea5006".stJam5006_2.arCarrier,
	                stInOutJamEntr := "DB_JamArea5006".stJam5006_2.stData,
	                arInOutJamFinger := "DB_JamArea5006".stJam5006_3.arCarrier,
	                stInOutJamFinger := "DB_JamArea5006".stJam5006_3.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5107"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO516,
	                xOutStopper => "MB3364",
	                xOutVarioMotor => "MA0066",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro516"]);
	        
	        "bx5107-TriggerEnable" := #arCognexInterface["cScannerBX5107"].xOutCamTriggerEnable;
	        "bx5107-Trigger" := #arCognexInterface["cScannerBX5107"].xOutCamTrigger;
	        "bx5107-ResultsAck" := #arCognexInterface["cScannerBX5107"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO516.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO516.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5006".stJam5006_2.arCarrier[1]);
	        END_REGION
	        
	        REGION Release Button
	            #"rTrig_Workstation2.0"(CLK := "IBN".xTriggerWorkstation2 OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[2].xUnloadReq));
	        END_REGION
	        
	        REGION Send CTMP to Fortna WES
	            IF #TRO516.xOutNewScan AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_CTMP"(sInPLCID := "cPLCID",
	                               nInBarcode := #TRO516.nOutScanResult,
	                               sInStationName := 'GOH-VAS-02',
	                               sInLaneNumber := '1',
	                               FIFO := "DB_LGF_FIFO_CommWES",
	                               BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                               nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[2].xIndexReq := FALSE;
	            END_IF;
	        END_REGION
	        REGION Send UNLDResp to Fortna WES
	            IF #TRO516.xOutBooked AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_UNLDResp"(sInPLCID := "cPLCID",
	                                   nInBarcode := 0,
	                                   sInStationName := 'GOH-VAS-02',
	                                   sInLaneNumber := '1',
	                                   sInReasonCode := '1',
	                                   FIFO := "DB_LGF_FIFO_CommWES",
	                                   BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[2].xUnloadReq := FALSE;
	            END_IF;
	        END_REGION
	    END_REGION
	    
	    REGION TRO 517 (1Sep)
	        #TRO517.stInSeparator1.Settings.nSeparatorNo := "cSep517.1";
	        #TRO517.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO517.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO517.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO517.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO517.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO517.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO517.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO517.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3370"];
	        #TRO517.stInSenJam2 := "DB_Inputs".Sensors["cInBG3371"];
	        
	        #TRO517.stInSeparator1.Settings.tSenFree := t#2000ms;
	        #TRO517.stInSeparator1.Settings.tSenWait := t#2000ms;
	        
	        #TRO517(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO517.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO517.TroOut,
	                nInMainTroNo := "cMainTro517",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO517,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5006"."stJam5006_3".arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5006".stJam5006_3.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_5.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_5.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO517,
	                xOutStopper1 => "MB3370",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro517"]);
	        
	    END_REGION
	    
	    REGION TRO 518 (1Sep1Switch) + Scanner (BX5108)
	        #TRO518.stInSeparator1.Settings.nSeparatorNo := "cSep518.1";
	        #TRO518.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO518.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO518.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO518.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO518.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO518.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO518.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3372"];
	        #TRO518.stInSenJam2 := "DB_Inputs".Sensors["cInBG3373"];
	        #TRO518.stInSenJam3 := "DB_Inputs".Sensors["cInBG3385"];
	        
	        #TRO518.stInSwitch1.Settings.nSwitchNo := "cSwi518.1";
	        #TRO518.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO518.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO518.stInSwitch1.Settings.tTransitEx := T#5s;
	        #TRO518.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO518.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO518.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5108"].xInCamTriggerReady := "bx5108-TriggerReady";
	        #arCognexInterface["cScannerBX5108"].xInCamTriggerAck := "bx5108-TriggerAck";
	        #arCognexInterface["cScannerBX5108"].xInCamResultsAvailable := "bx5108-Results Available";
	        #arCognexInterface["cScannerBX5108"].xInCamGeneralFault := "bx5108-General Fault";
	        #arCognexInterface["cScannerBX5108"].hwInCamInspectionResults := "BX5108~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO518.stInSettings.xPrioDir2 := TRUE;
	        
	        #TRO518(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO518.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO518.TroOut,
	                nInMainTroNo := "cMainTro518",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO518,
	                xInCarouselRun1 := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5108"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_5.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_5.stData,
	                arInOutJamExit2 := "DB_JamArea5007".stJam5007_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5007".stJam5007_1.stData,
	                arInOutJamExit3 := "DB_JamArea5002".stJam5002_6.arCarrier,
	                stInOutJamExit3 := "DB_JamArea5002".stJam5002_6.stData,
	                xOutStopper1 => "MB3372",
	                xOutSw1ExTo3 => "MB3373",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO518,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro518"]);
	        
	        "bx5108-TriggerEnable" := #arCognexInterface["cScannerBX5108"].xOutCamTriggerEnable;
	        "bx5108-Trigger" := #arCognexInterface["cScannerBX5108"].xOutCamTrigger;
	        "bx5108-ResultsAck" := #arCognexInterface["cScannerBX5108"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO518.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO518.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_5.arCarrier[1]);
	        END_REGION
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi518.1",
	                           nOutDirection => #TRO518.nInDirection,
	                           InOutCarrier := "DB_JamArea5002".stJam5002_5.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO518.xOutBookedDir1 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO518.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.F2H.03', //todo
	                                 sInActionTaken := '1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	                
	            END_IF;
	        END_REGION
	        
	        
	    END_REGION
	    
	    REGION TRO 519 (1Sep)
	        
	        #TRO519.stInSeparator1.Settings.nSeparatorNo := "cSep519.1";
	        #TRO519.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO519.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO519.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO519.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO519.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO519.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO519.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO519.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3374"];
	        #TRO519.stInSenJam2 := "DB_Inputs".Sensors["cInBG3375"];
	        
	        #TRO519.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO519.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO519.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO519(nInMainTroNo := "cMainTro519",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE, //Gefälle
	                xInRelease := NOT "DB_MachineGlobal".xActivateWESComms OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[3].xIndexReq),
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5007".stJam5007_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5007".stJam5007_1.stData,
	                arInOutJamExit2 := "DB_JamArea5007".stJam5007_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5007".stJam5007_2.stData,
	                xOutStopper1 => "MB3374",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO519,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro519"]);
	        
	    END_REGION
	    
	    REGION TRO 520 (Vario)+Scanner(BX5109) 
	        #TRO520.stInSeparator1.Settings.nSeparatorNo := "cSep520.1";
	        #TRO520.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO520.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO520.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO520.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO520.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO520.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO520.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO520.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3376"];
	        #TRO520.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO520.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5109"].xInCamTriggerReady := "bx5109-TriggerReady";
	        #arCognexInterface["cScannerBX5109"].xInCamTriggerAck := "bx5109-TriggerAck";
	        #arCognexInterface["cScannerBX5109"].xInCamResultsAvailable := "bx5109-Results Available";
	        #arCognexInterface["cScannerBX5109"].xInCamGeneralFault := "bx5109-General Fault";
	        #arCognexInterface["cScannerBX5109"].hwInCamInspectionResults := "BX5109~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO520.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO520.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO520.stInSettings.bSepType.%X0 := TRUE; //am ersten Bein halten
	        #TRO520.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO520.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO520.stInVario.Settings.tConvEmpty := t#20000ms;//T#8000ms;
	        #TRO520.stInVario.Settings.nCountCarrier := 1;
	        #TRO520.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO520.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3377"]; //Finger in Pos
	        #TRO520.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3381"]; // Conveyor full
	        #TRO520.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3387"]; // Jam detector
	        #TRO520.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3380"]; // MT in Pos
	        
	        #TRO520.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        IF "DB_JamArea5007".stJam5007_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea5007".stJam5007_2.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_IF;
	        
	        #TRO520(nInMainTroNo := "cMainTro520",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_automatik,
	                xInReset := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO520 AND (#"rTrig_Workstation3.0".Q OR "IBN".xSkipWorkstation3),
	                xInMotorProtection := "FC0067",
	                arInOutJamEntr := "DB_JamArea5007".stJam5007_2.arCarrier,
	                stInOutJamEntr := "DB_JamArea5007".stJam5007_2.stData,
	                arInOutJamFinger := "DB_JamArea5007".stJam5007_3.arCarrier,
	                stInOutJamFinger := "DB_JamArea5007".stJam5007_3.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5109"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO520,
	                xOutStopper => "MB3376",
	                xOutVarioMotor => "MA0067",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro520"]);
	        
	        "bx5109-TriggerEnable" := #arCognexInterface["cScannerBX5109"].xOutCamTriggerEnable;
	        "bx5109-Trigger" := #arCognexInterface["cScannerBX5109"].xOutCamTrigger;
	        "bx5109-ResultsAck" := #arCognexInterface["cScannerBX5109"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO520.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO520.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5007".stJam5007_2.arCarrier[1]);
	        END_REGION
	        
	        REGION Release Button
	            #"rTrig_Workstation3.0"(CLK := "IBN".xTriggerWorkstation3 OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[3].xUnloadReq));
	        END_REGION
	        
	        REGION Send CTMP to Fortna WES
	            IF #TRO520.xOutNewScan AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_CTMP"(sInPLCID := "cPLCID",
	                               nInBarcode := #TRO520.nOutScanResult,
	                               sInStationName := 'GOH-VAS-03',
	                               sInLaneNumber := '1',
	                               FIFO := "DB_LGF_FIFO_CommWES",
	                               BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                               nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[3].xIndexReq := FALSE;
	
	            END_IF;
	        END_REGION
	        REGION Send UNLDResp to Fortna WES
	            IF #TRO520.xOutBooked AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_UNLDResp"(sInPLCID := "cPLCID",
	                                   nInBarcode := 0,
	                                   sInStationName := 'GOH-VAS-03',
	                                   sInLaneNumber := '1',
	                                   sInReasonCode := '1',
	                                   FIFO := "DB_LGF_FIFO_CommWES",
	                                   BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[3].xUnloadReq := FALSE;
	            END_IF;
	        END_REGION
	    END_REGION
	    
	    REGION TRO 521(1Sep)
	        #TRO521.stInSeparator1.Settings.nSeparatorNo := "cSep521.1";
	        #TRO521.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO521.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO521.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO521.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO521.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO521.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO521.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO521.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3382"];
	        #TRO521.stInSenJam2 := "DB_Inputs".Sensors["cInBG3383"];
	        
	        #TRO521.stInSeparator1.Settings.tSenFree := t#2000ms;
	        #TRO521.stInSeparator1.Settings.tSenWait := t#2000ms;
	        
	        #TRO521(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO521.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO521.TroOut,
	                nInMainTroNo := "cMainTro521",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO521,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5007"."stJam5007_3".arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5007".stJam5007_3.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_6.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_6.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO521,
	                xOutStopper1 => "MB3382",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro521"]);
	        
	    END_REGION
	    
	    REGION TRO 522 (1Sep1Switch) + Scanner (BX5110)
	        #TRO522.stInSeparator1.Settings.nSeparatorNo := "cSep522.1";
	        #TRO522.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO522.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO522.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO522.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO522.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO522.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO522.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3420"];
	        #TRO522.stInSenJam2 := "DB_Inputs".Sensors["cInBG3421"];
	        #TRO522.stInSenJam3 := "DB_Inputs".Sensors["cInBG3437"];
	        
	        #TRO522.stInSwitch1.Settings.nSwitchNo := "cSwi522.1";
	        #TRO522.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO522.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO522.stInSwitch1.Settings.tTransitEx := T#5s;
	        #TRO522.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO522.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO522.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5110"].xInCamTriggerReady := "bx5110-TriggerReady";
	        #arCognexInterface["cScannerBX5110"].xInCamTriggerAck := "bx5110-TriggerAck";
	        #arCognexInterface["cScannerBX5110"].xInCamResultsAvailable := "bx5110-Results Available";
	        #arCognexInterface["cScannerBX5110"].xInCamGeneralFault := "bx5110-General Fault";
	        #arCognexInterface["cScannerBX5110"].hwInCamInspectionResults := "BX5110~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO522.stInSettings.xPrioDir2 := TRUE;
	        
	        #TRO522(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO522.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO522.TroOut,
	                nInMainTroNo := "cMainTro522",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO522,
	                xInCarouselRun1 := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5110"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_6.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_6.stData,
	                arInOutJamExit2 := "DB_JamArea5008".stJam5008_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5008".stJam5008_1.stData,
	                arInOutJamExit3 := "DB_JamArea5002".stJam5002_7.arCarrier,
	                stInOutJamExit3 := "DB_JamArea5002".stJam5002_7.stData,
	                xOutStopper1 => "MB3420",
	                xOutSw1ExTo3 => "MB3421",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO522,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro522"]);
	        
	        "bx5110-TriggerEnable" := #arCognexInterface["cScannerBX5110"].xOutCamTriggerEnable;
	        "bx5110-Trigger" := #arCognexInterface["cScannerBX5110"].xOutCamTrigger;
	        "bx5110-ResultsAck" := #arCognexInterface["cScannerBX5110"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO522.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO522.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_6.arCarrier[1]);
	        END_REGION
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi522.1",
	                           nOutDirection => #TRO522.nInDirection,
	                           InOutCarrier := "DB_JamArea5002".stJam5002_6.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO522.xOutBookedDir1 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO522.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.F2H.04', //todo
	                                 sInActionTaken := '1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	                
	            END_IF;
	        END_REGION
	        
	        
	    END_REGION
	    
	    REGION TRO 523 (1Sep)
	        
	        #TRO523.stInSeparator1.Settings.nSeparatorNo := "cSep523.1";
	        #TRO523.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO523.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO523.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO523.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO523.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO523.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO523.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO523.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3422"];
	        #TRO523.stInSenJam2 := "DB_Inputs".Sensors["cInBG3423"];
	        
	        #TRO523.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO523.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO523.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO523(nInMainTroNo := "cMainTro523",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE, //Gefälle
	                xInRelease := NOT "DB_MachineGlobal".xActivateWESComms OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[4].xIndexReq),
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5008".stJam5008_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5008".stJam5008_1.stData,
	                arInOutJamExit2 := "DB_JamArea5008".stJam5008_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5008".stJam5008_2.stData,
	                xOutStopper1 => "MB3422",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO523,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro523"]);
	        
	    END_REGION
	    
	    REGION TRO 524 (Vario)+Scanner(BX5231) 
	        #TRO524.stInSeparator1.Settings.nSeparatorNo := "cSep524.1";
	        #TRO524.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO524.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	        #TRO524.stInSeparator1.Settings.tHandlingTime := t#400ms;
	        #TRO524.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO524.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO524.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO524.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO524.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3424"];
	        #TRO524.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO524.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5111"].xInCamTriggerReady := "bx5111-TriggerReady";
	        #arCognexInterface["cScannerBX5111"].xInCamTriggerAck := "bx5111-TriggerAck";
	        #arCognexInterface["cScannerBX5111"].xInCamResultsAvailable := "bx5111-Results Available";
	        #arCognexInterface["cScannerBX5111"].xInCamGeneralFault := "bx5111-General Fault";
	        #arCognexInterface["cScannerBX5111"].hwInCamInspectionResults := "BX5111~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO524.stInSeparator1.Settings.tSenFree := T#1200ms;
	        #TRO524.stInSeparator1.Settings.tSenWait := T#4300ms;
	        #TRO524.stInSettings.bSepType.%X0 := TRUE; //am ersten Bein halten
	        #TRO524.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO524.stInVario.Settings.tWaitForJog := T#400ms;
	        #TRO524.stInVario.Settings.tConvEmpty := t#20000ms;//T#8000ms;
	        #TRO524.stInVario.Settings.nCountCarrier := 1;
	        #TRO524.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO524.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3425"]; //Finger in Pos
	        #TRO524.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3427"]; // Conveyor full
	        #TRO524.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3444"]; // Jam detector
	        #TRO524.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3426"]; // MT in Pos
	        
	        #TRO524.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        IF "DB_JamArea5008".stJam5008_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea5008".stJam5008_2.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_IF;
	        
	        IF "DB_Prozessdaten".xTestFlushWorkstationStart THEN
	            "DB_Prozessdaten".xTestFlushWorkstation := TRUE;
	            IF "DB_JamArea5008".stJam5008_1.stData.Status.nCount = 0 THEN
	                "DB_Prozessdaten".xTestFlushWorkstation := FALSE;
	                "DB_Prozessdaten".xTestFlushWorkstationStart := FALSE;
	            END_IF;
	        END_IF;
	        
	        #TRO524(nInMainTroNo := "cMainTro524",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_automatik,
	                xInReset := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO524 AND (((#"rTrig_Workstation4.0".Q OR "IBN".xSkipWorkstation4) AND NOT "DB_Prozessdaten".xTestFlushWorkstation) OR "DB_Prozessdaten".xTestFlushWorkstation),
	                xInMotorProtection := "FC0070",
	                arInOutJamEntr := "DB_JamArea5008".stJam5008_2.arCarrier,
	                stInOutJamEntr := "DB_JamArea5008".stJam5008_2.stData,
	                arInOutJamFinger := "DB_JamArea5008".stJam5008_3.arCarrier,
	                stInOutJamFinger := "DB_JamArea5008".stJam5008_3.stData,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5111"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO524,
	                xOutStopper => "MB3424",
	                xOutVarioMotor => "MA0070",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro524"]);
	        
	        "bx5111-TriggerEnable" := #arCognexInterface["cScannerBX5111"].xOutCamTriggerEnable;
	        "bx5111-Trigger" := #arCognexInterface["cScannerBX5111"].xOutCamTrigger;
	        "bx5111-ResultsAck" := #arCognexInterface["cScannerBX5111"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO524.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO524.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5008".stJam5008_2.arCarrier[1]);
	        END_REGION
	        
	        REGION Release Button
	            //Reset Button für IBN hergenommen
	            #"rTrig_Workstation4.0"(CLK := "IBN".xTriggerWorkstation4 OR ("DB_MachineGlobal".xActivateWESComms AND "DB_Prozessdaten".stWorkStations.arWorkStations[4].xUnloadReq));
	        END_REGION
	        
	        REGION Send CTMP to Fortna WES
	            IF #TRO524.xOutNewScan AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_CTMP"(sInPLCID := "cPLCID",
	                               nInBarcode := #TRO524.nOutScanResult,
	                               sInStationName := 'GOH-VAS-04',
	                               sInLaneNumber := '1',
	                               FIFO := "DB_LGF_FIFO_CommWES",
	                               BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                               nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[4].xIndexReq := FALSE;
	            END_IF;
	        END_REGION
	        REGION Send UNLDResp to Fortna WES
	            IF #TRO524.xOutBooked AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_UNLDResp"(sInPLCID := "cPLCID",
	                                   nInBarcode := 0,
	                                   sInStationName := 'GOH-VAS-01',
	                                   sInLaneNumber := '1',
	                                   sInReasonCode := '1',
	                                   FIFO := "DB_LGF_FIFO_CommWES",
	                                   BUFFER := "DB_Buffer_CommunicationWES".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWESDeviceHub);
	                
	                "DB_Prozessdaten".stWorkStations.arWorkStations[4].xUnloadReq := FALSE;
	                
	            END_IF;
	        END_REGION
	    END_REGION
	    
	    REGION TRO 525(1Sep)
	        #TRO525.stInSeparator1.Settings.nSeparatorNo := "cSep525.1";
	        #TRO525.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO525.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO525.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO525.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO525.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO525.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO525.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO525.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3430"];
	        #TRO525.stInSenJam2 := "DB_Inputs".Sensors["cInBG3431"];
	        
	        #TRO525.stInSeparator1.Settings.tSenFree := t#2000ms;
	        #TRO525.stInSeparator1.Settings.tSenWait := t#2000ms;
	        
	        #TRO525(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO525.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO525.TroOut,
	                nInMainTroNo := "cMainTro525",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO525,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5008"."stJam5008_3".arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5008".stJam5008_3.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_7.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_7.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO525,
	                xOutStopper1 => "MB3430",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro525"]);
	    END_REGION
	    
	    REGION TRO 526 (1Sep) + Scanner (BX5112)
	        #TRO526.stInSeparator1.Settings.nSeparatorNo := "cSep526.1";
	        #TRO526.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO526.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO526.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO526.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO526.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO526.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO526.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO526.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3432"];
	        // #TRO526.stInSenJam2 := "DB_Inputs".Sensors["cInBG3302"];
	        
	        #TRO526.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO526.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5112"].xInCamTriggerReady := "bx5112-TriggerReady";
	        #arCognexInterface["cScannerBX5112"].xInCamTriggerAck := "bx5112-TriggerAck";
	        #arCognexInterface["cScannerBX5112"].xInCamResultsAvailable := "bx5112-Results Available";
	        #arCognexInterface["cScannerBX5112"].xInCamGeneralFault := "bx5112-General Fault";
	        #arCognexInterface["cScannerBX5112"].hwInCamInspectionResults := "BX5112~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO526.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO526(nInMainTroNo := "cMainTro526",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO526,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5112"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_7.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_7.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_8.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_8.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO526,
	                xOutStopper1 => "MB3432",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro526"]);
	        
	        "bx5112-TriggerEnable" := #arCognexInterface["cScannerBX5112"].xOutCamTriggerEnable;
	        "bx5112-Trigger" := #arCognexInterface["cScannerBX5112"].xOutCamTrigger;
	        "bx5112-ResultsAck" := #arCognexInterface["cScannerBX5112"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO526.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO526.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_7.arCarrier[1]);
	        END_REGION
	        
	        REGION Längenmessung 
	            "FB_Längenmessung_DB"(xInStartMessung := (#TRO526.nState = 2500 AND #TRO526.fbSeparator1.xOutTrolleyReleasedEdge),
	                                  xInEndeMessung := "DB_Inputs".Sensors["cInBG3443"].xDirectSensor,
	                                  xInTeilVorhanden := "DB_Inputs".Sensors["cInBG3440"].xDirectSensor,
	                                  xInTeilLang := NOT "DB_Inputs".Sensors["cInBG3441"].xDirectSensor,
	                                  xInTeilzuLang := NOT "DB_Inputs".Sensors["cInBG3442"].xDirectSensor);
	            
	            #rTrig_LengthMeasurement(CLK := "FB_Längenmessung_DB".xOutFinished);
	            
	            IF #rTrig_LengthMeasurement.Q THEN
	                IF "FB_Längenmessung_DB".xOutTeilKurz THEN
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nBarcode := "DB_JamArea5002".stJam5002_8.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := 1; //kurz
	                ELSIF "FB_Längenmessung_DB".xOutTeilLang THEN
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nBarcode := "DB_JamArea5002".stJam5002_8.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := 2; //lang
	                ELSIF "FB_Längenmessung_DB".xOutErrorzuLang THEN
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nBarcode := "DB_JamArea5002".stJam5002_8.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := -1; // zu lang
	                ELSIF "FB_Längenmessung_DB".xOutLeer THEN
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nBarcode := "DB_JamArea5002".stJam5002_8.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := 10; // leer
	                ELSE
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nBarcode := "DB_JamArea5002".stJam5002_8.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := -99; //Fehler
	                END_IF;
	            END_IF;
	            
	            REGION DecisionRequest to Fortna WCS
	                // Wenn Längenmessung abgeschlossen dann Telegram mit spezifizierten Daten generieren und in TCP Sende-FIFO schieben
	                
	                IF #rTrig_LengthMeasurement.Q THEN
	                    IF "FB_Längenmessung_DB".xOutTeilKurz THEN
	                        #sLengthInfo := 'Short';
	                    ELSIF "FB_Längenmessung_DB".xOutTeilLang THEN
	                        #sLengthInfo := 'Long';
	                    ELSIF "FB_Längenmessung_DB".xOutErrorzuLang THEN
	                        #sLengthInfo := 'Too Long';
	                    ELSIF "FB_Längenmessung_DB".xOutLeer THEN
	                        #sLengthInfo := 'Empty';
	                    ELSE
	                        #sLengthInfo := 'Error';
	                    END_IF;
	                    
	                    "FC_Send_GOHDReqM"(sInPLCID := "cPLCID",
	                                       xInSSCCReq := FALSE,
	                                       xInLengthReq := TRUE,
	                                       xInDockDoorReq := FALSE,
	                                       xInLaneStatusReq := FALSE,
	                                       nInBarcode := "DB_JamArea5002".stJam5002_8.arCarrier[1].nBarcode,
	                                       sInSSCC := '',
	                                       sInDecisionPoint := 'GOH.Proc.03',
	                                       sInDockDoor := '',
	                                       sInLengthInfo := #sLengthInfo,
	                                       arInLaneStatus := #tmpPlaceHolderLaneStatus,
	                                       nInLaneCnt := 0,
	                                       FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                       BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                       nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	                END_IF;
	                
	            END_REGION
	            
	            
	            
	            (* "FB_Längenmessung_DB"(
	                                   xInEndeMessung := "DB_Inputs".Sensors["cInBG3443"].xDirectSensor,
	                                   xInTeilVorhanden := "DB_Inputs".Sensors["cInBG3440"].xDirectSensor,
	                                   xInTeilLang := NOT "DB_Inputs".Sensors["cInBG3441"].xDirectSensor,
	                                   xInTeilzuLang := NOT "DB_Inputs".Sensors["cInBG3442"].xDirectSensor); *)
	            
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 527 (1Sep1Switch) 
	        
	        #TRO527.stInSeparator1.Settings.nSeparatorNo := "cSep527.1";
	        #TRO527.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO527.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO527.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO527.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO527.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO527.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO527.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3433"];
	        #TRO527.stInSenJam2 := "DB_Inputs".Sensors["cInBG3436"];
	        #TRO527.stInSenJam3 := "DB_Inputs".Sensors["cInBG3434"];
	        
	        #TRO527.stInSwitch1.Settings.nSwitchNo := "cSwi527.1";
	        #TRO527.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO527.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO527.stInSwitch1.Settings.tTransitEx := T#5s;
	        #TRO527.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO527.stInPriorityManagerDir1.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #stJamDataPlaceHolder.Config.nCapacitySet := 1;
	        
	        REGION TEST!!!!!!!!!!!!!!!!
	            //   "DB_JamArea5002".stJam5002_8.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_REGION
	        
	        
	        #TRO527(nInMainTroNo := "cMainTro527",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_Test".TRO527,
	                xInCarouselRun1 := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_8.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_8.stData,
	                arInOutJamExit2 := #arCarrierPlaceHolder,
	                stInOutJamExit2 := #stJamDataPlaceHolder,
	                arInOutJamExit3 := "DB_JamArea5002".stJam5002_9.arCarrier,
	                stInOutJamExit3 := "DB_JamArea5002".stJam5002_9.stData,
	                xOutStopper1 => "MB3433",
	                xOutSw1ExTo3 => "MB3436",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO527,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro527"]);
	        (*      
	              REGION Carr_Glob_Correction            
	                  "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO527.xOutCorrection, //Führe Korrektur aus
	                                                nInBarcodeScan := #TRO527.nBarcodeResult,
	                                                nInStation := 0,
	                                                arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                                InOutCarrierExpect := "DB_JamArea5002".stJam5002_9.arCarrier[1]);
	              END_REGION *)
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi527.1",
	                           nOutDirection => #TRO527.nInDirection,
	                           InOutCarrier := "DB_JamArea5002".stJam5002_8.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO527.xOutBookedDir1 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO527.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.Proc.03',
	                                 sInActionTaken := '1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            ELSIF #TRO527.xOutBookedDir2 AND "DB_MachineGlobal".xActivateWESComms THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO527.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := 'GOH.Proc.03',
	                                 sInActionTaken := '-1',
	                                 nReasonCode := 1,
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 528 (1Sep)
	        
	        #TRO528.stInSeparator1.Settings.nSeparatorNo := "cSep528.1";
	        #TRO528.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO528.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO528.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO528.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO528.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO528.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO528.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO528.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3306"];
	        
	        #TRO528.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        // "DB_JamArea5002".stJam5002_9.arCarrier[1].nBarcode := 2000;
	        // "DB_JamArea5002".stJam5002_9.arCarrier[1].bStatus.%X0 := TRUE;
	        
	        #TRO528(nInMainTroNo := "cMainTro528",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_Test".TRO528,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_9.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_9.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_10.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_10.stData,
	                xOutStopper1 => "MB3306",
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO528,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro528"]);
	        
	    END_REGION
	    
	    REGION TRO 529 (1Sep) + Scanner (BX5113)
	        #TRO529.stInSeparator1.Settings.nSeparatorNo := "cSep529.1";
	        #TRO529.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO529.stInSeparator1.Settings.tTrailingTime := t#0ms;
	        #TRO529.stInSeparator1.Settings.tHandlingTime := t#0ms;
	        #TRO529.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO529.stInSeparator1.Settings.xPluggedJam := TRUE;
	        
	        #TRO529.stInSeparator1.Settings.xPluggedPart := TRUE;
	        #TRO529.stInSettings.bSepType.%X0 := TRUE;
	        #TRO529.stInSettings.bSepType.%X1 := TRUE;
	        #TRO529.stInSettings.tPartSenHigh := T#500ms;
	        #TRO529.stInSettings.tInSenHigh := T#500ms;
	        
	        #TRO529.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO529.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3307"];
	        #TRO529.stInSeparator1.stSenPart := "DB_Inputs".Sensors["cInBG3327"];
	        #TRO529.stInSenJam2 := "DB_Inputs".Sensors["cInBG3310"];
	        
	        #TRO529.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO529.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX5113"].xInCamTriggerReady := "bx5113-TriggerReady";
	        #arCognexInterface["cScannerBX5113"].xInCamTriggerAck := "bx5113-TriggerAck";
	        #arCognexInterface["cScannerBX5113"].xInCamResultsAvailable := "bx5113-Results Available";
	        #arCognexInterface["cScannerBX5113"].xInCamGeneralFault := "bx5113-General Fault";
	        #arCognexInterface["cScannerBX5113"].hwInCamInspectionResults := "BX5113~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO529.stInPriorityManager.xReleaseOk := "cTodoTRUE";
	        
	        IF "DB_Interface_HMI".stControl.xEmptyCarrierInsertReq THEN
	            "DB_JamArea5002".stJam5002_10.arCarrier[1].nDestination := "cDestLeaveF2H";
	        END_IF;
	        
	        #TRO529((* stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO529.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO529.TroOut, *)
	                nInMainTroNo := "cMainTro529",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease :=  (* "DB_TRO_Test".TRO529 *)"DB_Interface_HMI".stControl.xEmptyCarrierInsertReq OR #rTrig_ClarificationButton.Q,
	                xInCarouselRun := #fbCarousel5002.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinet,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX5113"],
	                arInOutJamEntr1 := "DB_JamArea5002".stJam5002_10.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea5002".stJam5002_10.stData,
	                arInOutJamExit2 := "DB_JamArea5002".stJam5002_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea5002".stJam5002_1.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.stTRO529,
	                xOutStopper1 => "MB3307",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro529"]);
	        
	        "bx5113-TriggerEnable" := #arCognexInterface["cScannerBX5113"].xOutCamTriggerEnable;
	        "bx5113-Trigger" := #arCognexInterface["cScannerBX5113"].xOutCamTrigger;
	        "bx5113-ResultsAck" := #arCognexInterface["cScannerBX5113"].xOutCamResultsAck;
	        
	        REGION Clarification Release
	            
	            #rTrig_ClarificationButton(CLK := "SF0056"); //Release Button Clarification Point
	            
	        END_REGION
	        
	        REGION Trolley Handling
	            
	            IF NOT "DB_Inputs".Sensors["cInBG3307"].xDirectSensor AND
	                "DB_Interface_HMI".stClearingStation.xDeleteTrolley
	            THEN
	                "DB_JamArea5002".stJam5002_10.arCarrier[1] := #stEmptyCarrier;
	                "DB_Interface_HMI".stClearingStation.xDeleteTrolley := FALSE;
	                #TRO529.nState := 100;
	            END_IF;
	            
	            IF NOT "DB_Inputs".Sensors["cInBG3327"].xDirectSensor AND
	                "DB_Interface_HMI".stClearingStation.xDeleteLoad
	            THEN
	                "DB_JamArea5002".stJam5002_10.arCarrier[1].bStatus.%X1 := FALSE;
	                "DB_Interface_HMI".stClearingStation.xDeleteLoad := FALSE;
	            END_IF;
	        END_REGION ;
	        
	        REGION Carr_Glob_Correction            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO529.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO529.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea5002".stJam5002_10.arCarrier[1]);
	        END_REGION
	        IF #TRO529.xOutNewScan THEN
	            #tmpLaneStatus[0] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                     stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[1]);
	            #tmpLaneStatus[1] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                     stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[2]);
	            #tmpLaneStatus[2] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                     stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[3]);
	            #tmpLaneStatus[3] := "FC_Get_LaneStatus"(stInOutJamData := "DB_JamArea5005"."stJam5005_1".stData,
	                                                     stInOutWorkStation := "DB_Prozessdaten".stWorkStations.arWorkStations[4]);
	            
	            
	            "FC_Send_GOHDReqM"(sInPLCID := "cPLCID",
	                               xInSSCCReq := FALSE,
	                               xInLengthReq := FALSE,
	                               xInDockDoorReq := FALSE,
	                               xInLaneStatusReq := TRUE,
	                               nInBarcode := #TRO529.nOutScanResult,
	                               sInSSCC := '',
	                               sInDecisionPoint := "cDP_GOH_PROC_02",
	                               sInDockDoor := '',
	                               sInLengthInfo := '',
	                               arInLaneStatus := #tmpLaneStatus,
	                               nInLaneCnt := 4,
	                               FIFO := "DB_LGF_FIFO_CommWCSBL",
	                               BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                               nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	        END_IF;
	        
	    END_REGION
	    REGION NEUE TROs - Stand: Vorbereitet für Umbau
	        REGION TRO 530 (Vario)
	            #TRO530.stInSeparator1.Settings.nSeparatorNo := "cSep530.1";
	            #TRO530.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	            #TRO530.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	            #TRO530.stInSeparator1.Settings.tHandlingTime := t#400ms;
	            #TRO530.stInSeparator1.Settings.tJam := "TimeForSepJam";
	            #TRO530.stInSeparator1.Settings.xPluggedJam := FALSE;
	            #TRO530.stInSeparator1.Settings.xPluggedPart := FALSE;
	            #TRO530.stInSeparator1.Settings.xPluggedScanner := FALSE;
	            #TRO530.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3457"];
	            
	            #TRO530.stInSeparator1.Settings.tSenFree := T#1200ms;
	            #TRO530.stInSeparator1.Settings.tSenWait := T#4300ms;
	            
	            #TRO530.stInVario.Settings.xContinousEmptying := FALSE;
	            #TRO530.stInVario.Settings.tWaitForJog := T#400ms;
	            #TRO530.stInVario.Settings.tConvEmpty := t#90s;// bei IBN anpassen todo!
	            #TRO530.stInVario.Settings.nCountCarrier := 1;
	            #TRO530.stInVario.Settings.tWaitForStop := T#3s;
	            
	            #TRO530.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3460"]; //Finger in Pos
	            #TRO530.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3303"]; // Conveyor full
	            #TRO530.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3325"]; // Jam detector
	            #TRO530.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3461"]; // MT in Pos
	            
	            #TRO530.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	            
	            #TRO530(nInMainTroNo := "cMainTro530",
	                    xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                    xInAllRdyToStart := TRUE,
	                    xInReset := "cTodoFalse",
	                    xInAutomatic := #t_automatik,
	                    xInRelease := "DB_TRO_Test".TRO530,
	                    xInMotorProtection := "FC0061",
	                    arInOutJamEntr := "DB_JamArea5001".stJam5001_2.arCarrier,
	                    stInOutJamEntr := "DB_JamArea5001".stJam5001_2.stData,
	                    arInOutJamFinger := "DB_JamArea5001".stJam5001_3.arCarrier,
	                    stInOutJamFinger := "DB_JamArea5001".stJam5001_3.stData,
	                    stInOutMachineState := #stInOutControlUnitCabinet,
	                    stInOutCognexInterface := #stCognexInterfaceDummy,
	                    stInOutHMI := "DB_Interface_HMI".stTRO.stTRO530,
	                    xOutStopper => "MB3457",
	                    xOutVarioMotor => "MA0061",
	                    nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro530"]);
	            
	        END_REGION ;
	        
	         REGION TRO 531 (Vario)
	             #TRO531.stInSeparator1.Settings.nSeparatorNo := "cSep531.1";
	             #TRO531.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	             #TRO531.stInSeparator1.Settings.tTrailingTime := "cTimeSepTrailing";
	             #TRO531.stInSeparator1.Settings.tHandlingTime := t#400ms;
	             #TRO531.stInSeparator1.Settings.tJam := "TimeForSepJam";
	             #TRO531.stInSeparator1.Settings.xPluggedJam := FALSE;
	             #TRO531.stInSeparator1.Settings.xPluggedPart := FALSE;
	             #TRO531.stInSeparator1.Settings.xPluggedScanner := FALSE;
	             #TRO531.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3452"];
	             
	             #TRO531.stInSeparator1.Settings.tSenFree := T#1200ms;
	             #TRO531.stInSeparator1.Settings.tSenWait := T#4300ms;
	             
	             #TRO531.stInVario.Settings.xContinousEmptying := FALSE;
	             #TRO531.stInVario.Settings.tWaitForJog := T#400ms;
	             #TRO531.stInVario.Settings.tConvEmpty := t#90s;// bei IBN anpassen todo!
	             #TRO531.stInVario.Settings.nCountCarrier := 1;
	             #TRO531.stInVario.Settings.tWaitForStop := T#3s;
	             
	             #TRO531.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3453"]; //Finger in Pos
	             #TRO531.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3300"]; // Conveyor full
	             #TRO531.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3311"]; // Jam detector
	             #TRO531.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3454"]; // MT in Pos
	             
	             #TRO531.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	             
	             #TRO531(nInMainTroNo := "cMainTro531",
	                     xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	                     xInAllRdyToStart := TRUE,
	                     xInReset := "cTodoFalse",
	                     xInAutomatic := #t_automatik,
	                     xInRelease := "DB_TRO_Test".TRO531,
	                     xInMotorProtection := "FC0060",
	                     arInOutJamEntr := "DB_JamArea5000".stJam5000_2.arCarrier,
	                     stInOutJamEntr := "DB_JamArea5000".stJam5000_2.stData,
	                     arInOutJamFinger := "DB_JamArea5000".stJam5000_3.arCarrier,
	                     stInOutJamFinger := "DB_JamArea5000".stJam5000_3.stData,
	                     stInOutMachineState := #stInOutControlUnitCabinet,
	                     stInOutCognexInterface := #stCognexInterfaceDummy,
	                     stInOutHMI := "DB_Interface_HMI".stTRO.stTRO531,
	                     xOutStopper => "MB3452",
	                     xOutVarioMotor => "MA0060",
	                     nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro531"]);
	             
	         END_REGION
	         
	     END_REGION
	END_REGION ;
END_FUNCTION_BLOCK

