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.

The following 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

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