Creating dynamic network variables – Echelon LNS User Manual
Page 198
LNS Programmer's Guide
184
Set MyNewTag = MyMessageTags.Add(“newName”)
4. For information on using message tags and message monitor points for
monitor and control operations, see Chapter 9, Monitor and Control.
Creating Dynamic Network Variables
You can add network variables to custom interfaces on devices that support dynamic
network variables, to dynamic
LonMarkObject
objects
,
or to static
LonMarkObject
objects that support dynamic network variable assignment. If you attempt to add a
network variable to a static LonMarkObject or a device’s main interface, then the
LCA#119 lcaErrInterfaceNotModifyable exception will be thrown, unless the
device supports the addition of dynamic network variables to static
LonMarkObject
objects. You can determine whether a LonMarkObject is static or dynamic by reading
the object’s
IsDynamic
property.
You should note that network variables contained within the same custom Interface
objects must have unique user names (Name property). In addition, some devices, such as
the
i
.LON 100 Internet Server, require that all network variables within the device have
unique programmatic names (ProgammaticName property). If you attempt to assign a
duplicate user name or programmatic name to a network variable on such a device or
interface, the operation will fail, and the LCA#132 lcaErrUniqueNvNameRequired
exception will be thrown.
To add a network variable to a custom interface or to a LonMarkObject, follow these
steps:
1. Access the custom interface you want to add the network variable to. If
necessary, create a new custom interface, as described in Adding a
Custom Interface to a Device on page 181. Or, access the LonMarkObject
you want to add a network variable to.
Dim MyInterfaces as LcaInterfaces
Dim
MyNewInt
as LcaInterface
Set MyInterfaces = MyAppDevice.Interfaces
Set
MyNewInt
= MyInterfaces.Item(“newInt”)
2. Access the interface or LonMarkObject object’s NetworkVariables
collection.
Dim myNVs as LcaNetworkVariables
Set myNVs =
MyNewInt
.NetworkVariables
3. Call
Add() to add a new network variable to the collection. For
descriptions of the parameters you need to specify, see the LNS Object
Server Reference help file.
Dim NewNV as LcaNetworkVariable
Set NewNV = myNVs.Add(“nv3”,nvType, nvDirection, _
nvOptions, memberNumber,manufacturerAssigned)
Note that you can also use the MoveToInterface() method to move dynamic network
variables from one interface to another. This may be useful if you want to remove a
dynamic network variable from a device’s main interface. You cannot use the Remove()
method to remove a network variable from NetworkVariables collection on a device's
main interface, even if it is a dynamic network variable. However, you can use the