co🗁e: (XML) File Handling

aliazzz hermsen


Project Members:


co🗁e: (XML) File Handling

File handling made easy

Introduction | Usecase | Download | Acknowledgements

Introduction

A simple yet flexible library to enable easy file control and parse / compose XML data in CODESYS based PLC's via the following function blocks;

Usecase

Function Block (Class) Usecase
FB_Filecontrol Provides the user a generic and easy way to open, close, read, write files on disk
FB_StreamBuffer Provides the user a generic and easy way to compose file contents, this enables you to build your own file content parser quickly
FB_XmlControl Provides a complete solution to read, write, parse and compose XML files.

File Control

Provides generic file control manager in following manner:

Action Task
Open Opens a file on disk (or create and open)
Close Close a file on disk
Read Read contents into a buffer for further handling
Write Write buffer contents to file on disc
SetPos Sets the file position pointer on disk to an offset, so you can read or write with an offset
Delete Deletes the file from disk
Important: Every file on disk needs to implement a seperate File Control manager

The generic file control manager can easily be expanded with tasks like returning the full path of your file or returning the file size on disk.
For sake of simplicity these methods are not implemented.

Stream Buffer

Enables the user to compose various types of file contents, via ASCII.
The buffersize is allocated on initialization and has a user-configurable size.
This FB forms a basis for any file format on disk like json, csv, etc, etc.

XML parsing

Provides easy xml-parsing and composing.
Parsing and composing depends on several factors but mainly the available memory in the PLC system;

Method pro's con's
Large Buffer fast parsing, easy to implement, large memory footprint, suited for larger controllers can only handles files which fit entirely into the memory buffer
Tiny Buffer fast parsing, easy to implement, tiny memory footprint, suited for micro embedded controllers can handle any file size on disk
Examples for large and tiny memory footprint parsing methods are included

Download

Downloads hosted on github;
https://github.com/HAHermsen/co5e-XML-File-Handling

Acknowledgements

  • Basic idea and coding: H.A. Hermsen
  • Tiny memory footprint XML parsing: TimvH
  • Bugfixes, testing: i-campbell and Aliazzz.



https://www.linkedin.com/in/hahermsen
Project Members: