FUNCTION_BLOCK "FB_ILS_MTRO_PinStore_Auto"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      stInEncoderParameter : Struct
         nPosActDif : DInt;
         nPosPitchPart : DInt;
      END_STRUCT;
      stInSeparatorPin : Struct   // Separator Pin- Band | Lagerblock Eingang
         stSenTrolley : "UDT_Sensor";
         stSettings : "SettingsSeparator";
      END_STRUCT;
      arInSep : Array[1..21] of Struct
         stSenTrolley : "UDT_Sensor";
         stSettings : "SettingsSeparator";
      END_STRUCT;
      stInBarcodeReader : Struct   // Scanner Einstellungen
         Settings : "UDT_SettingsBarcodeReader";
      END_STRUCT;
      arInJamSensor : Array[1..#cUnloadingStations] of "UDT_Sensor";   // Sensor Stau / Abwurf überprüfen
      xInQuitLocal : Bool;   // Fehler quittieren
      stInStorageCarrStats : "CarrierStatisticsStore";
      xInConveyorRunIn : Bool;   // Einlagerkreisel (Pin)
      xInConveyorRunOut : Bool;   // Auslagerkreisel
      stInSensorReference : "UDT_Sensor";
      stInAddHangerSensor : "UDT_Sensor";   // Sensor, der Carrier in das SHR einfügt
      stInSyncSensor1 : "UDT_Sensor";   // Syncsensor Pinband 1
      stInSyncSensor2 : "UDT_Sensor";   // Syncsensor Pinband 2
      stInSyncSensor3 : "UDT_Sensor";   // Syncsensor Pinband 3
      stInSyncSensor4 : "UDT_Sensor";   // Syncsensor Pinband 4
      stInSyncSensor5 : "UDT_Sensor";   // Syncsensor Pinband 5
      stInSettings : Struct
         nDestGeneral : Int;
         nConvStations : Int;
         nStationsMax : Int;
         nStorageThreshold : Int := 10;
         nNoOfLines : USInt := 13;
         nNoOfPositions : USInt := 90;
         sJamSrc : String;
         sJamDest : String;
      END_STRUCT;
      stInSenJam2 : "UDT_Sensor";
      xInTestMode : Bool;   // Testmodus aktivieren
      xInCancel : Bool;   // TRO komplett rücksetzen
      xInAreaStopActive : Bool;   // Bereichshalt
      xInRelease : Bool;   // Freigabe/Anforderung
      nInMainTroNo : UInt;   // TRO-Nummer
      xInSftyOk : Bool;   // Safety ok
      xInAllRdyToStart : Bool;   // Alles bereit
      stInPriorityManager : "UDT_Response";   // Schnittstelle Prioritätenmanager (z.B. bei Kreuzungen)
      nInTestTarget : Int;
   END_VAR

   VAR_OUTPUT 
      arOutSwitch : Array[1..#cUnloadingStations] of Bool;   // Ausgänge Ausschleusselemente
      arOutUnloadingError : Array[1..#cUnloadingStations] of Bool;
      xOutUnloadingError : Bool;
      arOutLineOverloaded : Array[1..#cUnloadingStations] of Bool;
      xOutSeparatorPin : Bool;   // Ausgang Separator Pin Ventil
      arOutSeparatorStore : Array[1..#cUnloadingStations] of Bool;   // Ausgänge Separator Lagerstrecken Ventil
      xOutConvReqSort : Bool;   // Einlagerkreisel anfordern
      xOutConvReqExit : Bool;   // Auslagerkreisel anfordern
      stOutPriorityManager : "UDT_Request";   // Schnittstelle Prioritätenmanager (z.B. bei Kreuzungen)
      xOutCorrection : Bool;
   END_VAR

   VAR_IN_OUT 
      stInOutControlUnitCabinet : "UDT_MainState";   // Hauptzustandsmaschine
      arInOutStorageLines : Array[*] of "stStorageLine";   // Daten Lagerlinien
      arInOutJamEntr : Array[*] of "stCarrier";   // Jam vor Separator Pin (?)
      stInOutJamEntr : "stJamData";
      arInOutJamExit : Array[*] of "stCarrier";   // Jam nach Linien-Separatoren
      stInOutJamExit : "stJamData";   // Konfig+Status-Daten Staubereich Ausgang 1
      arInOutJamBypass : Array[*] of "stCarrier";
      stInOutJamBypass : "stJamData";
      stInOutHMI : "UDT_HMI_TRO_PinStore";   // HMI Schnittstelle Separator Lagerlinien
      stCognexInterfacePin : "stCognexInterface";   // Schnittstelle Cognex  Barcode Reader
      stMFRStorageRemovalInterface : "UDT_MFR_StoreTRO";
      stConveyorStations : "stConveyorStations";
   END_VAR

   VAR 
      fbSeparatorPin : "FB_ILS_STRO_Sep";   // Aufruf Separator Pin
      fbCarrierWaitSepPin : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore1 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore2 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore3 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore4 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore5 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore6 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore7 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore8 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore9 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore10 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore11 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore12 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore13 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore14 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore15 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore16 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore17 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore18 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore19 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore20 : "FB_CarrAccumulate1Sep";
      fbCarrierWaitStore21 : "FB_CarrAccumulate1Sep";
      arfbStationUnloadPin : Array[1..#cUnloadingStations] of "FB_StationUnloadPin";   // Aufruf Abwurfstationen
      fbBarcodeReader1 : "FB_BarcodeReaderCognex";
      fbStateManagerE : "FB_StateManager";   // Schrittketten Manager
      fbStateManagerA : "FB_StateManager";
   END_VAR
   VAR RETAIN
      xStartScan : Bool;
   END_VAR
   VAR 
      nBarcodeResult : DInt;
      xHandshakeScan : Bool;
      xReadSecondLeg : Bool;
   END_VAR
   VAR RETAIN
      nTarget1 : USInt := 11;   // Ziel vergeben Pinband
   END_VAR
   VAR 
      arfbSeparatorStorage : Array[1..#cUnloadingStations] of "FB_ILS_STRO_Sep";   // Aufruf Separatoren Lagerlinien
      rTrigBypass {InstructionName := 'R_TRIG'; LibVersion := '1.0'} : R_TRIG;
      nBarcodeBypass : DInt;
   END_VAR
   VAR RETAIN
      nStateE : Int;
      nStateA : Int;
   END_VAR
   VAR 
      xReleaseTrolleySep1 : Bool;
      sStateText : String;
      xMTRORdy : Bool;
      stCarrierDummy { ExternalAccessible := 'False'; ExternalVisible := 'False'; ExternalWritable := 'False'} : "stCarrier" := (1, (), 16#01);
      xTrolleyWithPart : Bool;
      xTrolleyWoPart : Bool;
      tOnSvReleaseSep {InstructionName := 'TON_TIME'; LibVersion := '1.0'} : TON_TIME;   // Supervision - Freigabe Separator
      arConveyorEnable : Array[1..2] of Bool;
      fbSepPrio : "FB_SepPrio";
   END_VAR
   VAR RETAIN
      nActLine : Int;
   END_VAR
   VAR 
      nLastLine : Int;
      xCodeEven : Bool;
      nBarcodeHelp : DInt;
      sBarcodeString : String;
      fbPrioManagerTest : "FB_PriorityManager";   // Eingefügt zum Testen
      stPrioParam : "UDT_PrioParameter";
      stPrioSep1 : "UDT_MTRO_Prio";
      stPrioSep2 : "UDT_MTRO_Prio";
      fbEventLog_Route1 : "FB_EventLog_Booking";
      fbEventLog_Route2 : "FB_EventLog_Booking";
      fbEventLogCorrection1 : "FB_EventLog_Correction";
      fbEventLogCorrection2 : "FB_EventLog_Correction";
      fbEventLogCarrierUnknown : "FB_EventLog_Scan";
      fbEventLogCarrierNew : "FB_EventLog_Scan";
      fbEventLogGoodRead : "FB_EventLog_Scan";
      nArrayMax : Int;
      arArrayMax : Array[1..21] of Int;
      nTestStorageOut : Int := 1;
      xStart : Bool;
      xHand : Bool;
      stDummyCarrier : "stCarrier" := (1, 0, 16#1);
      xVersatz : Bool;
      stActRequest : Struct
         nMode : Int;
         nActLine : Int;
         nCountReq : Int;
         nCountAct : Int;
      END_STRUCT;
      xBypassStat : Bool;
   END_VAR

   VAR_TEMP 
      nIdx1 : Int;
      arStartUnloading : Array[1..#cUnloadingStations] of Bool;
      arStopUnloading : Array[1..#cUnloadingStations] of Bool;
      stEmptyCarrier : "stCarrier";
      stCarrierPin : "stCarrierPin";
      stBookingInfo : "stEventBookingInfo";
      arEmptyCarrier : Array[1..1] of "stCarrier";
      arLineRelease : Array[1.."cNoLines"] of Bool;
      nTargetHelp : Int;
      nNoOfLines : Int;
      nActNo : USInt;
      xTemp : Bool;
      tmpActUnivTon : Bool;
      tmpReasonForStop : USInt;   // Anhaltegrund in der Schrittkette | 0: Nichts | 5: Alle BT ausgefahren | 10: Fehler in SubTro | 15: Kein BT/NBT am Eingang | 20: Stau im nächsten MTRO | 25: NBT | 30: Falsch gefahren | 35: Initial-BT kam nicht am Ziel an | 40: Allgemeiner Fehler | 45: Abbruch durch MFR | 50: Fehler in Anfrage von MRF | 55: MFR hat TRO pausiert
      nNoOfSameTarget1 : Int;
      nIdx2 : Int;
      arStoreCount1 : Array[1.."cNoLines"] of Int;
      xFreeAhead1 : Bool;
      xSepFree : Bool;
      arEventCorrectionInfo : Array[0..1] of "stEventCorrectionInfo";
      xEventLogBookSHR : Bool;
      xEventLogBookExit : Bool;
      stEventNew : "stEventScanInfo";
      stEventUnknown : "stEventScanInfo";
      xNewCarrier : Bool;
      xGoodRead : Bool;
      xUnknownCarrier : Bool;
      stEventGoodRead : "stEventScanInfo";
      tmpCarrierEmpty : "stCarrier";
      xTmpCorrection : Bool;
      stDummyHmiUnloading : "UDT_HMI_UnloadingStation";
      xBypass : Bool;
      nCounter : DInt;
      xResult : Bool;
   END_VAR

   VAR CONSTANT 
      c0000_StepOff : Int := 0;   // Schrittkette aus
      c0100_StepUndefined : Int := 100;   // Schrittkette undefiniert / Init
      c1000_StepWaitForTrolley1 : Int := 1000;   // Warte auf Trolley 1
      c1100_StepScannerTrig1 : Int := 1100;   // Scanner Triggern 
      c1200_StepScannerEval1 : Int := 1200;   // Scanergebnis auswerten 
      c1300_StepCheckLoad : Int := 1300;   // Beladung prüfen
      c1400_StepCheckSep1 : Int := 1400;   // Separator checken
      c1500_StepReleaseSep1 : Int := 1500;   // Freigabe an Separator
      c2000_StepWaitForTrolley2 : Int := 2000;   // Warte auf Trolley 2
      c2100_StepScannerTrig2 : Int := 2100;   // Scanner Triggern (nur wenn 1.Achse kein Ergebnis)
      c2200_StepScannerEval2 : Int := 2200;   // Scanergebnis auswerten (nur wenn 1.Achse kein Ergebnis)
      c2300_StepCheckSep2 : Int := 2300;   // Separator checken
      c2400_StepCheckJam : Int := 2400;   // Stau überprüfen
      c2500_StepReleaseSep2 : Int := 2500;   // Freigabe an Separator
      cUnloadingStations : Int := 22;
      cCarrierDummy : Int := 1;
      cCarrierUnknown : Int := 2;
   END_VAR


BEGIN
	(* IF "fbMain_DB".TRO344.xOutCorrection THEN
	    #xVersatz := TRUE;
	END_IF; *)
	
	REGION Arraygrößen ermitteln
	    #nNoOfLines := DINT_TO_INT(UPPER_BOUND(ARR := #arInOutStorageLines, DIM := 1));
	END_REGION
	
	REGION Prüfung Lager voll
	    //Prüfe ob Lager voll
	    FOR #nIdx1 := 1 TO USINT_TO_INT(#stInSettings.nNoOfLines) DO //Prüfe ob Lager schon voll ist oder voll wird mit denen die unterwegs sind und gib zusätzlich die resultierenden Gesamtfüllstände aus
	        IF #arInOutStorageLines[#nIdx1].stData.Status.nCount < #stInSettings.nStorageThreshold AND NOT #arInOutStorageLines[#nIdx1].stData.Status.bByte.%X2 THEN
	            IF #stConveyorStations.stData.nTrolleysOnline > 0 THEN //zähle gleiche Ziele zusammen erst wenn überhaupt etwas unterwegs ist
	                FOR #nIdx2 := 1 TO #stConveyorStations.stData.nTrolleysOnline DO
	                    IF #stConveyorStations.arTrolleysOnline[#nIdx2].stPinValues.nTargetPos = #nIdx1 + 10 THEN
	                        #nNoOfSameTarget1 += 1; //addiere die gleichen vergebenen Ziele auf dem Pinband
	                    END_IF;
	                END_FOR;
	            END_IF;
	            #arStoreCount1[#nIdx1] := #nNoOfSameTarget1 + #arInOutStorageLines[#nIdx1].stData.Status.nCount; //resultierender Gesamtfüllstand pro Linie
	            IF #arStoreCount1[#nIdx1] < #stInSettings.nStorageThreshold THEN
	                #xFreeAhead1 := TRUE; //Wenn True, dann ist irgendwo bei mid. einer Linie noch Platz
	            END_IF;
	            #nNoOfSameTarget1 := 0; //Zähler nullen da er für jede Linie verwendet wird
	        ELSE
	            #arStoreCount1[#nIdx1] := #arInOutStorageLines[#nIdx1].stData.Status.nCount; //Wenn Linie bereits max Kapazität hat, schreibe diese in Gesamtzahl hinein
	        END_IF;
	    END_FOR;
	    
	    IF NOT #xFreeAhead1 THEN //Verhindere dass SepPin überhaupt rauslässt falls alles voll ist
	        #xSepFree := FALSE;
	    ELSE
	        #xSepFree := TRUE;
	    END_IF;
	END_REGION
	
	REGION Schrittkette Einlagern       
	    CASE #nStateE OF
	        #c0000_StepOff:
	            REGION 0000: Off
	                // akt. Zustand
	                #sStateText := 'OFF';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                #xCodeEven := FALSE;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                // SCHRITT 0 WIRD GEBRAUCHT!
	                //STATE MANAGER KÜMMERT SICH UM TRANSITION!
	            END_REGION
	            
	        #c0100_StepUndefined:
	            REGION 0100: Undefined
	                // akt. Zustand
	                #sStateText := 'Undefined';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                #xMTRORdy := FALSE;
	                #xCodeEven := FALSE;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                #nStateE := #c1000_StepWaitForTrolley1;
	            END_REGION
	            
	        #c1000_StepWaitForTrolley1:
	            REGION 1000: Wait for Trolley
	                //akt. Zustand
	                #sStateText := 'Wait for Trolley';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                
	                #xReleaseTrolleySep1 := FALSE;
	                #xMTRORdy := TRUE;
	                #xCodeEven := FALSE;
	                
	                //Transition
	                IF #fbSeparatorPin.stOutMainTro.xBtPresent THEN //Separator meldet Belegung
	                    IF #stInSeparatorPin.stSettings.xPluggedScanner THEN //Scanner verbaut?
	                        #nStateE := #c1100_StepScannerTrig1; //Nächster Schritt -> Scannen
	                    ELSIF #arInOutJamEntr[1].bStatus.%X0 THEN // Kein Scanner verbaut, aber Carrier online (z.B. Dummy wurde angelegt)
	                        IF #stInSeparatorPin.stSettings.xPluggedPart THEN
	                            #nStateE := #c1300_StepCheckLoad; // Nächster Schritt -> Beladung prüfen
	                        ELSE
	                            #nStateE := #c1400_StepCheckSep1; //Nächster Schritt -> Separator chekcen
	                        END_IF;
	                    END_IF;
	                END_IF;
	            END_REGION
	            
	        #"c1100_StepScannerTrig1":
	            REGION 1100: Scanner Trigger 1
	                
	                // akt. Zustand
	                #sStateText := 'Scanner Trigger 1';
	                
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                
	                IF #fbBarcodeReader1.xOutReadyForNewScan THEN //Scanner bereit
	                    #xStartScan := TRUE; //Startbefehl 
	                END_IF;
	                
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                
	                IF #fbBarcodeReader1.xOutReadingDone THEN //Scanner Rückmeldung
	                    #xStartScan := FALSE;
	                    #nStateE := #c1200_StepScannerEval1; //Weiter
	                END_IF;
	            END_REGION
	            
	        #"c1200_StepScannerEval1":
	            REGION 1200: Scanner Evaluation 1
	                
	                // akt. Zustand
	                #sStateText := 'Scanner Evaluation 1';
	                
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                
	                // Logic - TODO in eigenen FC packen?..
	                
	                IF #fbBarcodeReader1.xOutCodeGood THEN
	                    #nBarcodeResult := LINT_TO_DINT(#fbBarcodeReader1.#nOutBarcode); // Good read vom Barcode reader übernehmen
	                    
	                    REGION Event log Good read
	                        #xGoodRead := TRUE; // Trigger
	                        #stEventGoodRead.nScanType := 4;
	                        #stEventGoodRead.sBarcode := DELETE(IN := DINT_TO_STRING(#nBarcodeResult), L := 1, P := 1);
	                        #stEventGoodRead.sReaderId := DELETE(IN := INT_TO_STRING(#stInBarcodeReader.Settings.#nStation), L := 1, P := 1);
	                    END_REGION
	                    
	                    
	                    REGION Gerade Zahl erkannt
	                        IF (((#nBarcodeResult / 10) MOD 100) MOD 2 <> 1) THEN //anderes Ergebnis als 1 bedeutet, (xxxxxYYx) YY=gerade, also hinteres Bein von MiniTrolley
	                            #xCodeEven := TRUE; //Bit sagt Separator dass hinteres Bein und nicht erstes zur Korrektur in Schrittkette
	                            // #nBarcodeTarget := #nBarcodeTarget - 10; //Mache danach die gerade Zahl zur ungeraden UPDATE: WEGEN 8. ZIFFER KLAPPT DAS SO NICHT
	                            #nBarcodeHelp := (#nBarcodeResult / 10) - 1;
	                            
	                            "FC_Ean8_CheckDigit"(sInDigits := DELETE(IN := DINT_TO_STRING(IN := #nBarcodeHelp), L := 1, P := 1),
	                                                 sOutBarcode => #sBarcodeString,
	                                                 nOutBarcode => #nBarcodeResult);
	                            
	                            //    #sOutBarcode := #sBarcodeString;
	                        END_IF;
	                    END_REGION
	                    
	                ELSIF #fbBarcodeReader1.#xOutCodeBad THEN
	                    #nBarcodeResult := #arInOutJamEntr[1].nBarcode;  //erwarteter Barcode wird aus JamDaten übernommen
	                END_IF;
	                
	                IF (#nBarcodeResult > 100) AND
	                    (#nBarcodeResult < 2147483647) AND  // Good Read (2.147.483.647 Maximum von DINT)
	                    (#arInOutJamEntr[1].nBarcode = 0 OR #arInOutJamEntr[1].nBarcode = 1) THEN    //Wenn keine Daten oder ein Dummy erwartet werden   
	                    
	                    #xTmpCorrection := TRUE;
	                    
	                    // REGION Carr_Glob_Correction
	                    
	                    //     "FC_CARR_GLOB_CORRECTION"(xInStart := TRUE, //Führe Korrektur aus
	                    //                               nInBarcodeScan := #nBarcodeResult,
	                    //                               nInStation:=1,
	                    //                               xOutNotFound => #xTemp,
	                    //                               arOutEventLogInfo => #arEventCorrectionInfo,
	                    //                               InOutCarrierExpect := #arInOutJamEntr[1]);
	                    // END_REGION
	                    
	                    
	                    // IF NOT #xTemp THEN
	                    //     ;
	                    //     // #stInOutCarrier.stCarrData.nNrOfScans += 1;
	                    // ELSE
	                    //     #arInOutJamEntr[1].nDestination := "cDestNONE"; //neuer Carrier // TODO
	                    //     //     #stInOutCarrier.stCarrData.nNrOfScans += 1;
	                    //     #arInOutJamEntr[1].nBarcode := #nBarcodeResult; //Hier werden neue Carrier im System angelegt
	                    //     #arInOutJamEntr[1].bStatus.%X0 := TRUE;
	                    // END_IF;
	                    
	                    // REGION Event Log New Carrier
	                    
	                    //     #xNewCarrier := TRUE; // Trigger
	                    //     #stEventNew.nScanType := 2;
	                    //     #stEventNew.sBarcode := DELETE(IN := DINT_TO_STRING(#arInOutJamEntr[1].nBarcode), L := 1, P := 1);
	                    //     #stEventNew.sDest := DELETE(IN := INT_TO_STRING(#arInOutJamEntr[1].nDestination), L := 1, P := 1);
	                    //     #stEventNew.sReaderId := DELETE(IN := INT_TO_STRING(#stInBarcodeReader.Settings.#nStation), L := 1, P := 1);
	                    
	                    // END_REGION
	                    
	                ELSIF
	                    (#nBarcodeResult > 100) AND
	                    (#nBarcodeResult < 2147483647) AND // Good Read (2.147.483.647 Maximum von DINT)
	                    #arInOutJamEntr[1].nBarcode = #nBarcodeResult THEN //Barcodes stimmen überein ODER es wird hier gelandet mit BadRead wobei normaler Barcode erwartet wird-> mache normal weiter
	                    ;
	                ELSIF
	                    (#nBarcodeResult > 100) AND
	                    (#nBarcodeResult < 2147483647) AND
	                    #arInOutJamEntr[1].nBarcode <> #nBarcodeResult AND //Barcodes stimmen nicht überein, erwarteter Carrier enthält aber normalen Barcode
	                    #arInOutJamEntr[1].nBarcode <> 0 AND
	                    #arInOutJamEntr[1].nBarcode <> 1 THEN
	                    
	                    #xTmpCorrection := TRUE;
	                    
	                    // REGION Carr_Glob_Correction
	                    
	                    //     "FC_CARR_GLOB_CORRECTION"(xInStart := TRUE, //Führe Korrektur aus
	                    //                               nInBarcodeScan := #nBarcodeResult,
	                    //                               nInStation:=1,
	                    //                               xOutNotFound => #xTemp,
	                    //                               arOutEventLogInfo => #arEventCorrectionInfo,
	                    //                               InOutCarrierExpect := #arInOutJamEntr[1]);
	                    // END_REGION
	                    
	                    // IF NOT #xTemp THEN
	                    //     ;
	                    //     // #stInOutCarrier.stCarrData.nNrOfScans += 1;
	                    // ELSE
	                    //     #arInOutJamEntr[1].nDestination := "cDestNONE"; //neuer Carrier // TODO
	                    //     //     #stInOutCarrier.stCarrData.nNrOfScans += 1;
	                    //     #arInOutJamEntr[1].nBarcode := #nBarcodeResult; //Hier werden neue Carrier im System angelegt
	                    //     #arInOutJamEntr[1].bStatus.%X0 := TRUE;
	                    // END_IF;
	                    
	                    // REGION Event Log New Carrier
	                    
	                    //     #xNewCarrier := TRUE; // Trigger
	                    //     #stEventNew.nScanType := 2;
	                    //     #stEventNew.sBarcode := DELETE(IN := DINT_TO_STRING(#arInOutJamEntr[1].nBarcode), L := 1, P := 1);
	                    //     #stEventNew.sDest := DELETE(IN := INT_TO_STRING(#arInOutJamEntr[1].nDestination), L := 1, P := 1);
	                    //     #stEventNew.sReaderId := DELETE(IN := INT_TO_STRING(#stInBarcodeReader.Settings.#nStation), L := 1, P := 1);
	                    
	                    // END_REGION
	                ELSE        // Bad Read, falls nichts oder Dummy erwartet wird -> HANDLING TO DO!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	                    #arInOutJamEntr[1].bStatus.%X0 := TRUE;
	                    #arInOutJamEntr[1].nBarcode := 2; //unbekannter Carrier mit Badread, erwartet 0 und physikalisch vorhanden
	                    #arInOutJamEntr[1].nDestination := 123; //todo
	                    
	                    REGION Event Log unknown Carrier
	                        
	                        #xUnknownCarrier := TRUE; // Trigger
	                        #stEventUnknown.nScanType := 3;
	                        #stEventUnknown.sBarcode := DELETE(IN := DINT_TO_STRING(#arInOutJamEntr[1].nBarcode), L := 1, P := 1);
	                        #stEventUnknown.sDest := DELETE(IN := INT_TO_STRING(#arInOutJamEntr[1].nDestination), L := 1, P := 1);
	                        #stEventUnknown.sReaderId := DELETE(IN := INT_TO_STRING(#stInBarcodeReader.Settings.#nStation + 50), L := 1, P := 1);
	                        //    #stEventUnknown.sJobNo := DELETE(IN := DINT_TO_STRING(#stInOutCarrier.stLoadData.nJobNo), L := 1, P := 1);
	                        //    #stEventUnknown.sProductNo := DELETE(IN := DINT_TO_STRING(#stInOutCarrier.stLoadData.nProductNo), L := 1, P := 1);
	                        
	                    END_REGION
	                    
	                END_IF;
	                
	                #xHandshakeScan := TRUE;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                IF #stInSeparatorPin.stSettings.xPluggedPart THEN
	                    #nStateE := #c1300_StepCheckLoad;
	                ELSIF #xCodeEven THEN
	                    #xCodeEven := FALSE;
	                    #nStateE := #c2000_StepWaitForTrolley2; //Scanner bestätigt zweites Bein gelesen -> Korrigieren!
	                ELSE
	                    #nStateE := #c1400_StepCheckSep1;
	                END_IF;
	                
	            END_REGION
	        #c1300_StepCheckLoad:
	            REGION 1300: Check Load 
	                
	                // akt. Zustand
	                #sStateText := 'Check Load';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                #xHandshakeScan := FALSE;
	                #xReleaseTrolleySep1 := FALSE;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                #tmpActUnivTon := TRUE;
	                IF (#arInOutJamEntr[1].bStatus.%X1 AND #xTrolleyWithPart) OR //Daten und physikalisch -> beladen Ok!
	                    (NOT #arInOutJamEntr[1].bStatus.%X1 AND #xTrolleyWoPart) //Daten und physikalisch -> unbeladen Ok!
	                THEN
	                    #nStateE := #c1400_StepCheckSep1; // Weiter
	                ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                    #tmpReasonForStop := 123; // TODO: Beladekontrolle Fehler
	                END_IF;
	                
	            END_REGION
	            
	        #c1400_StepCheckSep1:
	            REGION 1400: Check Separator                
	                // akt. Zustand
	                #sStateText := 'Check Sep';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                #tmpActUnivTon := TRUE;
	                IF #fbSeparatorPin.stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                    #nStateE := #c1500_StepReleaseSep1;
	                ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                    #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                END_IF;
	                
	            END_REGION
	            
	        #c1500_StepReleaseSep1:
	            REGION 1500: Release Sep 1            
	                // akt. Zustand
	                #sStateText := 'Leave Sep 1';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                
	                #xReleaseTrolleySep1 := #xInConveyorRunIn AND #xInSftyOk; // Erste Achse darf vereinzelt werden
	                
	                //////// Transition ////////    
	                IF #fbSeparatorPin.stOutMainTro.nStatus = "SepState_Finish" THEN
	                    #nStateE := #c2000_StepWaitForTrolley2;
	                ELSIF #xReleaseTrolleySep1 AND #tOnSvReleaseSep.Q THEN
	                    #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                END_IF;
	                
	            END_REGION
	            
	        #c2000_StepWaitForTrolley2:
	            REGION 2000: Wait for Trolley 2
	                //akt. Zustand
	                #sStateText := 'Wait for Trolley 2';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                
	                #xReleaseTrolleySep1 := FALSE;
	                
	                //Korrektur 2.Bein kommt nicht
	                // IF NOT #fbSeparatorPin.stOutMainTro.xBtPresent (* AND #xInCarouselRun *) AND NOT #stInSeparatorPin.stSettings.xPluggedScanner AND #fbStateManagerE.tOutTimeInStep > T#3s THEN
	                //     #nStateE := #c1000_StepWaitForTrolley1;
	                // END_IF;
	                
	                
	                //Transition
	                IF #fbSeparatorPin.stOutMainTro.xBtPresent AND //Separator meldet Belegung
	                    #arInOutJamEntr[1].bStatus.%X0 // Carrier ist online
	                    AND #xInRelease //Freigabe
	                THEN
	                    IF #xReadSecondLeg // zweites Bein muss gelesen werden (TODO!!!!)
	                        AND #stInSeparatorPin.stSettings.xPluggedScanner // Scanner verbaut?
	                    THEN
	                        #nStateE := #c2100_StepScannerTrig2; // Nächster Schritt -> Scannen
	                    ELSE
	                        #nStateE := #c2300_StepCheckSep2; // Nächster Schritt -> Separator
	                    END_IF;
	                END_IF;
	            END_REGION
	            
	        #c2100_StepScannerTrig2:
	            REGION 2100: Scanner Trigger 2
	                
	                // akt. Zustand
	                #sStateText := 'Scanner Trigger 2';
	                
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                
	                IF #fbBarcodeReader1.xOutReadyForNewScan THEN
	                    #xStartScan := TRUE;
	                END_IF;
	                
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                
	                IF #fbBarcodeReader1.xOutReadingDone THEN
	                    #xStartScan := FALSE;
	                    #nStateE := #c2200_StepScannerEval2;
	                END_IF;
	            END_REGION
	            
	        #c2200_StepScannerEval2:
	            REGION 2200: Scanner Evaluation 2
	                
	                // akt. Zustand
	                #sStateText := 'Scanner Evaluation 2';
	                
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                
	                // Logic
	                
	                IF #fbBarcodeReader1.xOutCodeGood THEN
	                    #nBarcodeResult := LINT_TO_DINT(#fbBarcodeReader1.#nOutBarcode); // Good read vom Barcode reader
	                ELSIF #fbBarcodeReader1.#xOutCodeBad THEN
	                    #nBarcodeResult := #arInOutJamEntr[1].nBarcode;  //erwarteter Barcode wird aus JamDaten übernommen
	                END_IF;
	                
	                IF (#nBarcodeResult > 100) AND
	                    (#nBarcodeResult < 2147483647) AND  // Good Read (2.147.483.647 Maximum von DINT)
	                    (#arInOutJamEntr[1].nBarcode = 0 OR #arInOutJamEntr[1].nBarcode = 1) THEN    //Wenn keine Daten oder ein Dummy erwartet werden   
	                    REGION TODO
	                        (*  "FC_CARR_GLOB_CORRECTION"(xInStart := TRUE, //Führe Korrektur aus
	                                                    nInBarcodeScan := #nBarcodeResult,
	                                                    nInStation := 0, // todo
	                                                    xOutNotFound => #xTemp,
	                                                    arOutEventLogInfo => #arEventCorrectionInfo,
	                                                    InOutCarrierExpect := #arInOutJamEntr1[1]); *)
	                    END_REGION
	                    
	                    
	                    IF NOT #xTemp THEN
	                        ;
	                        // #stInOutCarrier.stCarrData.nNrOfScans += 1;
	                    ELSE
	                        #arInOutJamEntr[1].nDestination := "cDestNONE"; //neuer Carrier // TODO
	                        //     #stInOutCarrier.stCarrData.nNrOfScans += 1;
	                        #arInOutJamEntr[1].nBarcode := #nBarcodeResult; //Hier werden neue Carrier im System angelegt
	                        #arInOutJamEntr[1].bStatus.%X0 := TRUE;
	                    END_IF;
	                ELSIF
	                    (#nBarcodeResult > 100) AND
	                    (#nBarcodeResult < 2147483647) AND // Good Read (2.147.483.647 Maximum von DINT)
	                    #arInOutJamEntr[1].nBarcode = #nBarcodeResult THEN //Barcodes stimmen überein ODER es wird hier gelandet mit BadRead wobei normaler Barcode erwartet wird-> mache normal weiter
	                    ;
	                ELSIF
	                    (#nBarcodeResult > 100) AND
	                    (#nBarcodeResult < 2147483647) AND
	                    #arInOutJamEntr[1].nBarcode <> #nBarcodeResult AND //Barcodes stimmen nicht überein, erwarteter Carrier enthält aber normalen Barcode
	                    #arInOutJamEntr[1].nBarcode <> 0 AND
	                    #arInOutJamEntr[1].nBarcode <> 1 THEN
	                    ;
	                    REGION TODO
	                        (*           "FC_CARR_GLOB_CORRECTION"(xInStart := TRUE, //Führe Korrektur aus
	                                                                       nInBarcodeScan := #nBarcodeResult,
	                                                                       nInStation := 0, // todo
	                                                                       xOutNotFound => #xTemp,
	                                                                       arOutEventLogInfo => #arEventCorrectionInfo,
	                                                                       InOutCarrierExpect := #arInOutJamEntr1[1]); *)
	                    END_REGION
	                    
	                ELSE        // Bad Read, falls nichts oder Dummy erwartet wird -> HANDLING TO DO!!!!!!!!!!!!!!!!!!!!!!!!!!!!
	                    #arInOutJamEntr[1].bStatus.%X0 := TRUE;
	                    #arInOutJamEntr[1].nBarcode := 2; //unbekannter Carrier mit Badread, erwartet 0 und physikalisch vorhanden
	                    #arInOutJamEntr[1].nDestination := 123; //todo
	                END_IF;
	                
	                #xHandshakeScan := TRUE;
	                
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                #nStateE := #c2300_StepCheckSep2;
	                
	            END_REGION
	            
	        #c2300_StepCheckSep2:
	            REGION 2300: Check Separator                
	                // akt. Zustand
	                #sStateText := 'Check Sep';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                #xHandshakeScan := FALSE;
	                #xReleaseTrolleySep1 := FALSE;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                #tmpActUnivTon := TRUE;
	                IF #fbSeparatorPin.stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                    #nStateE := #c2500_StepReleaseSep2;//#c2400_StepCheckJam; Anders lösen, Target Decision entscheidet
	                ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                    #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                END_IF;
	                
	            END_REGION
	            
	        #c2400_StepCheckJam:
	            REGION 2400: Check Jam
	                // akt. Zustand
	                #sStateText := 'Check Jam';
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                
	                /////////  Timer  //////////
	                //////// Transition ////////
	                
	              //  IF (#arInOutJamEntr[1].nDestination <> #stInSettings.nDestGeneral) AND (#arInOutJamEntr[1].nDestination <> 0)
	                // IF (#arInOutJamEntr[1].nDestination > #stInSettings.nDestGeneral + #stInSettings.nNoOfLines) //Bypass
	                // THEN
	                //     IF (#stInOutJamBypass.Status.nCount >= #stInOutJamBypass.Config.nCapacitySet)
	                //     THEN
	                //         #tmpReasonForStop := "Rsn_JamNextError";
	                //     ELSE
	                //         #nStateE := #c2500_StepReleaseSep2;//#"c2500_StepReleaseSep2";
	                //     END_IF;
	                // ELSE 
	                    IF (* (#stInOutJamExit2.Status.nCount = #stInOutJamExit2.Config.nCapacitySet) //Zielstaubereich ist datentechnisch voll
	                        OR (#stInSeparatorPin.Settings.xPluggedJam AND #stInSenJam2.xJam) // Stausensor *)
	                        NOT #xSepFree // Lager voll -> Am besten in Target Decision reinmachen
	                    THEN
	                        #tmpReasonForStop := "Rsn_JamNextError";
	                    ELSE
	                        #nStateE := #c2500_StepReleaseSep2;//#"c2500_StepReleaseSep2";
	                    END_IF;
	              //  END_IF;
	                
	            END_REGION
	            
	        2450:
	            REGION 2450: Calculate AND set Target
	                // akt. Zustand
	                #sStateText := 'CalcSetTarget';
	                
	                ///////// Statics //////////
	                #xReleaseTrolleySep1 := FALSE;
	                
	             (*   "FC_TargetDecision"(arInStorageLineCalc := #arStoreCount1,
	                                    arInStorage := #arInOutStorageLines,
	                                    arInSenStore := #arInJamSensor,
	                                    nInDestGeneral := #stInSettings.nDestGeneral,
	                                    nInNoOfLines := #stInSettings.nNoOfLines,
	                                    nInStorageThreshold := 3,//#stInSettings.nStorageThreshold,
	                                    nInMode := 3, //1 -> Abwechselnd; 2 -> Gleichmäßig befüllen , 3: Jede Linie nacheinander befüllen                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
	                                    nInOutTarget := #nTarget1,
	                                    xInOutFree := #arConveyorEnable[1],
	                                    stInOutConveyorStations := #stConveyorStations,
	                                    stInOutCarrier:=#arInOutJamEntr[1], *)
	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
	                
	                #nStateE := #c2500_StepReleaseSep2;
	                
	            END_REGION
	            
	        #c2500_StepReleaseSep2:
	            REGION 2500: Release Sep Second          
	                // akt. Zustand
	                #sStateText := 'Leave Sep';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                #stOutPriorityManager.xTransportReq := #xInSftyOk AND #xInConveyorRunIn AND NOT #xInAreaStopActive;
	                
	                //////// Transition ////////    
	                IF #xInSftyOk AND #xInConveyorRunIn AND NOT #xInAreaStopActive AND #stInPriorityManager.xReleaseOk AND
	                    NOT #fbCarrierWaitSepPin.xOutLockSep1 AND #stInSensorReference.xDirectEdgePos THEN // Freigabe an Separator
	                    REGION Target Decision und Release
	                        // Ziel bestimmen
	                            "FC_TargetDecision"(arInStorageLineCalc := #arStoreCount1,
	                                                arInStorage := #arInOutStorageLines,
	                                                arInSenStore := #arInJamSensor,
	                                                nInDestGeneral := #stInSettings.nDestGeneral,
	                                                nInNoOfLines := #stInSettings.nNoOfLines,
	                                                nInStorageThreshold := #stInSettings.nStorageThreshold,
	                                                nInMode := 3, //1 -> Abwechselnd; 2 -> Gleichmäßig befüllen; 3: jede Linie nacheinander befüllen
	                                                xOutBypass=> #xBypassStat,
	                                                nInOutTarget := #nTarget1,
	                                                xInOutFree := #xReleaseTrolleySep1,//arConveyorEnable[1],
	                                                stInOutConveyorStations := #stConveyorStations,
	                                                stInOutCarrier:=#arInOutJamEntr[1],
	                                                stInOutJamBypass:=#stInOutJamBypass);
	                            
	                    END_REGION
	                END_IF;
	                
	                IF #fbSeparatorPin.stOutMainTro.nStatus = "SepState_Finish" THEN
	                    REGION SHR buchen                                               
	                        // Carrier in Zielbereich umbuchen
	                        #stCarrierPin.stCarrier := #arInOutJamEntr[1];
	                        IF NOT #xBypassStat THEN
	                            //Exakte Destination für Linie eintragen
	                            #stCarrierPin.stCarrier.nDestination := #stInSettings.nDestGeneral + #nTarget1 - 10; //z.B. 21100 + 11 - 10 = 21101
	                        END_IF;
	                        
	                        "FC_SHR_HangerAddPin"(stInCarrier := #stCarrierPin,
	                                              nInPos := 2,
	                                              nInTarget := #nTarget1,
	                                              nInConvStations := #stInSettings.nConvStations,
	                                              nInStationsMax := #stInSettings.nStationsMax,
	                                              stInOutConveyorStations := #stConveyorStations);
	                        
	                        // Quellbereich 
	                        IF NOT #xBypassStat THEN
	                            "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                            arTSHR := #arInOutJamEntr);
	                        END_IF;
	                        
	                        #nTarget1 += 1;
	                        
	                        REGION Daten buchen zum Bypass
	                            IF #xBypassStat THEN
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutJamEntr,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamBypass);
	                            END_IF;
	                        END_REGION
	                        
	                        #xEventLogBookSHR := TRUE;
	                    END_REGION;                   
	                    #nStateE := #c1000_StepWaitForTrolley1;
	                ELSIF #xReleaseTrolleySep1 AND #tOnSvReleaseSep.Q THEN
	                    #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                END_IF;
	            END_REGION
	    END_CASE;
	END_REGION
	
	REGION Schrittkette Auslagern
	    CASE #nStateA OF
	        #c0000_StepOff:
	            REGION 0000: Off
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := FALSE;
	                
	                // akt. Zustand
	                #sStateText := 'OFF';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                // SCHRITT 0 WIRD GEBRAUCHT!
	                //STATE MANAGER KÜMMERT SICH UM TRANSITION!
	            END_REGION
	            
	        #c0100_StepUndefined:
	            REGION 0100: Undefined
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := FALSE;
	                
	                // akt. Zustand
	                #sStateText := 'Undefined';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                /////////  Timer  //////////
	                
	                //////// Transition ////////
	                #nStateA := #c1000_StepWaitForTrolley1;
	            END_REGION
	            
	        #c1000_StepWaitForTrolley1:
	            REGION 1000: Wait for Trolley
	                
	                ///////// Statics //////////
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                
	                #stMFRStorageRemovalInterface.UDT_State.xReady := TRUE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := FALSE;
	                
	                IF #stMFRStorageRemovalInterface.UDT_Ctrl.xStart THEN
	                    #nStateA := 1100;
	                END_IF;
	                
	                (* IF #xStart THEN
	                     #nActLine := #nTestStorageOut;
	                     IF #nActLine <> #nLastLine THEN
	                         #stDummyCarrier.nBarcode := 1;
	                     END_IF;
	                     #nLastLine := #nActLine;
	                     IF #arfbSeparatorStorage[#nActLine].stOutMainTro.xBtPresent AND (#arInOutStorageLines[#nActLine].arCarrier[1].bStatus.%X0 = TRUE)
	                     THEN
	                         #nStateA := #c1400_StepCheckSep1;
	                     END_IF;
	                 END_IF; *)
	            END_REGION
	            
	        1100:
	            REGION 1100: Prepare Req
	                
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                #stActRequest.nMode := #stMFRStorageRemovalInterface.UDT_Ctrl.nMode;
	                #stActRequest.#nActLine := #stMFRStorageRemovalInterface.UDT_Ctrl.nLine;
	                #stActRequest.nCountReq := #stMFRStorageRemovalInterface.UDT_Ctrl.nAmount + #stMFRStorageRemovalInterface.UDT_Ctrl.nAmountOffset;
	                #stActRequest.nCountAct := 0;
	                
	                IF #stMFRStorageRemovalInterface.UDT_Ctrl.xStart AND
	                    #stActRequest.nActLine > 0 AND #stActRequest.nMode > 0 AND ((#stActRequest.nMode = 1 AND #stActRequest.nCountReq > 0) OR #stActRequest.nMode = 2 OR #stActRequest.nMode = 3)
	                THEN
	                    #nStateA := 1200; //Plausibel, Weiter
	                ELSE
	                    #nStateA := 1000; //Fehler in Anfrage, Abbrechen
	                END_IF;
	                
	                
	            END_REGION
	            
	        1200:
	            REGION 1200: Check Req
	                
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                IF #stMFRStorageRemovalInterface.UDT_Ctrl.xStart //Start-Befehl von MFR-Baustein
	                    AND #stInOutJamExit.Status.nCount = 0 //Bei jedem neuen Start einer Linie, muss der Exit-Jam vom Lagerblock leer sein 
	                THEN
	                    IF #stMFRStorageRemovalInterface.UDT_Ctrl.nMode = 1 THEN //Job mit Anzahl
	                        #nStateA := 1300;
	                    ELSIF #stMFRStorageRemovalInterface.UDT_Ctrl.nMode = 2 THEN // RapidFire
	                        #nStateA := 1310;
	                    ELSIF #stMFRStorageRemovalInterface.UDT_Ctrl.nMode = 3 THEN // Initialisieren/Entleeren
	                        #nStateA := 1320;
	                    ELSE
	                        #nStateA := 1000;
	                    END_IF;
	                ELSE
	                    #nStateA := 1000;
	                END_IF;
	                
	            END_REGION
	            
	        1300:
	            REGION 1300: Mode Job
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                IF #stMFRStorageRemovalInterface.UDT_Ctrl.xStart AND (#stActRequest.nCountAct < #stActRequest.nCountReq) THEN
	                    #nStateA := #c1400_StepCheckSep1; //Weitermachen
	                ELSIF (#stActRequest.nCountAct >= #stActRequest.nCountReq) OR NOT #stMFRStorageRemovalInterface.UDT_Ctrl.xStart THEN
	                    #nStateA := 1000; //fertig
	                END_IF;
	            END_REGION
	            
	        1310:
	            REGION 1310: Mode RapidFire
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                IF #stMFRStorageRemovalInterface.UDT_Ctrl.xStart THEN
	                    #nStateA := #c1400_StepCheckSep1;
	                ELSE
	                    #nStateA := 1000; //fertig
	                END_IF;
	            END_REGION
	            
	            
	        1320:
	            REGION 1320: Mode Entleeren
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                IF #stMFRStorageRemovalInterface.UDT_Ctrl.xStart AND (#arInOutStorageLines[#stActRequest.nActLine].stData.Status.nCount > 0) AND (#stActRequest.nCountAct < #stActRequest.nCountReq) THEN
	                    #nStateA := #c1400_StepCheckSep1;
	                ELSIF NOT #stMFRStorageRemovalInterface.UDT_Ctrl.xStart OR (#stActRequest.nCountAct >= #stActRequest.nCountReq) THEN
	                    #nStateA := 3000; 
	                    //#nStateA := 1000;
	                END_IF;
	            END_REGION
	            
	        #c1400_StepCheckSep1:
	            REGION 1400: Check Separator
	                
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                
	                CASE #stActRequest.nActLine OF
	                    1:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    2:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    3:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    4:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    5:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    6:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    7:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    8:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    9:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    10:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    11:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    12:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    13:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    14:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    15:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    16:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    17:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    18:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    19:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    20:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    21:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c1500_StepReleaseSep1;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                END_CASE;
	                
	            END_REGION
	            
	        #c1500_StepReleaseSep1:
	            #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	            #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	            
	            REGION 1500: Release Sep 1            
	                // akt. Zustand
	                #sStateText := 'Leave Sep 1';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                
	                FOR #nIdx1 := 1 TO 21 DO
	                    IF #nIdx1 = #stActRequest.nActLine THEN
	                        #arLineRelease[#nIdx1] := TRUE;
	                    ELSE
	                        #arLineRelease[#nIdx1] := FALSE;
	                    END_IF;
	                END_FOR;
	                
	                
	                //////// Transition ////////
	                CASE #stActRequest.nActLine OF
	                    1:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    2:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    3:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    4:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    5:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    6:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    7:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    8:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    9:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    10:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    11:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    12:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    13:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    14:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    15:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    16:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    17:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    18:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    19:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    20:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    21:
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            #nStateA := #c2000_StepWaitForTrolley2;
	                        ELSIF #arLineRelease[#stActRequest.nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                END_CASE;
	                
	            END_REGION
	            
	        #c2000_StepWaitForTrolley2:
	            REGION 2000: Wait for Trolley 2
	                //akt. Zustand
	                #sStateText := 'Wait for Trolley 2';
	                ///////// Ausgänge /////////
	                
	                ///////// Statics //////////
	                
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                
	                
	                //Transition
	                CASE #stActRequest.nActLine OF
	                    1:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                    2:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    3:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    4:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    5:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    6:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                    7:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    8:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    9:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    10:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    11:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                    12:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    13:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    14:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    15:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    16:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                    17:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    18:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    19:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    20:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                    21:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent AND #arInOutStorageLines[#stActRequest.nActLine].arCarrier[1].bStatus.%X0 THEN
	                            #nStateA := #c2300_StepCheckSep2;
	                        END_IF;
	                        
	                END_CASE;
	            END_REGION
	            
	        #c2300_StepCheckSep2:
	            REGION 2300: Check Separator
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                
	                //Transition
	                CASE #stActRequest.nActLine OF
	                    1:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    2:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    3:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    4:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    5:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    6:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    7:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    8:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    9:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    10:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    11:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    12:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    13:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    14:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    15:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    16:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                    17:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    18:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    19:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    20:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                    21:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_WaitForReq" THEN // Separator ist bereit
	                            #nStateA := #c2400_StepCheckJam;
	                        ELSIF #fbStateManagerE.tOutUnivTonR > T#3s THEN
	                            #tmpReasonForStop := "Rsn_SubError";    // SubTRO: Separator ist nicht bereit
	                        END_IF;
	                        
	                END_CASE;
	                
	                
	            END_REGION
	            
	        #c2400_StepCheckJam:
	            REGION 2400: Check Jam
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                // akt. Zustand
	                #sStateText := 'Check Jam';
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                FOR #nIdx1 := 1 TO 21 DO
	                    #arLineRelease[#nIdx1] := FALSE;
	                END_FOR;
	                
	                /////////  Timer  //////////
	                //////// Transition ////////
	                IF (#stInOutJamExit.Status.nCount = #stInOutJamExit.Config.nCapacitySet) //Zielstaubereich ist datentechnisch voll
	                    OR (#arInSep[1].stSettings.xPluggedJam AND #stInSenJam2.xJam) // Stausensor *)
	                THEN
	                    #tmpReasonForStop := "Rsn_JamNextError";
	                ELSE
	                    #nStateA := #c2500_StepReleaseSep2;
	                END_IF;
	            END_REGION
	            
	        #c2500_StepReleaseSep2:
	            REGION 2500: Release Sep Second     
	                #stMFRStorageRemovalInterface.UDT_State.xReady := FALSE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := TRUE;
	                
	                // akt. Zustand
	                #sStateText := 'Leave Sep';
	                
	                ///////// Ausgänge /////////
	                ///////// Statics //////////
	                #stOutPriorityManager.xTransportReq := #xInSftyOk AND #xInConveyorRunOut (* AND NOT #stInMfr.xPause *)AND NOT #xInAreaStopActive;
	                
	                FOR #nIdx1 := 1 TO 21 DO
	                    IF #nIdx1 = #stActRequest.nActLine THEN
	                        #arLineRelease[#nIdx1] := #xInSftyOk AND #xInConveyorRunOut AND NOT #xInAreaStopActive AND #stInPriorityManager.xReleaseOk AND NOT #arInOutStorageLines[#nIdx1].stData.Status.bByte.%X3;
	                    ELSE
	                        #arLineRelease[#nIdx1] := FALSE;
	                    END_IF;
	                END_FOR;
	                
	                //////// Transition ////////
	                //Transition
	                
	                FOR #nIdx1 := 1 TO #stActRequest.nActLine DO
	                    IF #nIdx1 = #stActRequest.nActLine THEN
	                        IF #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                IF NOT #xVersatz THEN // Alles normal buchen
	                                    "FC_Route"(xInSingle := FALSE,
	                                               xInSeparate := FALSE,
	                                               xInSepEdge := TRUE,
	                                               xInSensor := FALSE,
	                                               xInDelay := FALSE,
	                                               stInCarrier := #stEmptyCarrier,
	                                               stOutBookingInfo => #stBookingInfo,
	                                               arJamEntr := #arInOutStorageLines[#stActRequest.nActLine].arCarrier,
	                                               arOnTheWay := #arEmptyCarrier,
	                                               arJamExit := #arInOutJamExit);
	                                    
	                                ELSE // Dummy (=ohne Daten) buchen
	                                    "FC_TSHR_AddAtEnd"(stInTrolley := #stDummyCarrier,
	                                                       nOutCounter => #nCounter,
	                                                       xOutResult => #xResult,
	                                                       arTSHR := #arInOutJamExit);
	                                    
	                                    #stDummyCarrier.nBarcode += 1;
	                                    
	                                    IF #stDummyCarrier.nBarcode > 99 THEN
	                                        #stDummyCarrier.nBarcode := 1;
	                                    END_IF;
	                                END_IF;
	                                #xVersatz := FALSE;
	                            END_REGION ;
	                            #xEventLogBookExit := TRUE;
	                            
	                            IF #stActRequest.nMode = 1 THEN
	                                #stActRequest.nCountAct := #stActRequest.nCountAct + 1; //Hochzählen
	                                #nStateA := 1300;
	                            ELSIF #stActRequest.nMode = 2 THEN
	                                #nStateA := 1310;
	                            ELSIF #stActRequest.nMode = 3 THEN
	                                #stActRequest.nCountAct := #stActRequest.nCountAct + 1; //Hochzählen
	                                #nStateA := 1320;
	                            END_IF;
	                            
	                            //  #nStateA := #c1000_StepWaitForTrolley1;
	                            EXIT;
	                        END_IF;
	                    END_IF;
	                END_FOR;
	                
	                
	                
	                
	                (*        CASE #nActLine OF
	                            1:  // Statement section case 1
	                                IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                                    //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                                    REGION Daten buchen Store1 -> ExitJam
	                                        "FC_Route"(xInSingle := FALSE,
	                                                   xInSeparate := FALSE,
	                                                   xInSepEdge := TRUE,
	                                                   xInSensor := FALSE,
	                                                   xInDelay := FALSE,
	                                                   stInCarrier := #stEmptyCarrier,
	                                                   stOutBookingInfo => #stBookingInfo,
	                                                   arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                                   arOnTheWay := #arEmptyCarrier,
	                                                   arJamExit := #arInOutJamExit);
	                                    END_REGION
	                                    #xEventLogBookExit := TRUE;
	                                    #nStateA := #c1000_StepWaitForTrolley1;
	                                ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                                    #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                                END_IF;
	                            2:  // Statement section case 1
	                                IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                                    //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                                    REGION Daten buchen Store1 -> ExitJam - TEST!!
	                                      (*  "FC_Route"(xInSingle := FALSE,
	                                                   xInSeparate := FALSE,
	                                                   xInSepEdge := TRUE,
	                                                   xInSensor := FALSE,
	                                                   xInDelay := FALSE,
	                                                   stInCarrier := #stEmptyCarrier,
	                                                   stOutBookingInfo => #stBookingInfo,
	                                                   arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                                   arOnTheWay := #arEmptyCarrier,
	                                                   arJamExit := #arInOutJamExit); *)
	                                
	                                "FC_TSHR_AddAtEnd"(stInTrolley := #stDummyCarrier,
	                                                   nOutCounter => #nCounter,
	                                                   xOutResult => #xResult,
	                                                   arTSHR := #arInOutJamExit);
	                                
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    3:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    4:  // Statement section case 1
	                        #tmpActUnivTon := TRUE;
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    5:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    6:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    7:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    8:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    9:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    10:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    11:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    12:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    13:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    14:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    15:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    16:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                    17:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    18:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    19:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    20:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                    21:  // Statement section case 1
	                        IF #arfbSeparatorStorage[#nActLine].stOutMainTro.nStatus = "SepState_Finish" THEN
	                            //Hier könnte man noch einbauen, ob optional nicht gebucht wird, z.B. für Fehlerkorrektur
	                            REGION Daten buchen Store1 -> ExitJam
	                                "FC_Route"(xInSingle := FALSE,
	                                           xInSeparate := FALSE,
	                                           xInSepEdge := TRUE,
	                                           xInSensor := FALSE,
	                                           xInDelay := FALSE,
	                                           stInCarrier := #stEmptyCarrier,
	                                           stOutBookingInfo => #stBookingInfo,
	                                           arJamEntr := #arInOutStorageLines[#nActLine].arCarrier,
	                                           arOnTheWay := #arEmptyCarrier,
	                                           arJamExit := #arInOutJamExit);
	                            END_REGION
	                            #xEventLogBookExit := TRUE;
	                            #nStateA := #c1000_StepWaitForTrolley1;
	                        ELSIF #arLineRelease[#nActLine] AND #tOnSvReleaseSep.Q THEN
	                            #tmpReasonForStop := "Rsn_SubError";    //  Timeout-Fehler im SubTRO "Separator": Freigabe erteilt, aber Separator gibt keine Rückmeldung an MainTRO
	                        END_IF;
	                        
	                END_CASE; *)
	                
	            END_REGION
	            
	        3000:
	            REGION 3000: Finish
	                #stMFRStorageRemovalInterface.UDT_State.xReady := TRUE;
	                #stMFRStorageRemovalInterface.UDT_State.xBusy := FALSE;
	                
	                IF NOT #stMFRStorageRemovalInterface.UDT_Ctrl.xStart THEN
	                    #nStateA := 1000;
	                END_IF;
	            END_REGION ;
	
	            
	    END_CASE;
	END_REGION
	
	REGION Auslagerjob überwachen
	    IF #stActRequest.nActLine > 0 THEN
	        IF (#nStateA > 1000) AND (#nStateA < 3000) AND (#fbStateManagerA.tOutTimeInStep > t#20s) AND //Wir warten seit langem in einem Schritt
	            (#stActRequest.nCountAct < #stActRequest.nCountReq) AND //Es werden noch Carrier erwartet
	            ((#arInOutStorageLines[#stActRequest.nActLine].stData.Status.nCount = 0) (* OR NOT #arfbSeparatorStorage[#stActRequest.nActLine].stOutMainTro.xBtPresent *)) //Keine Daten mehr oder keine Belegung mehr
	        THEN
	            #nStateA := 3000; //Auftrag beenden
	            //Optional den Grund mitgeben (Auftrga beendet... erfolgreich, keine Carrier mehr, keine Daten mehr...)
	        END_IF;
	    END_IF;
	    
	END_REGION
	
	
	REGION StateManager Einlagern
	    
	    #fbStateManagerE.stInSettings.nStartState := #c0100_StepUndefined;
	    #fbStateManagerE.stInSettings.nStartStateTestMode := #c0000_StepOff;
	    #fbStateManagerE.stInSettings.xActUnivTOn := TRUE;
	    #fbStateManagerE.stInSettings.xRestartAtStartState := FALSE;
	    #fbStateManagerE(xInFunctionEnabled := #stInOutControlUnitCabinet.xRunning, // AND #xInSftyOk,
	                     xInReset := (* #stInMfr.xCancel OR *)#xInCancel,
	                     xInRunUnivTOn := #tmpActUnivTon,
	                     xInTestMode := #xInTestMode,
	                     nInOutState := #nStateE);
	    
	END_REGION
	
	REGION StateManager Auslagern
	    
	    #fbStateManagerA.stInSettings.nStartState := #c0100_StepUndefined;
	    #fbStateManagerA.stInSettings.nStartStateTestMode := #c0000_StepOff;
	    #fbStateManagerA.stInSettings.xActUnivTOn := TRUE;
	    #fbStateManagerA.stInSettings.xRestartAtStartState := FALSE;
	    #fbStateManagerA(xInFunctionEnabled := #stInOutControlUnitCabinet.xRunning, // AND #xInSftyOk,
	                     xInReset := (* #stInMfr.xCancel OR *)#xInCancel,
	                     xInRunUnivTOn := #tmpActUnivTon,
	                     xInTestMode := #xInTestMode,
	                     nInOutState := #nStateA);
	    
	END_REGION
	
	REGION SHR - Cycle
	    "FC_SHR_CyclePin"(nInPosDiff := #stInEncoderParameter.nPosActDif,
	                      nInPosPitchPart := #stInEncoderParameter.nPosPitchPart,
	                      nInConvStations := #stInSettings.nConvStations,
	                      nInStationsMax := #stInSettings.nStationsMax,
	                      stInOutConveyorStations := #stConveyorStations);
	END_REGION
	
	REGION SHR - Check Station
	    // Funktioniert, aber TIA erlaubt kein Beobachten von Multiinstanzen innerhalb von Schleifen
	    (*    FOR #index := 1 TO #cUnloadingStations DO
	        "FC_SHR_CheckStationPinTEST_1"(nInStation := #index + 10, //11-29
	                                     xInTargetStation := 1,
	                                     xOutStationHi => #arStartUnloading[#index],
	                                     xOutStationNHi => #arStopUnloading[#index],
	                                     // xOutMiniTrolley=>#fbStationUnloading1_1.xInMiniTrolley,
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#index].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#index].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#index].sInBarcode,
	                                     stConveyorStations := stConveyorStations);
	    END_FOR;  *)
	    
	    REGION Check US1
	        #nActNo := 1;
	        "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                 xInTargetStation := TRUE,
	                                 nInConvStations := #stInSettings.nConvStations,
	                                 nInStationsMax := #stInSettings.nStationsMax,
	                                 xOutStationHi => #arStartUnloading[#nActNo],
	                                 xOutStationNHi => #arStopUnloading[#nActNo],
	                                 xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                 nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                 sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                 stInOutConveyorStations := #stConveyorStations);
	    END_REGION
	    
	    REGION Check US2
	        #nActNo := 2;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US3
	        #nActNo := 3;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US4
	        #nActNo := 4;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US5
	        #nActNo := 5;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US6
	        #nActNo := 6;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US7
	        #nActNo := 7;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US8
	        #nActNo := 8;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US9
	        #nActNo := 9;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	        
	    END_REGION
	    
	    REGION Check US10
	        #nActNo := 10;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US11
	        #nActNo := 11;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US12
	        #nActNo := 12;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US13
	        #nActNo := 13;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US14
	        #nActNo := 14;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US15
	        #nActNo := 15;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US16
	        #nActNo := 16;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US17
	        #nActNo := 17;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US18
	        #nActNo := 18;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US19
	        #nActNo := 19;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US20
	        #nActNo := 20;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION Check US21
	        #nActNo := 21;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,
	                                     xInTargetStation := TRUE,
	                                     nInConvStations := #stInSettings.nConvStations,
	                                     nInStationsMax := #stInSettings.nStationsMax,
	                                     xOutStationHi => #arStartUnloading[#nActNo],
	                                     xOutStationNHi => #arStopUnloading[#nActNo],
	                                     xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                     nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                     sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                     stInOutConveyorStations := #stConveyorStations);
	        END_IF;
	    END_REGION
	    
	    REGION BYPASS
	        #nActNo := #stInSettings.nNoOfLines + 1;
	        //Wird immer aufgerufen und hat die Nummer "letzte Linie + 1"
	        "FC_SHR_CheckStationPin"(nInStation := #nActNo + 10,//32,
	                                 xInTargetStation := TRUE,
	                                 nInConvStations := #stInSettings.nConvStations,
	                                 nInStationsMax := #stInSettings.nStationsMax,
	                                 xOutStationHi => #arStartUnloading[#nActNo],
	                                 xOutStationNHi => #arStopUnloading[#nActNo],
	                                 xOutStationHiBefore => #arfbStationUnloadPin[#nActNo].xInBefore,
	                                 nOutBarcode => #arfbStationUnloadPin[#nActNo].nInBarcode,
	                                 sOutBarcode => #arfbStationUnloadPin[#nActNo].sInBarcode,
	                                 stInOutConveyorStations := #stConveyorStations);
	        
	    END_REGION
	    
	END_REGION
	
	REGION Unloading Stations
	    // Funktioniert, aber TIA erlaubt kein Beobachten von Multiinstanzen innerhalb von Schleifen
	    (*    FOR #index := 1 TO #cUnloadingStations DO
	        #arfbStationUnloadPin[#index](xInMonitorUnloading := TRUE,
	                                      xInStartUnloading := #arStartUnloading[#index],
	                                      xInStopUnloading := #arStopUnloading[#index],
	                                      xInUnloadingCheckSensor := #arInUnloadingCheckSensor[#index].xDirectEdgePos,
	                                      xInPartAfterSwitch := #arInPartAfterSwitch[#index].xDbncdSensor,
	                                      xInReRouteAllowed := FALSE,
	                                      xInQuitLocal := #arInQuitLocal[#index],
	                                      xOutSwitch => #arOutSwitch[#index],
	                                      stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                      inOutConveyorStations := stConveyorStations,
	                                      InOutCarrierStorage := #arInOutStorageLines[#index],
	                                      stInOutHMI := #arHMIInOutUnloadingStations[#index]);
	    END_FOR; *)
	    
	    REGION US 1
	        #nActNo := 1;
	        #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                       xInStartUnloading := #arStartUnloading[#nActNo],
	                                       xInStopUnloading := #arStopUnloading[#nActNo],
	                                       xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                       stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                       xInReRouteAllowed := FALSE,
	                                       xInQuitLocal := #xInQuitLocal,
	                                       xOutSwitch => #arOutSwitch[#nActNo],
	                                       stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                       stInOutConveyorStations := #stConveyorStations,
	                                       arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                       stInOutHMI := #stInOutHMI.UDT_UnloadingStation1);
	        #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	        #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	    END_REGION
	    
	    REGION US 2
	        #nActNo := 2;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation2);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 3
	        #nActNo := 3;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation3);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 4
	        #nActNo := 4;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation4);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 5
	        #nActNo := 5;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation5);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 6
	        #nActNo := 6;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation6);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 7
	        #nActNo := 7;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation7);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 8
	        #nActNo := 8;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation8);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 9
	        #nActNo := 9;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation9);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 10
	        #nActNo := 10;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation10);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 11
	        #nActNo := 11;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation11);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 12
	        #nActNo := 12;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation12);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 13
	        #nActNo := 13;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation13);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 14
	        #nActNo := 14;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation14);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 15
	        #nActNo := 15;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation15);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 16
	        #nActNo := 16;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation16);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 17
	        #nActNo := 17;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation17);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 18
	        #nActNo := 18;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation18);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 19
	        #nActNo := 19;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation19);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 20
	        #nActNo := 20;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation20);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION US 21
	        #nActNo := 21;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := TRUE,
	                                           xInStartUnloading := #arStartUnloading[#nActNo],
	                                           xInStopUnloading := #arStopUnloading[#nActNo],
	                                           xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                           stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                           xInReRouteAllowed := FALSE,
	                                           xInQuitLocal := #xInQuitLocal,
	                                           xOutSwitch => #arOutSwitch[#nActNo],
	                                           stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                           stInOutConveyorStations := #stConveyorStations,
	                                           arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                           stInOutHMI := #stInOutHMI.UDT_UnloadingStation21);
	            #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	            #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        END_IF;
	    END_REGION
	    
	    REGION BYPASS
	        #nActNo := #stInSettings.nNoOfLines + 1;
	        //Wird immer aufgerufen und hat die Nummer "letzte Linie + 1"
	        #arfbStationUnloadPin[#nActNo](xInMonitorUnloading := FALSE, //?
	                                       xInStartUnloading := #arStartUnloading[#nActNo],
	                                       xInStopUnloading := #arStopUnloading[#nActNo],
	                                       xInUnloadingCheckSensor := #arInJamSensor[#nActNo].xDirectEdgePos,
	                                       stInPartAfterSwitch := #arInJamSensor[#nActNo],
	                                       xInReRouteAllowed := FALSE,
	                                       xInBypass := TRUE, //!
	                                       xInQuitLocal := #xInQuitLocal,
	                                       xOutSwitch => #arOutSwitch[#nActNo],
	                                       stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                                       stInOutConveyorStations := #stConveyorStations,
	                                       arInOutCarrier := #arInOutStorageLines[#nActNo].arCarrier,
	                                       stInOutHMI := #stDummyHmiUnloading);
	        
	        #arOutUnloadingError[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutUnloadingError;
	        #arOutLineOverloaded[#nActNo] := #arfbStationUnloadPin[#nActNo].xOutLineOverloaded;
	        
	    END_REGION
	    
	    
	END_REGION
	
	REGION Separator Pin
	    #fbSeparatorPin(stInSettings := #stInSeparatorPin.stSettings,
	                    xInConveyorRun := #xInConveyorRunIn,
	                    stInTrolley := #stInSeparatorPin.stSenTrolley,
	                    xInReceiveReady := #xReleaseTrolleySep1,
	                    xOutStopper => #xOutSeparatorPin,
	                    stInOutMainState := #stInOutControlUnitCabinet,
	                    stInOutHMI := #stInOutHMI.UDT_SeparatorPin,
	                    stInOutCarrDataInJam := #arInOutJamEntr);
	    
	    REGION Accumulate
	        #fbCarrierWaitSepPin.stInTimes.tFreeSen1 := #stInSeparatorPin.stSettings.tSenFree;
	        #fbCarrierWaitSepPin.stInTimes.tTimerWait := #stInSeparatorPin.stSettings.tSenWait;
	        #fbCarrierWaitSepPin(stInSensor1 := #stInSeparatorPin.stSenTrolley,
	                             xInConvActive := #xInConveyorRunIn);
	    END_REGION
	    
	    REGION Dummy Handling
	        
	        #nArrayMax := DINT_TO_INT(UPPER_BOUND(ARR := #arInOutJamEntr, DIM := 1));
	        
	        REGION Dummy erstellen
	            IF #fbSeparatorPin.stOutMainTro.xBtPresent AND
	                #fbSeparatorPin.stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                #stInSeparatorPin.stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                #arInOutJamEntr[1] = #tmpCarrierEmpty
	            THEN
	                #arInOutJamEntr[1].nBarcode := #cCarrierDummy;
	                #arInOutJamEntr[1].bStatus.%X0 := TRUE;
	            END_IF;
	            
	        END_REGION
	        
	        REGION Dummy löschen
	            IF #nArrayMax > 1 THEN //Staubereich mit Capacity > 0
	                IF (#arInOutJamEntr[1] = #stCarrierDummy) //Dummy an erster Position
	                    AND #arInOutJamEntr[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                    NOT #stInSeparatorPin.stSenTrolley.xDirectSensor AND #stInSeparatorPin.stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                    #fbSeparatorPin.stOutMainTro.nStatus = "SepState_WaitForBt" AND #fbSeparatorPin.#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                THEN
	                    #arInOutJamEntr[1] := #tmpCarrierEmpty; //Dummy löschen
	                ELSIF (#arInOutJamEntr[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                    AND (#arInOutJamEntr[2] = #stCarrierDummy OR #arInOutJamEntr[2] <> #stCarrierDummy) AND
	                    NOT #stInSeparatorPin.stSenTrolley.xDirectSensor AND #stInSeparatorPin.stSenTrolley.tDirectChangeLast > T#8s AND
	                    #fbSeparatorPin.stOutMainTro.nStatus = "SepState_WaitForBt" AND #fbSeparatorPin.#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                THEN
	                    #arInOutJamEntr[1] := #tmpCarrierEmpty;
	                    "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                    arTSHR := #arInOutJamEntr);
	                END_IF;
	            ELSIF #nArrayMax = 1 THEN
	                IF (#arInOutJamEntr[1] = #stCarrierDummy) AND
	                    NOT #stInSeparatorPin.stSenTrolley.xDirectSensor AND #stInSeparatorPin.stSenTrolley.tDirectChangeLast > T#8s AND
	                    #fbSeparatorPin.stOutMainTro.nStatus = "SepState_WaitForBt" AND #fbSeparatorPin.#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                THEN
	                    #arInOutJamEntr[1] := #tmpCarrierEmpty;
	                END_IF;
	            END_IF;
	            
	        END_REGION
	        
	    END_REGION
	    
	    
	    
	END_REGION
	
	REGION Separator StorageLines
	    
	    REGION Separator Freigabe
	        //Benötigtem Sep Freigabe erteilen
	        // FOR #nIdx1 := 1 TO #stInSettings.nNoOfLines DO
	        //     IF #stInStorageCarrStats.stRdyToLeave.nLine = #nIdx1 THEN
	        //         #arLineRelease[#nIdx1] := TRUE;
	        //     END_IF;
	        // END_FOR;
	    END_REGION
	    
	    REGION Sep 1
	        #nActNo := 1;
	        #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                       xInConveyorRun := #xInConveyorRunOut,
	                                       stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                       xInReceiveReady := NOT #fbCarrierWaitStore1.xOutLockSep1 AND #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                       xOutStopper => #arOutSeparatorStore[#nActNo],
	                                       stInOutMainState := #stInOutControlUnitCabinet,
	                                       stInOutHMI := #stInOutHMI.UDT_Separator1,
	                                       stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore1.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore1.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore1(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION Sep 2
	        #nActNo := 2;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := NOT #fbCarrierWaitStore2.xOutLockSep1 AND #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator2,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore2.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore2.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore2(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	        
	        
	    END_REGION
	    
	    REGION Sep 3
	        #nActNo := 3;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator3,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore3.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore3.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore3(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION Sep 4
	        #nActNo := 4;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator4,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore4.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore4.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore4(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 5
	        #nActNo := 5;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator5,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore5.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore5.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore5(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 6
	        #nActNo := 6;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator6,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore6.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore6.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore6(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 7
	        #nActNo := 7;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator7,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore7.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore7.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore7(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 8
	        #nActNo := 8;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator8,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore8.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore8.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore8(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 9
	        #nActNo := 9;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator9,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore9.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore9.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore9(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                 xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 10
	        #nActNo := 10;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator10,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore10.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore10.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore10(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 11
	        #nActNo := 11;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator11,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore11.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore11.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore11(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 12
	        #nActNo := 12;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           stInOutHMI := #stInOutHMI.UDT_Separator12,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore12.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore12.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore12(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 13
	        #nActNo := 13;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator13,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore13.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore13.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore13(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 14
	        #nActNo := 14;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator14,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore14.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore14.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore14(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 15
	        #nActNo := 15;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator15,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore15.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore15.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore15(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 16
	        #nActNo := 16;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator16,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore16.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore16.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore16(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 17
	        #nActNo := 17;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           stInOutHMI := #stInOutHMI.UDT_Separator17,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore17.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore17.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore17(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 18
	        #nActNo := 18;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator18,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore18.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore18.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore18(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 19
	        #nActNo := 19;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           stInOutHMI := #stInOutHMI.UDT_Separator19,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore19.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore19.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore19(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	    END_REGION
	    
	    REGION Sep 20
	        #nActNo := 20;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator20,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore20.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore20.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore20(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	        
	    END_REGION
	    
	    REGION Sep 21
	        #nActNo := 21;
	        IF #stInSettings.nNoOfLines >= #nActNo THEN
	            #arfbSeparatorStorage[#nActNo](stInSettings := #arInSep[#nActNo].stSettings,
	                                           xInConveyorRun := #xInConveyorRunOut,
	                                           stInTrolley := #arInSep[#nActNo].stSenTrolley,
	                                           xInReceiveReady := #arLineRelease[#nActNo] AND NOT #arInOutJamExit[#arInSep[#nActNo].stSettings.nJamLength].bStatus.%X0,
	                                           stInOutMainState := #stInOutControlUnitCabinet,
	                                           xOutStopper => #arOutSeparatorStore[#nActNo],
	                                           stInOutHMI := #stInOutHMI.UDT_Separator21,
	                                           stInOutCarrDataInJam := #arInOutStorageLines[#nActNo].arCarrier);
	        END_IF;
	        
	        REGION Carrier anstauen lassen
	            #fbCarrierWaitStore21.stInTimes.tFreeSen1 := T#2000ms;
	            #fbCarrierWaitStore21.stInTimes.tTimerWait := T#3000ms;
	            #fbCarrierWaitStore21(stInSensor1 := #arInSep[#nActNo].stSenTrolley,
	                                  xInConvActive := true);
	        END_REGION
	        
	        REGION Dummy Handling
	            
	            #arArrayMax[#nActNo] := 10;
	            
	            REGION Dummy erstellen
	                IF #arfbSeparatorStorage[#nActNo].stOutMainTro.xBtPresent AND
	                    #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForReq" AND
	                    #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#3s AND // variabel machen, Dummy immer anlegen?, Unterscheidung bei Borner?
	                    #arInOutStorageLines[#nActNo].arCarrier[1] = #tmpCarrierEmpty
	                THEN
	                    #arInOutStorageLines[#nActNo].arCarrier[1].nBarcode := #cCarrierDummy;
	                    #arInOutStorageLines[#nActNo].arCarrier[1].bStatus.%X0 := TRUE;
	                END_IF;
	                
	            END_REGION
	            
	            REGION Dummy löschen
	                IF #arArrayMax[#nActNo] > 1 THEN //Staubereich mit Capacity > 0
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dummy an erster Position
	                        AND #arInOutStorageLines[#nActNo].arCarrier[2] = #tmpCarrierEmpty AND //Keine Daten an zweiter Position
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND //keine Belegung
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty; //Dummy löschen
	                    ELSIF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) //Dasselbe wie oben aber mit nachrücken
	                        AND (#arInOutStorageLines[#nActNo].arCarrier[2] = #stCarrierDummy OR #arInOutStorageLines[#nActNo].arCarrier[2] <> #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                        "FC_TSHR_Shift"(xInShiftBack := TRUE,
	                                        arTSHR := #arInOutStorageLines[#nActNo].arCarrier);
	                    END_IF;
	                ELSIF #nArrayMax = 1 THEN
	                    IF (#arInOutStorageLines[#nActNo].arCarrier[1] = #stCarrierDummy) AND
	                        NOT #arInSep[#nActNo].stSenTrolley.xDirectSensor AND #arInSep[#nActNo].stSenTrolley.tDirectChangeLast > T#8s AND
	                        #arfbSeparatorStorage[#nActNo].stOutMainTro.nStatus = "SepState_WaitForBt" AND #arfbSeparatorStorage[#nActNo].#fbStateManager.tOutTimeInStep > T#8s //Separator Zustand abfragen
	                    THEN
	                        #arInOutStorageLines[#nActNo].arCarrier[1] := #tmpCarrierEmpty;
	                    END_IF;
	                END_IF;
	                
	            END_REGION
	            
	        END_REGION
	        
	    END_REGION
	    
	    
	END_REGION
	
	REGION Barcode Reader 1
	    #fbBarcodeReader1(stInSettings := #stInBarcodeReader.Settings,
	                      xInHWError := false, // todo
	                      xInStartReading := #xStartScan,
	                      xInHandshakeDone := #xHandshakeScan,
	                      stInOutInterface := #stCognexInterfacePin,
	                      stInOutControlUnitCabinet := #stInOutControlUnitCabinet,
	                      stInOutHMI := #stInOutHMI.UDT_BarcodeReader);
	END_REGION
	
	REGION Output
	    #xOutConvReqSort := (#nStateE = #c1500_StepReleaseSep1) OR (#nStateE = #c2500_StepReleaseSep2); //TRUE;//#fbSeparatorPin.xOutConveyorRequest;
	    #xOutConvReqExit := (#nStateA = #c1500_StepReleaseSep1) OR (#nStateA = #c2500_StepReleaseSep2);
	    
	    FOR #nIdx2 := 1 TO #cUnloadingStations DO
	        IF #arfbStationUnloadPin[#nIdx2].xOutUnloadingError THEN
	            #xOutUnloadingError := TRUE;
	            EXIT;
	        ELSE
	            #xOutUnloadingError := FALSE;
	        END_IF;
	    END_FOR;
	    
	    #xOutCorrection := #xTmpCorrection;
	END_REGION
	
	REGION BlockManager
	    // Funktionen die den ganzen Lagerblock betreffen
	    // z.B. Schrittkette 
	    // Füllstandsmanagement
	    // Verschiedene Modi (Einlagern, Auslagern, Ein-und Auslagern...)
	    REGION Einlagern
	        // Zielvergabe nach entsprechender Einlagerstrategie (chaotisch, nach Sorten...)
	        
	    END_REGION
	    
	    REGION Auslagern
	        // TRO bearbeitet eine Auftragsliste, die Aufträge (Minitrolley) werden vom WES von außen übergeben
	        // Steuerung der Separatoren an den Lagerausgängen, je nachdem was angefordert wird
	        
	    END_REGION
	    
	    REGION Füllgrad
	        // Füllgrad der Linien ermitteln / überwachen und nach außen übergeben
	        
	    END_REGION
	END_REGION
	
	REGION Vorfahrt-Logik Separatoren Auslagern
	    
	    #stPrioSep1.TroOut.nTroId := 1;
	    #stPrioSep1.TroOut.xTransportReq := #arfbSeparatorStorage[1].stOutMainTro.xBtPresent;
	    #stPrioSep1.TroOut.stJamExit := #stInOutJamExit;
	    
	    #stPrioSep2.TroOut.nTroId := 2;
	    #stPrioSep2.TroOut.xTransportReq := #arfbSeparatorStorage[2].stOutMainTro.xBtPresent;
	    #stPrioSep2.TroOut.stJamExit := #stInOutJamExit;
	    
	    #stPrioParam.nPrioMode := 1;
	    #fbPrioManagerTest(xInQuit := "cTodoFalse",
	                       tIn_ReleaseTime := T#10s,
	                       udtIn_Source1Req := #stPrioSep1.TroOut,
	                       udtIn_Source2Req := #stPrioSep2.TroOut,
	                       udt_PrioParameter := #stPrioParam);
	    
	    
	    
	    // #fbSepPrio(xInSepReq1 := #arfbSeparatorStorage[1].stInTrolley.xDbncdSensor,
	    //            xInSepReq2 := #arfbSeparatorStorage[1].stInTrolley.xDbncdSensor,
	    //            // xInSepRelease1 := #fbSepStore1_1.xOutTrolleyReleasedEdge, NIU
	    //            // xInSepRelease2 := #fbSepStore1_2.xOutTrolleyReleasedEdge, NIU
	    //            // xInActive := NOT #stHMI2.xDisableConveyor, NIU
	    //            tInTime3 := T#8000ms,
	    //            tInTime2 := T#6000ms,
	    //            InOutJam := "DB_JamPinDown".stJam.stData);
	END_REGION
	
	REGION Event Logs
	    REGION Event: Umbuchung SepPin auf SHR
	        #stBookingInfo.sJamSrc := #stInSettings.sJamSrc;
	        IF #nTarget1 = 11 THEN
	            #stBookingInfo.sJamDest := 'SHR';
	        ELSIF #nTarget1 = 12 THEN
	            #stBookingInfo.sJamDest := 'SHR';
	        END_IF;
	        #fbEventLog_Route1(xInTrigger := #xEventLogBookSHR,
	                           stInEventBookingInfo := #stBookingInfo);
	    END_REGION
	    
	    REGION Event: Umbuchung Lagerlinie auf Exit
	        IF #nActLine = 1 THEN
	            #stBookingInfo.sJamSrc := 'JamStore1';
	        ELSIF #nActLine = 2 THEN
	            #stBookingInfo.sJamSrc := 'JamStore2';
	        END_IF;
	        
	        #stBookingInfo.sJamDest := #stInSettings.sJamDest;
	        
	        #fbEventLog_Route2(xInTrigger := #xEventLogBookExit,
	                           stInEventBookingInfo := #stBookingInfo);
	    END_REGION
	    
	    // Pro Event wird ein Aufruf benötigt
	    REGION Korrekturvorgänge loggen
	        
	        #fbEventLogCorrection1(xInTrigger := #arEventCorrectionInfo[0].xTrigger,
	                               stInEventCorrectionInfo := #arEventCorrectionInfo[0]);
	        
	        #fbEventLogCorrection2(xInTrigger := #arEventCorrectionInfo[1].xTrigger,
	                               stInEventCorrectionInfo := #arEventCorrectionInfo[1]);
	        
	    END_REGION
	    
	    #fbEventLogCarrierUnknown(xInTrigger := #xUnknownCarrier,
	                              stInEventScanInfo := #stEventUnknown);
	    
	    #fbEventLogCarrierNew(xInTrigger := #xNewCarrier,
	                          stInEventScanInfo := #stEventNew);
	    
	    #fbEventLogGoodRead(xInTrigger := #xGoodRead,
	                        stInEventScanInfo := #stEventGoodRead);
	    
	END_REGION
END_FUNCTION_BLOCK

