beautypg.com

Creating and installing a l, Orks, Device in – Echelon i.LON SmartServer 2.0 User Manual

Page 394: Visual basic.net -42, Basic.net

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-42

Console.ReadLine()

Finally

SmartServer.CloseBindingToSmartServer()

End Try

End

Sub

End

Module

21.2.4

Creating and Installing a L

ON

W

ORKS

Device in Visual Basic.NET

This VB console example creates two L

ON

W

ORKS

devices, and then it commissions the devices, starts

the devices’ applications, and gets the devices’ templates (to display the devices’ functional blocks and
data points in the SmartServer Web interface). The example then prints out the names and statuses of
the devices that have been installed. Note that you need to replace the values of the ,
, , and properties provided in this example
with those of the devices you are creating and installing.

You can execute this code after you have referenced and inherited from the SmartServer WSDL as
described in section 20.1, and instantiated and initialized the Web service client as described in section
20.2.
You must also upload the device interface (XIF) files of the devices you are creating to the
root/LonWorks/import folder on the SmartServer flash disk.

For more information on the L

ON

W

ORKS

device properties set in this example, see section 14.3.2,

Using the Get Function on a LonWorks Device. For more information on the network management
commands issues in this example, see section 14.3.3.1, Issuing Network Management Commands.

Module

InstallDeviceModule


'Function required for converting device Neuron IDs and program IDs to a byte[]

Public

Function

HexStringToArray(

ByVal

str

As

String

)

As

Byte

()

Dim

nLen

As

Integer

= str.Length / 2

Dim

arr

As

Byte

() =

New

Byte

(nLen - 1) {}


For

i

As

Integer

= 0

To

nLen - 1

Dim

strByte

As

String

= str.Substring(i * 2, 2)

arr(i) = [Byte].Parse(strByte, System.Globalization.NumberStyles.HexNumber)

Next

Return

arr

End

Function

Public

Sub

Main()


Dim

SmartServer

As

iLON_SoapCalls =

New

iLON_SoapCalls

SmartServer.BindClientToSmartServer()

Try


' -------------- CREATING LONWORKS DEVICES --------------

'Create a new LON_Device_Cfg Item

Dim

my_LON_Device1

As

New

iLON_SmartServer.LON_Device_Cfg()

Dim

my_LON_Device2

As

New

iLON_SmartServer.LON_Device_Cfg()


'Create an ItemCfgColl to store the LON Devices we just created

Dim

ItemCfgColl

As

New

iLON_SmartServer.Item_CfgColl()

ItemCfgColl.Item =

New

iLON_SmartServer.Item_Cfg(1) {}

ItemCfgColl.Item(0) = my_LON_Device1
ItemCfgColl.Item(1) = my_LON_Device2

'=====CREATING AND INSTALLING LON DEVICE #1==================

' specify properties of new LON Device #1

my_LON_Device1.UCPTname =

"Net/LON/DIO-1"

my_LON_Device1.UCPTlocal = 0
my_LON_Device1.UCPTuniqueId = HexStringToArray(

"00a145791500"

)