jubnzv / iec-checker

Static analysis of IEC 61131-3 programs
GNU Lesser General Public License v3.0
60 stars 12 forks source link
ics iec61131-3 industrial-automation ocaml plc program-analysis static-analysis structured-text

IEC Checker

License: LGPL v3

This project aims to implement an open source tool for static code analysis of IEC 61131-3 programs.

Supported languages

This tool currently supports Structured Text programming language, PLCOpen XML and SEL XML formats. It works with extended Structured Text dialect that is completely compatible with matiec transpiler.

If you find, that iec-checker doesn't work with Structured Text extensions provided by your PLC vendor, please let me know. This can probably be easily implemented with some tweaks in the parser.

Features

The following features are currently implemented:

Installation

You can download the latest binary release for Linux and Windows x86_64 from GitHub releases.

Build from sources

Linux

Install the latest OCaml compiler and opam. Consider installation instructions at ocaml.org and opam.ocaml.org.

Then install the required dependencies:

opam install --deps-only .    # first time only

Build and install the bin/iec_checker binary:

make build

Windows

Install OCaml for Windows according to the installation guide. The graphic installer works well "out of the box".

Then open installed Cygwin shell, clone the repository and use the installation instructions from the "Linux" section.

Optional: Python scripts and test suite

There is also a convenient checker.py script that wraps OCaml binary and provide additional options like extended formatting support and running the Python plugins. The test suite is also written in Python and requires a Python interpreter with some additional packages.

Get Python 3 and install dependencies in the virtual environment:

virtualenv venv --python=/usr/bin/python3
source venv/bin/activate
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt

Then run unit tests:

make test

Usage examples

Check some demo programs written in Structured Text:

bin/iec_checker test/st/*.st

You can also use --help argument to display help.