FUNCTION_BLOCK "FB_BarcodeReader"
{ S7_Optimized_Access := 'FALSE' }
AUTHOR : 'e.yueksel'
VERSION : 0.1
//Aufrufe Barcode-Reader
   VAR 
      fbBarcodeReaderBX7100 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7101 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7102 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7103 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7104 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7105 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7106 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7107 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7108 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7109 : "FB_BarcodeReaderCognex";
      fbBarcodeReaderBX7112 : "FB_BarcodeReaderCognex";
      stCognexInterface : Struct
         BX7100 : "stCognexInterface";
         BX7101 : "stCognexInterface";
         BX7102 : "stCognexInterface";
         BX7103 : "stCognexInterface";
         BX7104 : "stCognexInterface";
         BX7105 : "stCognexInterface";
         BX7106 : "stCognexInterface";
         BX7107 : "stCognexInterface";
         BX7108 : "stCognexInterface";
         BX7109 : "stCognexInterface";
         BX7112 : "stCognexInterface";
      END_STRUCT;
      stHMI : Struct
         stBarcodeReader : Struct
            BX7100 : "UDT_BarcodeReader";
            BX7101 : "UDT_BarcodeReader";
            BX7102 : "UDT_BarcodeReader";
            BX7103 : "UDT_BarcodeReader";
            BX7104 : "UDT_BarcodeReader";
            BX7105 : "UDT_BarcodeReader";
            BX7106 : "UDT_BarcodeReader";
            BX7107 : "UDT_BarcodeReader";
            BX7108 : "UDT_BarcodeReader";
            BX7109 : "UDT_BarcodeReader";
            BX7112 : "UDT_BarcodeReader";
         END_STRUCT;
      END_STRUCT;
      stMainState : "IntfMainState";
   END_VAR


