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, 2024
9  ****************************************************
10  */
11 
12 
13 #ifndef FAUDES_PBP_INCLUDE_H
14 #define FAUDES_PBP_INCLUDE_H
15 
16 
17 
18 /**
19 
20 @defgroup PybindingsPlugin Python Bindings PlugIn
21 
22 
23 @ingroup AllPlugins
24 
25 <p>
26 This plug-in generates libFAUDES bindings for the scripting language Python;
27 see http://www.python.org.
28 With this plug-in, the most essential libFAUDES data types and functions
29 can be accesed from the Python interpreter.
30 </p>
31 
32 <p>
33 Disclaimer: the primary scripting laguage for libFAUDES is Lua; see the Lua bindings plug-in.
34 Specifically, Lua bindings provide a more comprehensive interface, which is systematically
35 tested on a more regular basis. If you experience short commings of libFAUDES Python bindings,
36 please do not hesitate to report back to us.
37 </p>
38 
39 <p>
40 Restrictions:
41 
42 - The build system allows for either Lua bindings or Python bindings; building both
43  simultaneously is not supported.
44 
45 
46 - For most plug-ins, bindings are automatically generated via SWIG based on so called
47  interface files (residing in <tt>libfaudes/plugins/`*`/registry/`*`.i</tt>);
48  regarding Python, only the plug-ins Synthesis and Observer have been tested.
49 
50 </p>
51 
52 @section SecPybindingsIntro1 Example Script
53 
54 <p>
55 In large, libFAUDES Python bindings follow the same conventions as the Lua bindingins.
56 Thus, you may want to inspect the documentation of the latter. For further inspiration,
57 tutorials can be found at <tt>pybindings/tutorial</tt>.
58 </p>
59 
60 <p>
61 For the following example, run Python in/from a directoty in which the
62 libFAUDES bindings reside (files <tt>_faudes.so</tt> and <tt>faudes.py</tt>).
63 </p>
64 
65 @code{.unparsed}
66 
67 # load libFAUDES bindings
68 import faudes
69 
70 # test
71 faudes.Version()
72 
73 # machine 1
74 gL1=faudes.Generator()
75 gL1.InsInitState("Idle")
76 gL1.SetMarkedState("Idle")
77 gL1.InsState("Busy")
78 gL1.InsEvent("alpha1")
79 gL1.InsEvent("beta1")
80 gL1.SetTransition("Idle","alpha1","Busy")
81 gL1.SetTransition("Busy","beta1","Idle")
82 
83 # machine 2
84 gL2=faudes.Generator()
85 gL2.InsInitState("Idle")
86 gL2.SetMarkedState("Idle")
87 gL2.InsState("Busy")
88 gL2.InsEvent("alpha2")
89 gL2.InsEvent("beta2")
90 gL2.SetTransition("Idle","alpha2","Busy")
91 gL2.SetTransition("Busy","beta2","Idle")
92 
93 # overall plant
94 gL=faudes.Generator()
95 faudes.Parallel(gL1,gL2,gL)
96 
97 # controllable events
98 sCtrl=faudes.EventSet()
99 sCtrl.Insert("alpha1")
100 sCtrl.Insert("alpha2")
101 
102 # specification aka buffer
103 gE=faudes.Generator()
104 gE.InsInitState("Empty")
105 gE.SetMarkedState("Empty")
106 gE.InsState("Full")
107 gE.InsEvent("beta1")
108 gE.InsEvent("alpha2")
109 gE.SetTransition("Empty","beta1","Full")
110 gE.SetTransition("Full","alpha2","Empty")
111 
112 # lift specification to overall eventset
113 sAll=faudes.EventSet()
114 sAll=gL.Alphabet()
115 faudes.InvProject(gE,sAll)
116 
117 # supremal closed loop
118 gK=faudes.Generator()
119 faudes.SupConNB(gL,sCtrl,gE,gK)
120 
121 # show result on console
122 gK.Write()
123 
124 # save result as graphics
125 gK.GraphWrite("K.png")
126 
127 @endcode
128 
129 <p>
130 Note: for graphics output you must have installed <tt>dot</tt> from the GraphViz package.
131 If <tt>dot</tt> is not in the systems path, you may direct libfaudes via
132 <tt>faudes.DocExecPath("/wherever_dot_is/dot")</tt>.
133 </p>
134 
135 
136 
137 @section SecLuabindingsIntro3 Build System
138 
139 <p>
140 To use python bindings, you will need to configure and recompile libFAUDES;
141 see also <a href="../faudes_build.html">build-system documentation</a> for
142 an overview.
143 </p>
144 
145 <p>
146 Notes:
147 
148 - You should configure libFAUDES to use no further plug-ins than Synthesis and Observer.
149  This is done in the main Makefile.
150  If you require Python bindings other plug-ins, please let us know.
151 
152 
153 - The build system is best supported on Linux and OS X. For Windows we recommend to MSYS2 or equivalents.
154 
155 
156 - The build process relies on the developer package of your Python distribution. It
157  needs to be pointed to the paths of <tt>Python.h</tt> and the
158  Python shared object <tt>libpython.so</tt>. There is an attempt to figure those
159  paths automatically, however, your milage may vary;
160  see <tt>pybindings/Makefile.plugin</tt> for manual configuration.
161 
162 
163 - After building libFAUDES as a shared object, copy the files <tt>pybindings/tutorial/faudes.py</tt>
164  and <tt>pybindings/tutorial/_faudes.so</tt> to reside in the same
165  directory as your Python project. Test your settings by starting a Python command promt within your
166  project directory and try, e.g. <tt>import faudes</tt> and <tt>faudes.Version()</tt>.
167 
168 
169 - After re-compiling libFAUDES and importing to Python, make shure to clear all caches;
170  i.e., start with a clean directory after each iteration of re-compilation.
171 </p>
172 
173 
174 @section PyLicense License
175 
176 The Python bindings plug-in is distributed with libFAUDES.
177 All code is provided under terms of the LGPL.
178 
179 
180 Copyright (c) 2023, 2024 Thomas Moor.
181 
182 
183 
184 */
185 
186 
187 
188 #endif

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen