pbp_include.h
Go to the documentation of this file.
1/** @file pbp_include.h Includes all luabindings plug-in headers */
2
3/*
4 ****************************************************
5 Convenience header file that includes all headers
6 relevant to the pybindings plug-in.
7
8 (c) Thomas Moor 2023 - 2026
9 ****************************************************
10 */
11
12
13#ifndef FAUDES_PBP_INCLUDE_H
14#define FAUDES_PBP_INCLUDE_H
15
16// include all headers for this plugin
17#include "pbp_addons.h"
18
19
20/**
21
22@defgroup PybindingsPlugin Python Bindings Plug-In
23
24
25@ingroup AllPlugins
26
27<p>
28This plug-in implements libFAUDES bindings for the scripting language Python;
29see https://www.python.org. Relevant libFAUDES data types and functions
30can be accessed from the Python interpreter. The most convenient method
31to make the faudes module available is to install it via <tt>pip</tt>; i.e., for
32Linux, macOS and Windows/MSYS
33</p>
34
35@code{.unparsed}
36$ pip install faudes
37$ python3 -c "import faudes; print(faudes.Version())"
38@endcode
39
40or, for native Windows
41
42@code{.unparsed}
43> py -m pip install faudes
44> py -c "import faudes; print(faudes.Version())"
45@endcode
46
47<p>
48This will search the index pypi.org for a binary distribution that fits your
49platform/archirectur. In the case that no such matching binary is present,
50please let us know. Instructions on how to compile
51your own binary are below.
52</p>
53
54
55
56
57@subsection SecPybindingsIntro1 Example Script
58
59<p>
60In large, libFAUDES Python bindings follow the same conventions as the Lua bindingins.
61Thus, you may want to inspect the documentation of the latter;
62see https://fgdes.tf.fau.de/faudes/luafaudes/index.html.
63libFAUDES specific Python tutorial ship with the sourcse distribution;
64see <tt>./libFAUDES/pybindings/tutorial</tt>.
65</p>
66
67<p>
68Example Python script:
69</p>
70
71@code{.unparsed}
72
73# load libFAUDES bindings
74import faudes
75
76# test
77faudes.Version()
78
79# machine 1
80gL1=faudes.Generator()
81gL1.InsInitState("Idle")
82gL1.SetMarkedState("Idle")
83gL1.InsState("Busy")
84gL1.InsEvent("alpha1")
85gL1.InsEvent("beta1")
86gL1.SetTransition("Idle","alpha1","Busy")
87gL1.SetTransition("Busy","beta1","Idle")
88
89# machine 2
90gL2=faudes.Generator()
91gL2.InsInitState("Idle")
92gL2.SetMarkedState("Idle")
93gL2.InsState("Busy")
94gL2.InsEvent("alpha2")
95gL2.InsEvent("beta2")
96gL2.SetTransition("Idle","alpha2","Busy")
97gL2.SetTransition("Busy","beta2","Idle")
98
99# overall plant
100gL=faudes.Generator()
101faudes.Parallel(gL1,gL2,gL)
102
103# controllable events
104sCtrl=faudes.EventSet()
105sCtrl.Insert("alpha1")
106sCtrl.Insert("alpha2")
107
108# specification aka buffer
109gE=faudes.Generator()
110gE.InsInitState("Empty")
111gE.SetMarkedState("Empty")
112gE.InsState("Full")
113gE.InsEvent("beta1")
114gE.InsEvent("alpha2")
115gE.SetTransition("Empty","beta1","Full")
116gE.SetTransition("Full","alpha2","Empty")
117
118# lift specification to overall eventset
119sAll=faudes.EventSet()
120sAll=gL.Alphabet()
121faudes.InvProject(gE,sAll)
122
123# supremal closed loop
124gK=faudes.Generator()
125faudes.SupCon(gL,sCtrl,gE,gK)
126
127# show result on console
128gK.Write()
129
130# save result as graphics
131gK.GraphWrite("K.png")
132
133@endcode
134
135<p>
136Note: for graphics output you must have installed <tt>dot</tt> from the GraphViz package.
137If <tt>dot</tt> is not in the systems path, you may direct libfaudes via
138<tt>faudes.DocExecPath("/wherever_dot_is/dot")</tt>.
139</p>
140
141
142
143@subsection SecPybindingsIntro3 Building the libFAUDES Python module
144
145<p>
146The faudes Python module consists of the glue code <tt>faudes.py</tt> and a suitably
147extended libFAUDES shrared object <tt>_faudes.so</tt> (or <tt>_faudes.pyd</tt> for Windows).
148Both files are generated by the libFAUDES build system; see
149<a href="../faudes_build.html">build-system documentation</a> for details.
150Manualy copying/renaming both files to a project folder enables the import of the
151faudes module from Python scripts in that folder.
152</p>
153
154<p>
155Example for the overall build process incl. copy/rename:
156<p>
157
158@code{.unparsed}
159./libFAUDES$ make dist-clean
160./libFAUDES$ make -j configure
161./libFAUDES$ make -j
162./libFAUDES$ cp plugings/pybindings/obj/faudes.py whereever/
163./libFAUDES$ cp plugings/pybindings/obj/_faudes.so whereever/
164./libFAUDES$ cd whereever
165./whereever$ python3 -c "import faudes; print(faudes.Version())"
166@endcode
167
168<p>
169The libFAUDES build system also has a dedicated target <tt>pybindings-wheel</tt>
170that utilises the Python module <tt>build</tt> to generate a Python package <tt>faudes-*.whl</tt>
171for binary distribution. The latter can be installed via <tt>pip</tt>.
172The benefit of this approach is that Python <tt>build</tt> takes care of matching
173toolchains etc. and that after installing the wheel the module files do not need
174to be copied to each relevant project folder.
175The downside is that Python <tt>build</tt> wont use parallel jobs and therefore can take quite
176some time.
177</p>
178
179<p>
180Example for the overall build process incl. installation:
181<p>
182
183@code{.unparsed}
184./libFAUDES$ make dist-clean
185./libFAUDES$ make -j configure
186./libFAUDES$ make pybindings-wheel
187./libFAUDES$ pip install faudes-2.34.0-cp314-cp314-macosx_10_15_universal2.whl
188@endcode
189
190<p>
191Alternatively, you may download the configured source from PyPI and invoke <tt>build</tt>
192directly; e.g. for Windows with official Python distribution and MSVC installed, but no MSYS
193avialable:
194</p>
195@code{.unparsed}
196./faudes-2.34> py -m build --wheel --outdir=./
197@endcode
198</p>
199
200
201@subsection PyLicense License
202
203The Python bindings plug-in is distributed with libFAUDES.
204All code is provided under terms of the LGPL.
205
206
207Copyright (c) 2023 - 2026 Thomas Moor.
208
209
210
211*/
212
213
214
215#endif

libFAUDES 2.34d --- 2026.03.11 --- c++ api documentaion by doxygen