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

   VAR 
      xAllMainContactorsOk { S7_SetPoint := 'True'} : Bool;
      xAllReadyToStartOF1 : Bool;
      xAllReadyToStartOF2 : Bool;
      xAllReadyToStartOF3 : Bool;
      xAllReadyToStartOF4 : Bool;
      xQuitNec : Bool;
      fbStateMainOF1 : "FB_StateMain";
      fbStateMainOF2 : "FB_StateMain";
      fbStateMainOF3 : "FB_StateMain";
      fbStateMainOF4 : "FB_StateMain";
      fbMonFuse24VUH02 : "FB_Monitoring";
      fbMonFuse24VUC021 : "FB_Monitoring";
      fbMonFuseMotorAndBrakeUC021 : "FB_Monitoring";
      fbMonFuse24VUC022 : "FB_Monitoring";
      fbMonFuseMotorAndBrakeUC022 : "FB_Monitoring";
      fbMonFuse24VUC023 : "FB_Monitoring";
      fbMonFuseMotorAndBrakeUC023 : "FB_Monitoring";
      fbMonFuseCircuitBrakerUH02 : "FB_Monitoring";
      fbMonMotorProtectionUH02 : "FB_Monitoring";
      fbMonMotorProtectionUC021 : "FB_Monitoring";
      fbMonMotorProtectionUC022 : "FB_Monitoring";
      fbMonMotorProtectionUC023 : "FB_Monitoring";
      fbMonPhaseFailure : "FB_Monitoring";
      fbMonFuse400VUC021 : "FB_Monitoring";
      fbMonFuse400VUC022 : "FB_Monitoring";
      fbMonFuse400VUC023 : "FB_Monitoring";
      fbMonPressureUH02 : "FB_Monitoring";
      fbMonPressureUC021 : "FB_Monitoring";
      fbMonPressureUC022 : "FB_Monitoring";
      fbMonPressureUC023 : "FB_Monitoring";
      fbMonMainContactorsUH02 : "FB_Monitoring";
      fbMonSafetyContactorsUH02toUH03 : "FB_Monitoring";
      fbMonSafetyContactorsUH02toUH05 : "FB_Monitoring";
      fbMonMainContactorsUC021 : "FB_Monitoring";
      fbMonSafetyContactorsUC021Extern : "FB_Monitoring";
      fbMonMainContactorsUC022 : "FB_Monitoring";
      fbMonSafetyContactorsUC022Extern : "FB_Monitoring";
      fbMonMainContactorsUC023 : "FB_Monitoring";
      fbMonSafetyContactorsUC023Extern : "FB_Monitoring";
      fbMonFAS : "FB_Monitoring";   // IF from FACP "fire alarm" DI0034
      fbMonCommFortnaWCS : "FB_Monitoring";
      fbMonCommFortnaWES_ASRS : "FB_Monitoring";
      fbMonEstopExternUC021 : "FB_Monitoring";
      fbMonEstopExternUC022 : "FB_Monitoring";
      fbMonEstopExternUC023 : "FB_Monitoring";
      fbMonEstopExternUH03 : "FB_Monitoring";
      fbMonEstopExternUH05 : "FB_Monitoring";
      arESTOPAck { S7_SetPoint := 'False'} : Array[0..30] of "FB_ESTOPhandling";
      xReInit : Bool;
      fTrigReIntTime {InstructionName := 'F_TRIG'; LibVersion := '1.0'} : F_TRIG;
      tOfReIntTime {InstructionName := 'TOF_TIME'; LibVersion := '1.0'} : TOF_TIME;   // nach Hochfahren vergeht diese Zeit bis erstmalig Quit
   END_VAR

   VAR_TEMP 
      tDebug : Int;
      nIdx : USInt;
   END_VAR

   VAR CONSTANT 
      c_UH02 : Int := 0;
      c_UZ0201 : Int := 1;
      c_UZ0202 : Int := 2;
      c_UZ0203 : Int := 3;
      c_UZ0204 : Int := 4;
      c_UZ0209 : Int := 5;
      c_UZ0210 : Int := 6;
      c_UZ0211 : Int := 7;
      c_UC021 : Int := 8;
      c_UZ2101 : Int := 9;
      c_UZ2102 : Int := 10;
      c_UZ2103 : Int := 11;
      c_UZ2104 : Int := 12;
      c_UC022 : Int := 13;
      c_UZ2201 : Int := 14;
      c_UZ2202 : Int := 15;
      c_UZ2203 : Int := 16;
      c_UZ2204 : Int := 17;
      c_UC023 : Int := 18;
      c_UZ2301 : Int := 19;
      c_UZ2302 : Int := 20;
      c_UZ2303 : Int := 21;
      c_UZ2304 : Int := 22;
      c_UH02_Extern1 : Int := 23;
      c_UH02_Extern2 : Int := 24;
      c_UC021_Extern : Int := 25;
      c_UC022_Extern : Int := 26;
      c_UC023_Extern : Int := 27;
   END_VAR


