FUNCTION_BLOCK "FB_EventLog_Booking"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      xInTrigger : Bool;
      stInEventBookingInfo : "stEventBookingInfo";
   END_VAR

   VAR 
      fbPaEventLogBooking {InstructionName := 'Program_Alarm'; LibVersion := '1.0'} : Program_Alarm;
      wStatus : Word;
      sLogMessage : String;
      sDelimiter : String[1] := ',';
      sFunction : String[10];
      xTriggerFlag : Bool;
   END_VAR

   VAR_TEMP 
      xError : Bool;
      tRunProgramAlarm : Bool;
   END_VAR


BEGIN
	REGION Call: Program Alarm
	    IF #xTriggerFlag XOR #xInTrigger THEN
	        
	        REGION Meldetext
	            #sDelimiter := ';';
	            #sFunction := 'Umbuchung';
	            #sLogMessage := CONCAT_STRING(IN1 := "FC_DateAsString"(),
	                                          IN2 := #sDelimiter,
	                                          IN3 := "FC_TimeAsString"(),
	                                          IN4 := #sDelimiter,
	                                          IN5 := #sFunction,
	                                          IN6 := #sDelimiter,
	                                          IN7 := 'Carrier(',
	                                          IN8 := 'Barcode:',
	                                          IN9 := #stInEventBookingInfo.sBarcode,
	                                          IN10 := #sDelimiter,
	                                          IN11 := 'JobNo:',
	                                          IN12 := #stInEventBookingInfo.sJobNo,
	                                          IN13 := #sDelimiter,
	                                          IN14 := 'ProdNo:',
	                                          IN15 := #stInEventBookingInfo.sProductNo,
	                                          IN16 := #sDelimiter,
	                                          IN17 := 'Dest:',
	                                          IN18 := #stInEventBookingInfo.sDest,
	                                          IN19 := ')',
	                                          IN20 := ' von ',
	                                          IN21 := #stInEventBookingInfo.sJamSrc,
	                                          IN22 := ' zu ',
	                                          IN23 := #stInEventBookingInfo.sJamDest,
	                                          IN24 := ' gebucht');
	        END_REGION
	        
	        #fbPaEventLogBooking(SIG := #xInTrigger,
	                             SD_1 := #sLogMessage,
	                             Status => #wStatus,
	                             Error => #xError);
	    END_IF;
	END_REGION
	
	REGION Flanken
	    #xTriggerFlag := #xInTrigger;
	END_REGION
END_FUNCTION_BLOCK

