Connecting devices, Ing and managing connections, see connecting – Echelon LNS User Manual
Page 152
LNS Programmer's Guide
138
device was associated with accordingly, but will not signal an error if the device itself
cannot be communicated with.
To remove a given AppDevice object that is referenced in multiple subsystems, collect
the list of subsystems it belongs to by reading the AppDevice object’s Subsystems
property. This returns a Subsystems object. Obtain the AppDevices collection for each
Subsystem object contained in the collection, and remove the AppDevice object from
each of them. You should delete the AppDevice by its name and not its index, as the
index will vary for each AppDevices collection it belongs to.
The following example removes an application device named AppDevice1 from all
subsystem objects it belongs to:
‘ Start a transaction:
MySystem.StartTransaction
‘ Fetch the AppDevice that is to be removed:
Dim MyAppDevices As LcaAppDevices
Dim MyAppDevice As LcaAppDevice
Set MyAppDevices = MySubsystem.AppDevices
Set MyAppDevice = MyAppDevices.Item(“AppDevice1”)
‘ Fetch this device’s Subsystems object:
Dim TheSubsystems As LcaSubsystems
Set TheSubsystems = MyAppDevice.Subsystems
‘ Remove the device from all Subsystem objects it belongs to
Dim CurrentSubsystem As LcaSubsystem
Dim CurrentAppDevices As LcaAppDevices
While TheSubsystems.Count
Set CurrentSubsystem = TheSubsystems.Item(1)
Set CurrentAppDevices = CurrentSubsystem.AppDevices
CurrentAppDevices.Remove(“AppDevice1”)
End While
‘ Release the stale reference held by the MyAppDevice variable:
Set MyAppDevice = nothing
‘ Commit the transaction:
MySystem.CommitTransaction
Note that the MyAppDevice variable becomes stale during this process. As the last
reference to the AppDevice is removed from the database, the variable itself refers to an
item that no longer exists. Accessing any property or method of the MyAppDevice object
variable will cause the LCA:#116 lcaErrStaleObject exception to be thrown. To
prevent this, you should release stale references as shown in the example above.
Connecting Devices
To understand how to use LNS to connect network variables and message tags, you
should first consider how Neuron Chip-based devices process incoming messages. There
are two pieces of information contained within each device that the Neuron Chip uses to
process and qualify an incoming network variable update messages. The first is the
message’s destination address. The device only processes the message if the message is
addressed to the device. If the device determines that the message is addressed to it, and
the message is a network variable message, the device checks if the network variable
selector in the message matches a network variable selector on the device.