FB_AdsLogStringMessageFifoQueue  Function Block

This function block is responsible for making sure that the ADSLOGSTR-messages to the ADS-router are transmitted cyclically and not in a burst. The reason this is necessary is because that if too many messages are sent at the same time some get lost and are never printed to the error list output


Variables

Name Type Default Description
ArrayBuffer ARRAY[0..((GVL_Param_TcUnit.AdsLogMessageFifoRingBufferSize * (SIZEOF(ST_ADSLogStringMessage) + MEM_RING_BUFFER_INTERNAL_USE_PER_DATA_RECORD)) - 1)] OF BYTE
MemRingBuffer FB_MemRingBuffer
TimerBetweenMessages TON (IN := TRUE, PT := TIME_BETWEEN_MESSAGES)
MEM_RING_BUFFER_INTERNAL_USE_PER_DATA_RECORD USINT 4
TIME_BETWEEN_MESSAGES TIME T#10MS
MessageToBeSent ST_AdsLogStringMessage
ErrorGet BOOL
ReturnValue DINT

Methods

GetAndRemoveLogFromQueue PRIVATE

Reads and removes the oldest message

Outputs

Name Type Description
AdsLogStringMessage ST_ADSLogStringMessage
Error BOOL Buffer empty
Implementation
MemRingBuffer.A_RemoveHead(pRead := ADR(AdsLogStringMessage),
                           cbRead := SIZEOF(ST_ADSLogStringMessage),
                           pBuffer := ADR(ArrayBuffer),
                           cbBuffer := SIZEOF(ArrayBuffer));
Error := NOT MemRingBuffer.bOk;
GetLogCount PRIVATE
Implementation
GetLogCount := MemRingBuffer.nCount;
WriteLog INTERNAL

Writes a new data set into the ring buffer

Parameters

Name Type Description
MsgCtrlMask DWORD
MsgFmtStr T_MaxString
StrArg T_MaxString

Outputs

Name Type Description
Error BOOL Buffer overflow
Implementation
// Only log message types of ERROR if log extended results is not enabled
IF MsgCtrlMask = ADSLOG_MSGTYPE_ERROR OR GVL_Param_TcUnit.LogExtendedResults THEN
    AdsLogStringMessage.MsgCtrlMask := MsgCtrlMask;
    AdsLogStringMessage.MsgFmtStr := MsgFmtStr;
    AdsLogStringMessage.StrArg := StrArg;

    MemRingBuffer.A_AddTail(pWrite := ADR(AdsLogStringMessage),
                            cbWrite := SIZEOF(ST_AdsLogStringMessage),
                            pBuffer := ADR(ArrayBuffer),
                            cbBuffer := SIZEOF(ArrayBuffer));

    Error := NOT MemRingBuffer.bOk;
END_IF

Used by

Declaration source
(* This function block is responsible for making sure that the ADSLOGSTR-messages to the ADS-router are transmitted
   cyclically and not in a burst. The reason this is necessary is because that if too many messages are sent at the
   same time some get lost and are never printed to the error list output
*)
FUNCTION_BLOCK FB_AdsLogStringMessageFifoQueue
VAR
    ArrayBuffer : ARRAY[0..((GVL_Param_TcUnit.AdsLogMessageFifoRingBufferSize * (SIZEOF(ST_ADSLogStringMessage) + MEM_RING_BUFFER_INTERNAL_USE_PER_DATA_RECORD)) - 1)] OF BYTE;
    MemRingBuffer : FB_MemRingBuffer;
    TimerBetweenMessages : TON := (IN := TRUE, PT := TIME_BETWEEN_MESSAGES);
END_VAR
VAR CONSTANT
    MEM_RING_BUFFER_INTERNAL_USE_PER_DATA_RECORD : USINT := 4;
    TIME_BETWEEN_MESSAGES : TIME := T#10MS;
END_VAR
VAR_TEMP
    MessageToBeSent : ST_AdsLogStringMessage;
    ErrorGet : BOOL;
    ReturnValue : DINT;
END_VAR