| |
|
|||||||
|
|
||||||||
|
Python Bindings Plug-In This plug-in implements libFAUDES bindings for the scripting language Python; see https://www.python.org. Relevant libFAUDES data types and functions can be accessed from the Python interpreter. The most convenient method to make the faudes module available is to install it via $ pip install faudes
$ python3 -c "import faudes; print(faudes.Version())"
or, for native Windows > py -m pip install faudes
> py -c "import faudes; print(faudes.Version())"
This will search the index pypi.org for a binary distribution that fits your platform/archirectur. In the case that no such matching binary is present, please let us know. Instructions on how to compile your own binary are below. Example ScriptIn large, libFAUDES Python bindings follow the same conventions as the Lua bindingins. Thus, you may want to inspect the documentation of the latter; see https://fgdes.tf.fau.de/faudes/luafaudes/index.html. libFAUDES specific Python tutorial ship with the sourcse distribution; see Example Python script: # load libFAUDES bindings
import faudes
# test
faudes.Version()
# machine 1
gL1=faudes.Generator()
gL1.InsInitState("Idle")
gL1.SetMarkedState("Idle")
gL1.InsState("Busy")
gL1.InsEvent("alpha1")
gL1.InsEvent("beta1")
gL1.SetTransition("Idle","alpha1","Busy")
gL1.SetTransition("Busy","beta1","Idle")
# machine 2
gL2=faudes.Generator()
gL2.InsInitState("Idle")
gL2.SetMarkedState("Idle")
gL2.InsState("Busy")
gL2.InsEvent("alpha2")
gL2.InsEvent("beta2")
gL2.SetTransition("Idle","alpha2","Busy")
gL2.SetTransition("Busy","beta2","Idle")
# overall plant
gL=faudes.Generator()
faudes.Parallel(gL1,gL2,gL)
# controllable events
sCtrl=faudes.EventSet()
sCtrl.Insert("alpha1")
sCtrl.Insert("alpha2")
# specification aka buffer
gE=faudes.Generator()
gE.InsInitState("Empty")
gE.SetMarkedState("Empty")
gE.InsState("Full")
gE.InsEvent("beta1")
gE.InsEvent("alpha2")
gE.SetTransition("Empty","beta1","Full")
gE.SetTransition("Full","alpha2","Empty")
# lift specification to overall eventset
sAll=faudes.EventSet()
sAll=gL.Alphabet()
faudes.InvProject(gE,sAll)
# supremal closed loop
gK=faudes.Generator()
faudes.SupCon(gL,sCtrl,gE,gK)
# show result on console
gK.Write()
# save result as graphics
gK.GraphWrite("K.png")
Note: for graphics output you must have installed Building the libFAUDES Python moduleThe faudes Python module consists of the glue code Example for the overall build process incl. copy/rename: ./libFAUDES$ make dist-clean
./libFAUDES$ make -j configure
./libFAUDES$ make -j
./libFAUDES$ cp plugings/pybindings/obj/faudes.py whereever/
./libFAUDES$ cp plugings/pybindings/obj/_faudes.so whereever/
./libFAUDES$ cd whereever
./whereever$ python3 -c "import faudes; print(faudes.Version())"
The libFAUDES build system also has a dedicated target Example for the overall build process incl. installation: ./libFAUDES$ make dist-clean
./libFAUDES$ make -j configure
./libFAUDES$ make pybindings-wheel
./libFAUDES$ pip install faudes-2.34.0-cp314-cp314-macosx_10_15_universal2.whl
Alternatively, you may download the configured source from PyPI and invoke ./faudes-2.34> py -m build --wheel --outdir=./
LicenseThe Python bindings plug-in is distributed with libFAUDES. All code is provided under terms of the LGPL. Copyright (c) 2023 - 2026 Thomas Moor. libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen |