|
|
||||||
|
Python Bindings PlugIn This plug-in generates libFAUDES bindings for the scripting language Python; see http://www.python.org. With this plug-in, the most essential libFAUDES data types and functions can be accesed from the Python interpreter. Disclaimer: the primary scripting laguage for libFAUDES is Lua; see the Lua bindings plug-in. Specifically, Lua bindings provide a more comprehensive interface, which is systematically tested on a more regular basis. If you experience short commings of libFAUDES Python bindings, please do not hesitate to report back to us. Restrictions:
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. For further inspiration, tutorials can be found at For the following example, run Python in/from a directoty in which the libFAUDES bindings reside (files # 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.SupConNB(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 Build SystemTo use python bindings, you will need to configure and recompile libFAUDES; see also build-system documentation for an overview. Notes:
LicenseThe Python bindings plug-in is distributed with libFAUDES. All code is provided under terms of the LGPL. Copyright (c) 2023, 2024 Thomas Moor. libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen |