Simple single file scenario
The simplest configuration writes a single data file to the server. New data will be appended to that file on a time interval. This is very similar to the way LoggerNet collects data.
(Click image to expand/collapse display)
In the example program, the tables names (highlighted) must match.
FTPResult=
|
The pertinent instruction in Single appended file is FTPClient()
configured as such:
FTPResult=FTPClient
("computer-name.domain.com"
, "Tutorial"
, "Tutorial_PW"
, "FTPTest"
, "FTP_Tutorial_1.csv"
, 9, 0, 5, Min, -1008)
The variable FTPResult
will be –1 if successful, 0 if it fails, or –2 if execution did not occur when the instruction was called (for instance, when the time into interval conditions are not met). In this example, during normal successful operations, you will see a result code of –2 most of the time. It will change to –1 for a few seconds near the top of every five minutes.
The first set of parameters are based on the receiving FTP server. See requirement 1 in Requirements. Your IP address, user name, and password will be different from the following example screenshot.
Next, in LocalFileName specify the name of the DataTable that contains the data to copy to the FTP server. Single appended file shows the table name in the instruction DataTable
(FTPTest,1,–1)
. Type the Table Name in quotes, and double-check to ensure there are not any typos.
Because the objective is to have a single file contain a continuous data set, assign a static RemoteFileName. You will be working with a copy of this file to analyze your data; so, give it a meaningful name and useful extension. This example uses a .csv extension, but you could use .dat or .txt.
The PutGetOption code of 9 specifies that the data logger will be appending to a file and using what is called a passive connection. Whether a connection is active or passive depends on how the FTP server is set up. Most data logger-to-computer FTP connections are most successful using passive mode.
FileOption specifies how the file will look on the server. The option code of –1008, as used in this example, generates a data file that looks like the data file collected by LoggerNet when using the default settings. Available choices include binary, ASCII, XML and JSON formats, and variations on what to include in the header. This example uses option 8, which is a full header in ASCII. To use the file name exactly as specified in RemoteFileName and not append an incrementing number, add 1000 to the option number. In this example, that results in 1008. To insert the header once at the top of the file, negate this number (for example: –1008).
The next group of parameters lets you specify how often and when you want the data logger to initiate the connection to the server and stream previously unsent data. IntervalStream and UnitsStream determine how often, every 5 minutes in this example. NumRecsStream lets you set an offset to the interval if desired. This is commonly kept at 0 so the connection and data streaming takes place at the top of the interval. Other typical intervals would be 0,12,Hr to stream every 12 hours at noon and midnight, or 0,1,Day to stream once a day at midnight. To stream once a day at 8 AM, use 8,24,Hr.
If the Ethernet connection is lost, the data logger sends the unsent data and appends when the connection comes back, similar to LoggerNet.
There is no checking of table definitions. If there is a mismatch but the file name remains the same, a new header will NOT be inserted.