Echelon i.LON SmartServer 2.0 User Manual
Page 399
![background image](/manuals/735732/399/background.png)
i.LON SmartServer 2.0 Programmer’s Reference
21-47
21.2.6
Discovering and Installing External Devices in Visual Basic.NET
This console example scans a L
ON
W
ORKS
network for uncommissioned devices, processes the Neuron
ID and program ID data of the discovered devices, and then 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.
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.3.
For more information on discovering uncommissioned L
ON
W
ORKS
devices, see section 14.1.3.2,
Issuing Network Scan Commands to Discover Devices. You must also upload the device interface
(XIF) files of the devices you are discovering and installing to the root/LonWorks/import folder on the
SmartServer flash disk, or create device templates (XML files) for the devices.
Imports
System.Threading
Module
Module1
'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
'create LONNetworkScanCommandInvoke item and ScanCommand attribute
Dim
networkScan
As
New
iLON_SmartServer.LON_Network_ScanCommand_Invoke()
networkScan.ScanCommand = iLON_SmartServer.LON_Network_eScanCommand.SetScan
'***set LONNetworkScanCommandInvoke properties***
'1. Set network UCPTname
networkScan.UCPTname =
"Net"
'2. Set Scan Command
'a. set scan frequency
Dim
scanFrequency
As
New
iLON_SmartServer.LON_Network_ScanCommand_InvokeCommand()
scanFrequency.UCPTcommand = iLON_SmartServer.LON_Device_IlonNi_eCommand.ScanOnce
'b. set scan status
Dim
scanStatus
As
New
iLON_SmartServer.E_LonString()
scanStatus.LonFormat =
"UCPTstatus"
scanStatus.Value =
"STATUS_REQUEST"
scanFrequency.UCPTstatus = scanStatus
'c. add scan command to LONNetworkScanCommandInvoke item
networkScan.Command =
New
iLON_SmartServer.LON_Network_ScanCommand_InvokeCommand(0) {}
networkScan.Command(0) = scanFrequency
'3. Set UCPTscan
Dim
domain
As
New
iLON_SmartServer.E_LonString()
domain.LonFormat =
"ucptScan"
domain.Value =
"NST_ILON_DOMAIN"
networkScan.UCPTscan =
New
iLON_SmartServer.E_LonString(0) {}