File Management
File Management functions provide the ability to:
- Read machine recipes or other machine operational data into the KAS program from the SD card, USB flash drive, or a shared directory.
- Read cam tables into the program from the SD card, USB flash drive, or a shared directory.
- Store machine operational data on internal PxMM or PCMM2G flash memory (retrievable through the Web server), the SD card, USB flash drive, or a shared directory.
-
A shared directory connection is setup through the Web server.
-
-
- Functions to parse out information from a file using a string format can be found in String Operations.
- If the file is in a .CSV format, these functions can be used: LogFileCSV, ApplyRecipeColumn.
- You can create, store, and retrieve recipes and other data using either:
- the AKI Terminals. For more information see the KVB manual.
- an external bus connection to the PxMM or PCMM2G with a supported fieldbus (e.g., UDP or HTTP).
Sequential Read / Write Function Blocks
Name |
Description |
---|---|
Closes an open file. |
|
Copies a file's contents to a new file. |
|
Removes a file from the file system. |
|
Test if the end of the file is reached in a file that is open for reading. |
|
Tests if a file exists. |
|
Create or open a file in append mode. |
|
Open a file for reading. |
|
Create or reset a file and open it for writing. |
|
Read binary data from a file. |
|
Reads a string value from a text file. |
|
Renames a file. |
|
Sets the current position in an open file. |
|
Gets the size of a file. |
|
Write binary data to a file. |
|
Writes a string value to a text file. |
SD card Functions
These functions handle mounting of SD cards:
Name |
Use |
---|---|
Verify the SD card is mounted. |
|
Mount the SD card. |
|
Unmount the SD card. |
Each file is identified in the application by a unique handle manipulated as a DINT value.
- The file handles are allocated by the target system.
- Handles are returned by the Open function blocks and used by all other function blocks for identifying the file.
Related Function Blocks
LogFileCSV log values of variables to a CSV file
-
-
- Files are opened and closed directly by the Operating System of the target.
- Verify each file successfully opened using FileOpenA, FileOpenR, and FileOpenW.
- The FileOpenW has a corresponding FileClose to close the file.
- Closing the file releases the file ID, making it available for operations on other files.
-
-
- Opening a file with FileOpenA, FileOpenR, and FileOpenW can be unsuccessful (invalid path or file name, too many open files.)
- Your application must check the file ID for a NULL value.
- If the file ID is NULL (zero), then file read or write operations will fail.
- File management may be unavailable on some targets.
- Memory on the SD card is available in addition to the existing flash memory.
- Valid paths for storing files depend on the target implementation.
- Error messages are logged in the Controller log section of KAS Runtime where there is a failure in any related function block.
- Using the KAS Simulator, all path names are ignored, and files are stored in a reserved directory. Only the file name passed to the Open functions is taken into account.
- AKD PDMM / PCMM files are big endian.
- PCMM2G files are little endian.
- Opening a file with FileOpenA, FileOpenR, and FileOpenW can be unsuccessful (invalid path or file name, too many open files.)
-
- Review the File Path Conventions to understand hardware-based functional differences.