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, USBClosed "Universal Serial Bus" USB is a serial bus standard to interface devices 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 in 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).

These function blocks enable sequential read / write operations in disk files:

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.

These 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 FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. 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.
      • The 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.