Adding connections – Echelon LNS User Manual

Page 156

Advertising
background image

LNS Programmer's Guide

142

• The msg_in tag always acts as an input only.
• If there is only one declared message tag in a connection, it acts as an

output only.

If there is more than one declared message tag in a connection, all of those declared

message tags act as bi-directional ports.

Adding Connections

To create a connection, you must first select a hub network variable or message tag, a set

of targets, and optionally, a connection description. You can then use LNS to connect the

hub and the targets together, and form a connection. To do so, follow these steps:

1. Select the network variable or message tag that will serve as the connection hub,

and fetch it from the applicable collection. To do so, you need to access an
Interface object from the device that contains the hub network variable or

message tag for the connection. For optimum performance, Echelon recommends
that you perform the following steps within a transaction.
MySystem.StartTransaction()

Set MyAppDevInterface = MyAppDevice.Interface

Set MyNvCollection = MyAppDevInterface.NetworkVariables

Set MyHubNv = MyNvCollection.Item("nvoAlarm")

2. Optionally, modify the connection parameters that the connection will use by

writing to the ConnectDescTemplate property of the hub network variable or

message tag. For more information on this, and for a description of the default
properties that are applied to each connection, see Connection Descriptions on

page 145.
Set MyTemplateLibrary = System.TemplateLibrary

Set MyConnectTemplates = MyTemplateLibrary.ConnectDescTemplates

Set MyConnDes = MyConnectTemplates.Add("SvcUnackd")

MyConnDesc.PropertyOptions = lcaConnPropsServiceType

MyConnDesc.ServiceType = lcaSvcUnackd

Set MyHubNv.ConnectionDescTemplate = MyConnDesc

3. Obtain the target network variables, as described in step 1.

Set AnotherInterface = AnotherDevice.Interface

Set AnotherNvCollection = AnotherInterface.NetworkVariables

Set MyTargetNv = AnotherNvCollection.Item("nviAlarm")

4. Call

AddTarget() on the hub network variable. Supply the TargetNv selected

in step 3 as the targetObject element.
MyHubNv.AddTarget(MyTargetNv)

5. Repeat steps 3 and 4 until the target list is complete, or the number of targets

reaches the maximum (25). If you need to add more than 25 connection members,

you must complete this procedure to create the connection, and then add
additional members, as described in the next section, Modifying Connections.

6. Call

Connect() on the hub network variable to instantiate the connection, and

commit the transaction to the LNS database.
MyHubNv.Connect()

MySystem.CommitTransaction()

Advertising