Modifying connections – Echelon LNS User Manual

Page 157

Advertising
background image

LNS Programmer's Guide

143

Modifying Connections

This section describes how to add members to a connection, remove members from a

connection, and delete a connection. To add more members to a connection, follow these
steps:

1. Obtain the hub NetworkVariable or MessageTag for the connection you want

to modify.

2. Start a transaction, and then invoke the AddTarget() method for each the new

targets you want to add. It is not necessary to re-specify existing targets. You

must limit the number of targets you add to 25 at a time.

3. When all the targets have been added, invoke the Connect() method on the hub

network variable or message tag. Then, call CommitTransaction() to commit

the transaction to the database.

4. If you need to add more than 25 targets to a connection, you can do so by

repeating steps 2 and 3. When doing so, you should perform all the steps within

the same transaction.

To remove one or more targets connected to a hub, or to remove an entire connection,

follow these steps:

1. Obtain the hub NetworkVariable or MessageTag for the connection you want

to modify.

2. Start a transaction, and specify the target network variables or message tags to

be removed from the connection using the hub’s AddTarget() method. You must

limit the number of targets you remove at one time to 25.

3. Call

the

Disconnect() method on the connection hub. Then, call

CommitTransaction() to commit the transaction to the database.

If no targets are specified in step 1 before the Disconnect() method is called,

the LNS Object Server will disconnect all targets from the hub, thus deleting the
connection. Note that this does not remove the hub network variable or message

tag from all connections it is involved in. It only removes the connections for

which the network variable or message tag was the connection hub.

4. If you need to remove more than 25 targets from a connection, you can do so by

repeating steps 2 and 3. When doing so, you should perform all the steps within
the same transaction.

5. To remove a specified network variable or message tag from all connections it is

involved in, you will also need to examine the network variable’s NVHubs

property, or the message tag’s MTHubs property. A network variable’s NVHubs

property contains a collection of the hub network variables for each connection in
which it is a target. A message tag’s MTHubs property contains a collection of the

hub message tags for each connection in which it is a target. You can call the
Disconnect() method on the connection hubs accessed through these

collections to remove a network variable or message tag from the connections it is
involved in.

Advertising