Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

MsgState

  • Last UpdatedJul 18, 2023
  • 1 minute read

Verifies the status of a message session. Use MsgState() to check the return value of MsgOpen(). A message post function is set effectively only if MsgState() returns 1, which means the message session is online.

Syntax

MsgState(hMsg)

hMsg:

The message handle, returned from the MsgOpen() function. The message handle identifies the table where all data on the associated message is stored.

Return Value

This function has the following possible return values:

  • -1 if the message session handle is invalid

  • 0 if the message session is offline

  • 1 if the message session is online

  • 2 if the message session is connecting

  • 3 if the message session is disconnecting.

MsgOpen

Example

INT hClient = -1;

// Open message session on the client, connecting using the
existing

// message session to the current Alarm server

FUNCTION

MsgClientOpen()

INT nState;

hClient = MsgOpen("Alarm", 0, MsgPostClient);

IF hClient <> -1 THEN

nState = MsgState(hClient);

SELECT CASE nState

CASE 1

Prompt("Message session is online!");

//Send a message to the server

MsgWrite(hClient, 1, "MyMessage");

CASE -1

Prompt("Message session handle is invalid!");

CASE 0

Prompt("Message session is offline!");

CASE 2

Prompt("Message session is connecting!");

CASE 3

Prompt("Message session is disconnecting!");

CASE ELSE

Prompt("Message session has unknown status!");

END SELECT

ELSE

Prompt("Message session could not be opened!");

END

END

See Also

Task Functions

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in