Skip to content

Python framework for easy control algorithms writing with many ready to use blocks. Can be seen as a combination of Node-RED and PLC ladder programming.

License

Notifications You must be signed in to change notification settings

KrystianD/pycontrolflow

Repository files navigation

pycontrolflow

Python framework for easy control algorithms writing. It can be seen as a combination of Node-RED and PLC ladder programming.

Write algorithms in the declarative (telling systems what you want), instead of the imperative way (telling systems what to do).

It is based on Nodes connected to each other via Variables forming a Flow.

Features

  • Many ready to use blocks,
  • Persistence support,
  • Strong type checking both in runtime and with mypy checking,
  • Nulls not allowed,
  • Fully testable - no dependency on the environment (date/time).

Example use cases

  • Controlling battery charging/discharging for solar installations,
  • Battery maintenance state machine,
  • Fault management,
  • ... and much more!

Example

See examples here.

Concepts

  • Flow - consists of Nodes that are executed in order,
  • Node - performs some operations on its inputs, resulting in outputs, configured via parameters,
  • Variable - holds data:
    • var - temporary variable for passing data out of the flow and to use between flow nodes
    • memory - variable that persists across flow executions, including passing data into the flow,
  • Timers - performing time-related tasks:
    • One shot - sets its output to True if time elapses, triggered with its trigger variable, or reset with its reset variable,
      • Repeating - sets its output to True every time it elapses

Nodes

Comparators

Date/time utils

  • DayCrosser - detects the day change (with optional specific time)
  • TimeCheck - checks if current time is within range

Flow control

  • If - branches flow depending on the condition

Gates

Logic

  • And - logical AND on the inputs
  • Or - logical OR on the inputs
  • Invert - logical NOT on the input
  • LogicOp - base node for creating logic operators

Timers

  • TimerOnDelay - enables its output if the input is True for specific amount of time (like PLC ON Timer)
  • TimerStop - stops running one-shot timer
  • TimerTrigger - triggers (or re-triggers) one-shot timer

Util

  • ConditionMonitor - advanced condition monitor with an optional gap allowance
  • Debounce - limit change rate of a variable
  • Select - helper for selecting values based on input value
  • Startup - outputs True only on the first Flow run
  • Transform - transforms input values into output value using specified user function

Values

  • Set - outputs True
  • Clear - outputs False
  • Move - moves input to output

About

Python framework for easy control algorithms writing with many ready to use blocks. Can be seen as a combination of Node-RED and PLC ladder programming.

Topics

Resources

License

Stars

Watchers

Forks