Using the onsystemnssidleevent, Developing remote tools – Echelon LNS User Manual

Page 330

Advertising
background image

LNS Programmer's Guide

316

should never be updated, as this defines the application interface. The configuration
property value file must be updated with ConfigProperty objects or with the
DownloadConfigProperties() method to ensure that the LNS database is kept in

synch with the values in the configuration value file. For more information on this, see
Downloading and Uploading Configuration Properties
on page 126.

Using the OnSystemNssIdleEvent

You can use the OnSystemNssIdle event to allow your application to execute code while

the LNS Server is busy completing an operation. This event is useful for refreshing

displays, and for providing a cancel option for operations that take a long time.

Call the System object’s BeginNssIdleEvent() method to enable OnSystemNssIdle

events. This method takes a single parameter that specifies the maximum number of
milliseconds between calls to the OnSystemNssIdle event handler. This event will then

be fired at that interval while your application is waiting for lengthy network operations

to complete. Instances of this event will be returned synchronously, and if your
application does not handle the event in a timely manner, then your application may

hang.

This event may be useful during any lengthy operation, such as when you change the
value of the MgmtMode property from lcaMgmtModeDeferConfigUpdates to
lcaMgmtModePropagateConfigUpdates, if you are loading a device’s application

image, or if you are commissioning a device. The main thread of your application will

need to wait for these operations to complete before moving on, so you could use this
event to refresh your client application’s display, so that the user knows it is not stuck.

However, your application should be prepared to use this event at any time. Even a

simple modification that does not normally consume a large amount of time may be held
up because of a lengthy transaction started by another LNS application.

The LNS calls you can make from within the handler for this event are limited to the
following. You can access the ServiceStatus property to determine the status of the

service LNS is trying to perform. If a transaction is taking too long for LNS to execute,
you can cancel it by calling the CancelTransaction() method from the event handler.

Or, if you are performing a network recovery, you could access the RecoveryStatus

property from the event handle to determine the status of the network recovery.

You could also use an event handler for the OnSystemNssIdle event to refresh your

application display. For example, Visual Basic will sometimes partially erase a form

while the Object Server is busy. To prevent this, the following Visual Basic example
implements an OnSystemNssIdle event handler that calls the Refresh() method for

the active form.
Private Sub lcaOS_OnSystemNssIdle()

Screen.ActiveForm.Refresh
End Sub

To turn off idle events, call the System object’s EndNssIdleEvent() method.

Developing Remote Tools

All LNS applications should be designed to support both local and remote operation.

Since remote operations may take more time to complete than local operations, your

Advertising