co📁e - (XML) File Handling

aliazzz hermsen
There is a newer version of this page. You can find it here.


Project Members:


co📁e - (XML) File Handling

Introduction | Usecases | Download | Acknowledgements

Introduction

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

Usecases

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
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 filesize on disk.
For sake of simplicity such tasks are not implemented by default.

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 Stream Buffer fast parsing, easy to implement, large memory requirement, suited for larger controllers only handles XML files which fit entirely into the buffer
Small Stream Buffer fast parsing, easy to implement, low memory requirement, suited for micro embedded controllers handles any XML file size on disk
Examples for both parsing methods are included

Downloads

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

Acknowledgements

  • Basic idea and coding: H.A. Hermsen
  • bugfixes, testing: i-campbell and Aliazzz.
  • Small memory footprint file parsing: TimvH



co📁e - XML File Handling

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

Project Members: