WriteData
Use WriteData function to write data to a file, or append a data string to a file on a local device, or an FTP server. You can use this function to log data results and view them in a file.
The WriteData function also has a File Cleanup feature that manages the file system of a production line, ensuring that operations do not need to be halted to clear space. When enabled, the cleanup function monitors the file system each time the WriteData tool is run to maintain a specified percentage of desired free space and remove the oldest files when necessary.
To prevent the cleanup feature from removing system critical files, such as jobs stored on the vision system, make sure that the provided file path does not point to the root of the user space. If you provide the root as the file path, or the file path is not valid, the tool returns an error.
The cleanup function sorts files in the specified directory and its subdirectories based on the last time they were modified, allowing for the oldest files to be removed first when cleanup is required.
WriteData Inputs
| Parameter | Description | |||||||||||
| Data |
Specifies a text string or a reference to a cell containing a text string you want to write or append to a file. |
|||||||||||
| Event |
Specifies the event that forces an update. This parameter needs to be a reference to any event with a timestamp, for example an |
|||||||||||
| Storage |
Specifies whether you want to save the data file to a local device or an FTP server. The save location depends on the connected device and the Storage setting of the function.
|
|||||||||||
| Server |
Specifies the server name (or IP address) of the FTP server on the network where the data file is written. An FTP server can be an In-Sight emulator or any other device recognized as an FTP server on the network. Note:
|
|||||||||||
| User Name |
Specifies the user name of the FTP server. When this field is left blank, "admin" is used. Note: This option is enabled only when you select FTP Server as the Storage type.
|
|||||||||||
| Password |
Specifies the password for the FTP server. The password is case-sensitive. If the FTP server does not have a password, you can leave this field blank. Note:
|
|||||||||||
| File Path |
Specifies the location where you want to save the file.
If you leave this field blank, you send the file to one of the following default locations:
|
|||||||||||
| File Name |
Specifies the name of the data file. Note: Follow the restrictions of the operating system on the legal characters.
|
|||||||||||
| Data Format |
Specifies the type of file. The extension is automatically appended to the File Name.
|
|||||||||||
| Append |
Specifies how the data is written to the file.
|
|||||||||||
| Enable File Cleanup |
Enables or disables the cleanup functionality of the tool. Note: This option is only available when the selected storage type is Local Device. When this setting is enabled, there is an additional 30-60 µs in processing time per tool execution for checking the free space on the vision system.
|
|||||||||||
| Minimum Free Space |
Specifies the minimum percentage of the vision system storage that is to be kept as free space. If the storage reaches the specified limit, the cleanup functionality starts cleaning up older files to ensure that the minimum free space is retained. |
|||||||||||
| Desired Free Space |
Specifies the desired percentage of the vision system storage that is to be kept as free space. When the vision system storage reaches the minimum free space limit, and the cleanup functionality starts cleaning up older files, the cleanup process stops when the vision system storage reaches the desired free space. Note: If the tool cannot delete enough files to reach the desired free space threshold, the function returns an error after deleting what it was able to delete. There is an additional 8 ms of approximated processing time for initiating cleanup, and an additional 0.8 ms for every file deleted.
|
WriteData Outputs
| Returns |
Note: Any invalid FTP server, path or file name does not return an #ERR.
|