Using the onattachment event – Echelon LNS User Manual

Page 144

Advertising
background image

LNS Programmer's Guide

130

return the expected and actual values of the device attributes tested. If a test fails, the
AuxResultData property of the TestInfo object will indicate whether a Neuron ID,

domain ID, subnet/Node ID, or program ID mismatch caused the test to fail.

When you call Test() on a router, a router failure can result in failure reports for all of

the devices on channels that are accessed via the failed router. For more information on

routers and on router failures, see Managing Networks with Multiple Channels on page
169.

Note that it can take a significant amount of time to test a device, depending on the

complexity of the tests performed in the device's application. For more information on the
Test() method and the various properties of the TestInfo object, see the LNS Object

Server Reference Help File.

Using the OnAttachment Event

The Test() method causes several messages to be sent to a device. An alternative way

to test a device that requires fewer messages is for the LNS Server to automatically ping

devices using the LonTalk Query Status network diagnostic message. The LNS Object
Server will determine whether or not a device has become detached from the network if it

fails to respond to a ping, or if it returns an unexpected response to a ping. If a device

does not respond to a ping, the LNS Object Server tests the intervening routers to verify
that the failure is due to the device, and not to a router along the communications path.

The frequency of the pinging is determined by the device's PingClass property. This

property may be set to one of the following values:

lcaPingClassMobile

Check detachment frequently (1

minute by default).

lcaPingClassTemporary

Check detachment less frequently

(2 minutes by default).

lcaPingClassStationary

Check detachment occasionally (15
minutes by default).

lcaPingClassPermanent

Never check.

You can set the interval assigned to each of the four ping classes by writing to the
System object's PingInterval property. The default class is
lcaPingClassStationary, unless the System object’s InstallOptions property is

set to lcaSharedMedia, in which case pinging will be disabled.

When the LNS Object Server discovers that a device has become attached or detached, it
uses the OnAttachment event to report this information. To program your application to
test for device failures using attachment events, call the BeginAttachmentEvents()

method on the System object to register your application for the OnAttachment event.
Filter the OnAttachment events your application receives for device failures. These are

events where the IsAttached parameter returned with the event is False, and the

device has not been manually removed from the network. You could then subject those
devices and routers to more detailed investigation using the AppDevice or Router

object’s Test() method. However, your OnAttachmentEvent event handler should not

contain code to examine suspect devices. It should return to LNS as soon as possible, and

Advertising