Using custom connection description templates – Echelon LNS User Manual
Page 162
LNS Programmer's Guide
148
Using Custom Connection Description Templates
As described in Chapter 6, the LNS Object Server provides connection descriptions in the
form of ConnectDescTemplate objects that determine the behavior of a connection.
Each network variable and message tag has a ConnectDescTemplate property
containing its ConnectDescTemplate object. When a network variable or message tag
acts as a connection hub, its ConnectDescTemplate is applied to that connection.
To create a new ConnectDescTemplate object and apply it to a connection, follow these
steps:
1. Invoke
the
Add() method on the ConnectDescTemplates collection retrieved
from the system’s TemplateLibrary.
Set MyTemplateLibrary = MySystem.TemplateLibrary
Set MyConnTemplates = MyTemplateLibrary.ConnectDescTemplates
Set MyNewTemplate = MyConnTemplates.Add(“myNewTemplate”)
2. You can customize the template created in step 1 by writing to its properties.
Note that you must designate the properties you are modifying as active
properties by writing to the PropertyOptions property. When building a
connection, the LNS Object Server only uses the attributes of the connection
description that are designated as active. See the LNS Object Server Reference
help file for more information on the PropertyOptions property.
The following code sample changes the new ConnectDescTemplate object’s
RepeatTimer and ServiceType properties, and then sets those properties as
active:
MyNewTemplate.RepeatTimer = 7
MyNewTemplate.ServiceType = lcaSvcAckd
MyNewTemplate.PropertyOptions = lcaConnPropsServiceType OR _
lcaConnPropsRepeatTimer
For descriptions of the various properties of the ConnectDescTemplate object,
and guidelines to follow when writing to those properties, see the next section,
Setting ConnectDescTemplate Properties.
3. Once you have modified the ConnectDescTemplate object to suit your needs,
assign it to the ConnectDescTemplate property of a network variable or
message tag you plan to use as a connection hub.
Set ConnectionHub.ConnectDescTemplate = MyNewTemplate
4. Create a connection using the selected network variable or message tag as the
connection hub. The connection will use the new template. For more information
on creating connections, see Adding Connections on page 142.
You can also modify the attributes of a connection description that is already being used
by a connection hub, and apply those changes to the connection. To do so, follow these
steps:
1. Access
the
ConnectDescTemplate
object of the hub network variable or
message tag for the connection you want to modify
Set MyTemplate = ConnectionHub.ConnectDescTemplate