File Management
File Management functions provide the ability to do the following:
- Read machine recipes or other machine operational data into the .kas program from the SD card or a remote drive
- Read cam tables into the program from the SD card or a remote drive.
- Store machine operational data in internal PxMM flash memory (retrievable through the web server), the SD card, or a remote drive
Please note that a remote drive connection is setup through the web server.
-
-
- If needed, functions to parse out information from a file using a string format can be found in String operations.
- If the file is in .CSV format, the following functions can be used: LogFileCSV, ApplyRecipeColumn
- You can create, store, and retrieve recipes and other data using:
- the AKI Terminals. For more information see the KVB manual.
- through an external bus connection to the PxMM with a supported fieldbus, such as UDP or HTTP.
Name | Use |
---|---|
F_AOPEN | Create or open a file in append mode |
F_CLOSE | Close an open file |
F_COPY | Copy a file |
F_DELETE | Remove a file |
F_EOF | Test if the end of the file is reached in a file that is open for reading |
F_EXIST | Test if a file exists |
F_GETSIZE | Get the size of a file |
F_RENAME | Rename a file |
F_ROPEN | Open a file for reading |
F_SEEK | Set the current position of a file |
F_WOPEN | Create or reset a file and open it for writing |
FA_READ | Read a DINT integer from a binary file |
FA_WRITE | Write a DINT integer to a binary file |
FB_READ | Read binary data from a file |
FB_WRITE | Write binary data to a file |
FM_READ | Read a string value from a text file |
FM_WRITE | Write a string value to a text file |
SD_ISREADY | Check that the SD card is ready for read/write |
SD_MOUNT | Mount an SD card |
SD_UNMOUNT | Unmount an 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 functions and used in all other calls for identifying the file.
Related function blocks:
LogFileCSV log values of variables to a CSV file
-
-
- These functions can have a serious impact on CPU load and the life expectancy of a flash drive. It is highly recommended that these be used on an event basis, and not at every PLC cycle.
- Files are opened and closed directly by the Operating System of the target. Opening some files can be dangerous for system safety and integrity. The number of open files (from F_AOPEN, F_ROPEN, and F_WOPEN) is limited by the resources available on the target system.
- Ensure that each file successfully opened using F_AOPEN, F_ROPEN, and F_WOPEN has a corresponding F_CLOSE to close the file. Closing the file will release the file ID, making it available for operations on other files.
- These functions can have a serious impact on CPU load and the life expectancy of a flash drive. It is highly recommended that these be used on an event basis, and not at every PLC cycle.
-
-
- Opening a file with F_AOPEN, F_ROPEN, and F_WOPEN 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 RuntimeIn computer science, runtime (or run-time) describes the operation of a computer program, the duration of its execution, from beginning to termination (compare compile time).
Within KAS, runtime also refers to the virtual machine that manage the program written in a computer language while it is running where there is a failure in any related function block.
- Using the KAS Simulator, all pathnames 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.
- Opening a file with F_AOPEN, F_ROPEN, and F_WOPEN 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..
-
- Be sure to review File Path Conventions so you understand hardware-based functional differences.