Opening a network – Echelon LNS User Manual
Page 65
LNS Programmer's Guide
51
property to NOTHING for Visual Basic, or NULL for Visual C++). This is described in more
detail in Chapter 5.
If multiple client applications have the same network open, they must either use the
same network interface, or they must all be in engineered mode. If an LNS application
opens a network without explicitly selecting a network interface, the network will be
opened using the same network interface that was used the last time the network was
opened, or it will be opened in engineered mode if the network was last opened in
engineered mode. Newly created networks will be opened in engineered mode if the
network interface is not explicitly specified.
To select a network interface for local operation, follow these steps:
1. Fetch
the
ObjectServer object’s NetworkInterfaces collection. All
network interfaces registered in the Windows System Registry on the PC
running your application are automatically detected by the LNS Object
Server and included in this collection.
Dim NICollection as LcaNetworkInterfaces
Set NICollection = ObjectServer.NetworkInterfaces
2. Select the desired network interface. The following code selects a network
interface named "LON1" which will be used to open the system.
Dim SelectedNI as LcaNetworkInterface
Set SelectedNI = NICollection.Item("LON1")
Opening a Network
Once you have opened the Object Server, you can begin using your Local client
application to access L
ON
W
ORKS
networks. This section describes how to open an existing
network, and how to create a new network. To open a network, or to create a new
network, follow these steps:
1. Retrieve
the
Networks collection from the ObjectServer object’s
Networks property. The Networks collection contains all local networks.
For Local client applications, the Object Server retrieves the Networks
collection from the LNS global database.
Dim MyNetworks as LcaNetworks
Set MyNetworks = ObjectServer.Networks
2. To create a new network, call the Add() method on the Networks
collection. Networks can only be created when running locally. The
following code creates a network named "Building 75" with database path
"c:\bldg75". The final parameter supplied to the Add() method forces the
creation of a new network database in the specified database path if set
to True, and imports an existing database from the specified database
path if set to False.
Dim MyNetwork as LcaNetwork
Set MyNetwork = MyNetworks.Add("Building75","c:\bldg75",True)
To fetch an existing network from the collection, obtain the desired
Network object from the Networks collection. You can iterate through
the Networks collection to list all available networks, or you can use the
Item property to open a specific network by its name or by its index