FG DES
libFAUDES
DESTool
LRT >>
EEI >>
About
User Reference
C++ API
luafaudes
Developer
Links
libFAUDES
C++ API
Sections
Sets
Generators
Functions
PlugIns
Tutorials
Index
Classes
Files
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>
28
This plug-in implements libFAUDES bindings for the scripting language Python;
29
see https://www.python.org. Relevant libFAUDES data types and functions
30
can be accessed from the Python interpreter. The most convenient method
31
to make the faudes module available is to install it via <tt>pip</tt>; i.e., for
32
Linux, 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
40
or, 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>
48
This will search the index pypi.org for a binary distribution that fits your
49
platform/archirectur. In the case that no such matching binary is present,
50
please let us know. Instructions on how to compile
51
your own binary are below.
52
</p>
53
54
55
56
57
@subsection SecPybindingsIntro1 Example Script
58
59
<p>
60
In large, libFAUDES Python bindings follow the same conventions as the Lua bindingins.
61
Thus, you may want to inspect the documentation of the latter;
62
see https://fgdes.tf.fau.de/faudes/luafaudes/index.html.
63
libFAUDES specific Python tutorial ship with the sourcse distribution;
64
see <tt>./libFAUDES/pybindings/tutorial</tt>.
65
</p>
66
67
<p>
68
Example Python script:
69
</p>
70
71
@code{.unparsed}
72
73
# load libFAUDES bindings
74
import faudes
75
76
# test
77
faudes.Version()
78
79
# machine 1
80
gL1=faudes.Generator()
81
gL1.InsInitState("Idle")
82
gL1.SetMarkedState("Idle")
83
gL1.InsState("Busy")
84
gL1.InsEvent("alpha1")
85
gL1.InsEvent("beta1")
86
gL1.SetTransition("Idle","alpha1","Busy")
87
gL1.SetTransition("Busy","beta1","Idle")
88
89
# machine 2
90
gL2=faudes.Generator()
91
gL2.InsInitState("Idle")
92
gL2.SetMarkedState("Idle")
93
gL2.InsState("Busy")
94
gL2.InsEvent("alpha2")
95
gL2.InsEvent("beta2")
96
gL2.SetTransition("Idle","alpha2","Busy")
97
gL2.SetTransition("Busy","beta2","Idle")
98
99
# overall plant
100
gL=faudes.Generator()
101
faudes.Parallel(gL1,gL2,gL)
102
103
# controllable events
104
sCtrl=faudes.EventSet()
105
sCtrl.Insert("alpha1")
106
sCtrl.Insert("alpha2")
107
108
# specification aka buffer
109
gE=faudes.Generator()
110
gE.InsInitState("Empty")
111
gE.SetMarkedState("Empty")
112
gE.InsState("Full")
113
gE.InsEvent("beta1")
114
gE.InsEvent("alpha2")
115
gE.SetTransition("Empty","beta1","Full")
116
gE.SetTransition("Full","alpha2","Empty")
117
118
# lift specification to overall eventset
119
sAll=faudes.EventSet()
120
sAll=gL.Alphabet()
121
faudes.InvProject(gE,sAll)
122
123
# supremal closed loop
124
gK=faudes.Generator()
125
faudes.SupCon(gL,sCtrl,gE,gK)
126
127
# show result on console
128
gK.Write()
129
130
# save result as graphics
131
gK.GraphWrite("K.png")
132
133
@endcode
134
135
<p>
136
Note: for graphics output you must have installed <tt>dot</tt> from the GraphViz package.
137
If <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>
146
The faudes Python module consists of the glue code <tt>faudes.py</tt> and a suitably
147
extended libFAUDES shrared object <tt>_faudes.so</tt> (or <tt>_faudes.pyd</tt> for Windows).
148
Both files are generated by the libFAUDES build system; see
149
<a href="../faudes_build.html">build-system documentation</a> for details.
150
Manualy copying/renaming both files to a project folder enables the import of the
151
faudes module from Python scripts in that folder.
152
</p>
153
154
<p>
155
Example 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>
169
The libFAUDES build system also has a dedicated target <tt>pybindings-wheel</tt>
170
that utilises the Python module <tt>build</tt> to generate a Python package <tt>faudes-*.whl</tt>
171
for binary distribution. The latter can be installed via <tt>pip</tt>.
172
The benefit of this approach is that Python <tt>build</tt> takes care of matching
173
toolchains etc. and that after installing the wheel the module files do not need
174
to be copied to each relevant project folder.
175
The downside is that Python <tt>build</tt> wont use parallel jobs and therefore can take quite
176
some time.
177
</p>
178
179
<p>
180
Example 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>
191
Alternatively, you may download the configured source from PyPI and invoke <tt>build</tt>
192
directly; e.g. for Windows with official Python distribution and MSVC installed, but no MSYS
193
avialable:
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
203
The Python bindings plug-in is distributed with libFAUDES.
204
All code is provided under terms of the LGPL.
205
206
207
Copyright (c) 2023 - 2026 Thomas Moor.
208
209
210
211
*/
212
213
214
215
#endif
pbp_addons.h
libFAUDES 2.34d
--- 2026.03.11 --- c++ api documentaion by
doxygen
>>
C++ API
Introduction
Sets
Generators
Functions
PlugIns
Tutorials
Classes
Files
Top of Page