Changeset 71 in flair-src
- Timestamp:
- Sep 8, 2016, 3:51:25 PM (8 years ago)
- Location:
- branches/mavlink/tools/Controller/Mavlink/src
- Files:
-
- 9 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/tools/Controller/Mavlink/src/main.cpp
r46 r71 17 17 18 18 #include "FrameworkManager.h" 19 #include "Mavlink_test.h"20 19 #include <stdio.h> 21 20 #include <tclap/CmdLine.h> 21 22 #include "GuiFlair.h" 23 #include "GuiGcs.h" 24 #include "Forwarder.h" 25 26 //todo remove for tests 27 #include <iostream> 22 28 23 29 using namespace TCLAP; 24 30 using namespace std; 25 31 using namespace flair::core; 26 using namespace flair::sensor;27 32 28 string receiverAddress; 29 int receiverPort; 30 int port; 31 string xml_file; 33 string xmlFile; 34 string mode; 35 string inputAddress; 36 int inputPort; 37 string outputAddress; 38 int outputPort; 39 string flairAddress; 40 int flairPort; 32 41 33 42 void parseOptions(int argc, char **argv); 34 43 35 44 int main(int argc, char *argv[]) { 45 std::cout << "avant parseOptions" << std::endl; 36 46 parseOptions(argc, argv); 37 47 48 std::cout << "parseOptions ok" << std::endl; 49 38 50 FrameworkManager *manager; 39 Mavlink *mavlink_handler; 51 manager = new FrameworkManager("mavlink"); 52 manager->SetupConnection(flairAddress, flairPort); 53 manager->SetupUserInterface(xmlFile); 40 54 41 manager = new FrameworkManager("mavlink"); 42 manager->SetupConnection("127.0.0.1", port); 43 manager->SetupUserInterface(xml_file); 55 std::cout << "MavPlanner mode : " << mode << std::endl; 44 56 45 mavlink_handler = new Mavlink(manager, "mavlink", receiverAddress, 46 receiverPort); 47 48 if (!manager->ErrorOccured()) { 49 mavlink_handler->Start(); 50 mavlink_handler->Join(); 57 if(mode == "forward") { 58 Forwarder *guiForwarder = new Forwarder(manager, "Forwarder", 59 inputAddress, inputPort, 60 outputAddress, outputPort); 61 if (!manager->ErrorOccured()) { 62 guiForwarder->Start(); 63 guiForwarder->Join(); 64 } 65 } else { 66 GuiInterface *guiHandler; 67 if(mode == "flair") { 68 guiHandler = new GuiFlair(manager, "GuiFlair"); 69 } else if (mode == "gcs") { 70 guiHandler = new GuiGcs(manager, "GuiGcs", outputAddress, outputPort); 71 } else { 72 //ERROR 73 } 74 if (!manager->ErrorOccured()) { 75 guiHandler->Start(); 76 guiHandler->Join(); 77 } 51 78 } 52 79 … … 58 85 CmdLine cmd("Command description message", ' ', "0.1"); 59 86 60 ValueArg<string> addressArg("a", "address",61 " data receiver address (ex: uav)", true,62 "127.0.0.1 :20000", "string");63 cmd.add( addressArg);87 ValueArg<string> inputAddressArg("", "inputAddress", 88 "input IP address", false, 89 "127.0.0.1", "string"); 90 cmd.add(inputAddressArg); 64 91 65 ValueArg<int> portArg("p", "port", 66 "local port used to connect to the ground station", 67 false, 9000, "int"); 68 cmd.add(portArg); 92 ValueArg<int> inputPortArg("", "inputPort", 93 "input IP port", false, 94 9000, "int"); 95 cmd.add(inputPortArg); 96 97 ValueArg<string> outputAddressArg("", "outputAddress", 98 "output IP address", false, 99 "127.0.0.1", "string"); 100 cmd.add(outputAddressArg); 101 102 ValueArg<int> outputPortArg("", "outputPort", 103 "output IP port", false, 104 9000, "int"); 105 cmd.add(outputPortArg); 106 107 ValueArg<string> flairAddressArg("a", "flairAddress", 108 "flair IP address", true, 109 "127.0.0.1", "string"); 110 cmd.add(flairAddressArg); 111 112 ValueArg<int> flairPortArg("p", "flairPort", 113 "flair IP port", true, 114 9000, "int"); 115 cmd.add(flairPortArg); 69 116 70 117 ValueArg<string> xmlArg("x", "xml", "xml file", true, "./settings.xml", … … 72 119 cmd.add(xmlArg); 73 120 121 ValueArg<string> modeArg("m", "mode", "application mode (forward, flair, gcs)", 122 true, "flair", "string"); 123 cmd.add(modeArg); 124 74 125 cmd.parse(argc, argv); 75 126 127 // string receiverAddressWithPort = inputAddressArg.getValue(); 128 // int semiColonPosition = receiverAddressWithPort.find(":"); 129 // receiverAddress = receiverAddressWithPort.substr(0, semiColonPosition); 130 // receiverPort = 131 // atoi(receiverAddressWithPort.substr(semiColonPosition + 1).c_str()); 132 76 133 // Get the value parsed by each arg. 77 string receiverAddressWithPort = addressArg.getValue(); 78 int semiColonPosition = receiverAddressWithPort.find(":"); 79 receiverAddress = receiverAddressWithPort.substr(0, semiColonPosition); 80 receiverPort = 81 atoi(receiverAddressWithPort.substr(semiColonPosition + 1).c_str()); 82 port = portArg.getValue(); 83 xml_file = xmlArg.getValue(); 134 inputAddress = inputAddressArg.getValue(); 135 inputPort = inputPortArg.getValue(); 136 outputAddress = outputAddressArg.getValue(); 137 outputPort = outputPortArg.getValue(); 138 flairAddress = flairAddressArg.getValue(); 139 flairPort = flairPortArg.getValue(); 140 xmlFile = xmlArg.getValue(); 141 mode = modeArg.getValue(); 84 142 85 143 } catch (ArgException &e) { // catch any exceptions
Note:
See TracChangeset
for help on using the changeset viewer.