Table of Contents

RingBufferMessage

Namespace
ZAux
Extends
Inherited Properties
Inherited Methods
Implements
FUNCTION_BLOCK RingBufferMessage EXTENDS ZCore.RingBuffer IMPLEMENTS ZCore.ILoggerBase

This function block is doing all the managing work of a ringbuffer and is responsible for holding and managing the log entries for a logger. The memory for this ringbuffer and also the necessary datetime instance for adding an entry with a proper timestamp is instantiated external and provided at construction time through FB_init. For more information on how a Zeugwerk Ringbuffer works please refer to the documentation here

Constructor

FB_init

METHOD FB_init (
 [input] bInitRetains : BOOL,
 [input] bInCopyCode : BOOL,
 [input] bufferSize : DINT,
 [input] dataBuffer : POINTER TO Message) : BOOL

Here the initialization of the Ringbuffer is done by providing a pointer to the first entry of an actual instantiated Message Array. Its also necessary to provide the size of the memory. All this information is necessary in order to bring the RingBuffer up to work and therefore it has to be provided at construction time of the object

Inputs

bInitRetains BOOL

if TRUE, the retain variables are initialized (warm start / cold start)

bInCopyCode BOOL

if TRUE, the instance afterwards gets moved into the copy code (online change)

bufferSize DINT

size of the buffer, however the actual ringbuffer size is buffersize - 1

dataBuffer POINTER TO Message

Pointer to the first entry of a data buffer which holds all the log entries

Returns

BOOL

Properties

MinimumLevel

PROPERTY MinimumLevel : ZCore.LogLevel

Sets the threshold of logged messages. Logging messages, which have the same severity level or higher will be emitted handled by the logger (others are ignored). The default value for MinimumLevel, which is used when this method is not used to overwrite it, can be parametrized with a library parameter. The MinimumLevel, which is set with this property is for instance only, if the minimum loglevel should be controlled globally for all loggers used in an application, use MinimumLevelRef

Note

Calling this method will unlink the logger instance from the pointer that has been passed with SetLevelRef The Logger uses whatever method was called last.

Property Value

LogLevel

MinimumLevelRef

PROPERTY MinimumLevelRef : REFERENCE TO ZCore.LogLevel

Sets the threshold of logged messages to logLevelRef^. Since the passed value is a reference, it can be changed at any time externally and be shared over several loggers. Logging messages which have the same severity level or higher will be emitted handled by the logger (others are ignored). The default value for logLevel, which is used when this method is not used to overwrite it, can be parametrized with a library parameter.

Note

Calling this method will not effect the logLevel that has been set with MinimumLevel. The Logger uses whatever method was called last.

Property Value

REFERENCE TO LogLevel

Methods

Clear

METHOD Clear ()

FirstItemRef

METHOD FirstItemRef () : REFERENCE TO Message

returns a reference to the data of the first item in the buffer

Returns

REFERENCE TO Message

ItemAt

METHOD ItemAt (
 [input] pos : DINT) : Message

returns the RingBuffer entry at the given specific position (by pos) in the circular buffer by value

Inputs

pos DINT

index given relative to the actual head; idx=1 returns head value

Returns

Message

ItemRefAt

METHOD ItemRefAt (
 [input] pos : DINT) : REFERENCE TO Message

returns a reference on the entry at the given specific position (by pos) in the circular buffer

Inputs

pos DINT

index given relative to the actual head; idx=1 returns head value

Returns

REFERENCE TO Message

LogMessageRef

METHOD LogMessageRef (
 [input] timestamp : ULINT,
 [input] text : REFERENCE TO ZCore.ZString,
 [input] logLevel : ZCore.LogLevel)

This method inserts a new entry into the buffer, increments the index and adds a timestamp if necessary. The latter is only done, if there is a datetime instance given at construction time and the given timestamp is zero.

Inputs

timestamp ULINT

Unix timestamp of the running PLC target in 1ms resolution, if zero and a datetime object is set the timestamp will be retrieved from the datetime object

text REFERENCE TO ZString

message as ASCII text which has to be stored inside the buffer

logLevel LogLevel

LogLevel based on Apache log4j

SetDateTime

METHOD SetDateTime (
 [input] intrf : ZCore.IDateTime)

Sets a Zeugwerk compatible DateTime function block that is used by the predefined logging-methods to automatically fill the timestamp property of a log message. If intrf=0 and no timestamp is provided by the Append method, the timestamp of every message that is logged is 0.

Inputs

intrf IDateTime

Interface to an instantiated Zeugwerk Framework compatible DateTime function block