Lua Bindings PlugIn
[PlugIns]
This plugin generates libFAUDES bindings for the scripting language Lua; see
http://www.lua.org. With this plugin, a Lua interpreter may serve as an interactive user interface to libFAUDES data types and functions. The tutorial section includes a number of example scripts to demonstrate libFAUDES access from Lua.
The luabindings plugin also includes the application luafaudes, a variation of the std Lua interpreter that runs FAUDES extended lua scripts. If your target platform is Linux, you really want to edit the Makefile.plugin for LBP_LUAGOAL=linux to activate advanced readline support (tab key completion, command history etc).
The following script runs a simple synthesis procedure to synthesise a supervisor - sic - for our two simple machines. For examples, see "./plugins/luabindings/tutorial/_*_.lua" and the introduction given on
http://www.rt.eei.uni-erlangen.de/FGdes/faudes/faudes_luafaudes.html
-- read original machine
machine = faudes.Generator("data/verysimplemachine.gen")
-- prepare two copies
machine1 = faudes.Generator();
machine2 = faudes.Generator();
faudes.Version(machine,"1",machine1);
faudes.Version(machine,"2",machine2);
-- compose overall plant
plant = faudes.Generator();
faudes.Parallel(machine1,machine2,plant);
-- load specification
spec = faudes.Generator("data/buffer12.gen");
-- run synthesis
super = faudes.Generator();
faudes.SupConNB(plant,spec,super);
-- report result
plant:Write();
spec:Write();
super:Write();
When you use the libFAUDES plugin mechanism to implement your algorithms, you may find it useful to include your extensions in the Lua based interface. The wrapper code is automatically generated from so called interface definition files using the tool SWIG; see
http://www.swig.org. Thus, the additional code required to integrate your plugin into luafaudes is minimal.
The following extract is from the example plugin and defines the interface for the AlternativeAccessible function; see also "./plugins/example/src/pex_interface.i".
%module example
%include <std_string.i>
%include <std_except.i>
%import "corefaudes.i"
%{
#include "corefaudes.h"
#include "pex_include.h"
using namespace faudes;
%}
void AlternativeAccessible(vGenerator& rGen);
void OtherFunction(vGenerator& rGen, rEventSet& rAlph);
bool IsGoodTest(vGenerator& rGen, rEventSet& rAlph);
...
Since not every libFAUDES based application requires luabindings, the luabindings plugin does not add code to libFAUDES itself but compiles to a seperate archive named libluafaudes (.a,.so,.dll)
The build system organises the compilation of the luabindings plugin in two statges:
- At stage one, SWIG is used to generate the wrapper code. Since the plugin ships with appropriate wrapper code, this stage only needs to be processed if you want to generate additional bindings for you plugin. You will need SWIG version 1.3.36 installed on your system; see http://www.swig.org. Use "make luabindings-clean" and "make luabindings-prepare" to re-make the wrapper code.
- At stage two, the wrapper code and Lua is compiled to the archive libluafaudes.h. The plugin includes the lua sources, no additional software requirements are imposed. This stage is processed by the std build procedure, eg "make dist-clean" and "make".
The luabindings plugin is distributed with libFAUDES. All code except the Lua sources are provided under terms of the LGPL.
Copyright (c) 2008, Thomas Moor.
Lua sources are included for convenience and come under terms of the following MIT License:
License for Lua 5.0 and later versions Copyright (c) 1994-2008 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.