PrintMessage

PLCopen motion icon Pipe Network motion icon

 FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. - Generates a log message with any wanted strings in the Log Messages tabs window.

Inputs

Input

Data Type

Range

Unit

Default

Description

Level

DINT

0, 4

N/A

No default

Level of the logged message (i.e., it's importance).

  • By default, not all messages are shown in the log windows.
  • Only Error and Critical messages are shown.
  • Change the log settings to display a lower level.
  • PrintMessage logs SYSTEM messages.

The Range defines are:

  • 0 = LEVEL_DEBUG
  • 1 = LEVEL_INFO
  • 2 = LEVEL_WARNING
  • 3 = LEVEL_ERROR
  • 4 = LEVEL_CRITICAL

Message

STRING

1 - 255

 

 

Content of the message.

The string is a maximum of 255 characters.

Outputs

Output

Data Type

Range

Unit

Description

Default (.Q)

BOOL

 

N/A

Returns TRUE when the function successfully executes.

See Pipe Network - General Rules.

Remarks

Source

PrintMessage uses the SYSTEM message type.

To view all messages generated by PrintMessage, go to the log configuration and select the specified level for the SYSTEM source.

Level

The message could be sent with a logging level from 0 to 4 that qualifies its importance.

  • The highest level, 4, logs critical messages.
    • Available levels are: Debug, Informational, Warning, Error, and Critical.
  • Only Error and Critical messages a generated by default.
    • To force the system to generate every message level, use the Configuration Settings to change the settings to the desired level.

Usage

PrintMessage(  LEVEL_DEBUG, 'Message string to be logged' );

FBD Language Example

FFLD Language Example

IL Language Example

Not available.

ST Language Example

            // It's possible to create a temporary variable with the message.
            

MESSAGE := CONCAT( 'MachineState=', ANY_TO_STRING(MachineState), '. MachineSpeed=', ANY_TO_STRING(MachineSpeed) );



// Then print the message to the log window

PrintMessage( LEVEL_INFO, MESSAGE );

PrintMessage( LEVEL_WARNING, MESSAGE );

PrintMessage( LEVEL_ERROR, MESSAGE );



// Or to create the string directlyClosed The orientation components of a vector in space. in the function call:

PrintMessage( LEVEL_CRITICAL, CONCAT( 'MachineState=', ANY_TO_STRING(MachineState), '. MachineSpeed=', ANY_TO_STRING(MachineSpeed) ) );