Y_CO_ReName_FTP_SendData
Parameters
| * | Parameter | Data Type | Description | Default |
|---|---|---|---|---|
| VAR_IN_OUT | ||||
| V | RecordedData | Yt_CO_ReName_RecordedUserData | Rename and customize this structure based on the needs of the application. | |
| VAR_INPUT | ||||
| B | Enable | BOOL | The function will continue to execute every scan while Enable is held high and there are no errors. | FALSE |
| V | Append | BOOL | To select whether an existing the file on the server should be deleted and the new data should be appended to the existing data. | FALSE |
| V | Destination | Yt_String64 | The full file name and destination on the FTP server, e.g. 'metrics/example.csv'. | STRING#'' |
| V | FTPData | Yt_CO_FTP_Data | The input structure that configures the FTP transfer such as FTP server address, port, etc. |
|
| VAR_OUTPUT | ||||
| B | Valid | BOOL | Indicates that the function is operating normally and the outputs of the function are valid. | |
| B | Busy | BOOL | Set high upon the rising edge of the Execute input, and reset when Done, CommandAborted, or Error is true. In the case of a function block with an Enable input, a Busy output indicates the function is operating, but not ready to provide Valid information. (No Error). | |
| B | Error | BOOL | Set high if an error has occurred during the execution of the function block. This output is cleared when 'Execute' or 'Enable' goes low. | |
| E | ErrorID | UINT | If Error is true, this output provides the Error ID. This output is reset when 'Execute' or 'Enable' goes low. | |
| V | ErrorString | Yt_String256 | If 'Error' is true and it is an FTP response code related error then this output contains the response string from the FTP server. | |
Notes
- This block utilizes FTP, not SFTP. As a result, all FTP traffic sent and received (e.g. username, password, file data) is sent unencrypted in plain text and is visible to anyone with access to the network. This should not be a problem if the data being sent is not of a sensitive matter and the FTP server account is CHROOT'd properly (talk to your IT professional about using FTP).
- The FTP server should either have an internal/external domain name or use a static IP address because if the address changes, it will prevent the function from transferring files. See "Setup" for more details.
- The FTP user account must have "Write" privileges to successfully write files to the server. Optionally, the account may also have "Append" privileges. If files already exists and the FTP account only has "Write" privileges, then the file will be overwritten. If the file exists and the user account has "Append" privileges, then the file contents transferred will be appended to the existing file.
- There is a handshake system in place between Y_CO_ReName_FTP_RecordData and Y_CO_ReName_FTP_SendData so that if there is a timing problem and Y_CO_ReName_FTP_RecordData must switch to the other DataBank but Y_CO_ReName_FTP_SendData is still busy, and Error will occur. Timing issues could be based on the tasks in which both function blocks are executing, and if further customization has been performed, such as by modifying the number of samples in each DataBank.
Error Description
Example Customization
(It is assumed that an FTP server is configured and access is possible.)
- Open your project.
- Open the Comm Toolbox in a second copy of iCube Engineer.
- In the second copy (Comm Toolbox) Project Tree Window, select Y_CO_ReName_FTP_SendFile and Y_CO_ReName_FTP_RecordData and Copy.
- In the main project, Project Tree Window, right click on Logical POUs and select Paste.
- For both of the new function blocks in your project, right click on them to access the properties page and rename the function blocks.
DataTypes
Create a datatype which describes the information to be recorded. The four datatypes shown below make up "MyRecordedUserData" which must be connected to the function blocks. Customize the detailed information to be recorded as shown on lines 5 through 11. Add or subtract as many variables are required. All code shown here was copied and pasted from the Comm Toolbox, then all instances of "Yt_CO_ReName_" were changed to "My." Change to anything meaningful and appropriate. The only datatype which does not require modification and can remain in the Comm Toolbox is Yt_CO_RecordStatusData.
Initialization
Editing the variables worksheets
Variables worksheet for Y_CO_ReName_FTP_RecordData:
Rename the dataypes.
Variables worksheet for Y_CO_ReName_FTP_SendData:
Rename the datatype.
Function Blocks added to the Project:
MyFTP_RecordData_1 is in a "fast" task:
MyFTP_SendData is in the DEFAULT task: