Messaging
- Namespace
- ZApplication
- Implements
FUNCTION_BLOCK Messaging IMPLEMENTS ZCore.ILogger, ZCore.ILoggerFluentApi, ZCore.ILoggerImperativeApi, ZCore.ILoggerBase
This function block is meant to send messages to an external application (i.e. HMI) from the PLC. It has to be used together with a communication struct, which in turn is evaluated by the external application. The function block uses a ringbuffer to store messages, which allows to read and write at the same time. Provided that the external application is "fast enough" no messages should get lost because of this buffering mechanism.
Constructor
FB_init
METHOD FB_init (
[input] bInitRetains : BOOL,
[input] bInCopyCode : BOOL,
[input] parent : ZCore.IManagedObject,
[input] datetime : ZCore.IDateTime,
[input] com : REFERENCE TO MessagingCom) : BOOL
Inputs
bInitRetainsBOOLif TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCodeBOOLif TRUE, the instance afterwards gets moved into the copy code (online change)
parentIManagedObjectdatetimeIDateTimecomREFERENCE TO MessagingCom
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
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
AtDebug
METHOD AtDebug () : ZCore.ILoggerFluentAtLevel
Initiates logging a message fluently with log-severity level Debug if the severity level applies.
logger.AtDebug().LogMessage('hello world');
A Debug message is less granular compared to the trace level, but it is more than you will need in everyday use. The debug log level should be used for information that may be needed for diagnosing issues and troubleshooting or when running an application in a test environment for the purpose of making sure everything is running correctly. For more information about this loglevel, see sematext.
Returns
AtError
METHOD AtError () : ZCore.ILoggerFluentAtLevel
Initiates logging a message fluently with log-severity level Error if the severity level applies.
logger.AtError().LogMessage('hello world');
The error level should be used when the application hits an issue preventing one or more functionalities from properly functioning. For instance, if a servo-motor can not reach its desired position or if a sudden pneumatic pressure drop occurs. For more information about this loglevel, see sematext.
Returns
AtFatal
METHOD AtFatal () : ZCore.ILoggerFluentAtLevel
Initiates logging a message fluently with log-severity level Fatal if the severity level applies.
logger.AtFatal().LogMessage('hello world');
The error level should be used when the application hits errors that stop the booting process or other hardward related issues (device that is disconnected while using, fieldbus interruptions, ...). For more information about this loglevel, see sematext.
Returns
AtInfo
METHOD AtInfo () : ZCore.ILoggerFluentAtLevel
Initiates logging a message fluently with log-severity level Info if the severity level applies.
logger.AtInfo().LogMessage('hello world');
Info is the standard log level and is indicating that something happened, i.e. the application entered a certain state For instance, an operator of your production system starts the automatic sequence and this can be logged as info if it was successfull or not. The information logged using the info log level should be purely informative and not looking into them on a regular basis shouldn’t result in missing any important information. For more information about this loglevel, see sematext.
Returns
AtTrace
METHOD AtTrace () : ZCore.ILoggerFluentAtLevel
Initiates logging a message fluently with log-severity level Trace if the severity level applies.
logger.AtTrace().LogMessage('hello world');
Trace is the most fine-grained information only used in rare cases where you need the full visibility of what is happening in your application and inside the third-party libraries that you use. You can expect the trace logging level to be very verbose. You can use it for example to annotate each step in a sequence or extra entries in different if branches. For more information about this loglevel, see sematext.
Returns
AtWarning
METHOD AtWarning () : ZCore.ILoggerFluentAtLevel
Initiates logging a message fluently with log-severity level Warning if the severity level applies.
logger.AtWarning().LogMessage('hello world');
A warning indicates that something unexpected happened in the application, a problem, or a situation that might disturb one of the processes. But that doesn’t mean that the application failed or the production system had to be stopped. The warning log level should be used in situations that are unexpected, but the code can continue the work. For example, an electric motor (servo) has two levels for overheating. A warning temperature and a temperature were it is very likely that it will soon get broken. For more information about this loglevel, see sematext.
Returns
Debug
METHOD Debug (
[input] text : ZCore.ZString)
Logs a message to the logger with log-severity level Debug if the severity level applies.
A Debug message is less granular compared to the trace level, but it is more than you will need in everyday use. The debug log level should be used for information that may be needed for diagnosing issues and troubleshooting or when running an application in a test environment for the purpose of making sure everything is running correctly. For more information about this loglevel, see sematext.
Inputs
textZString
Error
METHOD Error (
[input] text : ZCore.ZString)
Logs a message to the logger with log-severity level Error if the severity level applies.
The error level should be used when the application hits an issue preventing one or more functionalities from properly functioning. For instance, if a servo-motor can not reach its desired position or if a sudden pneumatic pressure drop occurs. For more information about this loglevel, see sematext.
Inputs
textZString
Fatal
METHOD Fatal (
[input] text : ZCore.ZString)
Logs a message to the logger with log-severity level Trace if the severity level applies.
Trace is the most fine-grained information only used in rare cases where you need the full visibility of what is happening in your application and inside the third-party libraries that you use. You can expect the trace logging level to be very verbose. You can use it for example to annotate each step in a sequence or extra entries in different if branches. For more information about this loglevel, see sematext.
Inputs
textZString
Info
METHOD Info (
[input] text : ZCore.ZString)
Logs a message to the logger with log-severity level Info if the severity level applies.
Info is the standard log level and is indicating that something happened, i.e. the application entered a certain state For instance, an operator of your production system starts the automatic sequence and this can be logged as info if it was successfull or not. The information logged using the info log level should be purely informative and not looking into them on a regular basis shouldn’t result in missing any important information. For more information about this loglevel, see sematext.
Inputs
textZString
LogMessageRef
METHOD LogMessageRef (
[input] timestamp : ULINT,
[input] text : REFERENCE TO ZCore.ZString,
[input] logLevel : ZCore.LogLevel)
Inputs
timestampULINTtextREFERENCE TO ZStringmessage as string from type ZCore.ZString
logLevelLogLeveldesired Loglevel after Apache log4j LogLevelStandard
Trace
METHOD Trace (
[input] text : ZCore.ZString)
Logs a message to the logger with log-severity level Trace if the severity level applies.
Trace is the most fine-grained information only used in rare cases where you need the full visibility of what is happening in your application and inside the third-party libraries that you use. You can expect the trace logging level to be very verbose. You can use it for example to annotate each step in a sequence or extra entries in different if branches. For more information about this loglevel, see sematext.
Inputs
textZString
Warning
METHOD Warning (
[input] text : ZCore.ZString)
Logs a message to the logger with log-severity level Warning if the severity level applies.
A warning indicates that something unexpected happened in the application, a problem, or a situation that might disturb one of the processes. But that doesn’t mean that the application failed or the production system had to be stopped. The warning log level should be used in situations that are unexpected, but the code can continue the work. For example, an electric motor (servo) has two levels for overheating. A warning temperature and a temperature were it is very likely that it will soon get broken. For more information about this loglevel, see sematext.
Inputs
textZString