BEGIN
	    REGION Barcode Reader - BX7100        
	        #stCognexInterface.BX7100.xInCamTriggerReady := "bx7100-TriggerReady";
	        #stCognexInterface.BX7100.xInCamTriggerAck := "bx7100-TriggerAck";
	        #stCognexInterface.BX7100.xInCamResultsAvailable := "bx7100-Results Available";
	        #stCognexInterface.BX7100.xInCamGeneralFault := "bx7100-General Fault";
	        #stCognexInterface.BX7100.hwInCamInspectionResults := "=A01+UC07103-BX7100~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7100(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7100,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7100);
	        
	        "bx7100-TriggerEnable" := #stCognexInterface.BX7100.xOutCamTriggerEnable;
	        "bx7100-Trigger" := #stCognexInterface.BX7100.xOutCamTrigger;
	        "bx7100-ResultsAck" := #stCognexInterface.BX7100.xOutCamResultsAck;
	        
	    END_REGION
	    
	    REGION Barcode Reader - BX7101       
	        #stCognexInterface.BX7101.xInCamTriggerReady := "bx7101-TriggerReady";
	        #stCognexInterface.BX7101.xInCamTriggerAck := "bx7101-TriggerAck";
	        #stCognexInterface.BX7101.xInCamResultsAvailable := "bx7101-Results Available";
	        #stCognexInterface.BX7101.xInCamGeneralFault := "bx7101-General Fault";
	        #stCognexInterface.BX7101.hwInCamInspectionResults := "=A01+UC07103-BX7101~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7101(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7101,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7101);
	        
	        "bx7101-TriggerEnable" := #stCognexInterface.BX7101.xOutCamTriggerEnable;
	        "bx7101-Trigger" := #stCognexInterface.BX7101.xOutCamTrigger;
	        "bx7101-ResultsAck" := #stCognexInterface.BX7101.xOutCamResultsAck;
	        
	    END_REGION
	    
	    REGION Barcode Reader - BX7102        
	        #stCognexInterface.BX7102.xInCamTriggerReady := "bx7102-TriggerReady";
	        #stCognexInterface.BX7102.xInCamTriggerAck := "bx7102-TriggerAck";
	        #stCognexInterface.BX7102.xInCamResultsAvailable := "bx7102-Results Available";
	        #stCognexInterface.BX7102.xInCamGeneralFault := "bx7102-General Fault";
	        #stCognexInterface.BX7102.hwInCamInspectionResults := "=A01+UC07103-BX7102~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7102(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7102,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7102);
	        
	        "bx7102-TriggerEnable" := #stCognexInterface.BX7102.xOutCamTriggerEnable;
	        "bx7102-Trigger" := #stCognexInterface.BX7102.xOutCamTrigger;
	        "bx7102-ResultsAck" := #stCognexInterface.BX7102.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7103        
	        #stCognexInterface.BX7103.xInCamTriggerReady := "bx7103-TriggerReady";
	        #stCognexInterface.BX7103.xInCamTriggerAck := "bx7103-TriggerAck";
	        #stCognexInterface.BX7103.xInCamResultsAvailable := "bx7103-Results Available";
	        #stCognexInterface.BX7103.xInCamGeneralFault := "bx7103-General Fault";
	        #stCognexInterface.BX7103.hwInCamInspectionResults := "=A01+UC07103-BX7103~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7103(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7103,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7103);
	        
	        "bx7103-TriggerEnable" := #stCognexInterface.BX7103.xOutCamTriggerEnable;
	        "bx7103-Trigger" := #stCognexInterface.BX7103.xOutCamTrigger;
	        "bx7103-ResultsAck" := #stCognexInterface.BX7103.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7104        
	        #stCognexInterface.BX7104.xInCamTriggerReady := "bx7104-TriggerReady";
	        #stCognexInterface.BX7104.xInCamTriggerAck := "bx7104-TriggerAck";
	        #stCognexInterface.BX7104.xInCamResultsAvailable := "bx7104-Results Available";
	        #stCognexInterface.BX7104.xInCamGeneralFault := "bx7104-General Fault";
	        #stCognexInterface.BX7104.hwInCamInspectionResults := "=A01+UC07103-BX7104~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7104(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7104,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7104);
	        
	        "bx7104-TriggerEnable" := #stCognexInterface.BX7104.xOutCamTriggerEnable;
	        "bx7104-Trigger" := #stCognexInterface.BX7104.xOutCamTrigger;
	        "bx7104-ResultsAck" := #stCognexInterface.BX7104.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7105       
	        #stCognexInterface.BX7105.xInCamTriggerReady := "bx7105-TriggerReady";
	        #stCognexInterface.BX7105.xInCamTriggerAck := "bx7105-TriggerAck";
	        #stCognexInterface.BX7105.xInCamResultsAvailable := "bx7105-Results Available";
	        #stCognexInterface.BX7105.xInCamGeneralFault := "bx7105-General Fault";
	        #stCognexInterface.BX7105.hwInCamInspectionResults := "=A01+UC07103-BX7105~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7105(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7105,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7105);
	        
	        "bx7105-TriggerEnable" := #stCognexInterface.BX7105.xOutCamTriggerEnable;
	        "bx7105-Trigger" := #stCognexInterface.BX7105.xOutCamTrigger;
	        "bx7105-ResultsAck" := #stCognexInterface.BX7105.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7106        
	        #stCognexInterface.BX7106.xInCamTriggerReady := "bx7106-TriggerReady";
	        #stCognexInterface.BX7106.xInCamTriggerAck := "bx7106-TriggerAck";
	        #stCognexInterface.BX7106.xInCamResultsAvailable := "bx7106-Results Available";
	        #stCognexInterface.BX7106.xInCamGeneralFault := "bx7106-General Fault";
	        #stCognexInterface.BX7106.hwInCamInspectionResults := "=A01+UC7401-BX7106~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7106(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7106,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7106);
	        
	        "bx7106-TriggerEnable" := #stCognexInterface.BX7106.xOutCamTriggerEnable;
	        "bx7106-Trigger" := #stCognexInterface.BX7106.xOutCamTrigger;
	        "bx7106-ResultsAck" := #stCognexInterface.BX7106.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7107        
	        #stCognexInterface.BX7107.xInCamTriggerReady := "bx7107-TriggerReady";
	        #stCognexInterface.BX7107.xInCamTriggerAck := "bx7107-TriggerAck";
	        #stCognexInterface.BX7107.xInCamResultsAvailable := "bx7107-Results Available";
	        #stCognexInterface.BX7107.xInCamGeneralFault := "bx7107-General Fault";
	        #stCognexInterface.BX7107.hwInCamInspectionResults := "=A01+UC7402-BX7107~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7107(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7107,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7107);
	        
	        "bx7107-TriggerEnable" := #stCognexInterface.BX7107.xOutCamTriggerEnable;
	        "bx7107-Trigger" := #stCognexInterface.BX7107.xOutCamTrigger;
	        "bx7107-ResultsAck" := #stCognexInterface.BX7107.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7108        
	        #stCognexInterface.BX7108.xInCamTriggerReady := "bx7108-TriggerReady";
	        #stCognexInterface.BX7108.xInCamTriggerAck := "bx7108-TriggerAck";
	        #stCognexInterface.BX7108.xInCamResultsAvailable := "bx7108-Results Available";
	        #stCognexInterface.BX7108.xInCamGeneralFault := "bx7108-General Fault";
	        #stCognexInterface.BX7108.hwInCamInspectionResults := "=A01+UC0701-BX7108~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7108(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7108,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7108);
	        
	        "bx7108-TriggerEnable" := #stCognexInterface.BX7108.xOutCamTriggerEnable;
	        "bx7108-Trigger" := #stCognexInterface.BX7108.xOutCamTrigger;
	        "bx7108-ResultsAck" := #stCognexInterface.BX7108.xOutCamResultsAck;
	        
	    END_REGION
	    REGION Barcode Reader - BX7109        
	        #stCognexInterface.BX7109.xInCamTriggerReady := "bx7109-TriggerReady";
	        #stCognexInterface.BX7109.xInCamTriggerAck := "bx7109-TriggerAck";
	        #stCognexInterface.BX7109.xInCamResultsAvailable := "bx7109-Results Available";
	        #stCognexInterface.BX7109.xInCamGeneralFault := "bx7109-General Fault";
	        #stCognexInterface.BX7109.hwInCamInspectionResults := "=A01+UC07301-BX7109~Ergebnisse_–_64_Bytes_1";
	        
	        #fbBarcodeReaderBX7109(xInActivateCheckASCI := TRUE,
	                               tInTimeout := T#5s,
	                               stInOutInterface := #stCognexInterface.BX7109,
	                               stInOutControlUnitCabinet := #stMainState,
	                               stInOutHMI := #stHMI.stBarcodeReader.BX7109);
	        
	        "bx7109-TriggerEnable" := #stCognexInterface.BX7109.xOutCamTriggerEnable;
	        "bx7109-Trigger" := #stCognexInterface.BX7109.xOutCamTrigger;
	        "bx7109-ResultsAck" := #stCognexInterface.BX7109.xOutCamResultsAck;
	        
	    END_REGION
	    
	    REGION Barcode Reader - BX7112        
	        // #stCognexInterface.BX7112.xInCamTriggerReady := "bx7112-TriggerReady";
	        // #stCognexInterface.BX7112.xInCamTriggerAck := "bx7112-TriggerAck";
	        // #stCognexInterface.BX7112.xInCamResultsAvailable := "bx7112-Results Available";
	        // #stCognexInterface.BX7112.xInCamGeneralFault := "bx7112-General Fault";
	        // #stCognexInterface.BX7112.hwInCamInspectionResults := "=A01+UC7102-BX7112~Ergebnisse_–_64_Bytes_1";
	        
	        // #fbBarcodeReaderBX7112(xInActivateCheckASCI := TRUE,
	        //                        tInTimeout := T#5s,
	        //                        stInOutInterface := #stCognexInterface.BX7112,
	        //                        stInOutControlUnitCabinet := #stMainState,
	        //                        stInOutHMI := #stHMI.stBarcodeReader.BX7112);
	        
	        // "bx7112-TriggerEnable" := #stCognexInterface.BX7112.xOutCamTriggerEnable;
	        // "bx7112-Trigger" := #stCognexInterface.BX7112.xOutCamTrigger;
	        // "bx7112-ResultsAck" := #stCognexInterface.BX7112.xOutCamResultsAck;
	        
	    END_REGION
	    
	    REGION SCADA
	        "FB-OPC_UA_System-Stat_DB"(xInSystemStat := "7_HMI_Err_UH07_OB".System.Anlage_aus,
	                                   xInFireAlarm := "7_HMI_Err_UH07_OB".System.BST1_Feueralarm OR "7_HMI_Err_UH07_OB".System.BST2_Feueralarm OR "7_HMI_Err_UH07_OB".System.Gesamt_Feueralarm_Halle3 OR "7_HMI_Err_UH07_OB".System.Gesamt_Feueralarm_Halle4,
	                                   xInSafetyStop := "7_HMI_Err_UH07_OB"."Not".UH07,
	                                   //"7_HMI_Err_UH07_OB"."NOT".ausgeloest_UH07_UC71_UC73 OR "7_HMI_Err_UH07_OB"."NOT".ausgeloest_UC072 OR "7_HMI_Err_UH07_OB"."NOT".ausgeloest_UC074,
	                                   xInError := "PF0031",
	                                   xInCommunicationError := false,//7NOT "FB_CommunicationWCSBL_DB".fbTeleHandler.xOutConnectionActive OR NOT "FB_CommunicationWES_ASRS_DB".fbTeleHandler.xOutConnectionActive,
	                                   nOutScadaStatus => "DB_Status".System.Status);
	    END_REGION
	    
	    
	    
	    
	    
	    
END_FUNCTION_BLOCK

