[9] | 1 | #include <QApplication>
|
---|
| 2 | #include <QCleanlooksStyle>
|
---|
| 3 | #include <QLocale>
|
---|
| 4 | #include <qmetatype.h>
|
---|
| 5 | #include <tclap/CmdLine.h>
|
---|
| 6 |
|
---|
| 7 | #include "Manager.h"
|
---|
| 8 | #include "svnversion.h"
|
---|
| 9 |
|
---|
| 10 | using namespace TCLAP;
|
---|
| 11 | using namespace std;
|
---|
| 12 |
|
---|
| 13 | string name;
|
---|
| 14 | int port;
|
---|
| 15 |
|
---|
| 16 | void parseOptions(int argc, char** argv) {
|
---|
| 17 | try {
|
---|
| 18 | CmdLine cmd("Command description message", ' ', "0.1");
|
---|
| 19 |
|
---|
| 20 | ValueArg<string> nameArg("n","name","uav name",false,"x4-0","string");
|
---|
| 21 | cmd.add( nameArg );
|
---|
| 22 |
|
---|
| 23 | ValueArg<int> portArg("p","port","port number",false,9000,"int");
|
---|
| 24 | cmd.add( portArg );
|
---|
| 25 |
|
---|
| 26 | cmd.parse( argc, argv );
|
---|
| 27 |
|
---|
| 28 | // Get the value parsed by each arg.
|
---|
| 29 | name= nameArg.getValue();
|
---|
| 30 | port = portArg.getValue();
|
---|
| 31 |
|
---|
| 32 | } catch (ArgException &e) {// catch any exceptions
|
---|
| 33 | cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | int main(int argc, char *argv[]) {
|
---|
| 38 |
|
---|
| 39 | union {
|
---|
| 40 | uint32_t i;
|
---|
| 41 | char c[4];
|
---|
| 42 | } bint = {0x01020304};
|
---|
| 43 |
|
---|
| 44 | if(bint.c[0] == 1) {
|
---|
| 45 | printf("error, ground station is only compatible with little endian\n");
|
---|
| 46 | return -1;
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | printf(SVN_REV);
|
---|
| 50 |
|
---|
| 51 | parseOptions(argc,argv);
|
---|
| 52 | printf("listening on port %i\n",port);
|
---|
| 53 |
|
---|
| 54 | qRegisterMetaType<const char*>("const char*");
|
---|
| 55 | QLocale::setDefault(QLocale::C);
|
---|
| 56 | QApplication app(argc, argv);
|
---|
| 57 | app.setStyle(new QCleanlooksStyle);
|
---|
| 58 |
|
---|
| 59 | Manager manager(QString::fromStdString(name),port);
|
---|
| 60 |
|
---|
| 61 | manager.show();
|
---|
| 62 |
|
---|
| 63 | app.exec();
|
---|
| 64 | }
|
---|