Skip to content

Ceber/sfc

Repository files navigation

Sequential Function Chart Library – C++ 2nd party library: based on standard library

Library to handle sequence running composed by steps and transitions. Each step can trigger several actions.

The main purpose is to interpret "grafcet" sequences. It is not forseen for "production use" (even if it could be enough). It is used for sequences developpment, in collaboration with another library that enable to generate C++ code to "hard-code" sequences, that give more determinism and enable "soft real-time".

We distinguish three kinds of sequences, and all possible combinations that respect the chart constraints:

  • Unique Sequence
  • Simultaneous Sequence
  • Exclusive Sequence

Availibilities:

  • Run "interpreted sequences", Grafcet like.
  • Macro: Reusable sequence subset.
  • Check if sequences are crazy: Looping / Too Much Parallelism
  • Configurable threading (thread_pool sizing).
  • Sequence consistency checks.

About:

  • This library is not meant to be able to externally wait on step activation (We get an event notification when a step is activated/deactivated)
  • This implementation use a thread_pool whose default threads count is the current ‘hardware thread contexts’ count of the machine (16 on my device)
  • Each step run in its own thread (So only 16 steps can run simultaneously on my machine).

TODO

Check against EN60848 ? It is probably far to be exhaustive. Feel free to help.

Docker - Build for Windows

Build image

docker build -f docker/Dockerfile -t sfc-mingw .

Run container

docker run --name sfc-mingw -d --rm -it sfc-mingw

Attach to container

docker attach sfc-mingw

Run sfc build without attaching (outputs in build/bin)

docker run --rm --platform linux/amd64 -v "$(pwd):/src" --entrypoint /bin/bash sfc-mingw -c '
cd /src;                                                        
mkdir -p build && cd build;
cmake -G Ninja -DBUILD_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=/opt/mingw/mingw-toolchain.cmake .. && ninja
'

Build test main (outputs in docker/output)

docker run --rm --platform linux/amd64 -v "$(pwd):/src" -v "$(pwd)/docker/output:/output" --entrypoint /bin/bash sfc-mingw -c '
cd /src;                                                        
$CXX docker/test.cpp -Iinclude -Ibuild/third_party/mingw-std-threads/cmake_stdheaders_generator/cmake_stdheaders_generator -o /output/sfc_test.exe -std=c++20 -pthread -Lbuild/bin/ -lsfc -static-libgcc -static-libstdc++   
'

About

C++ 'Sequential function chart'

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors