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

   VAR 
      fbCarousel0101 : "FB_Conveyor";   // Eingangskreisel
      fbCarousel0102 : "FB_Conveyor";   // Ausgangskreisel
      fbConveyor0103 : "FB_Conveyor";   // Bürsten Zufahrt LS1
      fbCarousel0104 : "FB_Conveyor";   // Kreisel LS1
      fbConveyor0106 : "FB_Conveyor";   // Bürsten Abfuhr LS1
      fbConveyor0107 : "FB_Conveyor";   // Bürsten Zufahrt LS2
      fbCarousel0108 : "FB_Conveyor";
      fbConveyor0110 : "FB_Conveyor";   // Bürsten Abfuhr LS2
      fbCarousel4204 : "FB_Conveyor";
      fbConveyor4103_B : "FB_Conveyor";   // Bürsten Highway Loaded to Storage
      fbConveyor4203_B : "FB_Conveyor";   // Bürsten Highway Empty to Storage
      fbConveyor4302_A : "FB_Conveyor";   // Bürsten Highway Empty to Inbound
      fbConveyor4402_A : "FB_Conveyor";   // Bürsten Highway Loaded to AMR
      fbLoadingBoom1 : "FB_LoadingBoom_INBOUND";
      fbLoadingBoom2 : "FB_LoadingBoom_INBOUND";
      rTrig_IBN_KREISEL {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      xKreiselmerker : Bool;   // IBN
      arBarcodeReader { S7_SetPoint := 'False'} : Array[1.."cNoScanner"] of "FB_BarcodeReaderCognex";
   END_VAR
   VAR RETAIN
      arCognexInterface { S7_SetPoint := 'False'} : Array[1.."cNoScanner"] of "stCognexInterface";
   END_VAR
   VAR 
      stCognexInterfaceDummy : "stCognexInterface";
   END_VAR
   VAR RETAIN
      stConvStationsTro101 { S7_SetPoint := 'False'} : "stConveyorStations";   // 1.1.1
      stConvStationsTro102 : "stConveyorStations";
   END_VAR
   VAR 
      stCognexIntfTro105 { S7_SetPoint := 'False'} : "stCognexInterface";
      stCognexIntfTro110 : "stCognexInterface";
      TRO100 : "FB_ILS_MTRO_1Sep";
      TRO101_IN : "FB_ILS_MTRO_1Sep";
      TRO101 : "FB_EmptyCarrBuffer";
      TRO102_IN : "FB_ILS_MTRO_1Sep";
      TRO102 : "FB_EmptyCarrBuffer";
      TRO103 : "FB_ILS_MTRO_1Sep";
      TRO104 : "FB_ILS_MTRO_1Sep";
      TRO105 : "FB_ILS_MTRO_1Sep_SSCC";
      TRO106 : "FB_ILS_MTRO_1Sep";
      TRO107 : "FB_ILS_MTRO_1Sep1Swi";
      TRO108 : "FB_ILS_MTRO_1Sep";
      TRO109 : "FB_ILS_MTRO_1Sep";
      TRO110 : "FB_ILS_MTRO_1Sep_SSCC";
      TRO111 : "FB_ILS_MTRO_1Sep";
      TRO112 : "FB_ILS_MTRO_1Sep1Swi";
      TRO113 : "FB_ILS_MTRO_1Sep";
      TRO114 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_1Sep1Swi";
      TRO115 : "FB_ILS_MTRO_Vario";
      TRO116 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_1Sep";
      TRO117 : "FB_ILS_MTRO_1Sep";
      TRO120 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO121 : "FB_ILS_MTRO_Vario";
      TRO122 : "FB_ILS_MTRO_1Sep";
      TRO123 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO124 : "FB_ILS_MTRO_1Sep1Swi";
      TRO125 : "FB_ILS_MTRO_1Sep";
      TRO126 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO127 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO128 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO129 : "FB_ILS_MTRO_1Sep";
      TRO130 : "FB_ILS_MTRO_1Sep";
      TRO131 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO132 : "FB_ILS_MTRO_1Sep";
      TRO133 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      TRO134 { S7_SetPoint := 'False'} : "FB_ILS_MTRO_Vario";
      rTrig_ClarificationButton {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      rTrig_LengthMeasurement {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      rTimeResult : LReal;
      rTimeMem : LReal;
      xHighwayPrio124 : Bool;
      xHighwayPrio130 : Bool;
      xLineTro101 : Int;
      xLineTro102 : Int;
      nBarcodeEmpty : DInt;
      xReInit : Bool;
      rTrigReInit {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      stTelegramDReqM_TRO110 : "UDT_TelegramData_Send";
      xTest : Bool;
      tOfBürstentakt4103_B {InstructionName := 'TOF_TIME'; LibVersion := '1.0'} : TOF_TIME;
      tOfBürstentakt4203_B {InstructionName := 'TOF_TIME'; LibVersion := '1.0'} : TOF_TIME;
      tOfBürstentakt4302_A {InstructionName := 'TOF_TIME'; LibVersion := '1.0'} : TOF_TIME;
      tOfBürstentakt4402_A {InstructionName := 'TOF_TIME'; LibVersion := '1.0'} : TOF_TIME;
      xBrushFull4103_B : Bool;
      xBrushFull4203_B : Bool;
      xBrushFull4302_A : Bool;
      xBrushFull4402_A : Bool;
   END_VAR

   VAR_TEMP 
      nActCar : Int;
      nActNo101 : Int;
      nActNo102 : Int;
      nNiu : DInt;
      stGenerateCarrier : "stCarrier";
      nCounter1 : DInt;
      xResult1 : Bool;
      nIdx : Int;
      nIdx2 : Int;
      nFound : Int;
      stEmptyCarrier : "stCarrier";
      stEmptyCarrierData : "stJamData";
      arTmpStorageData101 : Array[1..5] of "stStorageData";
      arTmpCarrier : Array[1..1] of "stCarrier";   // Platzhalter
      arTmpCarrierBufferExit : Array[1..70] of "stCarrier";
      stHMISwitchPlaceholder : "UDT_UnloadingStation";
      idx : Int;
      arEmptyStorageLine_1 : Int;
      arEmptyStorageLine : Array[1..1] of "stCarrier";
      arDummyEventCorrectionInfo : Array[0..1] of "stEventCorrectionInfo";
      t_Automatik_OF1 : Bool;
      t_Automatik_OF2 : Bool;
      stTmpJamDataBufferEntry : "stJamData";
      tmpPlaceHolderLaneStatus : Array[0..4] of String;
      arStCarrierLeaveControl : Array[1..1] of "stCarrier";
      stJamDataLeaveControl : "stJamData";
      arStCarrier4104 : Array[1..1] of "stCarrier";
      stJamData4104 : "stJamData";
      sLengthInfo : String;
      stDummy : "stCarrier";
   END_VAR


BEGIN
	REGION Automatik
	    #t_Automatik_OF1 := "DB_InterfaceSafety".stFromSafety.stMainContactorsUH01.Q AND "DB_InterfaceSafety".stFromSafety.stMainContactorsUC0110.Q AND "DB_InterfaceSafety".stFromSafety.stMainContactorsUC0111.Q;//#stInOutControlUnitCabinetOF1.xRunning AND NOT #stInOutControlUnitCabinetOF1.xStarting AND "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q;
	    #t_Automatik_OF2 := "DB_InterfaceSafety".stFromSafety.stMainContactorsUC011.Q;//#stInOutControlUnitCabinetOF2.xRunning AND NOT #stInOutControlUnitCabinetOF2.xStarting AND "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q;
	    
	END_REGION
	
	REGION Reinitialisieren
	    IF NOT #xReInit THEN
	        #xReInit := TRUE;
	    END_IF;
	    
	    #rTrigReInit(CLK := #xReInit);
	    
	    IF #rTrigReInit.Q THEN
	        
	        #TRO100.nState := "DB_GLOB_TroState".arTroState["cMainTro100"];
	        #TRO101_IN.nState := "DB_GLOB_TroState".arTroState["cMainTro101_IN"];
	        #TRO102_IN.nState := "DB_GLOB_TroState".arTroState["cMainTro102_IN"];
	        #TRO101.nStateA := "DB_GLOB_TroState".arTroState["cMainTro101"];
	        #TRO102.nStateA := "DB_GLOB_TroState".arTroState["cMainTro102"];
	        #TRO103.nState := "DB_GLOB_TroState".arTroState["cMainTro103"];
	        #TRO104.nState := "DB_GLOB_TroState".arTroState["cMainTro104"];
	        #TRO105.nState := "DB_GLOB_TroState".arTroState["cMainTro105"];
	        #TRO106.nState := "DB_GLOB_TroState".arTroState["cMainTro106"];
	        #TRO107.nState := "DB_GLOB_TroState".arTroState["cMainTro107"];
	        #TRO108.nState := "DB_GLOB_TroState".arTroState["cMainTro108"];
	        #TRO109.nState := "DB_GLOB_TroState".arTroState["cMainTro109"];
	        #TRO110.nState := "DB_GLOB_TroState".arTroState["cMainTro110"];
	        #TRO111.nState := "DB_GLOB_TroState".arTroState["cMainTro111"];
	        #TRO112.nState := "DB_GLOB_TroState".arTroState["cMainTro112"];
	        #TRO113.nState := "DB_GLOB_TroState".arTroState["cMainTro113"];
	        #TRO114.nState := "DB_GLOB_TroState".arTroState["cMainTro114"];
	        #TRO115.nState := "DB_GLOB_TroState".arTroState["cMainTro115"];
	        #TRO116.nState := "DB_GLOB_TroState".arTroState["cMainTro116"];
	        #TRO117.nState := "DB_GLOB_TroState".arTroState["cMainTro117"];
	        // #TRO118.nState := "DB_GLOB_TroState".arTroState["cMainTro118"]; //gibt es nicht
	        // #TRO119.nState := "DB_GLOB_TroState".arTroState["cMainTro119"]; //gibt es nicht
	        #TRO120.nState := "DB_GLOB_TroState".arTroState["cMainTro120"];
	        #TRO121.nState := "DB_GLOB_TroState".arTroState["cMainTro121"];
	        #TRO122.nState := "DB_GLOB_TroState".arTroState["cMainTro122"];
	        #TRO123.nState := "DB_GLOB_TroState".arTroState["cMainTro123"];
	        #TRO124.nState := "DB_GLOB_TroState".arTroState["cMainTro124"];
	        #TRO125.nState := "DB_GLOB_TroState".arTroState["cMainTro125"];
	        #TRO126.nState := "DB_GLOB_TroState".arTroState["cMainTro126"];
	        #TRO127.nState := "DB_GLOB_TroState".arTroState["cMainTro127"];
	        #TRO128.nState := "DB_GLOB_TroState".arTroState["cMainTro128"];
	        #TRO129.nState := "DB_GLOB_TroState".arTroState["cMainTro129"];
	        #TRO130.nState := "DB_GLOB_TroState".arTroState["cMainTro130"];
	        #TRO131.nState := "DB_GLOB_TroState".arTroState["cMainTro131"];
	        // #TRO132.nState := "DB_GLOB_TroState".arTroState["cMainTro132"]; //gibt es nicht
	        #TRO133.nState := "DB_GLOB_TroState".arTroState["cMainTro133"];
	        #TRO134.nState := "DB_GLOB_TroState".arTroState["cMainTro134"];
	        
	        #fbLoadingBoom1.fbWorkSation.xStopperFull := "DB_GLOB_StopperState".xStopperLoadingBoom1;
	        #fbLoadingBoom2.fbWorkSation.xStopperFull := "DB_GLOB_StopperState".xStopperLoadingBoom2;
	        
	    END_IF;
	END_REGION
	
	REGION Conveyor
	    
	    REGION KR-M0101 (Entry Conv)
	        #fbCarousel0101.xInRequestRun :=
	        "fbPreMain_DB".fbStateMainOF1.nConveyorStartUpCounter = 100 OR
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        #TRO100.xOutCarouselReq OR
	        #TRO101_IN.xOutCarouselReq OR
	        #TRO102_IN.xOutCarouselReq;
	        
	        #fbCarousel0101.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbCarousel0101.Settings.xGridActive := TRUE;
	        #fbCarousel0101.Settings.sMotorProtectName := 'FC0060';
	        #fbCarousel0101.Settings.sGridSenName := 'BG3347';
	        #fbCarousel0101(xInEnabled := "cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3347"].xDirectSensor,
	                        xInGridQuit := "SF0031" OR "SF0002",
	                        xInAutomaticMode := #t_Automatik_OF1,
	                        xInMotorProtectionMonitoring := "FC0060",
	                        xOutPowerContactor => "MA0060",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".#stConveyors.stCarousel.stCar0101);
	    END_REGION
	    
	    REGION KR-M0102 (Exit Conv)
	        #fbCarousel0102.xInRequestRun :=
	        "fbPreMain_DB".fbStateMainOF1.nConveyorStartUpCounter = 100 OR
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        #TRO101.xOutCarouselReq OR
	        #TRO102.xOutCarouselReq OR
	        #TRO106.xOutCarouselReq OR
	        #TRO107.xOutCarouselReq1 OR
	        #TRO111.xOutCarouselReq OR
	        #TRO112.xOutCarouselReq1 OR
	        #TRO113.xOutCarouselReq OR
	        #TRO114.xOutCarouselReq1 OR
	        #TRO117.xOutCarouselReq;
	        
	        #fbCarousel0102.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbCarousel0102.Settings.xGridActive := TRUE;
	        #fbCarousel0102.Settings.sMotorProtectName := 'FC0061';
	        #fbCarousel0102.Settings.sGridSenName := 'BG3342';
	        #fbCarousel0102(xInEnabled := "cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3342"].xDirectSensor,
	                        xInGridQuit := "SF0033" OR "SF0002",
	                        xInAutomaticMode := #t_Automatik_OF1,
	                        xInMotorProtectionMonitoring := "FC0061",
	                        xOutPowerContactor => "MA0061",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0102);
	    END_REGION
	    
	    REGION KR-M0103 (Loading Boom 1 - Entry Conv)
	        #fbConveyor0103.xInRequestRun :=
	        "fbPreMain_DB".fbStateMainOF1.nConveyorStartUpCounter = 100 OR
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        #TRO103.xOutCarouselReq;
	        
	        #fbConveyor0103.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbConveyor0103.Settings.xGridActive := TRUE;
	        #fbConveyor0103.Settings.sMotorProtectName := 'FC0062';
	        #fbConveyor0103.Settings.sGridSenName := 'BG3270';
	        #fbConveyor0103(xInEnabled := "cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3270"].xDirectSensor,
	                        xInGridQuit := "SF0043" OR "SF0002",
	                        xInAutomaticMode := #t_Automatik_OF1,
	                        xInMotorProtectionMonitoring := "FC0062",
	                        xOutPowerContactor => "MA0062",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0103);
	    END_REGION
	    
	    REGION KR-M0104 (Car Boom1)
	        
	        // "MB0325" := "IBN".xBumperReset OR "SF0002";
	        
	        #fbCarousel0104.xInRequestRun :=
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        #TRO103.xOutCarouselReq(* OR "DB_JamBoom1".stJamStopper.arCarrier[1].bStatus.%X0 *)OR
	        #TRO104.xOutCarouselReq OR
	        "DB_Inputs".Sensors["cInBG0286"].xDirectEdgeNeg OR "DB_Inputs".Sensors["cInBG0285"].xDirectEdgeNeg OR
	        (#fbLoadingBoom1.stOutStopper.xStopper2 AND NOT "SF0306") OR (#fbLoadingBoom1.stOutStopper.xStopper1Finger AND "SF0306");
	        
	        #fbCarousel0104.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbCarousel0104.Settings.xGridActive := TRUE;
	        #fbCarousel0104.Settings.sMotorProtectName := 'FC0320';
	        #fbCarousel0104.Settings.sGridSenName := 'BG0284';
	        #fbCarousel0104(xInEnabled := TRUE,
	                        xInAutomaticMode := #t_Automatik_OF1 AND (#fbLoadingBoom1.xOutReady OR #fbLoadingBoom1.xOutMoveReq),
	                        xInMotorProtectionMonitoring := "FC0320",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG0284"].xDirectSensor,
	                        xInGridQuit := "SF0043" OR "SF0002",
	                        xOutPowerContactor => "MA0320",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0104);
	    END_REGION
	    
	    REGION KR-M0106 (Loading Boom 1 - Exit Conv)
	        #fbConveyor0106.xInRequestRun :=
	        "fbPreMain_DB".fbStateMainOF1.nConveyorStartUpCounter = 100 OR
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        (#fbLoadingBoom1.stOutStopper.xStopper2 AND NOT "SF0306") OR
	        (#fbLoadingBoom1.stOutStopper.xStopper1Finger AND "SF0306") OR
	        "DB_Inputs".Sensors["cInBG0285"].xDirectEdgePos;
	        
	        #fbConveyor0106.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbConveyor0106.Settings.xGridActive := FALSE;//TRUE;
	        #fbConveyor0106.Settings.sMotorProtectName := 'FC0064';
	        #fbConveyor0106.Settings.sGridSenName := 'BG3273';
	        #fbConveyor0106(xInEnabled := NOT "DB_Inputs".Sensors["cInBG3276"].xJam,//"cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3273"].xDirectSensor,
	                        xInGridQuit := "SF0043" OR "SF0002",
	                        xInAutomaticMode := #t_Automatik_OF1,
	                        xInMotorProtectionMonitoring := "FC0064",
	                        xOutPowerContactor => "MA0064",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0106);
	    END_REGION
	    
	    REGION KR-M0107 (Loading Boom 2 - Entry Conv)
	        #fbConveyor0107.xInRequestRun :=
	        "fbPreMain_DB".fbStateMainOF1.nConveyorStartUpCounter = 100 OR
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        #TRO108.xOutCarouselReq;
	        
	        #fbConveyor0107.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbConveyor0107.Settings.xGridActive := TRUE;
	        #fbConveyor0107.Settings.sMotorProtectName := 'FC0065';
	        #fbConveyor0107.Settings.sGridSenName := 'BG3284';
	        #fbConveyor0107(xInEnabled := "cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3284"].xDirectSensor,
	                        xInGridQuit := "SF0054" OR "SF0002",
	                        xInAutomaticMode := #t_Automatik_OF1,
	                        xInMotorProtectionMonitoring := "FC0065",
	                        xOutPowerContactor => "MA0065",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0107);
	    END_REGION
	    
	    REGION KR-M0108 (Car Boom2)
	        
	        // "MB0325" := "IBN".xBumperReset OR "SF0002";
	        
	        #fbCarousel0108.xInRequestRun :=
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        #TRO108.xOutCarouselReq(* OR "DB_JamBoom2".stJamStopper.arCarrier[1].bStatus.%X0 *)OR
	        #TRO109.xOutCarouselReq OR
	        "DB_Inputs".Sensors["cInBG0346"].xDirectEdgeNeg OR "DB_Inputs".Sensors["cInBG0345"].xDirectEdgeNeg OR
	        (#fbLoadingBoom2.stOutStopper.xStopper2 AND NOT "SF0366") OR (#fbLoadingBoom2.stOutStopper.xStopper1Finger AND "SF0366");
	        
	        #fbCarousel0108.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbCarousel0108.Settings.xGridActive := TRUE;
	        #fbCarousel0108.Settings.sMotorProtectName := 'FC0380';
	        #fbCarousel0108.Settings.sGridSenName := 'BG0344';
	        #fbCarousel0108(xInEnabled := TRUE,
	                        xInAutomaticMode := #t_Automatik_OF1 AND (#fbLoadingBoom2.xOutReady OR #fbLoadingBoom2.xOutMoveReq),
	                        xInMotorProtectionMonitoring := "FC0380",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG0344"].xDirectSensor,
	                        xInGridQuit := "SF0054" OR "SF0002",
	                        xOutPowerContactor => "MA0380",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0108);
	    END_REGION
	    
	    REGION KR-M0110 (Loading Boom 2 - Exit Conv)
	        #fbConveyor0110.xInRequestRun :=
	        "fbPreMain_DB".fbStateMainOF1.nConveyorStartUpCounter = 100 OR
	        #stInOutControlUnitCabinetOF1.xRestart OR
	        (#fbLoadingBoom2.stOutStopper.xStopper2 AND NOT "SF0366") OR
	        (#fbLoadingBoom2.stOutStopper.xStopper1Finger AND "SF0366") OR
	        "DB_Inputs".Sensors["cInBG0345"].xDirectEdgePos;
	        
	        #fbConveyor0110.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbConveyor0110.Settings.xGridActive := FALSE;//TRUE;
	        #fbConveyor0110.Settings.sMotorProtectName := 'FC0067';
	        #fbConveyor0110.Settings.sGridSenName := 'BG3285';
	        #fbConveyor0110(xInEnabled := NOT "DB_Inputs".Sensors["cInBG3294"].xJam,//"cTodoTRUE",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3285"].xDirectSensor,
	                        xInGridQuit := "SF0054" OR "SF0002",
	                        xInAutomaticMode := #t_Automatik_OF1,
	                        xInMotorProtectionMonitoring := "FC0067",
	                        xOutPowerContactor => "MA0067",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar0110);
	    END_REGION
	    
	    REGION KR-M4204 (Kreisel Highway)
	        #fbCarousel4204.Settings.tEnergySafeTime := T#90s;
	        #fbCarousel4204.Settings.tStartingTime := T#50ms;
	        #fbCarousel4204.Settings.xGridActive := TRUE;
	        #fbCarousel4204.xInRequestRun := (* "fbPreMain_DB".fbStateMain.nConveyorStartUpCounter = 100 *)#stInOutControlUnitCabinetOF2.xRestart OR
	        #stInOutControlUnitCabinetOF2.xRestart OR
	        #TRO124.xOutCarouselReq1 OR #TRO124.xOutCarouselReq2 OR
	        #TRO125.xOutCarouselReq OR
	        #TRO129.xOutCarouselReq OR
	        #TRO130.xOutCarouselReq;
	        
	        #fbCarousel4204.Settings.tEnergySafeTime := "cTimeEnergySafe";
	        #fbCarousel4204.Settings.xGridActive := TRUE;
	        #fbCarousel4204.Settings.sMotorProtectName := 'FC0140';
	        #fbCarousel4204.Settings.sGridSenName := 'BG3007';
	        #fbCarousel4204(xInEnabled := "SF0120" AND "SF0124",
	                        xInGridSen := "DB_Inputs".Sensors["cInBG3007"].xDirectSensor,
	                        xInGridQuit := "SF0117" OR "SF0121",
	                        xInAutomaticMode := #t_Automatik_OF2,
	                        xInMotorProtectionMonitoring := "FC0140",
	                        xOutPowerContactor => "MA0140",
	                        stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                        stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar4204);
	    END_REGION
	    
	    REGION ILS-CV M4103_B (Bürstenförderer)
	        
	        REGION Enable und RequestRun
	            IF "DB_Inputs".Sensors["cInBG3143"].xJam AND "DB_Inputs".Sensors["cInBG3142"].xDbncdSensor THEN //Bürstenförderer darf nicht fahren
	                #fbConveyor4103_B.xInEnabled := FALSE;
	                #xBrushFull4103_B := TRUE;
	            ELSIF NOT "DB_Inputs".Sensors["cInBG3143"].xJam THEN
	                #fbConveyor4103_B.xInEnabled := TRUE;
	                #xBrushFull4103_B := FALSE;
	            ELSIF "DB_Inputs".Sensors["cInBG3143"].xJam AND NOT #xBrushFull4103_B THEN
	                #fbConveyor4103_B.xInEnabled := #tOfBürstentakt4103_B.Q;
	            END_IF;
	            
	            #fbConveyor4103_B.xInRequestRun := "DB_Inputs".Sensors["cInBG3140"].xDirectEdgePos; // Trigger
	            
	            #tOfBürstentakt4103_B(IN:="DB_Inputs".Sensors["cInBG3140"].xDirectEdgePos,
	                            PT:= t#1s);
	            
	        END_REGION
	        
	        #fbConveyor4103_B.Settings.tEnergySafeTime := t#90s; //IBN todo
	        #fbConveyor4103_B.Settings.xGridActive := FALSE;
	        #fbConveyor4103_B.Settings.sMotorProtectName := 'FC0152';
	        #fbConveyor4103_B(xInAutomaticMode := #t_Automatik_OF2,
	                          xInMotorProtectionMonitoring := "FC0152",
	                          xOutPowerContactor => "MA0152",
	                          stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                          stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar4103_B);
	    END_REGION
	  
	    REGION ILS-CV M4203_B (Bürstenförderer)
	        REGION Enable und RequestRun
	            IF "DB_Inputs".Sensors["cInBG3147"].xJam AND "DB_Inputs".Sensors["cInBG3146"].xDbncdSensor THEN //Bürstenförderer darf nicht fahren
	                #fbConveyor4203_B.xInEnabled := FALSE;
	                #xBrushFull4203_B := TRUE;
	            ELSIF NOT "DB_Inputs".Sensors["cInBG3147"].xJam THEN
	                #fbConveyor4203_B.xInEnabled := TRUE;
	                #xBrushFull4203_B := FALSE;
	            ELSIF "DB_Inputs".Sensors["cInBG3147"].xJam AND NOT #xBrushFull4203_B THEN
	                #fbConveyor4203_B.xInEnabled := #tOfBürstentakt4203_B.Q;
	            END_IF;
	            
	            #fbConveyor4203_B.xInRequestRun := "DB_Inputs".Sensors["cInBG3144"].xDirectEdgePos; // Trigger
	            
	            #tOfBürstentakt4203_B(IN := "DB_Inputs".Sensors["cInBG3144"].xDirectEdgePos,
	                                  PT := t#1s);
	            
	        END_REGION
	        
	        #fbConveyor4203_B.Settings.tEnergySafeTime := t#90s; //IBN todo
	        #fbConveyor4203_B.Settings.xGridActive := FALSE;
	        #fbConveyor4203_B.Settings.sMotorProtectName := 'FC0153';
	        #fbConveyor4203_B(xInAutomaticMode := #t_Automatik_OF2,
	                          xInMotorProtectionMonitoring := "FC0153",
	                          xOutPowerContactor => "MA0153",
	                          stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                          stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar4203_B);
	    END_REGION
	    
	    REGION ILS-CV M4302_A (Bürstenförderer)
	        REGION Enable und RequestRun
	            IF "DB_Inputs".Sensors["cInBG3153"].xJam AND "DB_Inputs".Sensors["cInBG3152"].xDbncdSensor THEN //Bürstenförderer darf nicht fahren
	                #fbConveyor4302_A.xInEnabled := FALSE;
	                #xBrushFull4302_A := TRUE;
	            ELSIF NOT "DB_Inputs".Sensors["cInBG3153"].xJam THEN
	                #fbConveyor4302_A.xInEnabled := TRUE;
	                #xBrushFull4302_A := FALSE;
	            ELSIF "DB_Inputs".Sensors["cInBG3153"].xJam AND NOT #xBrushFull4302_A THEN
	                #fbConveyor4302_A.xInEnabled := #tOfBürstentakt4302_A.Q;
	            END_IF;
	            
	            #fbConveyor4302_A.xInRequestRun := "DB_Inputs".Sensors["cInBG3150"].xDirectEdgePos; // Trigger
	            
	            #tOfBürstentakt4302_A(IN := "DB_Inputs".Sensors["cInBG3150"].xDirectEdgePos,
	                                  PT := t#1s);
	            
	        END_REGION
	        
	        #fbConveyor4302_A.Settings.tEnergySafeTime := t#90s; //IBN todo
	        #fbConveyor4302_A.Settings.xGridActive := FALSE;
	        #fbConveyor4302_A.Settings.sMotorProtectName := 'FC0154';
	        #fbConveyor4302_A(xInAutomaticMode := #t_Automatik_OF2,
	                          xInMotorProtectionMonitoring := "FC0154",
	                          xOutPowerContactor => "MA0154",
	                          stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                          stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar4302_A);
	    END_REGION
	    
	    REGION ILS-CV M4402_A (Bürstenförderer)
	        REGION Enable und RequestRun
	            IF "DB_Inputs".Sensors["cInBG3157"].xJam AND "DB_Inputs".Sensors["cInBG3156"].xDbncdSensor THEN //Bürstenförderer darf nicht fahren
	                #fbConveyor4402_A.xInEnabled := FALSE;
	                #xBrushFull4402_A := TRUE;
	            ELSIF NOT "DB_Inputs".Sensors["cInBG3157"].xJam THEN
	                #fbConveyor4402_A.xInEnabled := TRUE;
	                #xBrushFull4402_A := FALSE;
	            ELSIF "DB_Inputs".Sensors["cInBG3157"].xJam AND NOT #xBrushFull4402_A THEN
	                #fbConveyor4402_A.xInEnabled := #tOfBürstentakt4402_A.Q;
	            END_IF;
	            
	            #fbConveyor4402_A.xInRequestRun := "DB_Inputs".Sensors["cInBG3154"].xDirectEdgePos; // Trigger
	            
	            #tOfBürstentakt4402_A(IN := "DB_Inputs".Sensors["cInBG3154"].xDirectEdgePos,
	                                  PT := t#1s);
	            
	        END_REGION
	        
	        #fbConveyor4402_A.Settings.tEnergySafeTime := t#90s; //IBN todo
	        #fbConveyor4402_A.Settings.xGridActive := FALSE;
	        #fbConveyor4402_A.Settings.sMotorProtectName := 'FC0155';
	        #fbConveyor4402_A(xInAutomaticMode := #t_Automatik_OF2,
	                          xInMotorProtectionMonitoring := "FC0155",
	                          xOutPowerContactor => "MA0155",
	                          stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                          stInOutInterfaceHMI := "DB_Interface_HMI".stConveyors.stCarousel.stCar4402_A);
	    END_REGION
	    
	END_REGION
	
	REGION LoadingBoom 1
	    
	    REGION Eingänge
	        REGION UZ0110-1
	            #fbLoadingBoom1.stInControl.xBtnReleaseMT1 := "SF0305";
	            #fbLoadingBoom1.stInControl.xSwitchLoadingPos2 := "SF0306";
	        END_REGION
	        
	        REGION UZ0110-2
	            #fbLoadingBoom1.stInControl.xBtnBack := FALSE;//"SF0330"; auskommentiert für IBN aus Sicherheitsgründen
	            #fbLoadingBoom1.stInControl.xBtnForth := FALSE;//"SF0331"; auskommentiert für IBN aus Sicherheitsgründen
	            #fbLoadingBoom1.stInControl.xBtnReleaseMT2 := "SF0332";
	        END_REGION
	        
	        REGION Schalter Stützfuß
	            #fbLoadingBoom1.stInControl.xSwitchFootUp := false;//"SF0334"; auskommentiert für IBN aus Sicherheitsgründen
	            #fbLoadingBoom1.stInControl.xSwitchFootDown := false;//"SF0333"; auskommentiert für IBN aus Sicherheitsgründen
	        END_REGION
	        
	        REGION UZ0103
	            #fbLoadingBoom1.stInControl.xSwitchLightOnOff := "SF0041";
	            #fbLoadingBoom1.stInControl.xBtnBoomActive := "SF0044";
	            #fbLoadingBoom1.stInControl.xBtnReset := "SF0043" OR "SF0002" OR "IBN".xQuit;
	        END_REGION
	        
	        REGION Schaltschrank
	            #fbLoadingBoom1.stInControl.xSwitchFootManual := "SF0025";
	        END_REGION
	        
	        REGION Signale Ladeschleife
	            #fbLoadingBoom1.stInBoom.xMotorProtection1 := "FC0070" AND "FC0072"; //Beides auf einen Eingang?
	            #fbLoadingBoom1.stInBoom.xLimitForth := "DB_Inputs".Sensors["cInBG3343"].xDirectSensor;
	            #fbLoadingBoom1.stInBoom.xLimitForthEmergency := "SF0051";
	            #fbLoadingBoom1.stInBoom.xLimitBack := "DB_Inputs".Sensors["cInBG3344"].xDirectSensor;
	            #fbLoadingBoom1.stInBoom.xLimitBackEmergency := "SF0050";
	            #fbLoadingBoom1.stInBoom.xBumperOk := TRUE;
	        END_REGION
	        
	        REGION Signale Fuß
	            #fbLoadingBoom1.stInFoot.xMotorProtection := "FC0321";
	            #fbLoadingBoom1.stInFoot.xLimitUp := "SF0322";
	            #fbLoadingBoom1.stInFoot.xLimitDown := "SF0323";
	        END_REGION
	        
	        REGION Sonstiges
	            
	            #fbLoadingBoom1.stInSettings.tBoomInput := T#5s;
	            #fbLoadingBoom1.stInSettings.tWheelInput := T#5s;
	            #fbLoadingBoom1.stInSettings.tSenWaitStopper1 := T#100ms;
	            #fbLoadingBoom1.stInSettings.tWaitAfterReleaseStopper1 := T#1200ms;
	            #fbLoadingBoom1.stInSettings.tWaitBeforeSwitchStopper2 := T#4000ms;
	            #fbLoadingBoom1.stInSettings.tTrailingStopper2 := T#150ms;
	            
	            #fbLoadingBoom1.stInTilt.wTilt := "wTiltSensorLS1";
	            #fbLoadingBoom1.stInTilt.xClock := "Clock_10Hz";
	            #fbLoadingBoom1.stInTilt.tDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.tTiltDiff;
	            #fbLoadingBoom1.stInTilt.tZero := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.tTiltZero;
	            #fbLoadingBoom1.stInTilt.nDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nTiltOffset;
	            #fbLoadingBoom1.stInTilt.nZeroOk := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nTiltZero;
	            #fbLoadingBoom1.stInTilt.nTiltComp := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nTiltNullen;
	            #fbLoadingBoom1.stInTilt.xComp := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xTiltTeach;
	            
	            "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xTiltTeachReq := #fbLoadingBoom1.fbTiltSensor.xOutTeachNec;
	            
	            #fbLoadingBoom1.stInDistance.wDistance := "wDistanceSensorLS1";
	            #fbLoadingBoom1.stInDistance.nStartSlow := 2510; // Format z.B. 2799 für 279,9mm
	            #fbLoadingBoom1.stInDistance.nStartFast := 2520;
	            #fbLoadingBoom1.stInDistance.nDistanceZero := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nDistanceZero;
	            #fbLoadingBoom1.stInDistance.nDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nDistanceDiff;
	            #fbLoadingBoom1.stInDistance.tDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.tDistanceDiff;
	            #fbLoadingBoom1.stInDistance.xComp := "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xDistanceTeach;
	            
	            "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xDistanceTeachReq := #fbLoadingBoom1.fbDistanceFoot.xOutTeachNec;
	            
	            
	            
	            //Für Landsberg am Lech: nDistanceZero = 2460(246mm), nDiff = 250(25mm), tDiff
	            
	            
	            //IBN
	            // IF #fbLoadingBoom1.fbTiltSensor.nTiltComp = 0 THEN
	            //Entsrpicht in LL ungefähr dem Hallenboden, daher soll nach reinitialisieren auch wieder dieser Wert geschrieben werden
	            // #fbLoadingBoom1.fbTiltSensor.nTiltComp := -20;
	            // END_IF;
	            //IBN
	            
	        END_REGION
	    END_REGION
	    
	    
	    REGION CALL
	        #fbLoadingBoom1(stInSen2mThreshold := "DB_Inputs".Sensors["cInBG0287"],
	                        stInSenJamEntr := "DB_Inputs".Sensors["cInBG0286"],
	                        stInSenJamExit1 := "DB_Inputs".Sensors["cInBG0285"],
	                        stInSenJamExit2 := "DB_Inputs".Sensors["cInBG3276"],
	                        stInSenStopper1 := "DB_Inputs".Sensors["cInBG0282"],
	                        stInSenStopper2 := "DB_Inputs".Sensors["cInBG0283"],
	                        xInMachineRunning := "DB_MachineGlobal".stStateMainOF1.xRunning,
	                        xInTrolleyInSep := #TRO104.nState >= 2500 AND #TRO104.xReleaseTrolleySep1, //to do mit welcehm Signal oder welchem Wert hier gehandhabt wird
	                        xInSafety := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q AND NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF1.AckReq,
	                        // xOutLedMovement => "PF0287",
	                        xOutLight => "QA0012",
	                        xOutBoomActive => "PF0044",
	                        arInOutCarrierStopper := "DB_JamArea0104".stJam0104_2.arCarrier,
	                        arInOutCarrierExit := "DB_JamArea0104".stJam0104_3.arCarrier,
	                        stInOutCarrierExit := "DB_JamArea0104".stJam0104_3.stData,
	                        xOutStopperState => "DB_GLOB_StopperState".xStopperLoadingBoom1);
	        "PF0287" := #fbLoadingBoom1.xOutLedMovement OR "SF0003";
	    END_REGION
	    
	    
	    
	    REGION Ausgänge
	        "MB0282" := #fbLoadingBoom1.stOutStopper.xStopper1Clamp; //prüfen
	        "MB0284" := #fbLoadingBoom1.stOutStopper.xStopper1Finger; //prüfen
	        "MB0283" := #fbLoadingBoom1.stOutStopper.xStopper2;
	        
	        "QA0071" := #fbLoadingBoom1.stOutBoom.xBoomForth1;
	        "QA0073" := #fbLoadingBoom1.stOutBoom.xBoomForth2;
	        "MA0070" := #fbLoadingBoom1.stOutBoom.xBoomBack1;
	        "MA0072" := #fbLoadingBoom1.stOutBoom.xBoomBack2;
	        
	        "DQ0322" := #fbLoadingBoom1.stOutFoot.xFootUp;
	        "DQ0323" := #fbLoadingBoom1.stOutFoot.xFootDown;
	        "DQ0324" := #fbLoadingBoom1.stOutFoot.xFootSpeed1;
	    END_REGION
	    
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xBoomActive := #fbLoadingBoom1.xOutBoomActive;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xMovement := #fbLoadingBoom1.xOutLedMovement;
	    
	    IF #fbLoadingBoom1.fbWorkSation.nActiveStopperNo = 1 THEN
	        "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xLoadingPos := TRUE;
	    ELSIF #fbLoadingBoom1.fbWorkSation.nActiveStopperNo = 2 THEN
	        "DB_Interface_HMI".stLoadingBoom.stDataBoom1.xLoadingPos := FALSE;
	    END_IF;
	    
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nPosition.%X0 := #fbLoadingBoom1.stInBoom.xLimitBackEmergency;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nPosition.%X1 := #fbLoadingBoom1.stInBoom.xLimitBack;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nPosition.%X2 := NOT #fbLoadingBoom1.xAbove2m;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nPosition.%X3 := #fbLoadingBoom1.stInBoom.xLimitForth;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom1.nPosition.%X4 := #fbLoadingBoom1.stInBoom.xLimitForthEmergency;
	    
	END_REGION
	
	REGION LoadingBoom 2
	    
	    REGION Eingänge
	        REGION UZ0111-1
	            #fbLoadingBoom2.stInControl.xBtnReleaseMT1 := "SF0365";
	            #fbLoadingBoom2.stInControl.xSwitchLoadingPos2 := "SF0366";
	        END_REGION
	        
	        REGION UZ0111-2
	            #fbLoadingBoom2.stInControl.xBtnBack := false; //"SF0390"; //auskommentiert für "IBN" aus Sicherheitsgründen
	            #fbLoadingBoom2.stInControl.xBtnForth := false; //"SF0391"; //auskommentiert für "IBN" aus Sicherheitsgründen
	            #fbLoadingBoom2.stInControl.xBtnReleaseMT2 := "SF0392";
	        END_REGION
	        
	        REGION Schalter Stützfuß
	            #fbLoadingBoom2.stInControl.xSwitchFootUp := false;//"SF0394"; auskommentiert für IBN aus Sicherheitsgründen
	            #fbLoadingBoom2.stInControl.xSwitchFootDown := false;//"SF0393"; auskommentiert für IBN aus Sicherheitsgründen
	        END_REGION
	        
	        REGION UZ0104
	            #fbLoadingBoom2.stInControl.xSwitchLightOnOff := "SF0046";
	            #fbLoadingBoom2.stInControl.xBtnBoomActive := "SF0055";
	            #fbLoadingBoom2.stInControl.xBtnReset := "SF0054" OR "SF0002" OR "IBN".xQuit; //sf0002 nur provisorisch
	        END_REGION
	        
	        REGION Schaltschrank
	            #fbLoadingBoom2.stInControl.xSwitchFootManual := "SF0026";
	        END_REGION
	        
	        REGION Signale Ladeschleife
	            #fbLoadingBoom2.stInBoom.xMotorProtection1 := "FC0074" AND "FC0076"; //Beides auf einen Eingang?
	            #fbLoadingBoom2.stInBoom.xLimitForth := "DB_Inputs".Sensors["cInBG3345"].xDirectSensor;
	            #fbLoadingBoom2.stInBoom.xLimitForthEmergency := "SF0053";
	            #fbLoadingBoom2.stInBoom.xLimitBack := "DB_Inputs".Sensors["cInBG3346"].xDirectSensor;
	            #fbLoadingBoom2.stInBoom.xLimitBackEmergency := "SF0052";
	            #fbLoadingBoom2.stInBoom.xBumperOk := TRUE;
	        END_REGION
	        
	        REGION Signale Fuß
	            #fbLoadingBoom2.stInFoot.xMotorProtection := "FC0381";
	            #fbLoadingBoom2.stInFoot.xLimitUp := "SF0382";
	            #fbLoadingBoom2.stInFoot.xLimitDown := "SF0383";
	        END_REGION
	        
	        REGION Sonstiges
	            
	            #fbLoadingBoom2.stInSettings.tBoomInput := T#5s;
	            #fbLoadingBoom2.stInSettings.tWheelInput := T#5s;
	            #fbLoadingBoom2.stInSettings.tSenWaitStopper1 := T#100ms;
	            #fbLoadingBoom2.stInSettings.tWaitAfterReleaseStopper1 := T#1200ms;
	            #fbLoadingBoom2.stInSettings.tWaitBeforeSwitchStopper2 := T#4000ms;
	            #fbLoadingBoom2.stInSettings.tTrailingStopper2 := T#150ms;
	            
	            #fbLoadingBoom2.stInTilt.wTilt := "wTiltSensorLS2";
	            #fbLoadingBoom2.stInTilt.xClock := "Clock_10Hz";
	            #fbLoadingBoom2.stInTilt.tDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.tTiltDiff;
	            #fbLoadingBoom2.stInTilt.tZero := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.tTiltZero;
	            #fbLoadingBoom2.stInTilt.nDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nTiltOffset;
	            #fbLoadingBoom2.stInTilt.nZeroOk := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nTiltZero;
	            #fbLoadingBoom2.stInTilt.nTiltComp := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nTiltNullen;
	            #fbLoadingBoom2.stInTilt.xComp := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xTiltTeach;
	            
	            "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xTiltTeachReq := #fbLoadingBoom2.fbTiltSensor.xOutTeachNec;
	            
	            #fbLoadingBoom2.stInDistance.wDistance := "wDistanceSensorLS2";
	            #fbLoadingBoom2.stInDistance.nStartSlow := 2510; // Format z.B. 2799 für 279,9mm
	            #fbLoadingBoom2.stInDistance.nStartFast := 2520;
	            #fbLoadingBoom2.stInDistance.nDistanceZero := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nDistanceZero;
	            #fbLoadingBoom2.stInDistance.nDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nDistanceDiff;
	            #fbLoadingBoom2.stInDistance.tDiff := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.tDistanceDiff;
	            #fbLoadingBoom2.stInDistance.xComp := "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xDistanceTeach;
	            
	            "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xDistanceTeachReq := #fbLoadingBoom2.fbDistanceFoot.xOutTeachNec;
	            
	            //Für Landsberg am Lech: nDistanceZero = 2460(246mm), nDiff = 250(25mm), tDiff
	            
	            //IBN
	            // IF #fbLoadingBoom1.fbTiltSensor.nTiltComp = 0 THEN
	            //Entsrpicht in LL ungefähr dem Hallenboden, daher soll nach reinitialisieren auch wieder dieser Wert geschrieben werden
	            // #fbLoadingBoom1.fbTiltSensor.nTiltComp := -20;
	            // END_IF;
	            //IBN
	            
	        END_REGION
	    END_REGION
	    
	    REGION CALL
	        #fbLoadingBoom2(stInSen2mThreshold := "DB_Inputs".Sensors["cInBG0347"],
	                        stInSenJamEntr := "DB_Inputs".Sensors["cInBG0346"],
	                        stInSenJamExit1 := "DB_Inputs".Sensors["cInBG0345"],
	                        stInSenJamExit2 := "DB_Inputs".Sensors["cInBG3294"],
	                        stInSenStopper1 := "DB_Inputs".Sensors["cInBG0342"],
	                        stInSenStopper2 := "DB_Inputs".Sensors["cInBG0343"],
	                        xInMachineRunning := "DB_MachineGlobal".stStateMainOF1.xRunning,
	                        xInTrolleyInSep := #TRO109.nState >= 2500 AND #TRO109.xReleaseTrolleySep1, //to do mit welcehm Signal oder welchem Wert hier gehandhabt wird
	                        xInSafety := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q AND NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF1.AckReq,
	                        // xOutLedMovement => "PF0347",
	                        xOutLight => "QA0013",
	                        xOutBoomActive => "PF0055",
	                        arInOutCarrierStopper := "DB_JamArea0108".stJam0108_2.arCarrier,
	                        arInOutCarrierExit := "DB_JamArea0108".stJam0108_3.arCarrier,
	                        stInOutCarrierExit := "DB_JamArea0108".stJam0108_3.stData,
	                        xOutStopperState => "DB_GLOB_StopperState".xStopperLoadingBoom2);
	        "PF0347" := #fbLoadingBoom2.xOutLedMovement OR "SF0003";
	    END_REGION
	    
	    REGION Ausgänge
	        "MB0342" := #fbLoadingBoom2.stOutStopper.xStopper1Clamp; //prüfen
	        "MB0344" := #fbLoadingBoom2.stOutStopper.xStopper1Finger; //prüfen
	        "MB0343" := #fbLoadingBoom2.stOutStopper.xStopper2;
	        
	        "QA0075" := #fbLoadingBoom2.stOutBoom.xBoomForth1;
	        "QA0077" := #fbLoadingBoom2.stOutBoom.xBoomForth2;
	        "MA0074" := #fbLoadingBoom2.stOutBoom.xBoomBack1;
	        "MA0076" := #fbLoadingBoom2.stOutBoom.xBoomBack2;
	        
	        "DQ0382" := #fbLoadingBoom2.stOutFoot.xFootUp;
	        "DQ0383" := #fbLoadingBoom2.stOutFoot.xFootDown;
	        "DQ0384" := #fbLoadingBoom2.stOutFoot.xFootSpeed1;
	    END_REGION
	    
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xBoomActive := #fbLoadingBoom2.xOutBoomActive;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xMovement := #fbLoadingBoom2.xOutLedMovement;
	    
	    IF #fbLoadingBoom2.fbWorkSation.nActiveStopperNo = 1 THEN
	        "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xLoadingPos := TRUE;
	    ELSIF #fbLoadingBoom2.fbWorkSation.nActiveStopperNo = 2 THEN
	        "DB_Interface_HMI".stLoadingBoom.stDataBoom2.xLoadingPos := FALSE;
	    END_IF;
	    
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nPosition.%X0 := #fbLoadingBoom2.stInBoom.xLimitBackEmergency;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nPosition.%X1 := #fbLoadingBoom2.stInBoom.xLimitBack;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nPosition.%X2 := NOT #fbLoadingBoom2.xAbove2m;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nPosition.%X3 := #fbLoadingBoom2.stInBoom.xLimitForth;
	    "DB_Interface_HMI".stLoadingBoom.stDataBoom2.nPosition.%X4 := #fbLoadingBoom2.stInBoom.xLimitForthEmergency;
	    
	END_REGION
	
	REGION Empty Carrier Buffer
	    
	    REGION Buffer Entscheidung
	        
	        IF #TRO101.xOutFull AND #TRO102.xOutFull THEN
	            #TRO101.xInPause := TRUE;
	            #TRO102.xInPause := TRUE;
	        ELSIF #TRO101.nOutFillLevel > #TRO102.nOutFillLevel THEN
	            #TRO101.xInPause := TRUE;//true
	            #TRO102.xInPause := FALSE;
	        ELSE
	            #TRO101.xInPause := FALSE;
	            #TRO102.xInPause := FALSE;
	        END_IF;
	    END_REGION
	    
	    REGION TRO101 (Empty Buffer rechts)
	        
	        REGION TRO 101_IN(1Sep)
	            
	            #TRO101_IN.stInSeparator1.Settings.nSeparatorNo := 999;
	            #TRO101_IN.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	            #TRO101_IN.stInSeparator1.Settings.tTrailingTime := t#100ms;
	            #TRO101_IN.stInSeparator1.Settings.tHandlingTime := t#50ms;
	            #TRO101_IN.stInSeparator1.Settings.tJam := "TimeForSepJam";
	            #TRO101_IN.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	            #TRO101_IN.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	            // #TRO101_IN.stInSeparator1.Settings.xPluggedJam := TRUE; //siehe weiter unten
	            #TRO101_IN.stInSeparator1.Settings.xPluggedPart := FALSE;
	            #TRO101_IN.stInSeparator1.Settings.xPluggedScanner := FALSE;
	            #TRO101_IN.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3246"];
	            // #TRO101_IN.stInSenJam2 := "DB_Inputs".Sensors["cInBG3245"];//siehe weiter unten
	            
	            #TRO101_IN.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	            #TRO101_IN.stInSettings.xIsBorner := TRUE;
	            #TRO101_IN.stInSettings.nBornerDest := "cDestInboundLS";
	            
	            IF #TRO101.xOutBypass THEN
	                #TRO101_IN.stInSeparator1.Settings.xPluggedJam := TRUE; //IBN zum Klicken
	                #TRO101_IN.stInSenJam2 := "DB_Inputs".Sensors["cInBG3245"];//IBN
	                #TRO101_IN(nInMainTroNo := 1000,
	                           xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                           xInAllRdyToStart := TRUE,
	                           // xInCancel := "cTodoFalse", //IBN
	                           xInCarouselRun := #fbCarousel0101.xOutConveyorFullSpeed,
	                           xInRelease := #TRO101.xOutReadyToReceive OR (NOT #TRO101.xOutReadyToReceive AND NOT "DB_Inputs".Sensors["cInBG3245"].xDbncdSensor(* AND #fbEmptyBuffer101.nOutLineNr = 6 *)),//IBN
	                           stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                           stInOutCognexInterface := #stCognexInterfaceDummy,
	                           arInOutJamEntr1 := "DB_JamArea0101".stJam0101_1.arCarrier,
	                           stInOutJamEntr1 := "DB_JamArea0101".stJam0101_1.stData,
	                           arInOutJamExit2 := "DB_JamArea0101".stJam0101_2.arCarrier,//arTmpCarrier,
	                           stInOutJamExit2 := "DB_JamArea0101".stJam0101_2.stData,
	                           xOutStopper1 => "MB3246",
	                           nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro101_IN"],
	                           stInOutHMI := "DB_Interface_HMI".stTRO.TRO101_In); // TODO!!!!!!!!!!!
	            ELSE
	                #stTmpJamDataBufferEntry.Config.nCapacitySet := "DB_JamBuffer101".arLine[#TRO101.nOutLineNr].stData.Config.nCapacitySet;
	                #stTmpJamDataBufferEntry.Status.nCount := "DB_JamBuffer101".arLine[#TRO101.nOutLineNr].stData.Status.nCount;
	                
	                #TRO101_IN.stInSeparator1.Settings.xPluggedJam := FALSE;
	                #TRO101_IN(nInMainTroNo := 1000,
	                           xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                           xInAllRdyToStart := TRUE,
	                           // xInCancel := "cTodoFalse", //IBN
	                           xInCarouselRun := #fbCarousel0101.xOutConveyorFullSpeed,
	                           xInRelease := #TRO101.xOutReadyToReceive(* AND #fbEmptyBuffer101.nOutLineNr = 6 *),//IBN
	                           stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                           stInOutCognexInterface := #stCognexInterfaceDummy,
	                           arInOutJamEntr1 := "DB_JamArea0101".stJam0101_1.arCarrier,
	                           stInOutJamEntr1 := "DB_JamArea0101".stJam0101_1.stData,
	                           arInOutJamExit2 := "DB_JamBuffer101".arLine[#TRO101.nOutLineNr].arCarrier,//arTmpCarrier,
	                           stInOutJamExit2 := #stTmpJamDataBufferEntry,
	                           xOutStopper1 => "MB3246",
	                           nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro101_IN"],
	                           stInOutHMI := "DB_Interface_HMI".stTRO.TRO101_In); // TODO!!!!!!!!!!!
	            END_IF;
	            
	        END_REGION
	        
	        REGION Separator Settings
	            
	            REGION Sep Buffer 1
	                #nActNo101 := 1;
	                #TRO101.arInSep[#nActNo101].stSettings.nJamLength := 5;//"cStorage111ExitJam1";
	                #TRO101.arInSep[#nActNo101].stSenTrolley := "DB_Inputs".Sensors["cInBG3320"];
	                #TRO101.arInSep[#nActNo101].stSettings.tHandlingTime := T#200ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tTrailingTime := T#500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.xPluggedScanner := FALSE;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenFree := T#1500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenWait := T#3000ms;
	                
	            END_REGION
	            
	            REGION Sep Buffer 2
	                #nActNo101 := 2;
	                #TRO101.arInSep[#nActNo101].stSettings.nJamLength := 7;
	                #TRO101.arInSep[#nActNo101].stSenTrolley := "DB_Inputs".Sensors["cInBG3321"];
	                #TRO101.arInSep[#nActNo101].stSettings.tHandlingTime := T#200ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tTrailingTime := T#500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.xPluggedScanner := FALSE;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenFree := T#1500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 3
	                #nActNo101 := 3;
	                #TRO101.arInSep[#nActNo101].stSettings.nJamLength := 10;
	                #TRO101.arInSep[#nActNo101].stSenTrolley := "DB_Inputs".Sensors["cInBG3322"];
	                #TRO101.arInSep[#nActNo101].stSettings.tHandlingTime := T#200ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tTrailingTime := T#500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.xPluggedScanner := FALSE;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenFree := T#1500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 4
	                #nActNo101 := 4;
	                #TRO101.arInSep[#nActNo101].stSettings.nJamLength := 10;
	                #TRO101.arInSep[#nActNo101].stSenTrolley := "DB_Inputs".Sensors["cInBG3323"];
	                #TRO101.arInSep[#nActNo101].stSettings.tHandlingTime := T#200ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tTrailingTime := T#500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.xPluggedScanner := FALSE;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenFree := T#1500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 5
	                #nActNo101 := 5;
	                #TRO101.arInSep[#nActNo101].stSettings.nJamLength := 10;
	                #TRO101.arInSep[#nActNo101].stSenTrolley := "DB_Inputs".Sensors["cInBG3324"];
	                #TRO101.arInSep[#nActNo101].stSettings.tHandlingTime := T#200ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tTrailingTime := T#500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.xPluggedScanner := FALSE;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenFree := T#1500ms;
	                #TRO101.arInSep[#nActNo101].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	        END_REGION
	        REGION Jamsensoren
	            #TRO101.arInJamSensor[1] := "DB_Inputs".Sensors["cInBG3250"];
	            
	            #TRO101.arInJamSensor[2] := "DB_Inputs".Sensors["cInBG3251"];
	            
	            #TRO101.arInJamSensor[3] := "DB_Inputs".Sensors["cInBG3252"];
	            
	            #TRO101.arInJamSensor[4] := "DB_Inputs".Sensors["cInBG3253"];
	            
	            #TRO101.arInJamSensor[5] := "DB_Inputs".Sensors["cInBG3254"];
	        END_REGION
	        
	        REGION Dummy Zielvergabe
	            #stDummy.nBarcode := 1;
	            #stDummy.nDestination := 0;
	            #stDummy.bStatus.%X0 := TRUE;
	            
	            IF "DB_JamBuffer101".arLine[1].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer101".arLine[1].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer101".arLine[2].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer101".arLine[2].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer101".arLine[3].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer101".arLine[3].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer101".arLine[4].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer101".arLine[4].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer101".arLine[5].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer101".arLine[5].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	        END_REGION
	        
	        
	        REGION TRO 101 CALL
	            #TRO101.xStart := "DB_TRO_TEST".TRO101Start OR ("DB_JamArea0107".stJam0107_1.stData.Status.nCount < ("DB_JamArea0107".stJam0107_1.stData.Config.nCapacitySet * 75 / 100)); //NUR FÜR TEST
	            #TRO101.stInSettings.nNoOfLines := 5;
	            #TRO101(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO101.TroIn,
	                    stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO101.TroOut,
	                    nInBufferNr := "cMainTro101",
	                    xInBufferReq := TRUE,//IBN
	                    xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                    xInConveyorRunOut := #fbCarousel0102.xOutConveyorFullSpeed,
	                    xInBufferRelease := "DB_TRO_TEST".TRO101 AND "DB_JamArea0107".stJam0107_1.stData.Status.nCount < ("cJam0107_1" / 2),
	                    stInSenJamExit := "DB_Inputs".Sensors["cInBG3330"],
	                    nOutActNo => #nActNo101,
	                    stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                    arInOutStorageLines := "DB_JamBuffer101".arLine,
	                    arInOutJamExit := "DB_JamArea0102".stJam0102_2.arCarrier,
	                    stInOutJamExit := "DB_JamArea0102".stJam0102_2.stData,
	                    nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro101"],
	                    stInOutHMI := "DB_Interface_HMI".stTRO.TRO101);
	            
	            "MB3250" := #TRO101.arOutSwitchLine[1];
	            "MB3251" := #TRO101.arOutSwitchLine[2];
	            "MB3252" := #TRO101.arOutSwitchLine[3];
	            "MB3253" := #TRO101.arOutSwitchLine[4];
	            "MB3254" := #TRO101.arOutSwitchLine[5];
	            
	            
	            "MB3320" := #TRO101.arOutSeparatorStore[1];
	            "MB3321" := #TRO101.arOutSeparatorStore[2];
	            "MB3322" := #TRO101.arOutSeparatorStore[3];
	            "MB3323" := #TRO101.arOutSeparatorStore[4];
	            "MB3324" := #TRO101.arOutSeparatorStore[5];
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO102 (Empty Buffer links)
	        
	        REGION TRO 102_IN(1Sep)
	            #stTmpJamDataBufferEntry.Config.nCapacitySet := "DB_JamBuffer102".arLine[#TRO102.nOutLineNr].stData.Config.nCapacitySet;
	            #stTmpJamDataBufferEntry.Status.nCount := "DB_JamBuffer102".arLine[#TRO102.nOutLineNr].stData.Status.nCount;
	            
	            #TRO102_IN.stInSeparator1.Settings.nSeparatorNo := 999;
	            #TRO102_IN.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	            #TRO102_IN.stInSeparator1.Settings.tTrailingTime := t#100ms;
	            #TRO102_IN.stInSeparator1.Settings.tHandlingTime := t#50ms;
	            #TRO102_IN.stInSeparator1.Settings.tJam := "TimeForSepJam";
	            #TRO102_IN.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	            #TRO102_IN.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	            // #TRO102_IN.stInSeparator1.Settings.xPluggedJam := TRUE; //hat nicht
	            #TRO102_IN.stInSeparator1.Settings.xPluggedPart := FALSE;
	            #TRO102_IN.stInSeparator1.Settings.xPluggedScanner := FALSE;
	            #TRO102_IN.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3257"];
	            // #TRO102_IN.stInSenJam2 := "DB_Inputs".Sensors["cInBG3245"]; //hat nicht
	            
	            #TRO102_IN.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	            #TRO102_IN.stInSettings.xIsBorner := TRUE;
	            #TRO102_IN.stInSettings.nBornerDest := "cDestInboundLS";
	            
	            #TRO102_IN(nInMainTroNo := 1000,
	                       xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                       xInAllRdyToStart := TRUE,
	                       // xInCancel := "cTodoFalse", //IBN
	                       xInCarouselRun := #fbCarousel0101.xOutConveyorFullSpeed,
	                       xInRelease := #TRO102.xOutReadyToReceive,//IBN
	                       stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                       stInOutCognexInterface := #stCognexInterfaceDummy,
	                       arInOutJamEntr1 := "DB_JamArea0101".stJam0101_2.arCarrier,//"DB_JamBuffer101".arLine[6].arCarrier,
	                       stInOutJamEntr1 := "DB_JamArea0101".stJam0101_2.stData,
	                       arInOutJamExit2 := "DB_JamBuffer102".arLine[#TRO102.nOutLineNr].arCarrier,//arTmpCarrier,
	                       stInOutJamExit2 := #stTmpJamDataBufferEntry,
	                       xOutStopper1 => "MB3257",
	                       nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro102_IN"],
	                       stInOutHMI := "DB_Interface_HMI".stTRO.TRO102_In);  // TODO!!!!!!!!!!!
	            
	        END_REGION
	        
	        REGION Separator Settings
	            
	            REGION Sep Buffer 1
	                #nActNo102 := 1;
	                #TRO102.arInSep[#nActNo102].stSettings.nJamLength := 5;//"cStorage111ExitJam1";
	                #TRO102.arInSep[#nActNo102].stSenTrolley := "DB_Inputs".Sensors["cInBG3310"];
	                #TRO102.arInSep[#nActNo102].stSettings.tHandlingTime := T#200ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tTrailingTime := T#500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.xPluggedScanner := FALSE;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenFree := T#1500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 2
	                #nActNo102 := 2;
	                #TRO102.arInSep[#nActNo102].stSettings.nJamLength := 7;
	                #TRO102.arInSep[#nActNo102].stSenTrolley := "DB_Inputs".Sensors["cInBG3311"];
	                #TRO102.arInSep[#nActNo102].stSettings.tHandlingTime := T#200ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tTrailingTime := T#500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.xPluggedScanner := FALSE;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenFree := T#1500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 3
	                #nActNo102 := 3;
	                #TRO102.arInSep[#nActNo102].stSettings.nJamLength := 9;
	                #TRO102.arInSep[#nActNo102].stSenTrolley := "DB_Inputs".Sensors["cInBG3312"];
	                #TRO102.arInSep[#nActNo102].stSettings.tHandlingTime := T#200ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tTrailingTime := T#500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.xPluggedScanner := FALSE;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenFree := T#1500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 4
	                #nActNo102 := 4;
	                #TRO102.arInSep[#nActNo102].stSettings.nJamLength := 10;
	                #TRO102.arInSep[#nActNo102].stSenTrolley := "DB_Inputs".Sensors["cInBG3313"];
	                #TRO102.arInSep[#nActNo102].stSettings.tHandlingTime := T#200ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tTrailingTime := T#500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.xPluggedScanner := FALSE;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenFree := T#1500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	            REGION Sep Buffer 5
	                #nActNo102 := 5;
	                #TRO102.arInSep[#nActNo102].stSettings.nJamLength := 10;
	                #TRO102.arInSep[#nActNo102].stSenTrolley := "DB_Inputs".Sensors["cInBG3314"];
	                #TRO102.arInSep[#nActNo102].stSettings.tHandlingTime := T#200ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tTrailingTime := T#500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.xPluggedScanner := FALSE;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenFree := T#1500ms;
	                #TRO102.arInSep[#nActNo102].stSettings.tSenWait := T#3000ms;
	            END_REGION
	            
	        END_REGION
	        
	        REGION Jamsensoren
	            #TRO102.arInJamSensor[1] := "DB_Inputs".Sensors["cInBG3260"];
	            
	            #TRO102.arInJamSensor[2] := "DB_Inputs".Sensors["cInBG3261"];
	            
	            #TRO102.arInJamSensor[3] := "DB_Inputs".Sensors["cInBG3262"];
	            
	            #TRO102.arInJamSensor[4] := "DB_Inputs".Sensors["cInBG3263"];
	            
	            #TRO102.arInJamSensor[5] := "DB_Inputs".Sensors["cInBG3264"];
	        END_REGION
	        
	        REGION Dummy Zielvergabe
	            #stDummy.nBarcode := 1;
	            #stDummy.nDestination := 0;
	            #stDummy.bStatus.%X0 := TRUE;
	            
	            IF "DB_JamBuffer102".arLine[1].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer102".arLine[1].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer102".arLine[2].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer102".arLine[2].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer102".arLine[3].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer102".arLine[3].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer102".arLine[4].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer102".arLine[4].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	            IF "DB_JamBuffer102".arLine[5].arCarrier[1] = #stDummy THEN
	                "DB_JamBuffer102".arLine[5].arCarrier[1].nDestination := 10;
	            END_IF;
	            
	        END_REGION
	        
	        
	        REGION TRO 102 CALL
	            #TRO102.xStart := "DB_TRO_TEST".TRO102Start OR ("DB_JamArea0103".stJam0103_1.stData.Status.nCount < ("DB_JamArea0103".stJam0103_1.stData.Config.nCapacitySet * 75 / 100)); //NUR FÜR TEST
	            #TRO102.stInSettings.nNoOfLines := 5;
	            #TRO102(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO102.TroIn,
	                    stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO102.TroOut,
	                    nInBufferNr := "cMainTro102",
	                    xInBufferReq := TRUE,//IBN
	                    xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                    xInConveyorRunOut := #fbCarousel0102.xOutConveyorFullSpeed,
	                    xInBufferRelease := "DB_TRO_TEST".TRO102 AND "DB_JamArea0103".stJam0103_1.stData.Status.nCount < ("cJam0103_1" / 2),
	                    stInSenJamExit := "DB_Inputs".Sensors["cInBG3304"],
	                    nOutActNo => #nActNo102,
	                    stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                    arInOutStorageLines := "DB_JamBuffer102".arLine,
	                    arInOutJamExit := "DB_JamArea0102".stJam0102_1.arCarrier,
	                    stInOutJamExit := "DB_JamArea0102".stJam0102_1.stData,
	                    nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro102"],
	                    stInOutHMI := "DB_Interface_HMI".stTRO.TRO102);
	            
	            "MB3260" := #TRO102.arOutSwitchLine[1];
	            "MB3261" := #TRO102.arOutSwitchLine[2];
	            "MB3262" := #TRO102.arOutSwitchLine[3];
	            "MB3263" := #TRO102.arOutSwitchLine[4];
	            "MB3264" := TRUE;//#fbEmptyBuffer101.arOutSwitchLine[5];
	            
	            
	            "MB3310" := #TRO102.arOutSeparatorStore[1];
	            "MB3311" := #TRO102.arOutSeparatorStore[2];
	            "MB3312" := #TRO102.arOutSeparatorStore[3];
	            "MB3313" := #TRO102.arOutSeparatorStore[4];
	            "MB3314" := #TRO102.arOutSeparatorStore[5];
	        END_REGION
	        
	    END_REGION
	END_REGION
	
	REGION TRO
	    
	    REGION TRO 100 (1Sep)
	        #TRO100.stInSeparator1.Settings.nSeparatorNo := "cSep100.1";
	        #TRO100.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO100.stInSeparator1.Settings.tTrailingTime := t#600ms;
	        #TRO100.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO100.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO100.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO100.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO100.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO100.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3242"];
	        #TRO100.stInSenJam2 := "DB_Inputs".Sensors["cInBG3243"];
	        
	        #TRO100.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO100.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO100.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO100(nInMainTroNo := "cMainTro100",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun := #fbCarousel0101.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_TEST".TRO100,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0100".stJam0100_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0100".stJam0100_1.stData,
	                arInOutJamExit2 := "DB_JamArea0101".stJam0101_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0101".stJam0101_1.stData,
	                xOutStopper1 => "MB3242",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro100"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO100);
	        
	        
	    END_REGION
	    
	    REGION TRO 103 (1Sep)
	        #TRO103.stInSeparator1.Settings.nSeparatorNo := "cSep103.1";
	        #TRO103.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO103.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO103.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO103.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO103.stInSeparator1.Settings.tSenWait := T#3000ms;
	        #TRO103.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO103.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO103.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO103.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO103.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3271"];
	        #TRO103.stInSenJam2 := "DB_Inputs".Sensors["cInBG0286"];
	        
	        #TRO103.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO103(nInMainTroNo := "cMainTro103",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun := #fbCarousel0104.xOutConveyorFullSpeed AND #fbConveyor0103.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_TEST".TRO103,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0103".stJam0103_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0103".stJam0103_1.stData,
	                arInOutJamExit2 := "DB_JamArea0104".stJam0104_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0104".stJam0104_1.stData,
	                xOutStopper1 => "MB3271",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro103"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO103);
	        
	    END_REGION
	    
	    
	    REGION TRO 104 (1Sep)+Scanner
	        #TRO104.stInSeparator1.Settings.nSeparatorNo := "cSep104.1";
	        #TRO104.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO104.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO104.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO104.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO104.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	        #TRO104.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	        #TRO104.stInSeparator1.Settings.xPluggedJam := TRUE; //?
	        #TRO104.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO104.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO104.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG0280"];
	        #TRO104.stInSenJam2 := "DB_Inputs".Sensors["cInBG0281"]; //sinnvoll? BG0281 gibt es nicht mehr
	        
	        #TRO104.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO104.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX1103"].xInCamTriggerReady := "bx1103-TriggerReady";
	        #arCognexInterface["cScannerBX1103"].xInCamTriggerAck := "bx1103-TriggerAck";
	        #arCognexInterface["cScannerBX1103"].xInCamResultsAvailable := "bx1103-Results Available";
	        #arCognexInterface["cScannerBX1103"].xInCamGeneralFault := "bx1103-General Fault";
	        #arCognexInterface["cScannerBX1103"].hwInCamInspectionResults := "BX1103~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO104.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO104(nInMainTroNo := "cMainTro104",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInRelease := #fbLoadingBoom1.xOutReady AND #fbLoadingBoom1.stOutStopper.xStopperReceive, //Freigabe
	                xInCarouselRun := #fbCarousel0104.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1103"],
	                arInOutJamEntr1 := "DB_JamArea0104".stJam0104_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0104".stJam0104_1.stData,
	                arInOutJamExit2 := "DB_JamArea0104".stJam0104_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0104".stJam0104_2.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO104,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro104"],
	                xOutStopper1 => "MB0280");
	        
	        "bx1103-TriggerEnable" := #arCognexInterface["cScannerBX1103"].xOutCamTriggerEnable;
	        "bx1103-Trigger" := #arCognexInterface["cScannerBX1103"].xOutCamTrigger;
	        "bx1103-ResultsAck" := #arCognexInterface["cScannerBX1103"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO104.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO104.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0104".stJam0104_1.arCarrier[1]);
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 105 (1Sep)+Scanner
	        #TRO105.stInSeparator1.Settings.nSeparatorNo := "cSep105.1";
	        #TRO105.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO105.stInSeparator1.Settings.tTrailingTime := t#600ms;
	        #TRO105.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO105.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO105.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	        #TRO105.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	        #TRO105.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO105.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO105.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO105.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3280"];
	        #TRO105.stInSenJam2 := "DB_Inputs".Sensors["cInBG3281"];
	        
	        #TRO105.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO105.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO105.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO105.stInBarcodeReader.Settings.tTimeout := T#3000ms;
	        
	        #arCognexInterface["cScannerBX1104"].xInCamTriggerReady := "bx1104-TriggerReady";
	        #arCognexInterface["cScannerBX1104"].xInCamTriggerAck := "bx1104-TriggerAck";
	        #arCognexInterface["cScannerBX1104"].xInCamResultsAvailable := "bx1104-Results Available";
	        #arCognexInterface["cScannerBX1104"].xInCamGeneralFault := "bx1104-General Fault";
	        #arCognexInterface["cScannerBX1104"].hwInCamInspectionResults := "BX1104~Ergebnisse_–_64_Bytes_1";
	        
	        //SSCC
	        #stCognexIntfTro105.xInCamTriggerReady := "bx1107-TriggerReady";
	        #stCognexIntfTro105.xInCamTriggerAck := "bx1107-TriggerAck";
	        #stCognexIntfTro105.xInCamResultsAvailable := "bx1107-Results Available";
	        #stCognexIntfTro105.xInCamGeneralFault := "bx1107-General Fault";
	        #stCognexIntfTro105.hwInCamInspectionResults := "BX1107~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO105.stInBarcodeReaderSSCC.Settings.xActivateCheckASCI := TRUE;
	        #TRO105.stInBarcodeReaderSSCC.Settings.tTimeout := T#3s;
	        #TRO105.stInBarcodeReaderSSCC.xInPluggedSSCC := TRUE;
	        #TRO105.stInBarcodeReaderSSCC.stSenEndMeasurement := "DB_Inputs".Sensors["cInBG3281"];
	        
	        #TRO105.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO105(nInMainTroNo := "cMainTro105",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE,// Gefälle
	                xInRelease := "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive OR "IBN".xFahrenOhneTcpPartner,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1104"],
	                stInOutCognexInterfaceSSCC := #stCognexIntfTro105,
	                arInOutJamEntr1 := "DB_JamArea0104".stJam0104_3.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0104".stJam0104_3.stData,
	                arInOutJamExit2 := "DB_JamArea0106".stJam0106_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0106".stJam0106_2.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO105,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro105"],
	                xOutStopper1 => "MB3280");
	        
	        
	        "bx1104-TriggerEnable" := #arCognexInterface["cScannerBX1104"].xOutCamTriggerEnable;
	        "bx1104-Trigger" := #arCognexInterface["cScannerBX1104"].xOutCamTrigger;
	        "bx1104-ResultsAck" := #arCognexInterface["cScannerBX1104"].xOutCamResultsAck;
	        
	        //SSCC
	        "bx1107-TriggerEnable" := #stCognexIntfTro105.xOutCamTriggerEnable;
	        "bx1107-Trigger" := #stCognexIntfTro105.xOutCamTrigger;
	        "bx1107-ResultsAck" := #stCognexIntfTro105.xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO105.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO105.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0104".stJam0104_3.arCarrier[1]);
	        END_REGION
	        
	        REGION Write SSCC result TO HMI Interface 
	            IF #TRO105.xOutNewScanSSCC THEN
	                "DB_Interface_HMI".stSSCC.SSCC1107.stLastMeasurement.nBarcodeTrolley := "DB_JamArea0104".stJam0104_3.arCarrier[1].nBarcode;
	                "DB_Interface_HMI".stSSCC.SSCC1107.stLastMeasurement.sSSCC := LINT_TO_STRING(#TRO105.nOutScanResultSSCC);
	            END_IF;
	        END_REGION
	        
	        
	        REGION Send DReqM to Fortna WCS (SSCC)
	            // Wenn SSCC Read abgeschlossen, dann Telegram mit spezifizierten Daten generieren und in TCP Sende-FIFO schieben
	            
	            IF #TRO105.xOutNewScanSSCC AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive
	            THEN
	                "FC_Send_GOHDReqM"(sInPLCID := "cPLCID",
	                                   xInSSCCReq := TRUE,
	                                   xInLengthReq := FALSE,
	                                   xInDockDoorReq := TRUE,
	                                   xInLaneStatusReq := FALSE,
	                                   nInBarcode := "DB_JamArea0104".stJam0104_3.arCarrier[1].nBarcode,
	                                   sInSSCC := #TRO105.fbBarcodeReaderSSCC.sOutBarcode,////DELETE(IN := LINT_TO_STRING(#TRO105.nOutScanResultSSCC), L := 1, P := 1),
	                                   sInDecisionPoint := "cDP_DOCK_01",
	                                   sInDockDoor := '"1"',
	                                   sInLengthInfo := '',
	                                   arInLaneStatus := #tmpPlaceHolderLaneStatus,
	                                   nInLaneCnt := 0,
	                                   FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                   BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	            
	            IF "IBN".xTestTelegramSend THEN
	                "FC_Send_GOHDReqM"(sInPLCID := "cPLCID",
	                                   xInSSCCReq := TRUE,
	                                   xInLengthReq := FALSE,
	                                   xInDockDoorReq := TRUE,
	                                   xInLaneStatusReq := FALSE,
	                                   nInBarcode := 22343390,//"DB_JamArea0104".stJam0104_3.arCarrier[1].nBarcode,
	                                   sInSSCC := 'Test',//DELETE(IN := LINT_TO_STRING(#TRO105.nOutScanResultSSCC), L := 1, P := 1),
	                                   sInDecisionPoint := "cDP_DOCK_01",
	                                   sInDockDoor := '"1"',
	                                   sInLengthInfo := '',
	                                   arInLaneStatus := #tmpPlaceHolderLaneStatus,
	                                   nInLaneCnt := 0,
	                                   FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                   BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	                "IBN".xTestTelegramSend := FALSE;
	            END_IF;
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS            
	            IF #TRO105.xOutBookedDir1 AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO105.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := "cDP_DOCK_01",
	                                 sInActionTaken := "cSTRAIGHT",
	                                 nReasonCode := "cSUCCESS",
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 106 (1Sep)
	        #TRO106.stInSeparator1.Settings.nSeparatorNo := "cSep106.1";
	        #TRO106.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO106.stInSeparator1.Settings.tTrailingTime := t#600ms;
	        #TRO106.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO106.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO106.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO106.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO106.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO106.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3315"];
	        #TRO106.stInSenJam2 := "DB_Inputs".Sensors["cInBG3330"];
	        
	        #TRO106.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO106.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        IF "DB_JamArea0106".stJam0106_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea0106".stJam0106_2.arCarrier[1].nDestination := 100; // NUR ZUM TESTEN
	        END_IF;
	        
	        #TRO106(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO106.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO106.TroOut,
	                nInMainTroNo := "cMainTro106",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_TEST".TRO106,
	                xInCarouselRun := #fbCarousel0102.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0106".stJam0106_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0106".stJam0106_2.stData,
	                arInOutJamExit2 := "DB_JamArea0102".stJam0102_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0102".stJam0102_2.stData,
	                xOutStopper1 => "MB3315",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro106"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO106);
	        
	    END_REGION
	    
	    REGION TRO 107(1Sep1Swi)
	        #TRO107.stInSeparator1.Settings.nSeparatorNo := "cSep107.1";
	        #TRO107.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO107.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO107.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO107.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO107.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO107.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO107.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO107.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3306"];
	        #TRO107.stInSenJam2 := "DB_Inputs".Sensors["cInBG3305"];
	        #TRO107.stInSenJam3 := "DB_Inputs".Sensors["cInBG3330"];
	        
	        #TRO107.stInSwitch1.Settings.nSwitchNo := "cSwi107.1";
	        #TRO107.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO107.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO107.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        // "DB_JamArea0102".stJam0102_1.arCarrier[1].nDestination := 100; // NUR ZUM TESTEN 
	        
	        #TRO107.stInSettings.xPrioDir2 := TRUE;
	        #TRO107(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO107.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO107.TroOut,
	                nInMainTroNo := "cMainTro107",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun1 := #fbCarousel0102.xOutConveyorFullSpeed,
	                xInRelease := TRUE,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0102".stJam0102_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0102".stJam0102_1.stData,
	                arInOutJamExit2 := "DB_JamArea0103".stJam0103_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0103".stJam0103_1.stData,
	                arInOutJamExit3 := "DB_JamArea0102".stJam0102_2.arCarrier,
	                stInOutJamExit3 := "DB_JamArea0102".stJam0102_2.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO107,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro107"],
	                xOutStopper1 => "MB3306",
	                xOutSw1ExTo3 => "MB3304");
	        
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi107.1",
	                           nOutDirection => #TRO107.nInDirection,
	                           InOutCarrier := "DB_JamArea0102".stJam0102_1.arCarrier[1]);
	            
	        END_REGION
	    END_REGION
	    
	    REGION TRO 108 (1Sep)
	        #TRO108.stInSeparator1.Settings.nSeparatorNo := "cSep108.1";
	        #TRO108.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO108.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO108.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO108.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO108.stInSeparator1.Settings.tSenWait := T#3000ms;
	        #TRO108.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO108.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO108.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO108.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO108.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3283"];
	        #TRO108.stInSenJam2 := "DB_Inputs".Sensors["cInBG0346"];
	        
	        #TRO108.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO108(nInMainTroNo := "cMainTro108",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                // xInCancel := "cTodoFalse",//IBN
	                xInCarouselRun := #fbCarousel0108.xOutConveyorFullSpeed AND #fbConveyor0107.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_TEST".TRO108,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0107".stJam0107_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0107".stJam0107_1.stData,
	                arInOutJamExit2 := "DB_JamArea0108".stJam0108_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0108".stJam0108_1.stData,
	                xOutStopper1 => "MB3283",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro108"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO108);
	        
	    END_REGION
	    
	    REGION TRO 109 (1Sep)+Scanner
	        #TRO109.stInSeparator1.Settings.nSeparatorNo := "cSep109.1";
	        #TRO109.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO109.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO109.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO109.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO109.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	        #TRO109.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	        #TRO109.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO109.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO109.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO109.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG0340"];
	        
	        #TRO109.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO109.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX1105"].xInCamTriggerReady := "bx1105-TriggerReady";
	        #arCognexInterface["cScannerBX1105"].xInCamTriggerAck := "bx1105-TriggerAck";
	        #arCognexInterface["cScannerBX1105"].xInCamResultsAvailable := "bx1105-Results Available";
	        #arCognexInterface["cScannerBX1105"].xInCamGeneralFault := "bx1105-General Fault";
	        #arCognexInterface["cScannerBX1105"].hwInCamInspectionResults := "BX1105~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO109.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO109(nInMainTroNo := "cMainTro109",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_TEST".TRO109,
	                xInCarouselRun := #fbCarousel0108.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1105"],
	                arInOutJamEntr1 := "DB_JamArea0108".stJam0108_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0108".stJam0108_1.stData,
	                arInOutJamExit2 := "DB_JamArea0108".stJam0108_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0108".stJam0108_2.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO109,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro109"],
	                xOutStopper1 => "MB0340");
	        
	        
	        "bx1105-TriggerEnable" := #arCognexInterface["cScannerBX1105"].xOutCamTriggerEnable;
	        "bx1105-Trigger" := #arCognexInterface["cScannerBX1105"].xOutCamTrigger;
	        "bx1105-ResultsAck" := #arCognexInterface["cScannerBX1105"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO109.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO109.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0108".stJam0108_1.arCarrier[1]);
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 110 (1Sep)+Scanner
	        
	        #TRO110.stInSeparator1.Settings.nSeparatorNo := "cSep110.1";
	        #TRO110.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO110.stInSeparator1.Settings.tTrailingTime := t#600ms;
	        #TRO110.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO110.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO110.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO110.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO110.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO110.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3295"];
	        #TRO110.stInSenJam2 := "DB_Inputs".Sensors["cInBG3296"];
	        
	        #TRO110.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO110.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO110.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO110.stInBarcodeReader.Settings.tTimeout := T#3000ms;
	        
	        #arCognexInterface["cScannerBX1106"].xInCamTriggerReady := "bx1106-TriggerReady";
	        #arCognexInterface["cScannerBX1106"].xInCamTriggerAck := "bx1106-TriggerAck";
	        #arCognexInterface["cScannerBX1106"].xInCamResultsAvailable := "bx1106-Results Available";
	        #arCognexInterface["cScannerBX1106"].xInCamGeneralFault := "bx1106-General Fault";
	        #arCognexInterface["cScannerBX1106"].hwInCamInspectionResults := "BX1106~Ergebnisse_–_64_Bytes_1";
	        
	        // SSCC
	        #stCognexIntfTro110.xInCamTriggerReady := "bx1108-TriggerReady";
	        #stCognexIntfTro110.xInCamTriggerAck := "bx1108-TriggerAck";
	        #stCognexIntfTro110.xInCamResultsAvailable := "bx1108-Results Available";
	        #stCognexIntfTro110.xInCamGeneralFault := "bx1108-General Fault";
	        #stCognexIntfTro110.hwInCamInspectionResults := "BX1108~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO110.stInBarcodeReaderSSCC.Settings.xActivateCheckASCI := TRUE;
	        #TRO110.stInBarcodeReaderSSCC.Settings.tTimeout := T#3s;
	        #TRO110.stInBarcodeReaderSSCC.xInPluggedSSCC := TRUE;
	        #TRO110.stInBarcodeReaderSSCC.stSenEndMeasurement := "DB_Inputs".Sensors["cInBG3296"];
	        
	        #TRO110.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO110(nInMainTroNo := "cMainTro110",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInCarouselRun := TRUE, //Gefälle
	                xInRelease := "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive OR "IBN".xFahrenOhneTcpPartner,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1106"],
	                stInOutCognexInterfaceSSCC := #stCognexIntfTro110,
	                arInOutJamEntr1 := "DB_JamArea0108".stJam0108_3.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0108".stJam0108_3.stData,
	                arInOutJamExit2 := "DB_JamArea0110".stJam0110_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0110".stJam0110_2.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO110,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro110"],
	                xOutStopper1 => "MB3295");
	        
	        "bx1106-TriggerEnable" := #arCognexInterface["cScannerBX1106"].xOutCamTriggerEnable;
	        "bx1106-Trigger" := #arCognexInterface["cScannerBX1106"].xOutCamTrigger;
	        "bx1106-ResultsAck" := #arCognexInterface["cScannerBX1106"].xOutCamResultsAck;
	        
	        //SSCC
	        "bx1108-TriggerEnable" := #stCognexIntfTro110.xOutCamTriggerEnable;
	        "bx1108-Trigger" := #stCognexIntfTro110.xOutCamTrigger;
	        "bx1108-ResultsAck" := #stCognexIntfTro110.xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO110.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO110.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0108".stJam0108_3.arCarrier[1]);
	        END_REGION
	        
	        REGION Write SSCC result TO HMI Interface 
	            IF #TRO110.xOutNewScanSSCC THEN
	                "DB_Interface_HMI".stSSCC.SSCC1108.stLastMeasurement.nBarcodeTrolley := "DB_JamArea0108".stJam0108_3.arCarrier[1].nBarcode;
	                "DB_Interface_HMI".stSSCC.SSCC1108.stLastMeasurement.sSSCC := DELETE(IN := LINT_TO_STRING(#TRO110.nOutScanResultSSCC), L := 1, P := 1);
	            END_IF;
	        END_REGION
	        
	        
	        REGION Send DReqM to Fortna WCS (SSCC)
	            // Wenn SSCC Read abgeschlossen, dann Telegram mit spezifizierten Daten generieren und in TCP Sende-FIFO schieben
	            
	            IF #TRO110.xOutNewScanSSCC AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive THEN
	                "FC_Send_GOHDReqM"(sInPLCID := "cPLCID",
	                                   xInSSCCReq := TRUE,
	                                   xInLengthReq := FALSE,
	                                   xInDockDoorReq := TRUE,
	                                   xInLaneStatusReq := FALSE,
	                                   nInBarcode := "DB_JamArea0108".stJam0108_3.arCarrier[1].nBarcode,
	                                   sInSSCC := #TRO110.fbBarcodeReaderSSCC.sOutBarcode,//DELETE(IN := LINT_TO_STRING(#TRO110.nOutScanResultSSCC), L := 1, P := 1),
	                                   sInDecisionPoint := "cDP_DOCK_02",
	                                   sInDockDoor := '"2"',
	                                   sInLengthInfo := '',
	                                   arInLaneStatus := #tmpPlaceHolderLaneStatus,
	                                   nInLaneCnt := 0,
	                                   FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                   BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                   nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS            
	            IF #TRO110.xOutBookedDir1 AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO110.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := "cDP_DOCK_02",
	                                 sInActionTaken := "cSTRAIGHT",
	                                 nReasonCode := "cSUCCESS",
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 111 (1Sep)
	        #TRO111.stInSeparator1.Settings.nSeparatorNo := "cSep111.1";
	        #TRO111.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO111.stInSeparator1.Settings.tTrailingTime := t#600ms;
	        #TRO111.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO111.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO111.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO111.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO111.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO111.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3325"];
	        #TRO111.stInSenJam2 := "DB_Inputs".Sensors["cInBG3334"];
	        
	        #TRO111.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO111.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        IF "DB_JamArea0110".stJam0110_2.arCarrier[1].bStatus.%X0 THEN
	            "DB_JamArea0110".stJam0110_2.arCarrier[1].nDestination := 100; // NUR ZUM TESTEN 
	        END_IF;
	        
	        #TRO111(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO111.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO111.TroOut,
	                nInMainTroNo := "cMainTro111",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := TRUE,
	                xInCarouselRun := #fbCarousel0102.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0110".stJam0110_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0110".stJam0110_2.stData,
	                arInOutJamExit2 := "DB_JamArea0102".stJam0102_3.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0102".stJam0102_3.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO111,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro111"],
	                xOutStopper1 => "MB3325");
	        
	    END_REGION
	    
	    REGION TRO 112 (1Sep1Swi)
	        #TRO112.stInSeparator1.Settings.nSeparatorNo := "cSep112.1";
	        #TRO112.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO112.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO112.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO112.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO112.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO112.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO112.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO112.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3332"];
	        #TRO112.stInSenJam2 := "DB_Inputs".Sensors["cInBG3331"];
	        #TRO112.stInSenJam3 := "DB_Inputs".Sensors["cInBG3334"];
	        
	        #TRO112.stInSwitch1.Settings.nSwitchNo := "cSwi112.1";
	        #TRO112.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO112.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO112.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        // "DB_JamArea0102".stJam0102_2.arCarrier[1].nDestination := 100; // NUR ZUM TESTEN 
	        
	        #TRO112.stInSettings.xPrioDir2 := TRUE;
	        #TRO112(stInPriorityManagerDir2 := "DB_Prozessdaten".stPriorityManager.udt_TRO112.TroIn,
	                stOutPriorityManagerDir2 => "DB_Prozessdaten".stPriorityManager.udt_TRO112.TroOut,
	                nInMainTroNo := "cMainTro112",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun1 := #fbCarousel0102.xOutConveyorFullSpeed,
	                xInRelease := TRUE,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0102".stJam0102_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0102".stJam0102_2.stData,
	                arInOutJamExit2 := "DB_JamArea0107".stJam0107_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0107".stJam0107_1.stData,
	                arInOutJamExit3 := "DB_JamArea0102".stJam0102_3.arCarrier,
	                stInOutJamExit3 := "DB_JamArea0102".stJam0102_3.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO112,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro112"],
	                xOutStopper1 => "MB3332",
	                xOutSw1ExTo3 => "MB3330");
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi112.1",
	                           nOutDirection => #TRO112.nInDirection,
	                           InOutCarrier := "DB_JamArea0102".stJam0102_2.arCarrier[1]);
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 113 (1Sep)+Scanner
	        
	        REGION Schnittstelle RFID - TODO
	            //TRO113 darf nur rauslassen, wenn RFID Ready = TRUE
	            //27.11. funktioniert soweit. Wenn Rielec grün leuchtet, fahren wir durch und sie sannen. Wenn nicht, dann stoppen wir vorher
	            ;
	        END_REGION
	        
	        #TRO113.stInSeparator1.Settings.nSeparatorNo := "cSep113.1";
	        #TRO113.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO113.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO113.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO113.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO113.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	        #TRO113.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	        #TRO113.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO113.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO113.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO113.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3335"];
	        // #TRO113.stInSenJam2 := "DB_Inputs".Sensors["cInBG3336"];
	        
	        #TRO113.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO113.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX1101"].xInCamTriggerReady := "bx1101-TriggerReady";
	        #arCognexInterface["cScannerBX1101"].xInCamTriggerAck := "bx1101-TriggerAck";
	        #arCognexInterface["cScannerBX1101"].xInCamResultsAvailable := "bx1101-Results Available";
	        #arCognexInterface["cScannerBX1101"].xInCamGeneralFault := "bx1101-General Fault";
	        #arCognexInterface["cScannerBX1101"].hwInCamInspectionResults := "BX1101~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO113.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO113(nInMainTroNo := "cMainTro113",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun := #fbCarousel0102.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_TEST".TRO113 AND ("DI0047" OR (NOT "DI0047" AND "DI0042")) AND ("FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive OR "IBN".xFahrenOhneTcpPartner), //RFID Freigabe 
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1101"],
	                arInOutJamEntr1 := "DB_JamArea0102".stJam0102_3.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0102".stJam0102_3.stData,
	                arInOutJamExit2 := "DB_JamArea0102".stJam0102_4.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0102".stJam0102_4.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO113,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro113"],
	                xOutStopper1 => "MB3335");
	        
	        "bx1101-TriggerEnable" := #arCognexInterface["cScannerBX1101"].xOutCamTriggerEnable;
	        "bx1101-Trigger" := #arCognexInterface["cScannerBX1101"].xOutCamTrigger;
	        "bx1101-ResultsAck" := #arCognexInterface["cScannerBX1101"].xOutCamResultsAck;
	        
	        REGION RFID Austausch
	            //Simpel zum Testen
	            
	            "DQ0042" := #TRO113.nState = 2000; //Wait for release
	            
	            "DQ0047" := #TRO113.fbSeparator1.xOutTrolleyReleasedEdge; //Version: Flanke
	            
	            // IF #TRO113.fbSeparator1.xOutTrolleyReleasedEdge THEN
	            //     "DQ0047" := TRUE;
	            //     //xxxxxxxxxxxxxxxxx to do
	            // END_IF;
	            // 
	            
	            "DB_Interface_HMI".stRFID.FromPartner.xStationReady := "DI0042";
	            "DB_Interface_HMI".stRFID.FromPartner.xBypassMode := "DI0047";
	            
	            "DB_Interface_HMI".stRFID.ToPartner.xLineReady := "DQ0042";
	            "DB_Interface_HMI".stRFID.ToPartner.xJetSent := "DQ0047";
	            
	        END_REGION
	        
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO113.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO113.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0102".stJam0102_3.arCarrier[1]);
	        END_REGION
	        
	        REGION Längenmessung 
	            "FB_Längenmessung_DB"(xInStartMessung := (#TRO113.nState = 2500 AND #TRO113.fbSeparator1.xOutTrolleyReleasedEdge),
	                                  xInEndeMessung := "DB_Inputs".Sensors["cInBG3357"].xDirectEdgeNeg,
	                                  xInTeilVorhanden := "DB_Inputs".Sensors["cInBG3354"].xDirectSensor,
	                                  xInTeilLang := NOT "DB_Inputs".Sensors["cInBG3355"].xDirectSensor,
	                                  xInTeilzuLang := NOT "DB_Inputs".Sensors["cInBG3356"].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_JamArea0102".stJam0102_4.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_JamArea0102".stJam0102_4.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_JamArea0102".stJam0102_4.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_JamArea0102".stJam0102_4.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := 10; // leer
	                ELSE
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nBarcode := "DB_JamArea0102".stJam0102_4.arCarrier[1].nBarcode;
	                    "DB_Interface_HMI".stLengthMeasurement.stLastMeasurement.nResult := -99; //Fehler
	                END_IF;
	            END_IF;
	            
	            REGION DReqM to Fortna WCS (LM)
	                // Wenn Längenmessung abgeschlossen dann Telegram mit spezifizierten Daten generieren und in TCP Sende-FIFO schieben
	                
	                IF #rTrig_LengthMeasurement.Q AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive 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_JamArea0102".stJam0102_4.arCarrier[1].nBarcode,
	                                       sInSSCC := '',
	                                       sInDecisionPoint := "cDP_REC_01",
	                                       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
	            
	        END_REGION
	        
	        
	    END_REGION
	    
	    REGION TRO 114 (1Sep1Switch)+Scanner
	        #TRO114.stInSeparator1.Settings.nSeparatorNo := "cSep114.1";
	        #TRO114.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO114.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO114.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO114.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO114.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO114.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO114.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO114.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3337"];
	        #TRO114.stInSenJam2 := "DB_Inputs".Sensors["cInBG3340"];
	        #TRO114.stInSenJam3 := "DB_Inputs".Sensors["cInBG3341"];
	        
	        #TRO114.stInSwitch1.Settings.nSwitchNo := "cSwi114.1";
	        #TRO114.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO114.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO114.stInSwitch1.Settings.nTo1Destinations := 3; //Info nötig für HMI
	        
	        #TRO114.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO114.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX1102"].xInCamTriggerReady := "bx1102-TriggerReady";
	        #arCognexInterface["cScannerBX1102"].xInCamTriggerAck := "bx1102-TriggerAck";
	        #arCognexInterface["cScannerBX1102"].xInCamResultsAvailable := "bx1102-Results Available";
	        #arCognexInterface["cScannerBX1102"].xInCamGeneralFault := "bx1102-General Fault";
	        #arCognexInterface["cScannerBX1102"].hwInCamInspectionResults := "BX1102~Ergebnisse_–_64_Bytes_1";
	        
	        #TRO114.stInPriorityManagerDir1.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	      //  "DB_JamArea0102".stJam0102_4.arCarrier[1].nDestination := "cDestInboundOut"; // NUR ZUM TESTEN 
	        
	        #stJamData4104.Config.nCapacitySet := 1;
	        
	        #TRO114(nInMainTroNo := "cMainTro114",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun1 := #fbCarousel0102.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_TEST".TRO114 AND ("FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive OR "IBN".xFahrenOhneTcpPartner),
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1102"],
	                arInOutJamEntr1 := "DB_JamArea0102".stJam0102_4.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0102".stJam0102_4.stData,
	                arInOutJamExit2 := #arStCarrier4104,//"DB_JamArea4104".stJam4104_1.arCarrier,
	                stInOutJamExit2 := #stJamData4104,//"DB_JamArea4104".stJam4104_1.stData,
	                arInOutJamExit3 := "DB_JamArea0102".stJam0102_5.arCarrier,
	                stInOutJamExit3 := "DB_JamArea0102".stJam0102_5.stData,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO114,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro114"],
	                xOutStopper1 => "MB3337",
	                xOutSw1ExTo3 => "MB3340");
	        
	        "bx1102-TriggerEnable" := #arCognexInterface["cScannerBX1102"].xOutCamTriggerEnable;
	        "bx1102-Trigger" := #arCognexInterface["cScannerBX1102"].xOutCamTrigger;
	        "bx1102-ResultsAck" := #arCognexInterface["cScannerBX1102"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO114.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO114.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0102".stJam0102_4.arCarrier[1]);
	        END_REGION
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi114.1",
	                           nOutDirection => #TRO114.nInDirection,
	                           InOutCarrier := "DB_JamArea0102".stJam0102_4.arCarrier[1]);
	            
	        END_REGION
	        
	        REGION Send DUM to Fortna WCS
	            IF #TRO114.xOutBookedDir1 AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO114.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := "cDP_REC_01",
	                                 sInActionTaken := "cSTORAGE",
	                                 nReasonCode := "cSUCCESS",
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	            
	            IF #TRO114.xOutBookedDir2 AND "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive THEN
	                "FC_Send_GOHDUM"(sInPLCID := "cPLCID",
	                                 nInBarcode := #TRO114.stOutLastCarrier.nBarcode,
	                                 sInDecisionPoint := "cDP_REC_01",
	                                 sInActionTaken := "cSTRAIGHT",
	                                 nReasonCode := "cSUCCESS",
	                                 FIFO := "DB_LGF_FIFO_CommWCSBL",
	                                 BUFFER := "DB_Buffer_CommunicationWCSBL".BUFFER,
	                                 nInOutSequenceNumber := "DB_CommunicationParameters".nSeqNumWCSBL);
	            END_IF;
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION TRO 115 (Vario)
	        #TRO115.stInSeparator1.Settings.nSeparatorNo := "cSep115.1";
	        #TRO115.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO115.stInSeparator1.Settings.tTrailingTime := t#800ms;
	        #TRO115.stInSeparator1.Settings.tHandlingTime := t#300ms;
	        #TRO115.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO115.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO115.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO115.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO115.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3025"];
	        
	        #TRO115.stInSeparator1.Settings.tSenFree := t#2000ms;//T#1200ms;
	        #TRO115.stInSeparator1.Settings.tSenWait := T#5000ms;
	        
	        #TRO115.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO115.stInVario.Settings.tWaitForJog := T#300ms;
	        #TRO115.stInVario.Settings.tConvEmpty := T#45000ms;
	        #TRO115.stInVario.Settings.nCountCarrier := 1;
	        #TRO115.stInVario.Settings.tWaitForStop := t#3s;
	        
	        #TRO115.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO115.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        
	        #TRO115.stInVario.Settings.tRasterHigh := t#5s;
	        #TRO115.stInVario.Settings.tRasterLow := t#5s;
	        
	        #TRO115.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3026"]; // MT in Pos
	        #TRO115.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3027"]; // Pusher Dog in Pos
	        #TRO115.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3000"]; // Conveyor full
	        #TRO115.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3001"]; // Jam detector
	        
	        #TRO115.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        #TRO115.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO115.stInVario.Settings.tJamSenDelay := T#2s;
	        
	        #TRO115.stInSettings.xIsBorner := TRUE;
	        
	        #TRO115(nInMainTroNo := "cMainTro115",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInMotorProtection := "FC0145",
	                xInAllRdyToStart := TRUE,
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0002",
	                xInAutomatic := #t_Automatik_OF1 AND "SF0120",
	                xInRelease := "DB_TRO_TEST".TRO115,
	                arInOutJamEntr := "DB_JamArea4104".stJam4104_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4104".stJam4104_1.stData,
	                arInOutJamFinger := "DB_JamArea4103".stJam4103_1.arCarrier,
	                stInOutJamFinger := "DB_JamArea4103".stJam4103_1.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO115,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro115"],
	                xOutStopper => "MB3025",
	                xOutVarioMotor => "MA0145");
	        
	        
	    END_REGION
	    
	    REGION TRO 116 (1Sep)
	        #TRO116.stInSeparator1.Settings.nSeparatorNo := "cSep116.1";
	        #TRO116.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Medium";
	        #TRO116.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO116.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO116.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO116.stInSeparator1.Settings.xPluggedConfirm := FALSE;
	        #TRO116.stInSeparator1.Settings.xPluggedNullBT := FALSE;
	        #TRO116.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO116.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO116.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO116.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3316"];
	        #TRO116.stInSenJam2 := "DB_Inputs".Sensors["cInBG3300"];
	        
	        #TRO116.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO116(nInMainTroNo := "cMainTro116",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun := #fbCarousel0102.xOutConveyorFullSpeed,
	                xInRelease := "DB_TRO_TEST".TRO116,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea0102".stJam0102_5.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0102".stJam0102_5.stData,
	                arInOutJamExit2 := "DB_JamArea0102".stJam0102_6.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0102".stJam0102_6.stData,
	             //   nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro116"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO116,
	                xOutStopper1 => "MB3316");
	        
	        IF #TRO116.nOutStateLast > 1000 THEN
	            "DB_GLOB_TroState".arTroState["cMainTro116"] := #TRO116.nOutStateLast;
	        END_IF;
	        
	    END_REGION
	    
	    
	    REGION TRO 117 (1Sep) + Scanner
	        #TRO117.stInSeparator1.Settings.nSeparatorNo := "cSep117.1";
	        #TRO117.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO117.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO117.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO117.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO117.stInSeparator1.Settings.xPluggedJam := TRUE;
	        
	        #TRO117.stInSeparator1.Settings.xPluggedPart := TRUE;
	        #TRO117.stInSettings.bSepType.%X0 := TRUE;
	        #TRO117.stInSettings.bSepType.%X1 := TRUE;
	        #TRO117.stInSettings.tPartSenHigh := T#500ms;
	        #TRO117.stInSettings.tInSenHigh := T#500ms;
	        #TRO117.stInSeparator1.stSenPart := "DB_Inputs".Sensors["cInBG3301"];
	        
	        #TRO117.stInSeparator1.Settings.xPluggedScanner := TRUE;
	        #TRO117.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3300"];
	        #TRO117.stInSenJam2 := "DB_Inputs".Sensors["cInBG3304"];
	        
	        #TRO117.stInBarcodeReader.Settings.xActivateCheckASCI := TRUE;
	        #TRO117.stInBarcodeReader.Settings.tTimeout := T#5s;
	        
	        #arCognexInterface["cScannerBX1100"].xInCamTriggerReady := "bx1100-TriggerReady";
	        #arCognexInterface["cScannerBX1100"].xInCamTriggerAck := "bx1100-TriggerAck";
	        #arCognexInterface["cScannerBX1100"].xInCamResultsAvailable := "bx1100-Results Available";
	        #arCognexInterface["cScannerBX1100"].xInCamGeneralFault := "bx1100-General Fault";
	        #arCognexInterface["cScannerBX1100"].hwInCamInspectionResults := "BX1100~Ergebnisse_–_64_Bytes_1";
	        
	        REGION NUR FÜR TEST
	            
	            // "DB_JamArea0102".stJam0102_6.arCarrier[1].nDestination := "cDestClearing";
	        END_REGION
	        
	        #TRO117(stInPriorityManager := "DB_Prozessdaten".stPriorityManager.udt_TRO117.TroIn,
	                stOutPriorityManager => "DB_Prozessdaten".stPriorityManager.udt_TRO117.TroOut,
	                nInMainTroNo := "cMainTro117",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                xInAllRdyToStart := TRUE,
	                xInCarouselRun := #fbCarousel0102.xOutConveyorFullSpeed,
	                xInRelease := #rTrig_ClarificationButton.Q,
	                stInOutMachineState := #stInOutControlUnitCabinetOF1,
	                stInOutCognexInterface := #arCognexInterface["cScannerBX1100"],
	                arInOutJamEntr1 := "DB_JamArea0102".stJam0102_6.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea0102".stJam0102_6.stData,
	                arInOutJamExit2 := "DB_JamArea0102".stJam0102_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea0102".stJam0102_1.stData,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro117"],
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO117,
	                xOutStopper1 => "MB3300");
	        
	        "bx1100-TriggerEnable" := #arCognexInterface["cScannerBX1100"].xOutCamTriggerEnable;
	        "bx1100-Trigger" := #arCognexInterface["cScannerBX1100"].xOutCamTrigger;
	        "bx1100-ResultsAck" := #arCognexInterface["cScannerBX1100"].xOutCamResultsAck;
	        
	        REGION Carr_Glob_Correction
	            
	            "FC_CARR_GLOB_CORRECTION"(xInStart := #TRO117.xOutCorrection, //Führe Korrektur aus
	                                      nInBarcodeScan := #TRO117.nBarcodeResult,
	                                      nInStation := 0,
	                                      arOutEventLogInfo => #arDummyEventCorrectionInfo,
	                                      InOutCarrierExpect := "DB_JamArea0102".stJam0102_6.arCarrier[1]);
	        END_REGION
	        
	        REGION Clarification Release
	            
	            #rTrig_ClarificationButton(CLK := "SF0032");
	            
	        END_REGION
	        
	        REGION Trolley Handling
	            
	            IF NOT "DB_Inputs".Sensors["cInBG3300"].xDirectSensor AND
	                "DB_Interface_HMI".stClearingStation.xDeleteTrolley
	            THEN
	                "DB_JamArea0102".stJam0102_6.arCarrier[1] := #stEmptyCarrier;
	                "DB_Interface_HMI".stClearingStation.xDeleteTrolley := FALSE;
	                #TRO117.nState := 100;
	            END_IF;
	            
	            IF (* NOT "DB_Inputs".Sensors["cInBG3300"].xDirectSensor AND *)
	                NOT "BG3301" AND
	                "DB_Interface_HMI".stClearingStation.xDeleteLoad
	            THEN
	                "DB_JamArea0102".stJam0102_6.arCarrier[1].bStatus.%X1 := FALSE;
	                "DB_Interface_HMI".stClearingStation.xDeleteLoad := FALSE;
	            END_IF;
	            
	            
	            "DB_Interface_HMI".stClearingStation.stFirstCarrierInStation := "DB_JamArea0102".stJam0102_6.arCarrier[1];
	            "DB_Interface_HMI".stClearingStation.xTrolleyInStation := "DB_Inputs".Sensors["cInBG3300"].xDbncdSensor;
	        END_REGION ;
	        
	        
	        
	        
	        
	        
	    END_REGION ;
	    
	    REGION TRO 120 (Vario)  // Loaded To Storage 
	        
	        #TRO120.stInSeparator1.Settings.nSeparatorNo := "cSep120.1";
	        #TRO120.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO120.stInSeparator1.Settings.tTrailingTime := T#600ms;
	        #TRO120.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO120.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO120.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO120.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO120.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO120.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3003"];
	        
	        #TRO120.stInSeparator1.Settings.tSenFree := T#2000ms;
	        #TRO120.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO120.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3002"]; //Fingrer in Pos
	        #TRO120.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3006"]; // Conveyor full
	        #TRO120.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3004"]; // MT in Pos
	        #TRO120.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3005"]; // Jam detector
	        
	        #TRO120.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO120.stInVario.Settings.tWaitForJog := T#50ms;//T#400ms;
	        #TRO120.stInVario.Settings.tConvEmpty := T#90000ms;
	        #TRO120.stInVario.Settings.nCountCarrier := 1;
	        #TRO120.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO120.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO120.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        
	        #TRO120.stInVario.Settings.tRasterHigh := T#2500ms;
	        #TRO120.stInVario.Settings.tRasterLow := T#2500ms;
	        
	        #TRO120.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO120.stInVario.Settings.tJamSenDelay := T#2s;
	        
	        #TRO120.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #stJamDataLeaveControl.Config.nCapacitySet := 1;
	        
	        #TRO120(nInMainTroNo := "cMainTro120",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120" AND "SF0124" AND "SF0126" AND "SF0130",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0121",
	                xInMotorProtection := "FC0146",
	                xInRelease := "DB_TRO_TEST".TRO120,
	                arInOutJamEntr := "DB_JamArea4103".stJam4103_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4103".stJam4103_1.stData,
	                arInOutJamFinger := #arStCarrierLeaveControl,//JAM, Übergabe CPU Level 2!
	                stInOutJamFinger := #stJamDataLeaveControl,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO120,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro120"],
	                xOutStopper => "MB3003",
	                xOutVarioMotor => "MA0146");
	        
	    END_REGION
	    
	    REGION TRO 121(Vario)
	        
	        #TRO121.stInSeparator1.Settings.nSeparatorNo := "cSep121.1";
	        #TRO121.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO121.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO121.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO121.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO121.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO121.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO121.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO121.stInSeparator1.Settings.xStuckCorrection := 1;
	        
	        #TRO121.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3080"];
	        
	        #TRO121.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO121.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO121.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3081"]; //Finger  in Pos
	        #TRO121.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3062"]; // Conveyor full
	        #TRO121.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3082"]; // MT in Pos
	        #TRO121.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3061"]; // Jam detector
	        
	        #TRO121.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO121.stInVario.Settings.tWaitForJog := T#200ms;//T#400ms;
	        #TRO121.stInVario.Settings.tConvEmpty := T#45000ms;
	        #TRO121.stInVario.Settings.nCountCarrier := 1;
	        
	        #TRO121.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO121.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        
	        #TRO121.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO121.stInSettings.xIsBorner := TRUE;
	        #TRO121.stInSettings.nBornerDest := "cDestInboundLS";
	        #TRO121(nInMainTroNo := "cMainTro121",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2,
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0117",
	                xInMotorProtection := "FC0141",
	                xInRelease := "DB_TRO_TEST".TRO121,
	                arInOutJamEntr := "DB_JamArea4503".stJam4503_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4503".stJam4503_1.stData,
	                arInOutJamFinger := "DB_JamArea4503".stJam4503_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea4503".stJam4503_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO121,
	                xOutStopper => "MB3080",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro121"],
	                xOutVarioMotor => "MA0141");
	        
	        
	    END_REGION
	    
	    REGION TRO 122 (1Sep)
	        #TRO122.stInSeparator1.Settings.xStuckCorrection := 1;
	        #TRO122.stInSeparator1.Settings.nSeparatorNo := "cSep107.1";
	        #TRO122.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO122.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO122.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO122.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO122.stInSeparator1.Settings.xPluggedJam := FALSE; //nächster InSep mögl., aber Jam wurde erhöht
	        #TRO122.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO122.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO122.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3060"];
	        #TRO122.stInSenJam2 := "DB_Inputs".Sensors["cInBG3063"];
	        
	        #TRO122.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO122.stInSeparator1.Settings.tSenWait := T#3500ms;
	        
	        #TRO122.stInPriorityManager.xReleaseOk := "cTodoTRUE"; //Brandschutztor....
	        
	        #TRO122(nInMainTroNo := "cMainTro122",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_TEST".TRO122,
	                xInCarouselRun := "cTodoTRUE", //Gefälle mit Brandschutztor
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea4503".stJam4503_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea4503".stJam4503_2.stData,
	                arInOutJamExit2 := "DB_JamArea4502".stJam4502_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea4502".stJam4502_1.stData,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro122"],
	                xOutStopper1 => "MB3060",
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO122);
	        
	        
	    END_REGION
	    
	    REGION TRO 123 (Vario) 
	        #TRO123.stInSeparator1.Settings.xStuckCorrection := 1;
	        #TRO123.stInSeparator1.Settings.nSeparatorNo := "cSep123.1";
	        #TRO123.stInSeparator1.Settings.tTrailingTime := T#600ms;
	        #TRO123.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO123.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO123.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO123.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO123.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO123.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO123.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3063"];
	        
	        #TRO123.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO123.stInSeparator1.Settings.tSenWait := T#3500ms;
	        
	        #TRO123.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3065"]; //Finger in Pos
	        #TRO123.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3066"]; // Conveyor full
	        #TRO123.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3064"]; // MT in Pos
	        #TRO123.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3067"]; // Jam detector
	        
	        #TRO123.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO123.stInVario.Settings.tWaitForJog := T#200ms;//T#400ms;
	        #TRO123.stInVario.Settings.tConvEmpty := T#30000ms;
	        #TRO123.stInVario.Settings.nCountCarrier := 1;
	        #TRO123.stInVario.Settings.tWaitForStop := t#3s;
	        
	        #TRO123.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO123.stInVario.Settings.tJamSenDelay := T#1500ms;
	        
	        #TRO123.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO123.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        
	        #TRO123.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO123.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO123(nInMainTroNo := "cMainTro123",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0121",
	                xInMotorProtection := "FC0142",
	                xInRelease := "DB_TRO_TEST".TRO123,
	                arInOutJamEntr := "DB_JamArea4502".stJam4502_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4502".stJam4502_1.stData,
	                arInOutJamFinger := "DB_JamArea4502".stJam4502_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea4502".stJam4502_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO123,
	                xOutStopper => "MB3063",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro123"],
	                xOutVarioMotor => "MA0142");
	        
	    END_REGION
	    
	    REGION TRO 124 (1Sep1Switch)
	        #TRO124.stInSeparator1.Settings.xStuckCorrection := 1;
	        #TRO124.stInSeparator1.Settings.nSeparatorNo := "cSep124.1";
	        #TRO124.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO124.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO124.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO124.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO124.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO124.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO124.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO124.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3024"];
	        #TRO124.stInSenJam2 := "DB_Inputs".Sensors["cInBG3015"];
	        #TRO124.stInSenJam3 := "DB_Inputs".Sensors["cInBG3017"]; //BG3017
	        
	        #TRO124.stInSwitch1.Settings.nSwitchNo := "cSwi124.1";
	        #TRO124.stInSwitch1.Settings.xPluggedExSen3 := FALSE;
	        #TRO124.stInSwitch1.Settings.xPluggedExSen4 := FALSE;
	        #TRO124.stInSwitch1.Settings.nTo1Destinations := 4; //Info nötig für HMI
	        
	        #TRO124.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO124.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        // #TRO124.stInPriorityManager.xReleaseOk := TRUE;
	        
	        IF #TRO101.xOutFull AND #TRO102.xOutFull AND
	            ("DB_JamArea0100".stJam0100_1.stData.Status.nCount >= "DB_JamArea0100".stJam0100_1.stData.Config.nCapacitySet) THEN
	            "DB_JamArea4502".stJam4502_2.arCarrier[1].nDestination := "cDestHighwayStorage";
	        END_IF;
	        
	        
	        #TRO124.stInSettings.xPrioDir1 := TRUE;
	        #TRO124.stInSettings.xPrioDir2 := TRUE;
	        #TRO124.stInPriorityManagerDir1.xReleaseOk := TRUE;
	        #TRO124.stInPriorityManagerDir2.xReleaseOk := TRUE;
	        #TRO124(nInMainTroNo := "cMainTro124",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_TEST".TRO124 OR #xHighwayPrio124,
	                xInCarouselRun1 := #fbCarousel4204.xOutConveyorFullSpeed,
	                xInCarouselRun2 := #fbCarousel4204.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea4502".stJam4502_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea4502".stJam4502_2.stData,
	                arInOutJamExit2 := "DB_JamArea4204".stJam4204_2.arCarrier,
	                stInOutJamExit2 := "DB_JamArea4204".stJam4204_2.stData,
	                arInOutJamExit3 := "DB_JamArea4501".stJam4501_1.arCarrier,
	                stInOutJamExit3 := "DB_JamArea4501".stJam4501_1.stData,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro124"],
	                xOutStopper1 => "MB3024",
	                xOutSw1ExTo4 => "MB3015",
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO124);
	        
	        REGION Direction
	            "FC_Direction"(nInSwitchNo := "cSwi124.1",
	                           nOutDirection => #TRO124.nInDirection,
	                           InOutCarrier := "DB_JamArea4502".stJam4502_2.arCarrier[1]);
	        END_REGION
	        
	        REGION TO DO: WAS MACHT SWITCH?????
	            
	            IF NOT "DB_Inputs".Sensors["cInBG3024"].xDirectSensor AND "DB_Inputs".Sensors["cInBG3024"].tDirectChangeLast > T#8s THEN
	                #xHighwayPrio124 := FALSE; //Jam von TRO124 ist schon lange leer. TRO130 darf fahren und TRO124 darf nicht
	                #xHighwayPrio130 := TRUE;
	                "MB3015" := TRUE; //Weiche von 1Sep1Swi überschreiben!
	            ELSIF #xHighwayPrio130 AND
	                "DB_Inputs".Sensors["cInBG3024"].xDbncdSensor THEN
	                #xHighwayPrio124 := FALSE; //Wenn TRO130 Prio hatte und Sensor von TRO124 hat wieder eine Belegung. TRO124 darf fahren und TRO130 darf nicht
	                #xHighwayPrio130 := FALSE;
	                "MB3015" := TRUE; //Weiche von 1Sep1Swi überschreiben!
	            ELSIF "DB_Inputs".Sensors["cInBG3024"].xDirectSensor AND "DB_Inputs".Sensors["cInBG3024"].tDirectChangeLast > T#6s THEN
	                #xHighwayPrio124 := TRUE; //Wenn TRO130 Prio hatte und Sensor von TRO124 hat wieder eine Belegung. TRO124 darf fahren und TRO130 darf nicht
	                #xHighwayPrio130 := FALSE;
	                //Weiche von 1Sep1Swi nicht mehr überschreiben!
	            END_IF;
	            
	            REGION !!!!!!für Test auf GERADEAUS manipuliert!!!!!!!
	                
	           //      "MB3015" := FALSE; // DAS WIEDER AUSKOMMENTIEREN FÜR NORMALBETRIEB
	                
	            END_REGION
	            
	            
	        END_REGION ;
	        
	    END_REGION
	    
	    REGION TRO 125 (1Sep)
	        
	        #TRO125.stInSeparator1.Settings.nSeparatorNo := "cSep125.1";
	        #TRO125.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO125.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO125.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO125.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO125.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO125.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO125.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO125.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3010"];
	        #TRO125.stInSenJam2 := "DB_Inputs".Sensors["cInBG3014"];
	        
	        #TRO125.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO125(nInMainTroNo := "cMainTro125",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_TEST".TRO125,
	                xInCarouselRun := #fbCarousel4204.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea4204".stJam4204_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea4204".stJam4204_2.stData,
	                arInOutJamExit2 := "DB_JamArea4203".stJam4203_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea4203".stJam4203_1.stData,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro125"],
	                xOutStopper1 => "MB3010",
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO125);
	        
	        
	    END_REGION
	    
	    REGION TRO 126 (Vario)  // Empty to Storage
	        
	        #TRO126.stInSeparator1.Settings.nSeparatorNo := "cSep126.1";
	        #TRO126.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO126.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO126.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO126.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO126.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO126.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO126.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO126.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3120"];
	        
	        #TRO126.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO126.stInSeparator1.Settings.tSenWait := T#4300ms;
	        
	        #TRO126.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3122"]; //Pusher Dog in Pos
	        #TRO126.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3123"]; // Conveyor full
	        #TRO126.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3121"]; // MT in Pos
	        #TRO126.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3124"]; // Jam detector
	        
	        #TRO126.stInVario.Settings.tRasterHigh := T#5000ms;
	        #TRO126.stInVario.Settings.tRasterLow := T#5000ms;
	        
	        #TRO126.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO126.stInVario.Settings.tWaitForJog := T#200ms;//T#400ms;
	        #TRO126.stInVario.Settings.tConvEmpty := T#50000ms;
	        #TRO126.stInVario.Settings.nCountCarrier := 1;
	        #TRO126.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO126.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO126.stInVario.Settings.tJamSenDelay := T#2s;
	        
	        #TRO126.stInVario.Settings.tCarrierInPosDelay := t#1300ms;
	        
	        #TRO126.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO126.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #stJamDataLeaveControl.Config.nCapacitySet := 1;
	        
	        #TRO126(nInMainTroNo := "cMainTro126",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120" AND "SF0124" AND "SF0126" AND "SF0130",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "DB_Interface_HMI".stTRO.TRO126.UDT_Ctrl.xErrorQuit OR "SF0125",
	                xInMotorProtection := "FC0147",
	                xInRelease := "DB_TRO_TEST".TRO126,
	                arInOutJamEntr := "DB_JamArea4203".stJam4203_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4203".stJam4203_1.stData,
	                arInOutJamFinger := #arStCarrierLeaveControl, //Übergabe zu UH03
	                stInOutJamFinger := #stJamDataLeaveControl, //Übergabe zu UH03
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO126,
	                xOutStopper => "MB3120",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro126"],
	                xOutVarioMotor => "MA0147");
	        
	        
	    END_REGION
	    
	    REGION TRO 127 (Vario)
	        
	        #TRO127.stInSeparator1.Settings.nSeparatorNo := "cSep127.1";
	        #TRO127.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO127.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO127.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO127.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO127.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO127.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO127.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO127.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3020"];
	        
	        #TRO127.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO127.stInSeparator1.Settings.tSenWait := T#3500ms;
	        
	        #TRO127.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3021"]; //Finger in Pos
	        #TRO127.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3023"]; // Conveyor full
	        #TRO127.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3011"]; // MT in Pos
	        #TRO127.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3022"]; // Jam detector
	        
	        #TRO127.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO127.stInVario.Settings.tWaitForJog := T#300ms;//T#400ms;
	        #TRO127.stInVario.Settings.tConvEmpty := T#35000ms;
	        #TRO127.stInVario.Settings.nCountCarrier := 1;
	        #TRO127.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO127.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO127.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        
	        #TRO127.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO127(nInMainTroNo := "cMainTro127",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120" AND "SF0124",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0121",
	                xInMotorProtection := "FC0144",
	                xInRelease := "DB_TRO_TEST".TRO127,
	                arInOutJamEntr := "DB_JamArea4501".stJam4501_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4501".stJam4501_1.stData,
	                arInOutJamFinger := "DB_JamArea4501".stJam4501_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea4501".stJam4501_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO127,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro127"],
	                xOutStopper => "MB3020",
	                xOutVarioMotor => "MA0144");
	        
	    END_REGION
	    
	    REGION TRO 128 (Vario) // Empty to Inbound
	        
	        #TRO128.stInSeparator1.Settings.nSeparatorNo := "cSep128.1";
	        #TRO128.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO128.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO128.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO128.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO128.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO128.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO128.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO128.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3290"];
	        
	        #TRO128.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO128.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO128.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3291"]; //Finger in Pos
	        #TRO128.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3240"]; // Conveyor full
	        #TRO128.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3292"]; // MT in Pos
	        #TRO128.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3241"]; // Jam detector
	        
	        #TRO128.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO128.stInVario.Settings.tWaitForJog := T#300ms;//T#400ms;
	        #TRO128.stInVario.Settings.tConvEmpty := T#60000ms;
	        #TRO128.stInVario.Settings.nCountCarrier := 1;
	        #TRO128.stInVario.Settings.tWaitForStop := T#3s;
	        
	        #TRO128.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO128.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        
	        #TRO128.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO128(nInMainTroNo := "cMainTro128",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0121",
	                xInMotorProtection := "FC0057",
	                xInRelease := "DB_TRO_TEST".TRO128,
	                arInOutJamEntr := "DB_JamArea4501".stJam4501_2.arCarrier,
	                stInOutJamEntr := "DB_JamArea4501".stJam4501_2.stData,
	                arInOutJamFinger := "DB_JamArea0100".stJam0100_1.arCarrier,
	                stInOutJamFinger := "DB_JamArea0100".stJam0100_1.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO128,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro128"],
	                xOutStopper => "MB3290",
	                xOutVarioMotor => "MA0057");
	        
	    END_REGION
	    
	    REGION TRO 129 (1Sep)
	        
	        #TRO129.stInSeparator1.Settings.nSeparatorNo := "cSep129.1";
	        #TRO129.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO129.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO129.stInSeparator1.Settings.tTrailingTime := t#500ms;
	        #TRO129.stInSeparator1.Settings.tHandlingTime := t#200ms;
	        #TRO129.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO129.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO129.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO129.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3125"];
	        #TRO129.stInSenJam2 := "DB_Inputs".Sensors["cInBG3012"];
	        
	        #TRO129.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO129.stInSeparator1.Settings.tSenWait := T#3500ms;
	        
	        #TRO129.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO129(nInMainTroNo := "cMainTro129",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := "DB_TRO_TEST".TRO129 AND
	                (NOT #TRO101.xOutFull OR NOT #TRO102.xOutFull OR
	                ("DB_JamArea0100".stJam0100_1.stData.Status.nCount < "DB_JamArea0100".stJam0100_1.stData.Config.nCapacitySet)),
	                xInCarouselRun := #fbCarousel4204.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea4302".stJam4302_2.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea4302".stJam4302_2.stData,
	                arInOutJamExit2 := "DB_JamArea4204".stJam4204_1.arCarrier,
	                stInOutJamExit2 := "DB_JamArea4204".stJam4204_1.stData,
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro129"],
	                xOutStopper1 => "MB3125",
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO129);
	        
	    END_REGION
	    
	    REGION TRO 130 (1Sep)
	        
	        #TRO130.stInSeparator1.Settings.nSeparatorNo := "cSep130.1";
	        #TRO130.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO130.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO130.stInSeparator1.Settings.tTrailingTime := t#100ms;
	        #TRO130.stInSeparator1.Settings.tHandlingTime := t#50ms;
	        #TRO130.stInSeparator1.Settings.xPluggedJam := TRUE;
	        #TRO130.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO130.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO130.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3013"];
	        #TRO130.stInSenJam2 := "DB_Inputs".Sensors["cInBG3017"]; //BG3017!!!!!!!!!!!!!!!!!!!!!!!!!!!
	        
	        #TRO130.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        #TRO130(nInMainTroNo := "cMainTro130",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInCancel := "cTodoFalse",
	                xInRelease := #xHighwayPrio130 OR "DB_TRO_TEST".TRO130, //Nur wenn Weiche zum Abbiegen geschalten ist und Prio Freigabe true, darf dieser TRO überhaupt fahren
	                xInCarouselRun := #fbCarousel4204.xOutConveyorFullSpeed,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                arInOutJamEntr1 := "DB_JamArea4204".stJam4204_1.arCarrier,
	                stInOutJamEntr1 := "DB_JamArea4204".stJam4204_1.stData,
	                arInOutJamExit2 := "DB_JamArea4501".stJam4501_1.arCarrier, //"DB_JamArea4204".stJam4204_2.arCarrier,//
	                stInOutJamExit2 := "DB_JamArea4501".stJam4501_1.stData, //"DB_JamArea4204".stJam4204_2.stData,//
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro130"],
	                xOutStopper1 => "MB3013",
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO130);
	        
	        
	    END_REGION
	    
	    REGION TRO 131 (Vario) // Loaded to AMR
	        
	        #TRO131.stInSeparator1.Settings.nSeparatorNo := "cSep131.1";
	        #TRO131.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO131.stInSeparator1.Settings.tHandlingTime := T#400ms;
	        #TRO131.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO131.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO131.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO131.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO131.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO131.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3073"];
	        
	        #TRO131.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO131.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO131.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3075"]; //Finger in Pos
	        #TRO131.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3070"]; // Conveyor full
	        #TRO131.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3074"]; // MT in Pos
	        #TRO131.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3071"]; // Jam detector
	        
	        #TRO131.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO131.stInVario.Settings.tWaitForJog := T#350ms;//T#400ms;
	        #TRO131.stInVario.Settings.tConvEmpty := T#60000ms;
	        #TRO131.stInVario.Settings.nCountCarrier := 1;
	        #TRO131.stInVario.Settings.tWaitForStop := t#3s;
	        
	        #TRO131.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO131.stInVario.Settings.tJamSenDelay := T#2s;
	        
	        #TRO131.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO131.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        #TRO131.stInVario.Settings.tTimeOutCarrierInPos := t#5s;
	        
	        #TRO131.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO131.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #stJamDataLeaveControl.Config.nCapacitySet := 1;
	        #TRO131(nInMainTroNo := "cMainTro131",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120" AND "SF0124",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0125",
	                xInMotorProtection := "FC0143",
	                xInRelease := "DB_TRO_TEST".TRO131,
	                arInOutJamEntr := "DB_JamArea4403".stJam4403_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4403".stJam4403_1.stData,
	                arInOutJamFinger := #arStCarrierLeaveControl, //Übergang zu UH04
	                stInOutJamFinger := #stJamDataLeaveControl, //Übergang zu UH04
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO131,
	                xOutStopper => "MB3073",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro131"],
	                xOutVarioMotor => "MA0143");
	        
	    END_REGION
	    
	    // REGION TRO 132 (1Sep)
	    
	    //     #TRO132.stInSeparator1.Settings.nSeparatorNo := "cSep132.1";
	    //     #TRO132.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	    //     #TRO132.stInSeparator1.Settings.tJam := "TimeForSepJam";
	    //     #TRO132.stInSeparator1.Settings.tTrailingTime := t#500ms;
	    //     #TRO132.stInSeparator1.Settings.tHandlingTime := t#200ms;
	    //     #TRO132.stInSeparator1.Settings.xPluggedJam := TRUE;
	    //     #TRO132.stInSeparator1.Settings.xPluggedPart := FALSE;
	    //     #TRO132.stInSeparator1.Settings.xPluggedScanner := FALSE;
	    //     #TRO132.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3076"];
	    //     #TRO132.stInSenJam2 := "DB_Inputs".Sensors["cInBG3077"];
	    
	    //     #TRO132.stInSeparator1.Settings.tSenFree := T#1500ms;
	    //     #TRO132.stInSeparator1.Settings.tSenWait := T#3500ms;
	    
	    //     #TRO132.stInPriorityManager.xReleaseOk := TRUE; //Brandschutztor...
	    
	    //     #stJamDataLeaveControl.Config.nCapacitySet := 1;
	    
	    //     #TRO132(nInMainTroNo := "cMainTro132",
	    //             xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMain.Q,
	    //             xInAllRdyToStart := TRUE,
	    //             xInCancel := "cTodoFalse",
	    //             xInRelease := "DB_TRO_TEST".TRO132,
	    //             xInCarouselRun := "cTodoTRUE",
	    //             stInOutMachineState := #stInOutControlUnitCabinet,
	    //             stInOutCognexInterface := #stCognexInterfaceDummy,
	    //             arInOutJamEntr1 := "DB_JamArea4403".stJam4403_2.arCarrier,
	    //             stInOutJamEntr1 := "DB_JamArea4403".stJam4403_2.stData,
	    //             arInOutJamExit2 := #arStCarrierLeaveControl,//Übergabe zu UH04
	    //             stInOutJamExit2 := #stJamDataLeaveControl, //Übergabe zu UH04
	    //             nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro132"],
	    //             xOutStopper1 => "MB3076",
	    //             stInOutHMI := "DB_Interface_HMI".stTRO.TRO132);
	    
	    
	    
	    // END_REGION
	    
	    REGION TRO 133 (Vario) 
	        
	        #TRO133.stInSeparator1.Settings.nSeparatorNo := "cSep133.1";
	        #TRO133.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO133.stInSeparator1.Settings.tHandlingTime := T#200ms;
	        #TRO133.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO133.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO133.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO133.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO133.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO133.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3130"];
	        
	        #TRO133.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO133.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO133.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3132"]; //Finger in Pos
	        #TRO133.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3127"]; // Conveyor full
	        #TRO133.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3131"]; // MT in Pos
	        #TRO133.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3126"]; // Jam detector
	        
	        #TRO133.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO133.stInVario.Settings.tWaitForJog := T#50ms;//T#400ms;
	        #TRO133.stInVario.Settings.tConvEmpty := T#30000ms;
	        #TRO133.stInVario.Settings.nCountCarrier := 1;
	        #TRO133.stInVario.Settings.tWaitForStop := t#3s;
	        
	        #TRO133.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO133.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO133.stInVario.Settings.tJamSenDelay := T#2s;
	        
	        #TRO133.stInVario.Settings.tRasterHigh := t#2500ms;
	        #TRO133.stInVario.Settings.tRasterLow := t#2500ms;
	        
	        #TRO133.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO133.stInVario.Settings.tCarrierInPosDelay := t#1300ms;
	        
	        #TRO133.stInSettings.xIsBorner := TRUE;
	        #TRO133.stInSettings.nBornerDest := "cDestInboundLS"; //ales was von hier kommt, muss zu Ziel 10 = Ladeschleife
	        #TRO133(nInMainTroNo := "cMainTro133",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120" AND "SF0124" AND "SF0126" AND "SF0130",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0127" OR "SF0131",
	                xInMotorProtection := "FC0150",
	                xInRelease := "DB_TRO_TEST".TRO133,
	                arInOutJamEntr := "DB_JamArea4302".stJam4302_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4302".stJam4302_1.stData,
	                arInOutJamFinger := "DB_JamArea4302".stJam4302_2.arCarrier,
	                stInOutJamFinger := "DB_JamArea4302".stJam4302_2.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO133,
	                xOutStopper => "MB3130",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro133"],
	                xOutVarioMotor => "MA0150");
	        
	    END_REGION
	    
	    REGION TRO 134 (Vario) 
	        
	        #TRO134.stInSeparator1.Settings.nSeparatorNo := "cSep134.1";
	        #TRO134.stInSeparator1.Settings.tTrailingTime := T#500ms;
	        #TRO134.stInSeparator1.Settings.tHandlingTime := T#400ms;
	        #TRO134.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
	        #TRO134.stInSeparator1.Settings.tJam := "TimeForSepJam";
	        #TRO134.stInSeparator1.Settings.xPluggedJam := FALSE;
	        #TRO134.stInSeparator1.Settings.xPluggedPart := FALSE;
	        #TRO134.stInSeparator1.Settings.xPluggedScanner := FALSE;
	        #TRO134.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cInBG3135"];
	        
	        #TRO134.stInSeparator1.Settings.tSenFree := T#1500ms;
	        #TRO134.stInSeparator1.Settings.tSenWait := T#4000ms;
	        
	        #TRO134.stInVario.stSenFinger := "DB_Inputs".Sensors["cInBG3137"]; //Finger in Pos
	        #TRO134.stInVario.stSenLastPos := "DB_Inputs".Sensors["cInBG3133"]; // Conveyor full
	        #TRO134.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cInBG3136"]; // MT in Pos
	        #TRO134.stInVario.stSenJam := "DB_Inputs".Sensors["cInBG3134"]; // Jam detector
	        
	        #TRO134.stInVario.Settings.xContinousEmptying := FALSE;
	        #TRO134.stInVario.Settings.tWaitForJog := T#350ms;//T#400ms;
	        #TRO134.stInVario.Settings.tConvEmpty := T#30000ms;
	        #TRO134.stInVario.Settings.nCountCarrier := 1;
	        #TRO134.stInVario.Settings.tWaitForStop := t#3s;
	        
	        #TRO134.stInVario.Settings.xJamSenDelayActive := TRUE;
	        #TRO134.stInVario.Settings.tJamSenDelay := T#2s;
	        
	        #TRO134.stInVario.Settings.tCarrierInPosDelay := t#1200ms;
	        #TRO134.stInVario.Settings.tCarrierInPosEdgeDelay := t#100ms;
	        #TRO134.stInVario.Settings.tTimeOutCarrierInPos := t#5s;
	        
	        #TRO134.stInVario.Settings.xLongSlope := TRUE;
	        
	        #TRO134.stInPriorityManager.xReleaseOk := TRUE; //braucht keine Vorfahrtsregelung
	        
	        #TRO134.stInSettings.xIsBorner := TRUE;
	        #TRO134(nInMainTroNo := "cMainTro134",
	                xInSftyOk := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                xInAllRdyToStart := TRUE,
	                xInAutomatic := #t_Automatik_OF2 AND "SF0120" AND "SF0124" AND "SF0126" AND "SF0130",
	                xInReset := "cTodoFalse",
	                xInErrorQuit := "SF0127" OR "SF0131",
	                xInMotorProtection := "FC0151",
	                xInRelease := "DB_TRO_TEST".TRO134,
	                arInOutJamEntr := "DB_JamArea4402".stJam4402_1.arCarrier,
	                stInOutJamEntr := "DB_JamArea4402".stJam4402_1.stData,
	                arInOutJamFinger := "DB_JamArea4403".stJam4403_1.arCarrier,
	                stInOutJamFinger := "DB_JamArea4403".stJam4403_1.stData,
	                stInOutMachineState := #stInOutControlUnitCabinetOF2,
	                stInOutCognexInterface := #stCognexInterfaceDummy,
	                stInOutHMI := "DB_Interface_HMI".stTRO.TRO134,
	                xOutStopper => "MB3135",
	                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro134"],
	                xOutVarioMotor => "MA0151");
	        
	    END_REGION
	    
	END_REGION ;
	
	REGION IO_Device Bereichshalte
	    "IO_Device_UH01_TO_UH03".xAreaStopUZ1105 := "SF0130";
	END_REGION
	
	REGION Empty Carrier aus Storage anfordern - Simple Test
	    //Einfache Zweitpunktregelung
	    IF "DB_JamArea4302".stJam4302_2.stData.Status.nCount <= "DB_JamArea4302".stJam4302_2.stData.Config.nCapacitySet * 20 / 100 THEN //MIN
	        "IO_Device_UH01_TO_UH03".xNEED_MORE_EMPTY := TRUE;
	    ELSIF "DB_JamArea4302".stJam4302_2.stData.Status.nCount >= "DB_JamArea4302".stJam4302_2.stData.Config.nCapacitySet * 80 / 100 THEN //MAX
	        "IO_Device_UH01_TO_UH03".xNEED_MORE_EMPTY := FALSE;
	    END_IF;
	END_REGION ;
END_FUNCTION_BLOCK

