FunctionPrintMessagePLCopen motion iconPipe Network motion icon

Description

The PrintMessage block is used to generate a log message with any wanted strings in the Log Messages window.

About the Source

PrintMessage uses the SYSTEM message type. So, to display all messages generated by PrintMessage, go to the log configuration and select the specified level for the SYSTEM source.

About the 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).

Keep in mind that only Error and Critical messages a generated by default. If you want to force the system to generate every message level, go into the log configuration and change the settings to the desired level.

Arguments

Input

Level Description Level of the logged message. In other words, its importance. Keep in mind that not all messages are displayed in the log windows by default. Only Error and Critical messages are displayed by default. Change the log settings to display a lower level. PrintMessage logs SYSTEM messages.
  Data type DINT
  Range

[0 , 4]

Defines are: LEVEL_DEBUG, LEVEL_INFO, LEVEL_WARNING, LEVEL_ERROR, LEVEL_CRITICAL

  Unit n/a
  Default
Message Description Content of the message. A string of 255 characters maximum.
  Data type String
  Range 1 to 255 characters
  Unit n/a
  Default

Output

Default (.Q)

Description Returns true when function successfully executes

See more details here

  Data type BOOL
  Unit n/a

Usage

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

Example

Structured Text

// 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 directly in the function call:
PrintMessage( LEVEL_CRITICAL, CONCAT( 'MachineState=', ANY_TO_STRING(MachineState), '. MachineSpeed=', ANY_TO_STRING(MachineSpeed) ) );

 

Function Block Diagram

PrintMessage: FBD example

FFLD

Go back to the top of the page [Top]