Echelon i.LON SmartServer 2.0 User Manual
Page 338

i.LON SmartServer 2.0 Programmer’s Reference
20-16
// -------------- WRITING A DATA POINT VALUE --------------
// reset the DP priority (see section 4.3.6 for more information)
iLON_SmartServer.
Item_Coll
itemCollInvoke =
new
iLON_SmartServer.
Item_Coll
();
itemCollInvoke.Item =
new
iLON_SmartServer.
Item
[1];
itemCollInvoke.Item[0] =
new
iLON_SmartServer.
Dp_ResetPrio_Invoke
();
((iLON_SmartServer.
Dp_ResetPrio_Invoke
)(itemCollInvoke.Item[0])).UCPTname =
"Net/LON/iLON App/Digital Output 1/nviClaValue_1"
;
((iLON_SmartServer.
Dp_ResetPrio_Invoke
)(itemCollInvoke.Item[0])).UCPTpriority = 200;
((iLON_SmartServer.
Dp_ResetPrio_Invoke
)(itemCollInvoke.Item[0])).UCPTprioritySpecified =
true
;
SmartServer.InvokeCmd(
ref
itemCollInvoke);
// set the DP priority to 200 (see section 4.3.7 for more information)
((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTpriority = 200;
((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTprioritySpecified =
true
;
// set 100.0 1 as the value
((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTvalue =
new
iLON_SmartServer.
E_LonString
[1];
((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTvalue[0] =
new
iLON_SmartServer.
E_LonString
();
((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTvalue[0].Value =
"100.0 1"
;
// to write a preset, do this (see section 4.3.5.2 for more information)
// dpData.UCPTvalue[0].LonFormat = "UCPTvalueDef";
// dpData.UCPTvalue[0].Value = "ON";
// call the write function
iLON_SmartServer.
Item_Coll
writeResp = SmartServer.Write(dataColl);
if
(writeResp.Item ==
null
)
{
// sanity check. this should not happen
Console
.Out.WriteLine(
"No items were returned"
);
}
else
if
(writeResp.Item[0].fault !=
null
)
{
// error
Console
.Out.WriteLine(
"An error occurred. Fault code = "
+
writeResp.Item[0].fault.faultcode +
". Fault text = %s."
+
writeResp.Item[0].fault.faultstring);
}
else
{
// success
Console
.Out.WriteLine(
"Write is successful"
);
Console
.Out.WriteLine(((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTname +
" = "
+
((iLON_SmartServer.
Dp_Data
)dataColl.Item[0]).UCPTvalue[0].Value);
}
Console
.ReadLine();
}
finally
{
iLON_SoapCalls
.CloseBindingToSmartServer();
}
}
}
}
20.3.2
Reading and Writing Data Point Values in Visual C# .NET 2.0
The following Visual C# .NET 2.0 example reads the value of the Net/LON/iLON App/Digital Output
1/nviClaValue_1 data point on the SmartServer, and then writes a value of “100.0 1” to it. This
SNVT_switch data point is one of the relay outputs on the SmartServer. You can execute this code