Skip to main content

Python Finite State Machines for EPICS

Project description


Python Finite State Machines for EPICS

Developers: Damiano Bortolato - Davide Marcato @ Laboratori Nazionali di Legnaro - INFN

Main Repository:

Full documentation:

Main features

  • Easy to use and fast development of complex event based fsm - just code the states!
  • Full EPICS Channel Access integration via PyEpics.
  • High expandability as provided by all the libraries of Python.
  • Integrated configurable logging systems.
  • Convenient methods to access all the information on I/O.
  • Timers can be used to execute actions after a time delay.
  • Integrated watchdog logic.
  • Multi-threading: each fsm is executed on a different thread, sharing I/O.
  • Convenient loader to launch a daemon with multiple fsm.
  • Possibility to apply a configurable naming convention on I/O.


To install simply run:

pip install pysmlib

or download the latest release/sources from github, unpack it and run:

cd pysmlib
pip install .


Requires Python 3.6+. Pyepics is required and automatically installed by pip. Sphinx and its theme "Read the Docs" are required to build the documentation.


#! /usr/bin/python
from smlib import fsmBase, loader

# FSM definition
class exampleFsm(fsmBase):
    def __init__(self, name, *args, **kwargs):
        super(exampleFsm, self).__init__(name, **kwargs)

        self.counter = self.connect("testcounter") # connect to PV "testcounter"
        self.mirror = self.connect("testmirror")
        self.enable = self.connect("testenable")


    # idle state
    def idle_eval(self):
        if self.enable.rising():

    # mirroring state
    def mirroring_eval(self):
        if self.enable.falling():
        elif self.counter.changing():
            readValue = self.counter.val()

# Main
if __name__ == '__main__':
    # load the fsm
    l = loader()
    l.load(exampleFsm, "myFirstFsm")

    # start execution

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysmlib-3.2.0.tar.gz (36.5 kB view hashes)

Uploaded source

Built Distribution

pysmlib-3.2.0-py3-none-any.whl (35.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page