beautypg.com

3 using the write function on file system data, Using the write function on file system data -3, Using the write function on file system data – Echelon i.LON SmartServer 2.0 User Manual

Page 298

background image

i.LON SmartServer 2.0 Programmer’s Reference

18-3

returns the following data:

Hello
World
!

18.3

Using the Write Function on File System Data

You can use the Write function to upload a new alarm log, data log, or other user-defined file to the
SmartServer or to overwrite an existing file.

The Write function takes an element with a FileSystem_Data type as its input. You can specify
the format (text or hex) of the file in the property. If you do not include the
property and set it to “text”, the data is stored as a hex dump. The data to be
stored in the file must be included within the property.

The Write response message includes a that contains the length of the new file in
bytes.

Request (create a new user-defined file on the SmartServer)



xsi:type="FileSystem_Data">

/data/myCustomFile.csv
text
Hello

i.LON

SmartServer



Response



xsi:type="FileSystem_Data">

/Data/Test
2008-04-04T00:00:24Z

/>

LonFormat="UCPTfileFormat">text

31

Hello i.LON SmartServer




Note: You can write to a file in hex mode, and store the data in ASCII printable characters (text) and
control characters (e.g., new line). To do this, you enter a space-separated ascii hex string in the
property in the Write request. For example, you can write two lines to a text file (the first is
“ABC” and the second is “DEF”) by passing in the following ascii hex string in the property:

41 42 43 0D 0A 44 45 46

The following C# sample code demonstrates how to write to a file in hex mode using the previous
example:

ilonWebRef.Item_DataColl itemDataColl = new ilonWebRef.Item_DataColl();
itemDataColl.Item = new ilonWebRef.Item_Data[1];
ilonWebRef.FileSystem_Data fsData = new ilonWebRef.FileSystem_Data();
itemDataColl.Item[0] = fsData;

fsData.UCPTname = "/data/myfile.txt";
fsData.UCPTfileFormat = new ilonWebRef.E_LonString();
fsData.UCPTfileFormat.Value = "hex";

fsData.Value = “41 42 43 0D 0A 44 45 46”;