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 shared directory.
- Read cam tables into the program from the SD card or a shared directory.
- Store machine operational data in internal PxMM flash memory (retrievable through the web server), the SD card, or a shared directory.
Please note that a shared directory 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.
Fucnction Block | Use |
---|---|
FileClose | Close an open file |
FileCopy | Copy a file |
FileDelete | Remove a file |
FileEOF | Test if the end of the file is reached in a file that is open for reading |
FileExists | Test if a file exists |
FileOpenA | Create or open a file in append mode |
FileOpenR | Open a file for reading |
FileOpenW | Create or reset a file and open it for writing |
FileReadBinData | Read binary data from a file |
FileReadLine | Read a string value from a text file |
FileRename | Rename a file |
FileSeek | Set the current position of a file |
FileSize | Get the size of a file |
FileWriteBinData | Write binary data to a file |
FileWriteLine | Write a string value to a text file |
The following functions handle mounting of SD cards.
Name | Use |
---|---|
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 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. Opening some files can be dangerous for system safety and integrity. The number of open files (from FileOpenA, FileOpenR, and FileOpenW) is limited by the resources available on the target system.
- Ensure that each file successfully opened using FileOpenA, FileOpenR, and FileOpenW has a corresponding FileClose to close the file. Closing the file will release the file ID, making it available for operations on other files.
- The deprecated functions will stall the PLC"Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events, causing the controller to miss PLC cycles.
- The IDs used by the file function blocks are not compatible with the deprecated file functions.
- The IDs used by the deprecated file functions are not compatible with the file function blocks.
-
-
- 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 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 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.
-
- Be sure to review File Path Conventions to understand hardware-based functional differences.