Index: trunk/demos/Sinus/CMakeLists.txt
===================================================================
--- trunk/demos/Sinus/CMakeLists.txt (revision 14)
+++ trunk/demos/Sinus/CMakeLists.txt (revision 14)
@@ -0,0 +1,37 @@
+PROJECT(Sinus)
+cmake_minimum_required(VERSION 2.8)
+
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+SET(FLAIR_USE_FILTER TRUE)
+
+include($ENV{FLAIR_ROOT}/flair-dev/cmake-modules/GlobalCmakeFlair.cmake)
+include(${FLAIR_USE_FILE})
+
+SET(SRC_FILES
+ ${CMAKE_SOURCE_DIR}/src/main.cpp
+ ${CMAKE_SOURCE_DIR}/src/Loop.cpp
+ ${CMAKE_SOURCE_DIR}/src/Sinus.cpp
+ ${CMAKE_SOURCE_DIR}/src/MeanFilter.cpp
+)
+
+LINK_DIRECTORIES (
+ ${FLAIR_LIBRARY_DIR}
+)
+
+INCLUDE_DIRECTORIES(
+ ${FLAIR_INCLUDE_DIR}
+)
+
+#real time executable
+ADD_EXECUTABLE(${PROJECT_NAME}_rt
+ ${SRC_FILES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}_rt ${FLAIR_LIBRARIES_RT})
+
+#non real time executable
+ADD_EXECUTABLE(${PROJECT_NAME}_nrt
+ ${SRC_FILES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME}_nrt ${FLAIR_LIBRARIES_NRT})
Index: trunk/demos/Sinus/build
===================================================================
--- trunk/demos/Sinus/build (revision 14)
+++ trunk/demos/Sinus/build (revision 14)
@@ -0,0 +1,1 @@
+link build_x86_64
Index: trunk/demos/Sinus/build_arm/bin/Sinus.sh
===================================================================
--- trunk/demos/Sinus/build_arm/bin/Sinus.sh (revision 14)
+++ trunk/demos/Sinus/build_arm/bin/Sinus.sh (revision 14)
@@ -0,0 +1,10 @@
+#! /bin/bash
+
+if [ -f /proc/xenomai/version ];then
+ EXEC=./Sinus_rt
+else
+ EXEC=./Sinus_nrt
+fi
+
+$EXEC
+
Index: trunk/demos/Sinus/build_arm/bin/Sinus.xml
===================================================================
--- trunk/demos/Sinus/build_arm/bin/Sinus.xml (revision 14)
+++ trunk/demos/Sinus/build_arm/bin/Sinus.xml (revision 14)
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/demos/Sinus/build_i686/bin/Sinus.sh
===================================================================
--- trunk/demos/Sinus/build_i686/bin/Sinus.sh (revision 14)
+++ trunk/demos/Sinus/build_i686/bin/Sinus.sh (revision 14)
@@ -0,0 +1,10 @@
+#! /bin/bash
+
+if [ -f /proc/xenomai/version ];then
+ EXEC=./Sinus_rt
+else
+ EXEC=./Sinus_nrt
+fi
+
+$EXEC
+
Index: trunk/demos/Sinus/build_i686/bin/Sinus.xml
===================================================================
--- trunk/demos/Sinus/build_i686/bin/Sinus.xml (revision 14)
+++ trunk/demos/Sinus/build_i686/bin/Sinus.xml (revision 14)
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/demos/Sinus/build_x86_64/bin/Sinus.sh
===================================================================
--- trunk/demos/Sinus/build_x86_64/bin/Sinus.sh (revision 14)
+++ trunk/demos/Sinus/build_x86_64/bin/Sinus.sh (revision 14)
@@ -0,0 +1,10 @@
+#! /bin/bash
+
+if [ -f /proc/xenomai/version ];then
+ EXEC=./Sinus_rt
+else
+ EXEC=./Sinus_nrt
+fi
+
+$EXEC
+
Index: trunk/demos/Sinus/build_x86_64/bin/Sinus.xml
===================================================================
--- trunk/demos/Sinus/build_x86_64/bin/Sinus.xml (revision 14)
+++ trunk/demos/Sinus/build_x86_64/bin/Sinus.xml (revision 14)
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: trunk/demos/Sinus/src/Loop.cpp
===================================================================
--- trunk/demos/Sinus/src/Loop.cpp (revision 14)
+++ trunk/demos/Sinus/src/Loop.cpp (revision 14)
@@ -0,0 +1,95 @@
+// created: 2013/06/26
+// filename: Loop.h
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+//
+//
+/*********************************************************************/
+
+//include header of the class
+#include "Loop.h"
+//include only header of class declared in Loop.h (forward declaration)
+#include "Sinus.h"
+#include "MeanFilter.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+using namespace std;
+using namespace flair::core;
+using namespace flair::gui;
+using namespace flair::filter;
+using namespace flair::sensor;
+
+Loop::Loop(FrameworkManager* parent,string name,int priority): Thread(parent,name,priority) {
+ Tab *mainTab=new Tab(parent->GetTabWidget(),ObjectName());
+ killButton=new PushButton(mainTab->NewRow(),"kill");
+ startLogButton=new PushButton(mainTab->NewRow(),"start_log");
+ stopLogButton=new PushButton(mainTab->LastRowLastCol(),"stop_log");
+ period=new SpinBox(mainTab->NewRow(),"period thread:"," ms",10,1000,1);
+
+ sinus=new Sinus(parent,"sinus");
+ sinus->UseDefaultPlot();
+
+ //1st order law pass filter on raw signal, its parent is the sinus
+ firstLowPass=new LowPassFilter(sinus,sinus->GetSetupLayout()->NewRow(),"1st order lawpass filter");
+ sinus->GetPlot()->AddCurve(firstLowPass->Matrix()->Element(0),DataPlot::Blue);//add output of the filter to signal's graph
+
+ //3rd order law pass filter on raw signal, its parent is the sinus
+ thirdLowPass=new ButterworthLowPass(sinus,sinus->GetSetupLayout()->NewRow(),"3rd order lawpass filter",3);
+ sinus->GetPlot()->AddCurve(thirdLowPass->Matrix()->Element(0),DataPlot::Yellow);//add output of the filter to signal's graph
+
+ //mean filter on raw signal, its parent is the sinus
+ mean=new MeanFilter(sinus,sinus->GetSetupLayout()->NewRow(),"Mean filter");
+ sinus->GetPlot()->AddCurve(mean->GetMatrix()->Element(0),DataPlot::Green);//add output of the filter to signal's graph
+
+ //mean filter on 1st order law pass filter, its parent is the 1st order law pass filter
+ meanOnfirstLowPass=new MeanFilter(firstLowPass,sinus->GetSetupLayout()->NewRow(),"Mean filter on 1st order lawpass filter");
+ sinus->GetPlot()->AddCurve(meanOnfirstLowPass->GetMatrix()->Element(0),DataPlot::Black);//add output of the filter to signal's graph
+
+ //set ojects to be logged
+ //as the law pass filters and the mean filters have the sinus as parent, they are automatically logged
+ parent->AddDeviceToLog(sinus);
+}
+
+Loop::~Loop() {
+
+}
+
+//main loop of the Thread
+void Loop::Run(void) {
+ //warn if changing from primary to secondary mode when in real time
+ WarnUponSwitches(true);
+
+ sinus->Start();
+
+ SetPeriodMS(period->Value());
+
+ while(1) {
+ WaitPeriod();
+
+ if(period->ValueChanged()) SetPeriodMS(period->Value());
+
+ if(killButton->Clicked()) break;
+ if(startLogButton->Clicked()) getFrameworkManager()->StartLog();
+ if(stopLogButton->Clicked()) getFrameworkManager()->StopLog();
+
+ //nothing more to do
+ //this is a very simple example
+
+ //normaly, we should use results of filters to calculate a control law
+ }
+
+ WarnUponSwitches(false);
+}
Index: trunk/demos/Sinus/src/Loop.h
===================================================================
--- trunk/demos/Sinus/src/Loop.h (revision 14)
+++ trunk/demos/Sinus/src/Loop.h (revision 14)
@@ -0,0 +1,69 @@
+// created: 2013/06/26
+// filename: Loop.h
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+//
+//
+/*********************************************************************/
+
+#ifndef LOOP_H
+#define LOOP_H
+
+//necessary include, as Thread is a base of our class
+#include
+
+//forward declaration for other classes
+namespace flair {
+ namespace core {
+ class FrameworkManager;
+ }
+ namespace gui {
+ class PushButton;
+ class SpinBox;
+ }
+ namespace sensor {
+ class Sinus;
+ }
+ namespace filter {
+ class LowPassFilter;
+ class ButterworthLowPass;
+ class MeanFilter;
+ }
+}
+
+
+class Loop : public flair::core::Thread
+{
+ public:
+ /*!
+ * \brief Constructor
+ *
+ * Builds main loop
+ *
+ * \param parent the FrameworkManager to use
+ * \param name object name
+ * \param priority Thread priority, 51 by default (1:mini, 99:maxi)
+ */
+ Loop(flair::core::FrameworkManager* parent,std::string name,int priority=51);
+
+ /*!
+ * \brief Destructor
+ */
+ ~Loop();
+
+ private:
+ void Run(void);
+
+ flair::sensor::Sinus *sinus;
+ flair::filter::LowPassFilter *firstLowPass;
+ flair::filter::ButterworthLowPass *thirdLowPass;
+ flair::filter::MeanFilter *mean,*meanOnfirstLowPass;
+ flair::gui::PushButton *startLogButton,*stopLogButton,*killButton;
+ flair::gui::SpinBox *period;
+};
+
+#endif // LOOP_H
Index: trunk/demos/Sinus/src/MeanFilter.cpp
===================================================================
--- trunk/demos/Sinus/src/MeanFilter.cpp (revision 14)
+++ trunk/demos/Sinus/src/MeanFilter.cpp (revision 14)
@@ -0,0 +1,81 @@
+// created: 2013/06/27
+// filename: MeanFilter.cpp
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+// purpose: object computing a mean filter
+//
+//
+/*********************************************************************/
+
+#include "MeanFilter.h"
+#include
+#include
+#include
+#include
+
+using namespace std;
+using namespace flair::core;
+using namespace flair::gui;
+
+namespace flair { namespace filter {
+
+MeanFilter::MeanFilter(const IODevice* parent,const LayoutPosition* position,string name): IODevice(parent,name) {
+ //interface initialisation
+ groupBox=new GroupBox(position,name);
+ numberOfElements=new SpinBox(groupBox->NewRow(),"numberOfElements:",1,MAX_NUMBER_OF_ELEMENTS,1);//saturated to MAX_NUMBER_OF_ELEMENTS
+
+ //init storage
+ for(int i=0; iSetElementName(0,0,"mean filter");//name will be used for graphs and logs
+ output=new cvmatrix(this,desc,floatType,name);
+
+ AddDataToLog(output);
+}
+
+MeanFilter::~MeanFilter() {
+}
+
+cvmatrix *MeanFilter::GetMatrix() const {
+ return output;
+}
+
+float MeanFilter::GetValue(void) const {
+ return output->Value(0,0);
+}
+
+//UpdateFrom, where we implement the filter
+//this method is automatically called when the parent IODevice calls ProcessUpdate
+//in our case it is the sinus or the 1st orde law pass filter
+//(see in Sinus::Run the call to ProcessUpdate)
+void MeanFilter::UpdateFrom(const io_data *data) {
+
+ float result=0;
+ //get input argument in a cvmatrix
+ cvmatrix *input=(cvmatrix*)data;
+
+ //simple (and not efficent!) implementation of the filter
+ previousValues[numberOfElements->Value()-1]=input->Value(0,0);
+ for(int i=0; iValue(); i++) result+=previousValues[i];
+ for(int i=1; iValue(); i++) previousValues[i-1]=previousValues[i];
+
+ //put the result in output matrix
+ output->SetValue(0,0,result/numberOfElements->Value());
+ //put corresponding time
+ output->SetDataTime(data->DataTime());
+
+ //ProcessUpdate is very important
+ //we must call it after updating the output matrix
+ //it allows:
+ // -to save value in the logs
+ // -to automatically call the next filter UpdateFrom method
+ ProcessUpdate(output);
+}
+}// end namespace filter
+}// end namespace flair
Index: trunk/demos/Sinus/src/MeanFilter.h
===================================================================
--- trunk/demos/Sinus/src/MeanFilter.h (revision 14)
+++ trunk/demos/Sinus/src/MeanFilter.h (revision 14)
@@ -0,0 +1,90 @@
+// created: 2013/06/27
+// filename: MeanFilter.h
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+// purpose: object computing a mean filter
+//
+//
+/*********************************************************************/
+
+#ifndef MEANFILTER_H
+#define MEANFILTER_H
+
+//we fix the max number of elements to compute the mean
+//this is a simple example, it should be dynamical
+#define MAX_NUMBER_OF_ELEMENTS 200
+
+//necessary include, as IODevice is a base of our class
+#include
+
+//forward declaration for other classes
+namespace flair {
+ namespace core {
+ class cvmatrix;
+ }
+ namespace gui {
+ class LayoutPosition;
+ class GroupBox;
+ class SpinBox;
+ }
+}
+
+//MeanFilter is a class computing a mean
+// based on a parametrizable number of elements
+// it derives on IODevice as it as an input and an output
+// it is a filter, we extend the namespace
+namespace flair { namespace filter {
+ class MeanFilter : public core::IODevice {
+
+ public:
+ /*!
+ * \brief Constructor
+ *
+ * Builds a mean filter. \n
+ * After calling this function, position will be deleted as it is no longer usefull. \n
+ *
+ * \param parent IODevice to use as parent
+ * \param position where to place settings
+ * \param name name of the object
+ */
+ MeanFilter(const core::IODevice* parent,const gui::LayoutPosition* position,std::string name);
+
+ /*!
+ * \brief Destructor
+ */
+ ~MeanFilter();
+
+ /*!
+ * \brief Output matrix
+ *
+ * allows to access output matrix, to get signal value or to put it in a graph. \n
+ *
+ * \return pointer to the output matrix
+ */
+ core::cvmatrix *GetMatrix(void) const;
+
+ /*!
+ * \brief Value
+ *
+ * this method is equivalent to GetMatrix()->Value(0,0)
+ *
+ * \return actual mean value
+ */
+ float GetValue(void) const;
+
+ private:
+ //UpdateFrom method from base class IODevice
+ void UpdateFrom(const core::io_data *data);
+ gui::GroupBox *groupBox;
+ gui::SpinBox *numberOfElements;
+ core::cvmatrix *output;
+ float previousValues[MAX_NUMBER_OF_ELEMENTS];//previous values storage
+
+ };
+}// end namespace filter
+}// end namespace flair
+#endif // MEANFILTER_H
Index: trunk/demos/Sinus/src/Sinus.cpp
===================================================================
--- trunk/demos/Sinus/src/Sinus.cpp (revision 14)
+++ trunk/demos/Sinus/src/Sinus.cpp (revision 14)
@@ -0,0 +1,128 @@
+// created: 2013/06/26
+// filename: Sinus.cpp
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+// purpose: class generating a sinus signal
+//
+//
+/*********************************************************************/
+
+#include "Sinus.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define PI ((float)3.14159265358979323846)
+
+using namespace std;
+using namespace flair::core;
+using namespace flair::gui;
+
+namespace flair { namespace sensor {
+
+Sinus::Sinus(const FrameworkManager* parent,string name,int priority) : IODevice(parent,name),Thread(parent,name,priority) {
+
+ plot=NULL;
+
+ //1*1 output matrix
+ cvmatrix_descriptor* desc=new cvmatrix_descriptor(1,1);
+ desc->SetElementName(0,0,"value");//name will be used for graphs and logs
+ output=new cvmatrix((IODevice*)this,desc,floatType,name);
+ output->SetValue(0,0,0);
+
+
+ AddDataToLog(output);
+
+ //interface initialisation
+ mainTab=new Tab(parent->GetTabWidget(),name);
+ tabWidget=new TabWidget(mainTab->NewRow(),name);
+
+ Tab* settingsTab=new Tab(tabWidget,"Settings");
+ GroupBox* sinusGroupBox=new GroupBox(settingsTab->NewRow(),name);
+ frequency=new DoubleSpinBox(sinusGroupBox->NewRow(),"frequence:"," Hz",0,100,1);
+ amplitude=new DoubleSpinBox(sinusGroupBox->LastRowLastCol(),"amplitude:",0,10,1);
+ offset=new DoubleSpinBox(sinusGroupBox->LastRowLastCol(),"offset:",0,10,1);
+ period=new SpinBox(settingsTab->NewRow(),"period thread:"," ms",1,1000,1);
+
+ setupLayout=new GridLayout(settingsTab->NewRow(),"setup");//layout sui servira à placer des filtres par exemple
+}
+
+
+Sinus::~Sinus() {
+
+ SafeStop();
+ Join();
+
+ //main_tab has the FrameworkManager as parent; it will be destroyed when FrameworkManager is destroyed
+ //it is cleaner to delete it manually, because main_tab is unnecessary when Sinus is deleted
+ delete mainTab;
+}
+
+void Sinus::UseDefaultPlot(void) {
+ Tab* plotTab=new Tab(tabWidget,"Graph");
+ plot=new DataPlot1D(plotTab->NewRow(),"Sinus",-10,10);
+ plot->AddCurve(output->Element(0),DataPlot::Red);
+}
+
+GridLayout* Sinus::GetSetupLayout(void) const {
+ return setupLayout;
+}
+
+DataPlot1D* Sinus::GetPlot(void) const {
+ if(plot==NULL) Printf("Sinus::Plot, plot not yet defined, call UseDefaultPlot first\n");
+ return plot;
+}
+
+cvmatrix *Sinus::GetMatrix(void) const {
+ return output;
+}
+
+float Sinus::GetValue(void) const {
+ return output->Value(0,0);
+}
+
+//main function, where we compute the signal
+void Sinus::Run(void) {
+
+ SetPeriodMS(period->Value());
+
+ //warn if changing from primary to secondary mode when in real time
+ WarnUponSwitches(true);
+
+ Time initTime=GetTime();
+
+ while(!ToBeStopped()) {
+ WaitPeriod();
+
+ if(period->ValueChanged()==true) SetPeriodMS(period->Value());
+
+ //compute sinus
+ Time actualTime=GetTime();
+ float value=offset->Value()+amplitude->Value()*sinf(2*PI*frequency->Value()*(actualTime-initTime)/1000000000.);//les temps sont en nanosecondes
+
+ //put the result in output matrix
+ output->SetValue(0,0,value);
+ //put corresponding time
+ output->SetDataTime(actualTime);
+
+ //ProcessUpdate is very important
+ //we must call it after updating the output matrix
+ //it allows:
+ // -to save value in the logs
+ // -to automatically call the next filter UpdateFrom method
+ ProcessUpdate(output);
+ }
+}
+}// end namespace sensor
+}// end namespace flair
Index: trunk/demos/Sinus/src/Sinus.h
===================================================================
--- trunk/demos/Sinus/src/Sinus.h (revision 14)
+++ trunk/demos/Sinus/src/Sinus.h (revision 14)
@@ -0,0 +1,121 @@
+// created: 2013/06/26
+// filename: Sinus.h
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+// purpose: class generating a sinus signal
+//
+//
+/*********************************************************************/
+
+#ifndef SINUS_H
+#define SINUS_H
+
+//necessary includes, as IODevice and Thread are bases of our class
+#include
+#include
+
+//forward declaration for other classes
+namespace flair {
+ namespace core {
+ class FrameworkManager;
+ class cvmatrix;
+ }
+ namespace gui {
+ class Tab;
+ class TabWidget;
+ class GridLayout;
+ class DoubleSpinBox;
+ class SpinBox;
+ class DataPlot1D;
+ }
+}
+
+//sinus is a class generating a sinus signal
+//in this example, it emulates a sensonr, so we extend the namespace sensor
+//it derives frome
+// IODevice: as it has an ouput
+// Thread: is it a thread
+namespace flair { namespace sensor {
+ class Sinus : public core::IODevice, public core::Thread {
+ public:
+ /*!
+ * \brief Constructor
+ *
+ * Builds a sinus generator
+ *
+ * \param parent the FrameworkManager to use
+ * \param name object name
+ * \param priority Thread priority, 50 by default (1:mini, 99:maxi)
+ */
+ Sinus(const core::FrameworkManager* parent,std::string name,int priority=50);
+
+ /*!
+ * \brief Destructor
+ */
+ ~Sinus();
+
+ /*!
+ * \brief Output matrix
+ *
+ * allows to access output matrix, to get signal value or to put it in a graph. \n
+ *
+ * \return un pointeur vers la matrice de sortie
+ */
+ core::cvmatrix *GetMatrix(void) const;
+
+ /*!
+ * \brief Value
+ *
+ * this method is equivalent to GetMatrix()->Value(0,0)
+ *
+ * \return actual signal value
+ */
+ float GetValue(void) const;
+
+ /*!
+ * \brief Use defautl plot
+ *
+ * this method put a graph in a specific tab
+ *
+ */
+ void UseDefaultPlot(void);
+
+ /*!
+ * \brief SetupLayout
+ *
+ * this method allows to add other widgets in the sinus tab.
+ *
+ * \return the GridLayout
+ */
+ gui::GridLayout *GetSetupLayout(void) const;
+
+ /*!
+ * \brief Plot
+ *
+ * this method allows to add other curves in the graph
+ *
+ * \return the DataPlot1D
+ */
+ gui::DataPlot1D *GetPlot(void) const;
+
+ private:
+ //UpdateFrom method from base class IODevice
+ //sinus is like a sensor, so it does not have input; we define an empty method
+ void UpdateFrom(const core::io_data *data){};
+ void Run(void);
+
+ core::cvmatrix *output;
+ gui::Tab* mainTab;
+ gui::TabWidget* tabWidget;
+ gui::DataPlot1D* plot;
+ gui::DoubleSpinBox *frequency,*amplitude,*offset;
+ gui::SpinBox *period;
+ gui::GridLayout* setupLayout;
+ };
+}// end namespace sensor
+}// end namespace flair
+#endif // SINUS_H
Index: trunk/demos/Sinus/src/main.cpp
===================================================================
--- trunk/demos/Sinus/src/main.cpp (revision 14)
+++ trunk/demos/Sinus/src/main.cpp (revision 14)
@@ -0,0 +1,94 @@
+// created: 2013/06/26
+// filename: main.cpp
+//
+// author: Guillaume Sanahuja
+// Copyright Heudiasyc UMR UTC/CNRS 7253
+//
+// version: $Id: $
+//
+//
+//
+/*********************************************************************/
+
+#include "Loop.h"
+#include
+#include
+#include
+
+//we use namespace std, to avoid writing for examlpe std::string
+using namespace std;
+//idem for TCLAP
+using namespace TCLAP;
+//idem for flair
+using namespace flair::core;
+
+//global variables for the command line arguments
+string logPath;//path for logs
+string address;//address for FlairGCS
+int port;//port for FlairGCS
+string xmlFile;//setup xml file
+string name;//name
+
+void parseOptions(int argc, char** argv);
+
+int main(int argc, char* argv[]) {
+ //get command line arguments (name,port,xml_file,log_path)
+ parseOptions(argc,argv);
+
+ //creation of FrameworkManager
+ FrameworkManager *manager;
+ manager= new FrameworkManager(name);
+ manager->SetupConnection(address,port);
+ manager->SetupUserInterface(xmlFile);
+ manager->SetupLogger(logPath);
+
+ //creation of the
+ Loop* example=new Loop(manager,"Loop");
+
+ //start loop
+ example->Start();
+
+ //wait for loop ends (with kill button)
+ example->Join();
+
+ delete manager;
+}
+
+
+void parseOptions(int argc, char** argv) {
+ try {
+ CmdLine cmd("Command description message", ' ', "0.1");
+
+ //name of the FrameworkManager, Sinus by default
+ ValueArg nameArg("n","name","program name",false,"Sinus","string");
+ cmd.add( nameArg );
+
+ //setup xml file, ./Sinus.xml by default
+ ValueArg xmlArg("x","xml","xml file",false,"./Sinus.xml","string");
+ cmd.add( xmlArg );
+
+ //log path, ./ by defaults
+ ValueArg logArg("l","log","log path",false,"/tmp","string");
+ cmd.add( logArg );
+
+ //address for FlairGCS
+ ValueArg addressArg("a","address","address for FlairGCS station sol",false,"127.0.0.1","string");
+ cmd.add( addressArg );
+
+ //port for FlairGCS, 9000 by default
+ ValueArg portArg("p","port","port for FlairGCS",false,9000,"int");
+ cmd.add( portArg );
+
+ cmd.parse( argc, argv );
+
+ // Get the value parsed by each arg.
+ logPath = logArg.getValue();
+ port=portArg.getValue();
+ xmlFile = xmlArg.getValue();
+ name=nameArg.getValue();
+ address=addressArg.getValue();
+
+ } catch (ArgException &e) { // catch any exceptions
+ cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
+ }
+}