beautypg.com

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

Page 367: Visual c# .net -15

background image

i.LON SmartServer 2.0 Programmer’s Reference

21-15

myCalendar.Exception[0].Schedule[3].UCPTschedDay =

new

iLON_SmartServer.

E_LonString

();

myCalendar.Exception[0].Schedule[3].UCPTschedDay.LonFormat =

"UCPTschedDay"

;

myCalendar.Exception[0].Schedule[3].UCPTschedDay.Value =

"DM_DAY_25"

;


//set start date

myCalendar.Exception[0].Schedule[3].StartDate =

new

iLON_SmartServer.

UFPTcalendar_CfgESDate

();

myCalendar.Exception[0].Schedule[3].StartDate.UCPTdate =

new

DateTime

(2009, 6, 8);


//set end date

myCalendar.Exception[0].Schedule[3].EndDate =

new

iLON_SmartServer.

UFPTcalendar_CfgESDate

();

myCalendar.Exception[0].Schedule[3].EndDate.UCPTdate =

new

DateTime

(2020, 12, 31);


//call Set function

iLON_SmartServer.

Item_CfgColl

itemCfgColl_Calendar =

new

iLON_SmartServer.

Item_CfgColl

();

itemCfgColl_Calendar.Item =

new

iLON_SmartServer.

Item_Cfg

[1];

itemCfgColl_Calendar.Item[0] = myCalendar;


iLON_SmartServer.

Item_Coll

ItemColl_Set_Calendar_Return =

SmartServer.Set(itemCfgColl_Calendar);

if

(ItemColl_Set_Calendar_Return.UCPTfaultCount > 0)

{
PrintGetError(ItemColl);
}

else

{
iLON_SmartServer.

Item

newCalendar = ItemColl_Set_Calendar_Return.Item[0];

Console

.WriteLine(

"Calendar used for this Scheduler is "

+ newCalendar.UCPTname);

}

Console

.ReadLine();

}


finally

{

iLON_SoapCalls

.CloseBindingToSmartServer();

}


}
}
}

21.1.4

Creating and Installing a L

ON

W

ORKS

Device in Visual C# .NET

This C# 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.

using

System;

using

System.Collections.Generic;

using

System.Linq;

using

System.Text;

namespace

ConsoleApplication_LON_Device

{