TLServer 3.0 File and Email Services
Starting from version 2.0, the TLServer provides a number of File and Email services to the PLCs via the serial comm port. Basically a PLC can send service requests to the TLServer using "tags" (which are ASCII characters enclosed between the '<' and '>' characters) and the TLServer will perform the service requests upon receiving valid commands. All data between the <command [parameter]> tag and the </> tag will be treated as data for the requested service .
Since the PLC is the one which initiates the service request, it does not need to be linked to the TLServer all the time unless it needs to request a service from the TLServer. This makes it possible for a remote PLC to connect to the TLServer via the telephone line using a modem and perform the required file or email services, then disconnects itself from the TLServer so that other PLCs can take turns to connect to the TLServer to request for services.
Note: All the files created or used in the
write/append/read actions are located in the directory:
<trilogi base directory> /FileService. (hence the default path is
C:\TRiLOGI\TL6\FileService). You may also read/write files that are located in
sub-directory below the "..../FileService" directory provided that the
sub-directory already exists.
The currently supported files and emails services are described below:
1. Write data to file Format: |
E.g. To save data of DM[1] to DM[10] to a file name
"testWrite.txt", execute the following statement from a custom function: PRINT #1 "<WRITE
testWrite.txt>" ' Write data request The TLServer will close the file after it receives the
end-of-service tag "</>" from the PLC and it will in turn send a
"<OK>" string to the PLC to acknowledge that the WRITE
request has been completed successfully. It is up to your PLC program to check for the
"<OK>" tag to determine if it the service it requested have been completed
successfully. |
2. Append data to file Format: |
E.g. To append the time of an event to a file name "testAppend.txt",
execute the following statements in a custom function when the event take place: PRINT #1 "<APPEND testAppend.txt>"
' Append data request
|
3. Email data to recipient Format:
|
E.g. To send data to an
email address: whoever@yahoo.com with the subject "PLC Email Test",
execute the following statements: PRINT #1
"<EMAIL whoever@yahoo.com>" ' change it to your own email. Note:
|
4. Read Data from File Format: |
This service allows the PLC to request the
TLServer to open a text file and upload its content to the PLC. This may be useful
for loading some previously saved parameters. Upon
receiving this command and if the specified [filename] is successfully opened, the
TLServer will begin sending all the ASCII characters contained in the text file to the
PLC. Note that line breaks in a text file are sent to the PLC as CR character only and not
as a CR+LF pair. As such, your PLC program can easily use the INPUT$(1) command to read in
all the CR-terminated text string one string at a time and then interpret or convert the
data as necessary. After sending out the last byte in the data file to the PLC, the
TLServer will send a CR-terminated acknowledgement string "<OK>" to the
PLC to signal that the READ command have been properly completed. |
5. Read Real Tim Clock From
TLServer Format: <READ RTC[]> |
This service allows the PLC to
get the Real Time Clock data of the TLServer (i.e. the PC in which the TLServer runs on).
The type of data is indicated in the Date[n] and Time[n] parameter which correspond to the DATE[n] and TIME[n] system variables in TBASIC: i.e. Date[1] = year; Date[2]=month;
Date[3]=day; Date[4]=dayofWeek; For full synchronization, use the <READ RTC[]> tag which returns the values of the Date[1], Date[2], Date[3], Date[4], Time[1], Time[2], Time[3] in 7 CR-terminated ASCII strings. Upon receiving this command the TLServer will immediately send the relevant clock/calendar data as CR-terminated ASCII string(s) to the PLC. Your PLC program can easily use the INPUT$(1) command to read in the data and convert them into integers using the VAL command. Note that unlike the "READ file" service, the TLServer does not send "<OK>" string after performing the "READ RTC" service.
|