ADSLOGDINT

When called, the function outputs a message box with a predefinable text to the screen and writes an entry to the system's event log. As PLC programs are processed cyclically, it is necessary for items such as message boxes to be output edge-triggered. This is most easily achieved with an R_TRIG or F_TRIG function block placed in series (see also samples below).
Using the ADSLOGDINT function, a DINT value (4-byte signed integer) can be inserted in the text to be output at a point specified by the user. For this purpose, the created format string must contain the string %d at the desired position. The return parameter contains the function error code, or 0 if successful.
FUNCTION ADSLOGDINT : DINT
Inputs
VAR_INPUT
msgCtrlMask : DWORD;
msgFmtStr : T_MaxString;
dintArg : DINT;
END_VAR
Name | Type | Description |
---|---|---|
msgCtrlMask | DWORD | Control mask which determines the type and effect of the message output (see separate table). |
msgFmtStr | Contains the message to be output. It can contain the formatting character %d for the output of a DINT value at any position. Information: The length of the message is limited to 253 bytes (corresponds to 253 characters for strings in standard format). | |
dintArg | DINT | Contains the numerical value to be inserted into the message. |
Constant | Description |
---|---|
ADSLOG_MSGTYPE_HINT | Message type is hint. |
ADSLOG_MSGTYPE_WARN | Message type is warning. |
ADSLOG_MSGTYPE_ERROR | Message type is error. |
ADSLOG_MSGTYPE_LOG | Message is written into the log. |
ADSLOG_MSGTYPE_MSGBOX | Message is output in a message box. |
ADSLOG_MSGTYPE_STRING | Message is a directly given string (default). |
The control masks can be ORed in the desired combination.
Example of calling the function in FBD:

The resulting message box:

The DINT value 4711 is inserted here into a message. The insertion point is marked by the %d characters in the format string.
Example of calling the function in ST:
PROGRAM MAIN
VAR
rtMessageOutput: R_TRIG; (* Declaration *)
bFeedTooHigh: BOOL;
udiAdsLogRes: UDINT;
END_VAR
rtMessageOutput(CLK := bFeedTooHigh);
IF rtMessageOutput.Q THEN
UdiAdsLogRes := ADSLOGDINT( msgCtrlMask := ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_MSGBOX,
msgFmtStr := 'PLC Msg: Feed too high! Current feed: %d', dintArg:= 4711);
END_IF
Prerequisites
Development Environment | Target platform | PLC libraries to be integrated (category group) |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, Arm®) | Tc2_System (system) |