FUNCTION "FC_Send_BRRespM" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      sInPLCID : String;   // Steuerungsinfo (welche CPU)
      nInBarcode : DInt;   // Barcode 
      nInReasonCode : Int;   // Reason Code
      nInBufferLaneId : Int;
      nInStoreGroup : DInt;
   END_VAR

   VAR_IN_OUT 
      FIFO : "LGF_FIFO";
      BUFFER : Variant;
      nInOutSequenceNumber : LInt;
   END_VAR

   VAR_TEMP 
      empty : "UDT_TelegramData_Send";
      xSuccess : Bool;
      message : "UDT_TelegramData_Send";
      sBarcode : String;
      sReasonCode : String;
      sBufferLaneId : String;
      sStoreGroup : String;
   END_VAR

   VAR CONSTANT 
      cMessageType : String := 'BRRespM';
   END_VAR


BEGIN
	REGION Umwandeln
	    #sBarcode := DELETE(IN := DINT_TO_STRING(#nInBarcode), L := 1, P := 1);
	    #sReasonCode := DELETE(IN := INT_TO_STRING(#nInReasonCode), L := 1, P := 1);
	    #sBufferLaneId := DELETE(IN := INT_TO_STRING(#nInBufferLaneId), L := 1, P := 1);
	    #sStoreGroup := DELETE(IN := DINT_TO_STRING(#nInStoreGroup), L := 1, P := 1);
	END_REGION
	
	REGION Nachrichtenfelder
	    #message.nDataCount := 8;
	    #message.arDataString[1] := #sInPLCID;
	    #message.arDataString[2] := "FC_SequenceNumber"(#nInOutSequenceNumber);
	    #message.arDataString[3] := #cMessageType;
	    #message.arDataString[4] := #sStoreGroup;
	    #message.arDataString[5] := #sBarcode;
	    #message.arDataString[6] := #sBufferLaneId;
	    #message.arDataString[7] := #sReasonCode;
	    #message.arDataString[8] := CONCAT(IN1 := "FC_DateAsString_ISO"(), IN2 := ' ', IN3 := "FC_TimeAsString_ISO"());
	END_REGION
	
	REGION Senden
	    "FC_FIFO_Append"(DataIn := #message,
	                       InitialItem := #empty,
	                       MaxNo := 100,
	                       Success => #xSuccess,
	                       fifoBuffer := #FIFO,
	                       buffer := #BUFFER);
	END_REGION
END_FUNCTION

