source: flair-src/trunk/demos/Sinus/src/main.cpp@ 14

Last change on this file since 14 was 14, checked in by Sanahuja Guillaume, 7 years ago

sinus

File size: 2.6 KB
Line 
1// created: 2013/06/26
2// filename: main.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9//
10//
11/*********************************************************************/
12
13#include "Loop.h"
14#include <FrameworkManager.h>
15#include <tclap/CmdLine.h>
16#include <stdio.h>
17
18//we use namespace std, to avoid writing for examlpe std::string
19using namespace std;
20//idem for TCLAP
21using namespace TCLAP;
22//idem for flair
23using namespace flair::core;
24
25//global variables for the command line arguments
26string logPath;//path for logs
27string address;//address for FlairGCS
28int port;//port for FlairGCS
29string xmlFile;//setup xml file
30string name;//name
31
32void parseOptions(int argc, char** argv);
33
34int main(int argc, char* argv[]) {
35 //get command line arguments (name,port,xml_file,log_path)
36 parseOptions(argc,argv);
37
38 //creation of FrameworkManager
39 FrameworkManager *manager;
40 manager= new FrameworkManager(name);
41 manager->SetupConnection(address,port);
42 manager->SetupUserInterface(xmlFile);
43 manager->SetupLogger(logPath);
44
45 //creation of the
46 Loop* example=new Loop(manager,"Loop");
47
48 //start loop
49 example->Start();
50
51 //wait for loop ends (with kill button)
52 example->Join();
53
54 delete manager;
55}
56
57
58void parseOptions(int argc, char** argv) {
59 try {
60 CmdLine cmd("Command description message", ' ', "0.1");
61
62 //name of the FrameworkManager, Sinus by default
63 ValueArg<string> nameArg("n","name","program name",false,"Sinus","string");
64 cmd.add( nameArg );
65
66 //setup xml file, ./Sinus.xml by default
67 ValueArg<string> xmlArg("x","xml","xml file",false,"./Sinus.xml","string");
68 cmd.add( xmlArg );
69
70 //log path, ./ by defaults
71 ValueArg<string> logArg("l","log","log path",false,"/tmp","string");
72 cmd.add( logArg );
73
74 //address for FlairGCS
75 ValueArg<string> addressArg("a","address","address for FlairGCS station sol",false,"127.0.0.1","string");
76 cmd.add( addressArg );
77
78 //port for FlairGCS, 9000 by default
79 ValueArg<int> portArg("p","port","port for FlairGCS",false,9000,"int");
80 cmd.add( portArg );
81
82 cmd.parse( argc, argv );
83
84 // Get the value parsed by each arg.
85 logPath = logArg.getValue();
86 port=portArg.getValue();
87 xmlFile = xmlArg.getValue();
88 name=nameArg.getValue();
89 address=addressArg.getValue();
90
91 } catch (ArgException &e) { // catch any exceptions
92 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
93 }
94}
Note: See TracBrowser for help on using the repository browser.