BEGIN
	// ------------------------------------------------
	// GLOBAL INFORMATION - do before other FB calls
	// ------------------------------------------------
	
	REGION Reinitialisieren
	    #tOfReIntTime(IN := NOT #xReInit,
	                  PT := T#10s);
	    
	    IF NOT #xReInit THEN
	        #xReInit := TRUE;
	    END_IF;
	    
	    #fTrigReIntTime(CLK := #tOfReIntTime.Q);
	    
	END_REGION
	
	REGION CycleTime
	    // "DB_MachineGlobal".nLogicCycle := "DB_MachineGlobal".nLogicCycle + 1;
	    #tDebug := RD_SYS_T("DB_MachineGlobal".DTL_TimePLC);
	    // #fbCycleTime("DB_MachineGlobal".nPrevCycle);
	END_REGION
	
	REGION Alarmnummern zurücksetzten
	    IF "DB_MachineGlobal".Cold_Restart THEN
	        "DB_AlarmGlobal".nAlarmNoOffsetGlobal := 10;
	    END_IF;
	END_REGION
	
	REGION Monitoring
	    
	    REGION UH02
	        REGION Druckluft UH02
	            #fbMonPressureUH02.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonPressureUH02.stSettings.xSelfQuit := FALSE;
	            #fbMonPressureUH02(sInFctnName := 'Druckluftueberwachung',
	                               sInPrefix := 'Druckluft UH02',
	                               sInAlarmMessage := 'Druckluft zu niedrig',
	                               sInSuffix := 'BP0004',
	                               wInTextListId_Function := 5,
	                               wInTextListId_Message := 4,
	                               xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                               xInSignal := "BP0004",
	                               stOutHMI => "DB_Interface_HMI".stSystem.stPressure.UH02,
	                               InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Phasenüberwachung
	            #fbMonPhaseFailure.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonPhaseFailure.stSettings.xSelfQuit := FALSE;
	            #fbMonPhaseFailure(sInFctnName := 'Phasenausfall',
	                               sInPrefix := 'Phase',
	                               sInAlarmMessage := 'Phase ausgefallen',
	                               sInSuffix := 'DI0005',
	                               wInTextListId_Function := 6,
	                               wInTextListId_Message := 2,
	                               xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                               xInSignal := "DI0005",
	                               stOutHMI => "DB_Interface_HMI".stSystem.stPhase.UH02_400V,
	                               InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION 400 V UC021
	            #fbMonFuse400VUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse400VUC021.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse400VUC021(sInFctnName := 'Sicherungsfall',
	                                sInPrefix := '400V UC021',
	                                sInAlarmMessage := 'Sicherung ausgeloest',
	                                sInSuffix := 'DI0006',
	                                wInTextListId_Function := 4,
	                                wInTextListId_Message := 3,
	                                xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                xInSignal := "DI0006",
	                                stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC021_400V,
	                                InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION 400 V UC022
	            #fbMonFuse400VUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse400VUC022.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse400VUC022(sInFctnName := 'Sicherungsfall',
	                                sInPrefix := '400V UC022',
	                                sInAlarmMessage := 'Sicherung ausgeloest',
	                                sInSuffix := 'DI0007',
	                                wInTextListId_Function := 4,
	                                wInTextListId_Message := 3,
	                                xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                xInSignal := "DI0007",
	                                stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC022_400V,
	                                InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION 400 V UC023
	            #fbMonFuse400VUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse400VUC023.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse400VUC023(sInFctnName := 'Sicherungsfall',
	                                sInPrefix := '400V UC023',
	                                sInAlarmMessage := 'Sicherung ausgeloest',
	                                sInSuffix := 'DI0010',
	                                wInTextListId_Function := 4,
	                                wInTextListId_Message := 3,
	                                xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                xInSignal := "DI0010",
	                                stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC023_400V,
	                                InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Hauptschütze UH02
	            #fbMonMainContactorsUH02.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMainContactorsUH02.stSettings.xSelfQuit := FALSE;
	            #fbMonMainContactorsUH02(sInFctnName := 'Hauptschuetzueberwachung',
	                                     sInPrefix := 'Hauptschuetz UH02',
	                                     sInAlarmMessage := 'Hauptschuetz Fehler',
	                                     sInSuffix := 'DI0013',
	                                     wInTextListId_Function := 5,
	                                     wInTextListId_Message := 4,
	                                     xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                     xInSignal := "DB_InterfaceSafety".stFromSafety.stMainContactorsUH02.xOk,
	                                     stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UH02,
	                                     InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Sicherheitsrelais UH02 to UH03
	            #fbMonSafetyContactorsUH02toUH03.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonSafetyContactorsUH02toUH03.stSettings.xSelfQuit := FALSE;
	            #fbMonSafetyContactorsUH02toUH03(sInFctnName := 'Relaisueberwachung',
	                                             sInPrefix := 'Relais UH02 to UH03',
	                                             sInAlarmMessage := 'Relais Fehler',
	                                             sInSuffix := 'QA0660/61',
	                                             wInTextListId_Function := 5,
	                                             wInTextListId_Message := 4,
	                                             xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                             xInSignal := "DB_InterfaceSafety".stFromSafety.stSafetyContactorsUH02toUH03.xOk,
	                                             stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UH02toUH03,
	                                             InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Sicherheitsrelais UH02 to UH05
	            #fbMonSafetyContactorsUH02toUH05.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonSafetyContactorsUH02toUH05.stSettings.xSelfQuit := FALSE;
	            #fbMonSafetyContactorsUH02toUH05(sInFctnName := 'Relaisueberwachung',
	                                             sInPrefix := 'Relais UH02 to UH05',
	                                             sInAlarmMessage := 'Relais Fehler',
	                                             sInSuffix := 'QA0662/63',
	                                             wInTextListId_Function := 5,
	                                             wInTextListId_Message := 4,
	                                             xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                             xInSignal := "DB_InterfaceSafety".stFromSafety.stSafetyContactorsUH02toUH05.xOk,
	                                             stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UH02toUH05,
	                                             InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Sicherungsautomat UH02
	            #fbMonFuseCircuitBrakerUH02.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuseCircuitBrakerUH02.stSettings.xSelfQuit := FALSE;
	            #fbMonFuseCircuitBrakerUH02(sInFctnName := 'Sicherungsfall',
	                                        sInPrefix := 'Sicherung',
	                                        sInAlarmMessage := 'Sicherung ausgeloest',
	                                        sInSuffix := 'DI0016',
	                                        wInTextListId_Function := 4,
	                                        wInTextListId_Message := 3,
	                                        xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                        xInSignal := "DI0016",
	                                        stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UH02_400V,
	                                        InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION 24 V UH02
	            #fbMonFuse24VUH02.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse24VUH02.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse24VUH02(sInFctnName := 'Sicherungsfall 24 V UH02',
	                              sInPrefix := '24V-Intern',
	                              sInAlarmMessage := 'Sicherung ausgeloest',
	                              sInSuffix := 'DI0021-26',
	                              wInTextListId_Function := 4,
	                              wInTextListId_Message := 3,
	                              xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                              xInSignal := "DI0021" AND "DI0022" AND "DI0023" AND "DI0024" AND "DI0025" AND "DI0026",
	                              stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UH02_24V,
	                              InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Motor Protection UH02
	            #fbMonMotorProtectionUH02.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMotorProtectionUH02.stSettings.xSelfQuit := FALSE;
	            #fbMonMotorProtectionUH02(sInFctnName := 'Motorschutz UH02',
	                                      sInPrefix := 'Motor',
	                                      sInAlarmMessage := 'Motorschutz ausgeloest',
	                                      sInSuffix := 'FC0060-FC0077',
	                                      wInTextListId_Function := 3,
	                                      wInTextListId_Message := 1,
	                                      xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                      xInSignal := "FC0060" AND "FC0061" //nur diese zwei für IBN SL1.1, Ausgangskreisel oben
	                                      AND "FC0062" AND "FC0063" //Eingangskreisel Mitte
	                                      AND "FC0064" AND "FC0065" AND "FC0066" AND "FC0067" //Varios Mitte
	                                      AND "FC0070" //Vario von ObenÜbergang
	                                      AND "FC0071" //Vario rechts zum Kreisel
	                                      AND "FC0072" //Vario rechts zum Kreisel
	                                      AND "FC0073" //Vario rechts zum Kreisel
	                                      AND "FC0074" //Vario rechts Richtung Highway
	                                      AND "FC0075" //Kreisel rechts
	                                      AND "FC0076" //Vario rechts Richtung Highway
	                                      AND "FC0077", //Reserve
	                                      stOutHMI => "DB_Interface_HMI".stSystem.stMotorProtection.UH02,
	                                      InOutMachineState := #stInOutControlUnitCabinetOF1);
	        END_REGION
	        REGION Feueralarm
	            #fbMonFAS.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFAS.stSettings.xSelfQuit := FALSE;
	            #fbMonFAS(sInFctnName := 'Feueralarm',
	                      sInPrefix := 'UH02 | FAS',
	                      sInAlarmMessage := 'Feueralarm',
	                      sInSuffix := 'DI0034',
	                      wInTextListId_Function := 8,
	                      wInTextListId_Message := 6, 
	                      xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError OR "SF0002",
	                      xInSignal := "DI0034",
	                      InOutMachineState := #stInOutControlUnitCabinetOF1,
	                      stOutHMI => "DB_Interface_HMI".stSystem.stFireControl.NoFireAlarmFAS);
	            
	        END_REGION
	    END_REGION
	    
	    REGION UC021
	        REGION Druckluft UC021
	            #fbMonPressureUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonPressureUC021.stSettings.xSelfQuit := FALSE;
	            #fbMonPressureUC021(sInFctnName := 'Druckluftueberwachung',
	                                sInPrefix := 'Druckluft UC021',
	                                sInAlarmMessage := 'Druckluft zu niedrig',
	                                sInSuffix := 'BP0107',
	                                wInTextListId_Function := 5,
	                                wInTextListId_Message := 4,
	                                xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError OR "SF0117",
	                                xInSignal := "BP0107",
	                                stOutHMI => "DB_Interface_HMI".stSystem.stPressure.UC021,
	                                InOutMachineState := #stInOutControlUnitCabinetOF2);
	        END_REGION
	        REGION Vorsicherung Motor + Bremse UC021
	            #fbMonFuseMotorAndBrakeUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuseMotorAndBrakeUC021.stSettings.xSelfQuit := FALSE;
	            #fbMonFuseMotorAndBrakeUC021(sInFctnName := 'Sicherungsfall 400 V Motor+Bremse',
	                                         sInPrefix := '400V Intern UC021',
	                                         sInAlarmMessage := 'Sicherung ausgeloest',
	                                         sInSuffix := 'DI0100',
	                                         wInTextListId_Function := 4,
	                                         wInTextListId_Message := 3,
	                                         xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError OR "SF0117",
	                                         xInSignal := "DI0100",
	                                         stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC021_MotorBrake,
	                                         InOutMachineState := #stInOutControlUnitCabinetOF2);
	        END_REGION
	        REGION 24 V UC021
	            #fbMonFuse24VUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse24VUC021.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse24VUC021(sInFctnName := 'Sicherungsfall 24 V UC021',
	                               sInPrefix := '24V-Intern',
	                               sInAlarmMessage := 'Sicherung ausgeloest',
	                               sInSuffix := 'DI0101-103',
	                               wInTextListId_Function := 4,
	                               wInTextListId_Message := 3,
	                               xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError OR "SF0117",
	                               xInSignal := "DI0101" AND "DI0102" AND "DI0103",
	                               stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC021_24V,
	                               InOutMachineState := #stInOutControlUnitCabinetOF2);
	        END_REGION
	        REGION Hauptschütze UC021
	            #fbMonMainContactorsUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMainContactorsUC021.stSettings.xSelfQuit := FALSE;
	            #fbMonMainContactorsUC021(sInFctnName := 'Hauptschuetzueberwachung',
	                                      sInPrefix := 'Hauptschuetz UC021',
	                                      sInAlarmMessage := 'Hauptschuetz Fehler',
	                                      sInSuffix := 'DI0106',
	                                      wInTextListId_Function := 5,
	                                      wInTextListId_Message := 4,
	                                      xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError OR "SF0117",
	                                      xInSignal := "DB_InterfaceSafety".stFromSafety.stMainContactorsUC021.xOk,
	                                      stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UC021,
	                                      InOutMachineState := #stInOutControlUnitCabinetOF2);
	        END_REGION
	        REGION Sicherheitsrelais UC021 Extern
	            #fbMonSafetyContactorsUC021Extern.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonSafetyContactorsUC021Extern.stSettings.xSelfQuit := FALSE;
	            #fbMonSafetyContactorsUC021Extern(sInFctnName := 'Relaisueberwachung',
	                                              sInPrefix := 'Relais UC021 Extern',
	                                              sInAlarmMessage := 'Relais Fehler',
	                                              sInSuffix := 'QA0922/23',
	                                              wInTextListId_Function := 5,
	                                              wInTextListId_Message := 4,
	                                              xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError OR "SF0117",
	                                              xInSignal := "DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC021Extern.xOk,
	                                              stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UC021Extern,
	                                              InOutMachineState := #stInOutControlUnitCabinetOF2);
	        END_REGION
	        REGION Motor Protection UC021
	            #fbMonMotorProtectionUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMotorProtectionUC021.stSettings.xSelfQuit := FALSE;
	            #fbMonMotorProtectionUC021(sInFctnName := 'Motorschutz UC021',
	                                       sInPrefix := 'Motor',
	                                       sInAlarmMessage := 'Motorschutz ausgeloest',
	                                       wInTextListId_Function := 3,
	                                       wInTextListId_Message := 1,
	                                       sInSuffix := 'FC0140-FC0146',
	                                       xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError OR "SF0117",
	                                       xInSignal := "FC0140" AND "FC0141" AND "FC0142" AND "FC0143" AND "FC0144" AND "FC0145" AND "FC0146",
	                                       stOutHMI => "DB_Interface_HMI".stSystem.stMotorProtection.UC021,
	                                       InOutMachineState := #stInOutControlUnitCabinetOF2);
	        END_REGION
	    END_REGION
	    
	    REGION UC022
	        REGION Druckluft UC022
	            #fbMonPressureUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonPressureUC022.stSettings.xSelfQuit := FALSE;
	            #fbMonPressureUC022(sInFctnName := 'Druckluftueberwachung',
	                                sInPrefix := 'Druckluft UC022',
	                                sInAlarmMessage := 'Druckluft zu niedrig',
	                                sInSuffix := 'BP0167',
	                                wInTextListId_Function := 5,
	                                wInTextListId_Message := 4,
	                                xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError OR "SF0177",
	                                xInSignal := "BP0167",
	                                stOutHMI => "DB_Interface_HMI".stSystem.stPressure.UC022,
	                                InOutMachineState := #stInOutControlUnitCabinetOF3);
	        END_REGION
	        REGION Vorsicherung Motor + Bremse UC022
	            #fbMonFuseMotorAndBrakeUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuseMotorAndBrakeUC022.stSettings.xSelfQuit := FALSE;
	            #fbMonFuseMotorAndBrakeUC022(sInFctnName := 'Sicherungsfall 400 V Motor+Bremse',
	                                         sInPrefix := '400V Intern UC022',
	                                         sInAlarmMessage := 'Sicherung ausgeloest',
	                                         sInSuffix := 'DI0160',
	                                         wInTextListId_Function := 4,
	                                         wInTextListId_Message := 3,
	                                         xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError OR "SF0177",
	                                         xInSignal := "DI0160",
	                                         stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC022_MotorBrake,
	                                         InOutMachineState := #stInOutControlUnitCabinetOF3);
	        END_REGION
	        REGION 24 V UC022
	            #fbMonFuse24VUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse24VUC022.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse24VUC022(sInFctnName := 'Sicherungsfall 24 V UC022',
	                               sInPrefix := '24V-Intern',
	                               sInAlarmMessage := 'Sicherung ausgeloest',
	                               sInSuffix := 'DI0161-165',
	                               wInTextListId_Function := 4,
	                               wInTextListId_Message := 3,
	                               xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError OR "SF0177",
	                               xInSignal := "DI0161" AND "DI0162" AND "DI0163" AND "DI0164" AND "DI0165",
	                               stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC022_24V,
	                               InOutMachineState := #stInOutControlUnitCabinetOF3);
	        END_REGION
	        REGION Hauptschütze UC022
	            #fbMonMainContactorsUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMainContactorsUC022.stSettings.xSelfQuit := FALSE;
	            #fbMonMainContactorsUC022(sInFctnName := 'Hauptschuetzueberwachung',
	                                      sInPrefix := 'Hauptschuetz UC022',
	                                      sInAlarmMessage := 'Hauptschuetz Fehler',
	                                      sInSuffix := 'DI0166',
	                                      wInTextListId_Function := 5,
	                                      wInTextListId_Message := 4,
	                                      xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError OR "SF0177",
	                                      xInSignal := "DB_InterfaceSafety".stFromSafety.stMainContactorsUC022.xOk,
	                                      stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UC022,
	                                      InOutMachineState := #stInOutControlUnitCabinetOF3);
	        END_REGION
	        REGION Sicherheitsrelais UC022 Extern
	            #fbMonSafetyContactorsUC022Extern.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonSafetyContactorsUC022Extern.stSettings.xSelfQuit := FALSE;
	            #fbMonSafetyContactorsUC022Extern(sInFctnName := 'Relaisueberwachung',
	                                              sInPrefix := 'Relais UC022 Extern',
	                                              sInAlarmMessage := 'Relais Fehler',
	                                              sInSuffix := 'QA1232/33',
	                                              wInTextListId_Function := 5,
	                                              wInTextListId_Message := 4,
	                                              xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError OR "SF0117",
	                                              xInSignal := "DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC022Extern.xOk,
	                                              stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UC022Extern,
	                                              InOutMachineState := #stInOutControlUnitCabinetOF3);
	        END_REGION
	        REGION Motor Protection UC022
	            #fbMonMotorProtectionUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMotorProtectionUC022.stSettings.xSelfQuit := FALSE;
	            #fbMonMotorProtectionUC022(sInFctnName := 'Motorschutz UC022',
	                                       sInPrefix := 'Motor',
	                                       sInAlarmMessage := 'Motorschutz ausgeloest',
	                                       sInSuffix := 'FC0200-FC0203',
	                                       wInTextListId_Function := 3,
	                                       wInTextListId_Message := 1,
	                                       xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError OR "SF0177",
	                                       xInSignal := ("FC0200" AND "FC0201" AND "FC0202" AND "FC0203"),
	                                       stOutHMI => "DB_Interface_HMI".stSystem.stMotorProtection.UC022,
	                                       InOutMachineState := #stInOutControlUnitCabinetOF3);
	        END_REGION
	    END_REGION
	    
	    REGION UC023
	        
	        REGION Druckluft UC023
	            #fbMonPressureUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonPressureUC023.stSettings.xSelfQuit := FALSE;
	            #fbMonPressureUC023(sInFctnName := 'Druckluftueberwachung',
	                                sInPrefix := 'Druckluft UC023',
	                                sInAlarmMessage := 'Druckluft zu niedrig',
	                                sInSuffix := 'BP0227',
	                                wInTextListId_Function := 5,
	                                wInTextListId_Message := 4,
	                                xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError OR "SF0237",
	                                xInSignal := "BP0227",
	                                stOutHMI => "DB_Interface_HMI".stSystem.stPressure.UC023,
	                                InOutMachineState := #stInOutControlUnitCabinetOF4);
	        END_REGION
	        REGION Vorsicherung Motor + Bremse UC023
	            #fbMonFuseMotorAndBrakeUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuseMotorAndBrakeUC023.stSettings.xSelfQuit := FALSE;
	            #fbMonFuseMotorAndBrakeUC023(sInFctnName := 'Sicherungsfall 400 V Motor+Bremse',
	                                         sInPrefix := '400V Intern UC023',
	                                         sInAlarmMessage := 'Sicherung ausgeloest',
	                                         sInSuffix := 'DI0220',
	                                         wInTextListId_Function := 4,
	                                         wInTextListId_Message := 3,
	                                         xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError OR "SF0237",
	                                         xInSignal := "DI0220",
	                                         stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC023_MotorBrake,
	                                         InOutMachineState := #stInOutControlUnitCabinetOF4);
	        END_REGION
	        REGION 24 V UC023
	            #fbMonFuse24VUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonFuse24VUC023.stSettings.xSelfQuit := FALSE;
	            #fbMonFuse24VUC023(sInFctnName := 'Sicherungsfall 24 V UC023',
	                               sInPrefix := '24V-Intern',
	                               sInAlarmMessage := 'Sicherung ausgeloest',
	                               sInSuffix := 'DI0221-223',
	                               wInTextListId_Function := 4,
	                               wInTextListId_Message := 3,
	                               xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError OR "SF0237",
	                               xInSignal := ("DI0221" AND "DI0222" AND "DI0223"),
	                               stOutHMI => "DB_Interface_HMI".stSystem.stFuse.UC023_24V,
	                               InOutMachineState := #stInOutControlUnitCabinetOF4);
	        END_REGION
	        REGION Hauptschütze UC023
	            #fbMonMainContactorsUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMainContactorsUC023.stSettings.xSelfQuit := FALSE;
	            #fbMonMainContactorsUC023(sInFctnName := 'Hauptschuetzueberwachung',
	                                      sInPrefix := 'Hauptschuetz UC023',
	                                      sInAlarmMessage := 'Hauptschuetz Fehler',
	                                      sInSuffix := 'DI0234',
	                                      wInTextListId_Function := 5,
	                                      wInTextListId_Message := 4,
	                                      xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError OR "SF0237",
	                                      xInSignal := "DB_InterfaceSafety".stFromSafety.stMainContactorsUC023.xOk,
	                                      stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UC023,
	                                      InOutMachineState := #stInOutControlUnitCabinetOF4);
	        END_REGION
	        REGION Sicherheitsrelais UC023 Extern
	            #fbMonSafetyContactorsUC023Extern.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonSafetyContactorsUC023Extern.stSettings.xSelfQuit := FALSE;
	            #fbMonSafetyContactorsUC023Extern(sInFctnName := 'Relaisueberwachung',
	                                              sInPrefix := 'Relais UC023 Extern',
	                                              sInAlarmMessage := 'Relais Fehler',
	                                              sInSuffix := 'QA1542/43',
	                                              wInTextListId_Function := 5,
	                                              wInTextListId_Message := 4,
	                                              xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError OR "SF0237",
	                                              xInSignal := "DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC023Extern.xOk,
	                                              stOutHMI => "DB_Interface_HMI".stSystem.stMainContactor.UC023Extern,
	                                              InOutMachineState := #stInOutControlUnitCabinetOF4);
	        END_REGION
	        REGION Motor Protection UC023
	            #fbMonMotorProtectionUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonMotorProtectionUC023.stSettings.xSelfQuit := FALSE;
	            #fbMonMotorProtectionUC023(sInFctnName := 'Motorschutz UC023',
	                                       sInPrefix := 'Motor',
	                                       sInAlarmMessage := 'Motorschutz ausgeloest',
	                                       sInSuffix := 'FC0260-FC0266',
	                                       wInTextListId_Function := 3,
	                                       wInTextListId_Message := 1,
	                                       xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError OR "SF0237",
	                                       xInSignal := ("FC0260" AND "FC0261" AND "FC0262" AND "FC0263" AND "FC0264" AND "FC0265" AND "FC0266"),
	                                       stOutHMI => "DB_Interface_HMI".stSystem.stMotorProtection.UC023,
	                                       InOutMachineState := #stInOutControlUnitCabinetOF4);
	        END_REGION
	    END_REGION
	    
	    REGION MISC
	        REGION NOT-Halt extern
	            #fbMonEstopExternUC021.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonEstopExternUC021.stSettings.xSelfQuit := TRUE;
	            #fbMonEstopExternUC021(sInFctnName := 'Not-Halt Extern',
	                                   sInPrefix := 'UC021',
	                                   sInSuffix := 'SF0781',
	                                   wInTextListId_Function := 20,
	                                   wInTextListId_Message := 20,
	                                   xInQuitError := #stInOutControlUnitCabinetOF2.xQuitError,
	                                   xInSignal := "DB_InterfaceSafety".stFromSafety.EStopUC021Extern1.Q,
	                                   InOutMachineState := #stInOutControlUnitCabinetOF2,
	                                   stOutHMI => "DB_Interface_HMI".stSystem.stExternal.EStopUC021);
	                                   
	            #fbMonEstopExternUC022.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonEstopExternUC022.stSettings.xSelfQuit := TRUE;
	            #fbMonEstopExternUC022(sInFctnName := 'Not-Halt Extern',
	                                   sInPrefix := 'UC022',
	                                   sInSuffix := 'SF1091',
	                                   wInTextListId_Function := 20,
	                                   wInTextListId_Message := 20,
	                                   xInQuitError := #stInOutControlUnitCabinetOF3.xQuitError,
	                                   xInSignal := "DB_InterfaceSafety".stFromSafety.EStopUC022Extern1.Q,
	                                   InOutMachineState := #stInOutControlUnitCabinetOF3,
	                                   stOutHMI => "DB_Interface_HMI".stSystem.stExternal.EStopUC022);
	                                   
	            #fbMonEstopExternUC023.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonEstopExternUC023.stSettings.xSelfQuit := TRUE;
	            #fbMonEstopExternUC023(sInFctnName := 'Not-Halt Extern',
	                                   sInPrefix := 'UC023',
	                                   sInSuffix := 'SF1401',
	                                   wInTextListId_Function := 20,
	                                   wInTextListId_Message := 20,
	                                   xInQuitError := #stInOutControlUnitCabinetOF4.xQuitError,
	                                   xInSignal := "DB_InterfaceSafety".stFromSafety.EStopUC023Extern1.Q,
	                                   InOutMachineState := #stInOutControlUnitCabinetOF4,
	                                   stOutHMI => "DB_Interface_HMI".stSystem.stExternal.EStopUC023);
	                                   
	            #fbMonEstopExternUH03.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonEstopExternUH03.stSettings.xSelfQuit := TRUE;
	            #fbMonEstopExternUH03(sInFctnName := 'Not-Halt Extern',
	                                  sInPrefix := 'UH03',
	                                  sInSuffix := 'SF0541',
	                                  wInTextListId_Function := 20,
	                                  wInTextListId_Message := 20,
	                                  xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                  xInSignal := "DB_InterfaceSafety".stFromSafety.EStopUH02Extern1FromUH03.Q,
	                                  InOutMachineState := #stInOutControlUnitCabinetOF1,
	                                  stOutHMI => "DB_Interface_HMI".stSystem.stExternal.EStopUH03);
	                                  
	            #fbMonEstopExternUH05.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonEstopExternUH05.stSettings.xSelfQuit := TRUE;
	            #fbMonEstopExternUH05(sInFctnName := 'Not-Halt Extern',
	                                  sInPrefix := 'UH05',
	                                  sInSuffix := 'SF0542',
	                                  wInTextListId_Function := 20,
	                                  wInTextListId_Message := 20,
	                                  xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                  xInSignal := "DB_InterfaceSafety".stFromSafety.EStopUH02Extern2FromUH05.Q,
	                                  InOutMachineState := #stInOutControlUnitCabinetOF1,
	                                  stOutHMI => "DB_Interface_HMI".stSystem.stExternal.EStopUH05);
	                                  
	        END_REGION
	        
	        REGION TCP-Kommunikation
	            #fbMonCommFortnaWCS.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonCommFortnaWCS.stSettings.xSelfQuit := TRUE;
	            #fbMonCommFortnaWCS(sInFctnName := 'Kommunikationsfehler',
	                                sInPrefix := 'UH02',
	                                sInSuffix := 'Fortna WCS',
	                                wInTextListId_Function := 20000,
	                                wInTextListId_Message := 20000,
	                                xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                xInSignal := "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive,
	                                InOutMachineState := #stInOutControlUnitCabinetOF1,
	                                stOutHMI => "DB_Interface_HMI".stSystem.stExternal.TCPFortnaWCS);
	            
	            #fbMonCommFortnaWES_ASRS.stSettings.xErrLedIfMachineIsOff := TRUE;
	            #fbMonCommFortnaWES_ASRS.stSettings.xSelfQuit := TRUE;
	            #fbMonCommFortnaWES_ASRS(sInFctnName := 'Kommunikationsfehler',
	                                sInPrefix := 'UH02',
	                                sInSuffix := 'Fortna WES ASRS',
	                                wInTextListId_Function := 20000,
	                                wInTextListId_Message := 20000,
	                                xInQuitError := #stInOutControlUnitCabinetOF1.xQuitError,
	                                xInSignal := "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive,
	                                InOutMachineState := #stInOutControlUnitCabinetOF1,
	                                stOutHMI => "DB_Interface_HMI".stSystem.stExternal.TCPFortnaWES_ASRS);
	            
	        END_REGION
	        
	        
	    END_REGION
	
	    
	    
	END_REGION
	
	REGION AllReadyToStart
	    
	    #xAllReadyToStartOF1 :=
	    #fbMonPhaseFailure.xOutOk AND //betrifft alle OFs
	    #fbMonFuse400VUC021.xOutOk AND
	    #fbMonFuse400VUC022.xOutOk AND
	    #fbMonFuse400VUC023.xOutOk AND
	    #fbMonFuseCircuitBrakerUH02.xOutOk AND //enthält Vorsicherung von Phasen-Ü., betrifft alle OFs
	    // #fbMonMotorProtectionUH02.xOutOk AND //nicht erforderlich für alles andere. Meldung bleibt und Handling auf TRO Ebene
	    #fbMonMainContactorsUH02.xOutOk AND
	    #fbMonSafetyContactorsUH02toUH03.xOutOk AND
	    #fbMonSafetyContactorsUH02toUH05.xOutOk AND
	    #fbMonFuse24VUH02.xOutOk AND
	    #fbMonPressureUH02.xOutOk AND
	    #fbMonFAS.xOutOk; //betrifft alle OFs
	    
	    #xAllReadyToStartOF2 :=
	    #fbMonPhaseFailure.xOutOk AND //betrifft alle OFs
	    #fbMonFuseCircuitBrakerUH02.xOutOk AND //enthält Vorsicherung von Phasen-Ü., betrifft alle OFs
	    // #fbMonMotorProtectionUC021.xOutOk AND //nicht erforderlich für alles andere. Meldung bleibt und Handling auf TRO Ebene
	    #fbMonMainContactorsUC021.xOutOk AND
	    #fbMonSafetyContactorsUC021Extern.xOutOk AND
	    #fbMonFuse24VUC021.xOutOk AND
	    #fbMonFuseMotorAndBrakeUC021.xOutOk AND
	    #fbMonPressureUC021.xOutOk AND
	    #fbMonFAS.xOutOk; //betrifft alle OFs
	    
	    #xAllReadyToStartOF3 :=
	    #fbMonPhaseFailure.xOutOk AND //betrifft alle OFs
	    #fbMonFuseCircuitBrakerUH02.xOutOk AND //enthält Vorsicherung von Phasen-Ü., betrifft alle OFs
	    // #fbMonMotorProtectionUC022.xOutOk AND //nicht erforderlich für alles andere. Meldung bleibt und Handling auf TRO Ebene
	    #fbMonMainContactorsUC022.xOutOk AND
	    #fbMonSafetyContactorsUC022Extern.xOutOk AND
	    #fbMonFuse24VUC022.xOutOk AND
	    #fbMonFuseMotorAndBrakeUC022.xOutOk AND
	    #fbMonPressureUC022.xOutOk AND
	    #fbMonFAS.xOutOk; //betrifft alle OFs
	    
	    #xAllReadyToStartOF4 :=
	    #fbMonPhaseFailure.xOutOk AND //betrifft alle OFs
	    #fbMonFuseCircuitBrakerUH02.xOutOk AND //enthält Vorsicherung von Phasen-Ü., betrifft alle OFs
	    // #fbMonMotorProtectionUC023.xOutOk AND //nicht erforderlich für alles andere. Meldung bleibt und Handling auf TRO Ebene
	    #fbMonMainContactorsUC023.xOutOk AND
	    #fbMonSafetyContactorsUC023Extern.xOutOk AND
	    #fbMonFuse24VUC023.xOutOk AND
	    #fbMonFuseMotorAndBrakeUC023.xOutOk AND
	    #fbMonPressureUC023.xOutOk AND
	    #fbMonFAS.xOutOk; //betrifft alle OFs
	    
	END_REGION
	
	REGION StateMain
	    
	    #fbStateMainOF1.stSettings.xEnableStartUpWarning := TRUE;
	    #fbStateMainOF1.stSettings.tStartUpTime := T#5s;
	    #fbStateMainOF1(xInBtnMachineOn := "SF0001" OR "IBN".xEin,
	                    xInBtnMachineNotOff := "SF0000" AND "IBN".xAus,
	                    xInBtnTrigMot := "SF0002" OR "IBN".xQuitGlob,
	                    xInBtnQuitError := "SF0002" OR "IBN".xQuitGlob,
	                    xInAllReadyToStart := #xAllReadyToStartOF1,
	                    xInAllInExecute := TRUE,
	                    xInAllStarted := TRUE,
	                    xInSafetyActive := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                    xInAllInSafeState := "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q,
	                    stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                    stInOutHMI := "DB_Interface_HMI".stStateMachine);
	    
	    #fbStateMainOF2.stSettings.xEnableStartUpWarning := TRUE;
	    #fbStateMainOF2.stSettings.tStartUpTime := T#5s;
	    #fbStateMainOF2(xInBtnMachineOn := "SF0001" OR "IBN".xEin,
	                    xInBtnMachineNotOff := "SF0000" AND "IBN".xAus,
	                    xInBtnTrigMot := "SF0117" OR "IBN".xQuitGlob,
	                    xInBtnQuitError := "SF0117" OR "IBN".xQuitGlob,
	                    xInAllReadyToStart := #xAllReadyToStartOF2,
	                    xInAllInExecute := TRUE,
	                    xInAllStarted := TRUE,
	                    xInSafetyActive := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                    xInAllInSafeState := "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q,
	                    stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                    stInOutHMI := "DB_Interface_HMI".stStateMachine);
	    
	    #fbStateMainOF3.stSettings.xEnableStartUpWarning := TRUE;
	    #fbStateMainOF3.stSettings.tStartUpTime := T#5s;
	    #fbStateMainOF3(xInBtnMachineOn := "SF0001" OR "IBN".xEin,
	                    xInBtnMachineNotOff := "SF0000" AND "IBN".xAus,
	                    xInBtnTrigMot := "SF0177" OR "IBN".xQuitGlob,
	                    xInBtnQuitError := "SF0177" OR "IBN".xQuitGlob,
	                    xInAllReadyToStart := #xAllReadyToStartOF3,
	                    xInAllInExecute := TRUE,
	                    xInAllStarted := TRUE,
	                    xInSafetyActive := "DB_InterfaceSafety".stFromSafety.EStopMainOF3.Q,
	                    xInAllInSafeState := "DB_InterfaceSafety".stFromSafety.EStopMainOF3.Q,
	                    stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3,
	                    stInOutHMI := "DB_Interface_HMI".stStateMachine);
	    
	    #fbStateMainOF4.stSettings.xEnableStartUpWarning := TRUE;
	    #fbStateMainOF4.stSettings.tStartUpTime := T#5s;
	    #fbStateMainOF4(xInBtnMachineOn := "SF0001" OR "IBN".xEin,
	                    xInBtnMachineNotOff := "SF0000" AND "IBN".xAus,
	                    xInBtnTrigMot := "SF0237" OR "IBN".xQuitGlob,
	                    xInBtnQuitError := "SF0237" OR "IBN".xQuitGlob,
	                    xInAllReadyToStart := #xAllReadyToStartOF4,
	                    xInAllInExecute := TRUE,
	                    xInAllStarted := TRUE,
	                    xInSafetyActive := "DB_InterfaceSafety".stFromSafety.EStopMainOF4.Q,
	                    xInAllInSafeState := "DB_InterfaceSafety".stFromSafety.EStopMainOF4.Q,
	                    stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4,
	                    stInOutHMI := "DB_Interface_HMI".stStateMachine);
	    
	END_REGION
	
	REGION SCADA-Interface
	    "FB-OPC_UA_System-Stat_DB"(nInSystemStat := #fbStateMainOF1.nState,
	                               xInFireAlarm := #fbMonFAS.xOutError,
	                               xInSafetyStop := NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q OR
	                               NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q OR
	                               NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF3.Q OR
	                               NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF4.Q,
	                               xInError := "DB_Interface_HMI".nActiveAlarms > 0,
	                               xInCommunicationError := #fbMonCommFortnaWCS.xOutError OR #fbMonCommFortnaWES_ASRS.xOutError,
	                               nOutScadaStatus => "DB_Status".System.Status);
	END_REGION
	
	REGION Interface Safety
	    
	    REGION to Safety
	        
	        "DB_InterfaceSafety".stToSafety.xAckGlob := "IBN".xAckGlob OR #fTrigReIntTime.Q;
	        
	        "DB_InterfaceSafety".stToSafety.xQuitButtonHss := "SF0002" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0201 := "SF0041" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0202 := "SF0043" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0203 := "SF0045" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0204 := "SF0047" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0209 := "SF0081" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0210 := "SF0083" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ0211 := "SF0085" OR #fTrigReIntTime.Q;
	        
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUC021 := "SF0117" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2101 := "SF0121" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2102 := "SF0123" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2103 := "SF0125" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2104 := "SF0127" OR #fTrigReIntTime.Q;
	        
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUC022 := "SF0177" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2201 := "SF0181" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2202 := "SF0183" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2203 := "SF0185" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2204 := "SF0187" OR #fTrigReIntTime.Q;
	        
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUC023 := "SF0237" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2301 := "SF0241" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2302 := "SF0243" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2303 := "SF0245" OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.xQuitButtonUZ2304 := "SF0247" OR #fTrigReIntTime.Q;
	        
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUH02.xFeedback := "DI0013";
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUC021.xFeedback := "DI0106";
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUC022.xFeedback := "DI0166";
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUC023.xFeedback := "DI0226";
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUC021Extern.xFeedback := "DI0114";
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUC022Extern.xFeedback := "DI0174";
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUC023Extern.xFeedback := "DI0234";
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUH02.xQuit := "SF0002" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUC021.xQuit := "SF0117" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUC022.xQuit := "SF0177" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stMainContactorsUC023.xQuit := "SF0237" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUC021Extern.xQuit := "SF0117" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUC022Extern.xQuit := "SF0177" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUC023Extern.xQuit := "SF0237" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUH02toUH03.xFeedback := "DI0014";
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUH02toUH05.xFeedback := "DI0015";
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUH02toUH03.xQuit := "SF0002" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        "DB_InterfaceSafety".stToSafety.stSafetyContactorsUH02toUH05.xQuit := "SF0002" OR "IBN".xQuitGlob OR #fTrigReIntTime.Q;
	        
	        "DB_InterfaceSafety".stToSafety.xMachineRunningOF1 := #stInOutControlUnitCabinetOF1.xRunning;
	        "DB_InterfaceSafety".stToSafety.xMachineRunningOF2 := #stInOutControlUnitCabinetOF2.xRunning;
	        "DB_InterfaceSafety".stToSafety.xMachineRunningOF3 := #stInOutControlUnitCabinetOF3.xRunning;
	        "DB_InterfaceSafety".stToSafety.xMachineRunningOF4 := #stInOutControlUnitCabinetOF4.xRunning;
	        
	        "DB_InterfaceSafety".stToSafety.xMachineStartingOF1 := #stInOutControlUnitCabinetOF1.xStarting;
	        "DB_InterfaceSafety".stToSafety.xMachineStartingOF2 := #stInOutControlUnitCabinetOF2.xStarting;
	        "DB_InterfaceSafety".stToSafety.xMachineStartingOF3 := #stInOutControlUnitCabinetOF3.xStarting;
	        "DB_InterfaceSafety".stToSafety.xMachineStartingOF4 := #stInOutControlUnitCabinetOF4.xStarting;
	        
	    END_REGION
	    
	    // "DB_InterfaceSafety".xFeedback400 := "DI0006";
	    // "DB_InterfaceSafety".xFeedback24 := "DI0007";
	    
	    REGION from Safety
	        
	    END_REGION
	    
	END_REGION
	
	REGION Outputs
	    
	    REGION UH02
	        REGION Signalampel
	            //E-Stop Signalsäule
	            "PF0030" := NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF1.Q OR
	            NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF2.Q OR
	            NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF3.Q OR
	            NOT "DB_InterfaceSafety".stFromSafety.EStopMainOF4.Q OR "SF0003"
	            OR #fbMonFAS.xOutError;
	            
	            //LED Störung + Signalsäule gelb
	            "PF0000" := "PF0031" :=
	            #fbMonMotorProtectionUH02.xOutLedError OR
	            #fbMonMotorProtectionUC021.xOutLedError OR
	            #fbMonMotorProtectionUC022.xOutLedError OR
	            #fbMonMotorProtectionUC023.xOutLedError OR
	            #fbMonPhaseFailure.xOutLedError OR
	            #fbMonFuse24VUH02.xOutLedError OR
	            #fbMonFuse24VUC021.xOutLedError OR
	            #fbMonFuse24VUC022.xOutLedError OR
	            #fbMonFuse24VUC023.xOutLedError OR
	            #fbMonFuseMotorAndBrakeUC021.xOutLedError OR
	            #fbMonFuseMotorAndBrakeUC022.xOutLedError OR
	            #fbMonFuseMotorAndBrakeUC023.xOutLedError OR
	            #fbMonFuseCircuitBrakerUH02.xOutLedError OR
	            #fbMonFuse400VUC021.xOutLedError OR
	            #fbMonFuse400VUC022.xOutLedError OR
	            #fbMonFuse400VUC023.xOutLedError OR
	            #fbMonPressureUH02.xOutLedError OR
	            #fbMonPressureUC021.xOutLedError OR
	            #fbMonPressureUC022.xOutLedError OR
	            #fbMonPressureUC023.xOutLedError OR
	            ("DB_InterfaceSafety".stFromSafety.stMainContactorsUH02.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC021.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC022.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC023.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUH02toUH03.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUH02toUH05.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC021Extern.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC022Extern.xAckReq AND "Clock_1Hz") OR
	            ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC023Extern.xAckReq AND "Clock_1Hz") OR
	            "SF0003";
	            
	            // System Ready
	            "PF0032" := #stInOutControlUnitCabinetOF1.xRunning OR
	            #stInOutControlUnitCabinetOF1.xStartUpWarning OR
	            #stInOutControlUnitCabinetOF2.xRunning OR
	            #stInOutControlUnitCabinetOF2.xStartUpWarning OR
	            #stInOutControlUnitCabinetOF3.xRunning OR
	            #stInOutControlUnitCabinetOF3.xStartUpWarning OR
	            #stInOutControlUnitCabinetOF4.xRunning OR
	            #stInOutControlUnitCabinetOF4.xStartUpWarning OR "SF0003";
	            
	            //Anfahrwarnung
	            "PF0033" := ("DB_MachineGlobal".stStateMainOF1.xStartUpWarning AND "Clock_1Hz") OR
	            ("DB_MachineGlobal".stStateMainOF2.xStartUpWarning AND "Clock_1Hz") OR
	            ("DB_MachineGlobal".stStateMainOF3.xStartUpWarning AND "Clock_1Hz") OR
	            ("DB_MachineGlobal".stStateMainOF4.xStartUpWarning AND "Clock_1Hz");
	        END_REGION
	        
	        //LED Störung
	        //PF0000 Bei Ampel
	        
	        //LED Ein
	        "PF0001" := #stInOutControlUnitCabinetOF1.xRunning OR
	        #stInOutControlUnitCabinetOF1.xStartUpWarning OR "SF0003";
	        
	        //LED Start nach Störung
	        "PF0002" := #arESTOPAck[#c_UH02].xOutLed (* OR NOT #xAllReadyToStart *)OR
	        (#fbMonMotorProtectionUH02.xOutAckReq AND "Clock_1Hz") OR
	        // (#fbMonMotorProtectionUC021.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonMotorProtectionUC022.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonMotorProtectionUC023.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        (#fbMonPhaseFailure.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse24VUH02.xOutAckReq AND "Clock_1Hz") OR
	        // (#fbMonFuse24VUC021.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonFuse24VUC022.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonFuse24VUC023.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonFuseMotorAndBrakeUC021.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonFuseMotorAndBrakeUC022.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonFuseMotorAndBrakeUC023.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        (#fbMonFuseCircuitBrakerUH02.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse400VUC021.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse400VUC022.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse400VUC023.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonPressureUH02.xOutAckReq AND "Clock_1Hz") OR
	        // (#fbMonPressureUC021.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonPressureUC022.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // (#fbMonPressureUC023.xOutAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        ("DB_InterfaceSafety".stFromSafety.stMainContactorsUH02.xAckReq AND "Clock_1Hz") OR
	        // ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC021.xAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC022.xAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC023.xAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUH02toUH03.xAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUH02toUH05.xAckReq AND "Clock_1Hz") OR
	        // ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC021Extern.xAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC022Extern.xAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        // ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC023Extern.xAckReq AND "Clock_1Hz") OR //nur am eigenen Schrank
	        (#fbMonFAS.xOutAckReq AND "Clock_1Hz") OR
	        "SF0003";
	        
	        //LED Druckluft
	        "PF0003" := #fbMonPressureUH02.xOutLedError OR
	        // #fbMonPressureUC021.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonPressureUC022.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonPressureUC023.xOutLedError OR //nur am eigenen Schrank
	        "SF0003";
	        
	        //LED Motorschutz
	        "PF0004" := #fbMonMotorProtectionUH02.xOutLedError OR
	        // #fbMonMotorProtectionUC021.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonMotorProtectionUC022.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonMotorProtectionUC023.xOutLedError OR //nur am eigenen Schrank
	        "SF0003";
	        
	        //LED Sicherung
	        "PF0005" := #fbMonFuse24VUH02.xOutLedError OR
	        // #fbMonFuse24VUC021.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonFuse24VUC022.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonFuse24VUC023.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonFuseMotorAndBrakeUC021.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonFuseMotorAndBrakeUC022.xOutLedError OR //nur am eigenen Schrank
	        // #fbMonFuseMotorAndBrakeUC023.xOutLedError OR //nur am eigenen Schrank
	        #fbMonFuseCircuitBrakerUH02.xOutLedError OR
	        #fbMonFuse400VUC021.xOutLedError OR
	        #fbMonFuse400VUC022.xOutLedError OR
	        #fbMonFuse400VUC023.xOutLedError OR
	        "SF0003";
	        
	        //LED Brandfall
	        "PF0006" := "SF0003"
	        OR #fbMonFAS.xOutError;
	        
	    END_REGION
	    
	    REGION UC021
	        
	        //LED Start nach Störung
	        "PF0117" := #arESTOPAck[#c_UC021].xOutLed OR
	        ("fbMain_DB".TRO208.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO211.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO214.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO217.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1101.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1102.xOutError AND "Clock_1Hz") OR
	        // ("fbMain_DB".fbPinControl1101_1.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        // ("fbMain_DB".fbPinControl1102_1.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        (#fbMonMotorProtectionUC021.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse24VUC021.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuseMotorAndBrakeUC021.xOutAckReq AND "Clock_1Hz") OR
	        // (#fbMonFuse400VUC021.xOutAckReq AND "Clock_1Hz") OR //in UH02 drin
	        (#fbMonPressureUC021.xOutAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC021.xAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC021Extern.xAckReq AND "Clock_1Hz") OR "SF0003";
	        
	        //LED Druckluft
	        "PF0100" := #fbMonPressureUC021.xOutLedError OR "SF0003";
	        
	        //LED Motorschutz
	        "PF0101" := #fbMonMotorProtectionUC021.xOutLedError OR "SF0003";
	        
	        //LED Sicherung
	        "PF0102" :=
	        #fbMonFuse24VUC021.xOutLedError OR
	        #fbMonFuseMotorAndBrakeUC021.xOutLedError OR "SF0003";// OR
	        // #fbMonFuse400VUC021.xOutLedError; //in UH02 drin
	    END_REGION
	    
	    REGION UC022
	        
	        //LED Start nach Störung
	        "PF0177" := #arESTOPAck[#c_UC022].xOutLed (* OR NOT #xAllReadyToStart *)OR
	        ("fbMain_DB".TRO228.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO231.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO234.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO237.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1201.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1202.xOutError AND "Clock_1Hz") OR
	        // ("fbMain_DB".fbPinControl1201_1.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        // ("fbMain_DB".fbPinControl1202_1.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        (#fbMonMotorProtectionUC022.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse24VUC022.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuseMotorAndBrakeUC022.xOutAckReq AND "Clock_1Hz") OR
	        // (#fbMonFuse400VUC022.xOutAckReq AND "Clock_1Hz") OR //in UH02 drin
	        (#fbMonPressureUC022.xOutAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC022.xAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC022Extern.xAckReq AND "Clock_1Hz") OR "SF0003";
	        
	        //LED Druckluft
	        "PF0160" := #fbMonPressureUC022.xOutLedError OR "SF0003";
	        
	        //LED Motorschutz
	        "PF0161" := #fbMonMotorProtectionUC022.xOutLedError OR "SF0003";
	        
	        //LED Sicherung
	        "PF0162" :=
	        #fbMonFuse24VUC022.xOutLedError OR
	        #fbMonFuseMotorAndBrakeUC022.xOutLedError OR "SF0003";// OR
	        // #fbMonFuse400VUC022.xOutLedError; //in UH02 drin
	    END_REGION
	    
	    REGION UC023
	        
	        //LED Start nach Störung
	        "PF0237" := #arESTOPAck[#c_UC023].xOutLed (* OR NOT #xAllReadyToStart *)OR
	        ("fbMain_DB".TRO248.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO251.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO254.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO257.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1303.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1304.xOutError AND "Clock_1Hz") OR
	        // ("fbMain_DB".fbPinControl1303_1.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        // ("fbMain_DB".fbPinControl1304_1.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        (#fbMonMotorProtectionUC023.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuse24VUC023.xOutAckReq AND "Clock_1Hz") OR
	        (#fbMonFuseMotorAndBrakeUC023.xOutAckReq AND "Clock_1Hz") OR
	        // (#fbMonFuse400VUC023.xOutAckReq AND "Clock_1Hz") OR //in UH02 drin
	        (#fbMonPressureUC023.xOutAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stMainContactorsUC023.xAckReq AND "Clock_1Hz") OR
	        ("DB_InterfaceSafety".stFromSafety.stSafetyContactorsUC023Extern.xAckReq AND "Clock_1Hz") OR "SF0003";
	        
	        //LED Druckluft
	        "PF0220" := #fbMonPressureUC023.xOutLedError OR "SF0003";
	        
	        //LED Motorschutz
	        "PF0221" := #fbMonMotorProtectionUC023.xOutLedError OR "SF0003";
	        
	        //LED Sicherung
	        "PF0222" :=
	        #fbMonFuse24VUC023.xOutLedError OR
	        #fbMonFuseMotorAndBrakeUC023.xOutLedError OR "SF0003";// OR
	        // #fbMonFuse400VUC023.xOutLedError; //in UH02 drin
	    END_REGION
	    
	    REGION Ready FOR use (grüne LED)
	        
	        
	        "PF0040" := "PF0042" := "PF0044" := "PF0046" :=
	        "PF0050" := "PF0052" := "PF0054" := "PF0056" :=
	        "PF0080" := "PF0082" := "PF0084" :=
	        #stInOutControlUnitCabinetOF1.xRunning OR #stInOutControlUnitCabinetOF1.xStartUpWarning OR "SF0003";
	        
	        "PF0120" := "PF0122" := "PF0124" := "PF0126" :=
	        #stInOutControlUnitCabinetOF2.xRunning OR #stInOutControlUnitCabinetOF2.xStartUpWarning OR "SF0003";
	        
	        "PF0180" := "PF0182" := "PF0184" := "PF0186" :=
	        "PF0190" := "PF0192" := "PF0194" := "PF0196" :=
	        #stInOutControlUnitCabinetOF3.xRunning OR #stInOutControlUnitCabinetOF3.xStartUpWarning OR "SF0003";
	        
	        "PF0240" := "PF0242" := "PF0244" := "PF0246" :=
	        #stInOutControlUnitCabinetOF4.xRunning OR #stInOutControlUnitCabinetOF4.xStartUpWarning OR "SF0003";
	        
	    END_REGION ;
	    
	    
	    REGION Reset ohne Estop
	        REGION mittlerer Block
	            REGION UZ0205
	                "PF0051" :=
	                ("fbMain_DB".TRO228.xOutUnloadingError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbEncoderMonitor1201.xOutError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbPinControl1201_2.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	            
	            REGION UZ0206
	                "PF0053" :=
	                ("fbMain_DB".TRO231.xOutUnloadingError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbEncoderMonitor1201.xOutError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbPinControl1201_1.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	            
	            REGION UZ0207
	                "PF0055" :=
	                ("fbMain_DB".TRO234.xOutUnloadingError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbEncoderMonitor1202.xOutError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbPinControl1202_1.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	            
	            REGION UZ0208
	                "PF0057" :=
	                ("fbMain_DB".TRO237.xOutUnloadingError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbEncoderMonitor1202.xOutError AND "Clock_1Hz") OR
	                ("fbMain_DB".fbPinControl1202_2.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	        END_REGION
	        REGION unterer Block
	            REGION UZ2205
	                "PF0191" :=
	                ("fbMain_DB".TRO249.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	                ("fbMain_DB".fbExitConv1301.xOutGridError AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	            
	            REGION UZ2206
	                "PF0193" :=
	                ("fbMain_DB".TRO252.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	                ("fbMain_DB".fbExitConv1301.xOutGridError AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	            
	            REGION UZ2207
	                "PF0195" :=
	                ("fbMain_DB".TRO255.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	                ("fbMain_DB".fbExitConv1302.xOutGridError AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	            
	            REGION UZ2208
	                "PF0197" :=
	                ("fbMain_DB".TRO258.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	                ("fbMain_DB".fbExitConv1302.xOutGridError AND "Clock_1Hz") OR "SF0003";
	            END_REGION
	        END_REGION
	    END_REGION
	END_REGION
	
	REGION NOT-Halt
	    REGION UH02
	        #arESTOPAck[#c_UH02](sInAlarmFunction := 'HSS',
	                             sInAlarmDevice := 'UH02',
	                             sInAlarmMessage := 'Not-Halt aktiv',
	                             sInAlarmSuffix := 'PF0002',
	                             wInTextListId_Function := 0,
	                             wInTextListId_Message := 0,
	                             xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUH02.AckReq,
	                             xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUH02.Q,
	                             xInAckReqGlobal := #arESTOPAck[#c_UZ0201].xOutAckReq OR
	                             #arESTOPAck[#c_UZ0202].xOutAckReq OR
	                             #arESTOPAck[#c_UZ0203].xOutAckReq OR
	                             #arESTOPAck[#c_UZ0204].xOutAckReq OR
	                             #arESTOPAck[#c_UZ0209].xOutAckReq OR
	                             #arESTOPAck[#c_UZ0210].xOutAckReq OR
	                             #arESTOPAck[#c_UZ0211].xOutAckReq OR
	                             #arESTOPAck[#c_UH02_Extern1].xOutAckReq OR
	                             #arESTOPAck[#c_UH02_Extern2].xOutAckReq,// OR
	                             // #arESTOPAck[#c_UC021].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2101].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2102].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2103].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2104].xOutAckReq OR
	                             // #arESTOPAck[#c_UC022].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2201].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2202].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2203].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2204].xOutAckReq OR
	                             // #arESTOPAck[#c_UC023].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2301].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2302].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2303].xOutAckReq OR
	                             // #arESTOPAck[#c_UZ2304].xOutAckReq,
	                             xInSafetyNotOkGlobal := #arESTOPAck[#c_UZ0201].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UZ0202].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UZ0203].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UZ0204].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UZ0209].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UZ0210].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UZ0211].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UH02_Extern1].xOutSafetyNotOk OR
	                             #arESTOPAck[#c_UH02_Extern2].xOutSafetyNotOk,// OR 
	                             // #arESTOPAck[#c_UC021].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2101].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2102].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2103].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2104].xOutSafetyNotOk OR 
	                             // #arESTOPAck[#c_UC022].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2201].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2202].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2203].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2204].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UC023].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2301].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2302].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2303].xOutSafetyNotOk OR
	                             // #arESTOPAck[#c_UZ2304].xOutSafetyNotOk,
	                             xInMainCabinet := TRUE,
	                             //        xOutLed => "PF0002",
	                             stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                             stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UH02]);
	    END_REGION
	    
	    REGION UH02 Extern 1
	        #arESTOPAck[#c_UH02_Extern1](sInAlarmDevice := 'UH02 Ext1',
	                                     sInAlarmSuffix := 'PF0002',
	                                     wInTextListId_Function := 20,
	                                     wInTextListId_Message := 20,
	                                     stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UH02_Extern1],
	                                     stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                                     xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUH02Extern1FromUH03.AckReq,
	                                     xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUH02Extern1FromUH03.Q);
	        
	    END_REGION
	    
	    REGION UH02 Extern 2
	        #arESTOPAck[#c_UH02_Extern2](sInAlarmDevice := 'UH02 Ext2',
	                                     sInAlarmSuffix := 'PF0002',
	                                     wInTextListId_Function := 20,
	                                     wInTextListId_Message := 20,
	                                     stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UH02_Extern2],
	                                     stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                                     xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUH02Extern2FromUH05.AckReq,
	                                     xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUH02Extern2FromUH05.Q);
	        
	    END_REGION
	    
	    REGION UZ0201
	        #arESTOPAck[#c_UZ0201](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0201',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0041',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0201],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0201.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0201.Q);
	        // xOutLed => "PF0041");
	        
	        "PF0041" := #arESTOPAck[#c_UZ0201].xOutLed OR
	        ("fbMain_DB".TRO209.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1103.xOutGridError AND "Clock_1Hz") OR "SF0003";
	    END_REGION
	    
	    REGION UZ0202
	        #arESTOPAck[#c_UZ0202](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0202',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0043',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0202],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0202.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0202.Q);
	        // xOutLed => "PF0043");
	        
	        "PF0043" := #arESTOPAck[#c_UZ0202].xOutLed OR
	        ("fbMain_DB".TRO212.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1103.xOutGridError AND "Clock_1Hz") OR "SF0003";
	    END_REGION
	    
	    REGION UZ0203
	        #arESTOPAck[#c_UZ0203](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0203',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0045',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0203],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0203.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0203.Q);
	        // xOutLed => "PF0045");
	        
	        "PF0045" := #arESTOPAck[#c_UZ0203].xOutLed OR
	        ("fbMain_DB".TRO215.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1104.xOutGridError AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION ;
	    
	    REGION UZ0204
	        #arESTOPAck[#c_UZ0204](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0204',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0047',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0204],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0204.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0204.Q);
	        //xOutLed => "PF0047");
	        
	        "PF0047" := #arESTOPAck[#c_UZ0204].xOutLed OR
	        ("fbMain_DB".TRO218.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1104.xOutGridError AND "Clock_1Hz") OR "SF0003";
	    END_REGION ;
	    
	    REGION UZ0209
	        #arESTOPAck[#c_UZ0209](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0209',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0081',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0209],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0209.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0209.Q);
	        // xOutLed => "PF0081");
	        
	        "PF0081" := #arESTOPAck[#c_UZ0209].xOutLed OR
	        ("fbMain_DB".TRO264.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION
	    
	    REGION UZ0210
	        #arESTOPAck[#c_UZ0210](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0210',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0083',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0210],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0210.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0210.Q);
	        // xOutLed => "PF0083");
	        
	        "PF0083" := #arESTOPAck[#c_UZ0210].xOutLed OR
	        ("fbMain_DB".TRO260.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO262.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO270.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO272.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbCarousel1110.xOutGridError AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION
	    
	    REGION UZ0211
	       #arESTOPAck[#c_UZ0211](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ0211',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0085',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ0211],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF1,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0211.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ0211.Q);
	        // xOutLed => "PF0085");
	        
	        "PF0085" := #arESTOPAck[#c_UZ0211].xOutLed OR
	        ("fbMain_DB".TRO270.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".TRO272.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	        
	        
	    END_REGION
	    
	    REGION UC021
	        
	        #arESTOPAck[#c_UC021](sInAlarmFunction := 'Unterverteiler',
	                              sInAlarmDevice := 'UC021',
	                              sInAlarmMessage := 'Not-Halt aktiv',
	                              sInAlarmSuffix := 'PF0117',
	                              wInTextListId_Function := 0,
	                              wInTextListId_Message := 0,
	                              xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUC021.AckReq,
	                              xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUC021.Q,
	                              xInAckReqGlobal := #arESTOPAck[#c_UC021].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2101].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2102].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2103].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2104].xOutAckReq OR
	                              #arESTOPAck[#c_UC021_Extern].xOutAckReq,
	                              xInSafetyNotOkGlobal := #arESTOPAck[#c_UC021].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2101].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2102].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2103].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2104].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UC021_Extern].xOutSafetyNotOk,
	                              xInMainCabinet := TRUE,
	                              stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                              stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UC021]);
	        
	        // xOutLed => "PF0117"); wird oben beschrieben
	        
	    END_REGION
	    
	    REGION UC021 Extern
	        #arESTOPAck[#c_UC021_Extern](sInAlarmDevice := 'UC021 Ext',
	                                     sInAlarmSuffix := 'PF0117',
	                                     wInTextListId_Function := 20,
	                                     wInTextListId_Message := 20,
	                                     stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UC021_Extern],
	                                     stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                                     xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUC021Extern1.AckReq,
	                                     xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUC021Extern1.Q);
	        
	    END_REGION
	    
	    REGION UZ2101
	        
	        #arESTOPAck[#c_UZ2101](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2101',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0121',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2101],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2101.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2101.Q);
	        // xOutLed => "PF0121");
	        
	        "PF0121" := #arESTOPAck[#c_UZ2101].xOutLed OR
	        ("fbMain_DB".TRO208.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1101.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1101_2.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	    END_REGION
	    
	    REGION UZ2102
	        
	        #arESTOPAck[#c_UZ2102](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2102',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0123',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2102],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2102.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2102.Q);
	        // xOutLed => "PF0123");
	        
	        "PF0123" := #arESTOPAck[#c_UZ2102].xOutLed OR
	        ("fbMain_DB".TRO211.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1101.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1101_1.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	    END_REGION
	    
	    REGION UZ2103
	        
	        #arESTOPAck[#c_UZ2103](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2103',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0125',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2103],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2103.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2103.Q);
	        // xOutLed => "PF0125");
	        
	        "PF0125" := #arESTOPAck[#c_UZ2103].xOutLed OR
	        ("fbMain_DB".TRO214.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1102.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1102_1.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	    END_REGION ;
	    
	    REGION UZ2104
	        
	        #arESTOPAck[#c_UZ2104](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2104',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0127',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2104],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF2,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2104.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2104.Q);
	        // xOutLed => "PF0127");
	        
	        "PF0127" := #arESTOPAck[#c_UZ2104].xOutLed OR
	        ("fbMain_DB".TRO217.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1102.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1102_2.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	    END_REGION ;
	    
	    REGION UC022
	        
	        #arESTOPAck[#c_UC022](sInAlarmFunction := 'Unterverteiler',
	                              sInAlarmDevice := 'UC022',
	                              sInAlarmMessage := 'Not-Halt aktiv',
	                              sInAlarmSuffix := 'PF0177',
	                              wInTextListId_Function := 0,
	                              wInTextListId_Message := 0,
	                              xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUC022.AckReq,
	                              xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUC022.Q,
	                              xInAckReqGlobal := #arESTOPAck[#c_UC022].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2201].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2202].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2203].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2204].xOutAckReq OR
	                              #arESTOPAck[#c_UC022_Extern].xOutAckReq,
	                              xInSafetyNotOkGlobal := #arESTOPAck[#c_UC022].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2201].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2202].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2203].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2204].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UC022_Extern].xOutSafetyNotOk,
	                              xInMainCabinet := TRUE,
	                              stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UC022],
	                              stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3);
	        // xOutLed => "PF0177"); wird oben beschrieben
	    END_REGION
	    
	    REGION UC022 Extern
	        #arESTOPAck[#c_UC022_Extern](sInAlarmDevice := 'UC022 Ext',
	                                     sInAlarmSuffix := 'PF0177',
	                                     wInTextListId_Function := 20,
	                                     wInTextListId_Message := 20,
	                                     stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UC022_Extern],
	                                     stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3,
	                                     xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUC022Extern1.AckReq,
	                                     xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUC022Extern1.Q);
	        
	    END_REGION
	    
	    REGION UZ2201
	        
	        #arESTOPAck[#c_UZ2201](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2201',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0181',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2201],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2201.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2201.Q);
	        // xOutLed => "PF0181");
	        
	        "PF0181" := #arESTOPAck[#c_UZ2201].xOutLed OR
	        ("fbMain_DB".TRO229.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1203.xOutGridError AND "Clock_1Hz") OR "SF0003";
	    END_REGION
	    
	    REGION UZ2202
	        
	        #arESTOPAck[#c_UZ2202](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2202',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0183',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2202],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2202.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2202.Q);
	        // xOutLed => "PF0183");
	        
	        "PF0183" := #arESTOPAck[#c_UZ2202].xOutLed OR
	        ("fbMain_DB".TRO232.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1203.xOutGridError AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION
	    
	    REGION UZ2203
	        
	        #arESTOPAck[#c_UZ2203](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2203',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0185',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2203],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2203.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2203.Q);
	        // xOutLed => "PF0185");
	        
	        "PF0185" := #arESTOPAck[#c_UZ2203].xOutLed OR
	        ("fbMain_DB".TRO235.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1204.xOutGridError AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION
	    
	    REGION UZ2204
	        
	        #arESTOPAck[#c_UZ2204](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2204',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0187',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2204],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF3,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2204.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2204.Q);
	        // xOutLed => "PF0187");
	        
	        "PF0187" := #arESTOPAck[#c_UZ2204].xOutLed OR
	        ("fbMain_DB".TRO238.fbConvVario.fbFingerControl.xOutErrorRasterSensor AND "Clock_1Hz") OR
	        ("fbMain_DB".fbExitConv1204.xOutGridError AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION
	    
	    REGION UC023
	        
	        #arESTOPAck[#c_UC023](sInAlarmFunction := 'Unterverteiler',
	                              sInAlarmDevice := 'UC023',
	                              sInAlarmMessage := 'Not-Halt aktiv',
	                              sInAlarmSuffix := 'PF0237',
	                              wInTextListId_Function := 0,
	                              wInTextListId_Message := 0,
	                              xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUC023.AckReq,
	                              xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUC023.Q,
	                              xInAckReqGlobal := #arESTOPAck[#c_UC023].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2301].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2302].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2303].xOutAckReq OR
	                              #arESTOPAck[#c_UZ2304].xOutAckReq OR
	                              #arESTOPAck[#c_UC023_Extern].xOutAckReq,
	                              xInSafetyNotOkGlobal := #arESTOPAck[#c_UC023].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2301].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2302].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2303].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UZ2304].xOutSafetyNotOk OR
	                              #arESTOPAck[#c_UC023_Extern].xOutSafetyNotOk,
	                              xInMainCabinet := TRUE,
	                              stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UC023],
	                              stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4);
	                              // xOutLed => "PF0237"); wird oben beschrieben
	    END_REGION
	    
	    REGION UC023 Extern
	        #arESTOPAck[#c_UC023_Extern](sInAlarmDevice := 'UC023 Ext',
	                                     sInAlarmSuffix := 'PF0237',
	                                     wInTextListId_Function := 20,
	                                     wInTextListId_Message := 20,
	                                     stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UC023_Extern],
	                                     stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4,
	                                     xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUC023Extern1.AckReq,
	                                     xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUC023Extern1.Q);
	        
	    END_REGION
	    
	    REGION UZ2301
	        
	        #arESTOPAck[#c_UZ2301](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2301',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0241',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2301],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2301.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2301.Q);
	                               // xOutLed => "PF0241");
	        
	        "PF0241" := #arESTOPAck[#c_UZ2301].xOutLed OR
	        ("fbMain_DB".TRO248.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1303.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1303_2.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	        
	        
	        
	    END_REGION
	    
	    REGION UZ2302
	        
	        #arESTOPAck[#c_UZ2302](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2302',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0243',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2302],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2302.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2302.Q);
	                               // xOutLed => "PF0243");
	        
	        "PF0243" := #arESTOPAck[#c_UZ2302].xOutLed OR
	        ("fbMain_DB".TRO251.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1303.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1303_1.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	    END_REGION
	    
	    REGION UZ2303
	        
	        #arESTOPAck[#c_UZ2303](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2303',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0245',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2303],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2303.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2303.Q);
	                               // xOutLed => "PF0245");
	        
	        "PF0245" := #arESTOPAck[#c_UZ2303].xOutLed OR
	        ("fbMain_DB".TRO254.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1304.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1304_1.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	        
	        
	    END_REGION
	    
	    REGION UZ2304
	        
	        #arESTOPAck[#c_UZ2304](sInAlarmFunction := 'Bedientableau',
	                               sInAlarmDevice := 'UZ2304',
	                               sInAlarmMessage := 'Not-Halt aktiv',
	                               sInAlarmSuffix := 'PF0247',
	                               wInTextListId_Function := 1,
	                               wInTextListId_Message := 0,
	                               stInOutHmiEstopPanel := "DB_Interface_HMI".arEStops[#c_UZ2304],
	                               stInOutControlUnitCabinet := #stInOutControlUnitCabinetOF4,
	                               xInAckReqLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2304.AckReq,
	                               xInEstopOkLocal := "DB_InterfaceSafety".stFromSafety.EStopUZ2304.Q);
	                               // xOutLed => "PF0247");
	        
	        "PF0247" := #arESTOPAck[#c_UZ2304].xOutLed OR
	        ("fbMain_DB".TRO257.xOutUnloadingError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbEncoderMonitor1304.xOutError AND "Clock_1Hz") OR
	        ("fbMain_DB".fbPinControl1304_2.xOutErrorRasterSensor AND "Clock_1Hz") OR "SF0003";
	        
	    END_REGION
	    
	END_REGION
END_FUNCTION_BLOCK

