[308] | 1 | // created: 2019/03/12
|
---|
| 2 | // filename: main.cpp
|
---|
| 3 | //
|
---|
| 4 | // author: Guillaume Sanahuja
|
---|
| 5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 6 | //
|
---|
| 7 | // version: $Id: $
|
---|
| 8 | //
|
---|
| 9 | // purpose: vrpnlite, to forward it to bth for exemple
|
---|
| 10 | // usefull to reduce vrpn frame size
|
---|
| 11 | //
|
---|
| 12 | /*********************************************************************/
|
---|
| 13 |
|
---|
| 14 | #include "FrameworkManager.h"
|
---|
| 15 | #include "VrpnLite.h"
|
---|
| 16 | #include <stdio.h>
|
---|
| 17 | #include <tclap/CmdLine.h>
|
---|
| 18 |
|
---|
| 19 | using namespace TCLAP;
|
---|
| 20 | using namespace std;
|
---|
| 21 | using namespace flair::core;
|
---|
| 22 |
|
---|
| 23 | string xml_file;
|
---|
| 24 | string clientAddress,serverAddress;
|
---|
| 25 | int port;
|
---|
| 26 |
|
---|
| 27 | void parseOptions(int argc, char **argv);
|
---|
| 28 |
|
---|
| 29 | int main (int argc, char ** argv) {
|
---|
| 30 | parseOptions(argc,argv);
|
---|
| 31 |
|
---|
| 32 | FrameworkManager *manager;
|
---|
| 33 | manager = new FrameworkManager("vrpnforwarder");
|
---|
| 34 | manager->SetupConnection("127.0.0.1", port);
|
---|
| 35 | manager->SetupUserInterface(xml_file);
|
---|
| 36 |
|
---|
| 37 | VrpnLite* vrpnlite=new VrpnLite(clientAddress,serverAddress);
|
---|
| 38 |
|
---|
| 39 | vrpnlite->Start();
|
---|
| 40 | vrpnlite->Join();
|
---|
| 41 |
|
---|
| 42 | delete manager;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | void parseOptions(int argc, char **argv) {
|
---|
| 46 | try {
|
---|
| 47 | CmdLine cmd("Command description message", ' ', "0.1");
|
---|
| 48 |
|
---|
| 49 | ValueArg<string> clientaddressArg("c", "caddress","client address", true,
|
---|
| 50 | "127.0.0.1:3884", "string");
|
---|
| 51 | cmd.add(clientaddressArg);
|
---|
| 52 |
|
---|
| 53 | ValueArg<string> serveraddressArg("s", "saddress","server address", true,
|
---|
| 54 | "127.0.0.1:3883", "string");
|
---|
| 55 | cmd.add(serveraddressArg);
|
---|
| 56 |
|
---|
| 57 | ValueArg<int> portArg("p", "port","local port used to connect to the ground station",
|
---|
| 58 | false, 9000, "int");
|
---|
| 59 | cmd.add(portArg);
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | ValueArg<string> xmlArg("x", "xml", "xml file", true, "./settings.xml",
|
---|
| 63 | "string");
|
---|
| 64 | cmd.add(xmlArg);
|
---|
| 65 |
|
---|
| 66 | cmd.parse(argc, argv);
|
---|
| 67 |
|
---|
| 68 | clientAddress = clientaddressArg.getValue();
|
---|
| 69 | serverAddress = serveraddressArg.getValue();
|
---|
| 70 | port = portArg.getValue();
|
---|
| 71 | xml_file = xmlArg.getValue();
|
---|
| 72 |
|
---|
| 73 | } catch (ArgException &e) { // catch any exceptions
|
---|
| 74 | cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
|
---|
| 75 | }
|
---|
| 76 | }
|
---|