Ignore:
Timestamp:
Apr 8, 2016, 3:48:40 PM (5 years ago)
Author:
Bayard Gildas
Message:

Reformatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/Controller/DualShock3/src/main.cpp

    r11 r16  
    3333string xml_file;
    3434
    35 void parseOptions(int argc, char** argv);
     35void parseOptions(int argc, char **argv);
    3636
    37 int main(int argc, char* argv[]) {
    38     parseOptions(argc,argv);
     37int main(int argc, char *argv[]) {
     38  parseOptions(argc, argv);
    3939
    40     DualShock3 *joystick;
    41     FrameworkManager *manager;
     40  DualShock3 *joystick;
     41  FrameworkManager *manager;
    4242
    43     manager= new FrameworkManager("dualshock3");
    44     manager->SetupConnection("127.0.0.1",port);
    45     manager->SetupUserInterface(xml_file);
     43  manager = new FrameworkManager("dualshock3");
     44  manager->SetupConnection("127.0.0.1", port);
     45  manager->SetupUserInterface(xml_file);
    4646
    47     if(connection=="usb") {
    48 //        manager->Warn("!! adresse = %s !!\n", address.c_str());
    49         joystick=new DualShock3(manager,"dualshock3",receiverAddress,receiverPort,DualShock3::Usb,period,6);
    50     } else {
    51         joystick=new DualShock3(manager,"dualshock3",receiverAddress,receiverPort,DualShock3::Bluetooth,period,6);
    52     }
     47  if (connection == "usb") {
     48    //        manager->Warn("!! adresse = %s !!\n", address.c_str());
     49    joystick = new DualShock3(manager, "dualshock3", receiverAddress,
     50                              receiverPort, DualShock3::Usb, period, 6);
     51  } else {
     52    joystick = new DualShock3(manager, "dualshock3", receiverAddress,
     53                              receiverPort, DualShock3::Bluetooth, period, 6);
     54  }
    5355
    54     joystick->DrawUserInterface();
     56  joystick->DrawUserInterface();
    5557
    56     if(!manager->ErrorOccured()) {
    57         joystick->Start();
    58         joystick->Join();
    59     }
     58  if (!manager->ErrorOccured()) {
     59    joystick->Start();
     60    joystick->Join();
     61  }
    6062
    61     delete manager;
     63  delete manager;
    6264}
    6365
    64 void parseOptions(int argc, char** argv) {
    65     try {
    66         CmdLine cmd("Command description message", ' ', "0.1");
     66void parseOptions(int argc, char **argv) {
     67  try {
     68    CmdLine cmd("Command description message", ' ', "0.1");
    6769
    68         ValueArg<string> addressArg("a","address","data receiver address (ex: uav)",true,"127.0.0.1:20000","string");
    69         cmd.add(addressArg);
     70    ValueArg<string> addressArg("a", "address",
     71                                "data receiver address (ex: uav)", true,
     72                                "127.0.0.1:20000", "string");
     73    cmd.add(addressArg);
    7074
    71         ValueArg<string> connectionArg("c","connection","connection type (usb or bluetooth)",false,"bluetooth","string");
    72         cmd.add(connectionArg);
     75    ValueArg<string> connectionArg("c", "connection",
     76                                   "connection type (usb or bluetooth)", false,
     77                                   "bluetooth", "string");
     78    cmd.add(connectionArg);
    7379
    74         ValueArg<int> portArg("p","port","local port used to connect to the ground station",false,9000,"int");
    75         cmd.add(portArg);
     80    ValueArg<int> portArg("p", "port",
     81                          "local port used to connect to the ground station",
     82                          false, 9000, "int");
     83    cmd.add(portArg);
    7684
    77         ValueArg<int> periodArg("t","period","sending data period",false,10,"int");
    78         cmd.add(periodArg);
     85    ValueArg<int> periodArg("t", "period", "sending data period", false, 10,
     86                            "int");
     87    cmd.add(periodArg);
    7988
    80         ValueArg<string> xmlArg("x","xml","xml file",true,"./settings.xml","string");
    81         cmd.add( xmlArg );
     89    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./settings.xml",
     90                            "string");
     91    cmd.add(xmlArg);
    8292
    83         cmd.parse(argc, argv);
     93    cmd.parse(argc, argv);
    8494
    85         // Get the value parsed by each arg.
    86         string receiverAddressWithPort=addressArg.getValue();
    87         int semiColonPosition = receiverAddressWithPort.find(":");
    88         receiverAddress=receiverAddressWithPort.substr (0,semiColonPosition);
    89         receiverPort=atoi(receiverAddressWithPort.substr(semiColonPosition+1).c_str());
    90         connection=connectionArg.getValue();
    91         port=portArg.getValue();
    92         period=periodArg.getValue();
    93         xml_file=xmlArg.getValue();
     95    // Get the value parsed by each arg.
     96    string receiverAddressWithPort = addressArg.getValue();
     97    int semiColonPosition = receiverAddressWithPort.find(":");
     98    receiverAddress = receiverAddressWithPort.substr(0, semiColonPosition);
     99    receiverPort =
     100        atoi(receiverAddressWithPort.substr(semiColonPosition + 1).c_str());
     101    connection = connectionArg.getValue();
     102    port = portArg.getValue();
     103    period = periodArg.getValue();
     104    xml_file = xmlArg.getValue();
    94105
    95     } catch (ArgException &e) {  // catch any exceptions
    96         cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
    97     }
     106  } catch (ArgException &e) { // catch any exceptions
     107    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     108  }
    98109}
Note: See TracChangeset for help on using the changeset viewer.