Receiving message monitor point updates, Example message monitor point event handler – Echelon LNS User Manual

Page 240

Advertising
background image

LNS Programmer's Guide

226

To monitor messages that begin with a specific message code, set the

FilterByCode

monitoring options property to True, and the

FilterCode

property to the message code

to be monitored when you set the monitoring options for the monitor set.

To recap this discussion, follow these steps to monitor messages:

1. Create a monitor set, and add monitor points for the message tags you

want to monitor. For more information on these tasks, see Creating

Monitor Sets on page 194, and Managing Monitor Sets on page 195.

2. Connect one or more devices to the host PC, and add corresponding

message monitor points to the monitor set as described in the Adding
Message Monitor Points to a Monitor Set
section on page 197. In the case

where a remote device propagates an explicitly addressed message with

an appropriate destination address, no such connection will be required.

3. Open and enable the monitor set, as described in Opening and Enabling

Monitor Sets on page 213.

4. Use

the

OnMsgMonitorPointUpdateEvent

event to monitor the

message monitor points. An example event handler for the

OnMsgMonitorPointUpdateEvent

event is shown below.

Receiving Message Monitor Point Updates

Once you have opened and enabled your message monitor points, your application will

begin receiving

OnMsgMonitorPointUpdateEvent

events each time a message is sent

to the monitored devices via your message tags. The

OnMsgMonitorPointUpdateEvent

event returns the message monitor point that caused the event to be fired, and a

SourceAddress

object identifying the device containing the message point. It also

returns two

DataPoint

objects:

inputDataPoint

and

outputDataPoint

.

inputDataPoint

contains the information that was received from the monitored point.

If the incoming message is a request message, you can use the

outputDataPoint

parameter to return a response.

Note that Echelon discourages using the

SourceAddress

object to identify the source of

a message. It is more efficient to set the FilterByAddress property of the message tag

to True, and rely on the message tag to identify the sending device.

Example Message Monitor Point Event Handler

The following code example shows how the OnMsgMonitorPointUpdateEvent could be

used to return data to an external device that requested such data using the
request/response messaging service This event handler checks the name of the message

monitor point to determine which device sent the message, and if the message is a

request it then sends a response to the request.

Note that by using the

OnMsgMonitorPointUpdateEvent

event as described in these

sections, you will receive the events through the LNS Object Server. If your development

environment supports multi-threading, you can use the
ILcaMsgMonitorPointListener interface to receive the events directly from the

message monitor point. For more information on this, see Tracking Monitor Point

Updates on page 228.

Advertising