当前位置: 首页>>代码示例>>C++>>正文


C++ ArClientBase::addHandler方法代码示例

本文整理汇总了C++中ArClientBase::addHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ ArClientBase::addHandler方法的具体用法?C++ ArClientBase::addHandler怎么用?C++ ArClientBase::addHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArClientBase的用法示例。


在下文中一共展示了ArClientBase::addHandler方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
    Aria::init();
    ArClientBase client;
    std::string host;


    ArArgumentParser parser(&argc, argv);
    ArClientSimpleConnector clientConnector(&parser);

    parser.loadDefaultArguments();

    /* Check for -help, and unhandled arguments: */
    if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
    {
        clientConnector.logOptions();
        exit(0);
    }


    /* Connect our client object to the remote server: */
    if (!clientConnector.connectClient(&client))
    {
        if (client.wasRejected())
            printf("Server rejected connection, exiting\n");
        else
            printf("Could not connect to server, exiting\n");
        exit(1);
    }


    client.addHandler("getCameraModeListCam1",
                      new ArGlobalFunctor1<ArNetPacket *>(&getCameraModeList));

    client.requestOnce("getCameraModeListCam1");

    ArNetPacket sending;

    // This does the look at goal mode
    sending.empty();
    sending.strToBuf("lookAtGoal");
    client.requestOnce("setCameraModeCam1", &sending);

    // This does the look at point mode (at 0 0);

    sending.empty();
    sending.strToBuf("lookAtPoint");
    sending.byte4ToBuf(1157);
    sending.byte4ToBuf(-15786);
    client.requestOnce("setCameraModeCam1", &sending);

    while (Aria::getRunning() && client.isConnected())
    {
        client.loopOnce();
        ArUtil::sleep(1000);
    }
    Aria::shutdown();
    return 0;

};
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:60,代码来源:cameraModeClient.cpp

示例2: init

bool PtzCameraExample::init()
{
  // If the server has the "getCameraList" request, then it's using
  // ArServerHandlerCameraCollection, and migth have multiple PTZs/cameras each with
  // its own set of requests. So send a "getCameraList" request, and when its
  // reply is received, the handler will send "getCameraInfo" requests for each.
  // If the server does not have "getCameraList", it only has one PTZ camera, just
  // send "getCameraInfo". The handler for that will send various control
  // commands.
  // If the server does not have "getCameraInfo", then it doesn't provide any
  // access to PTZ cameras.
  if(myClient->dataExists("getCameraList"))
  {
    ArLog::log(ArLog::Normal, "Server may have multiple cameras. Requesting list.");
    myClient->addHandler("getCameraList", &myCameraListReplyFunc);
    myClient->requestOnce("getCameraList");
  }
  else if(myClient->dataExists("getCameraInfo"))
  {
    ArLog::log(ArLog::Normal, "Server does not support multiple cameras. Requesting info for its camera.");
    ArClientHandlerCamera *camClient = new ArClientHandlerCamera(myClient, "");
    camClient->requestUpdates(100);
    mutex.lock();
    myCameras.insert(camClient);
    mutex.unlock();
  }
  else
  {
    ArLog::log(ArLog::Terse, "Error, server does not have any camera control requests. (Was the server run with video features enabled or video forwarding active?)");
    return false;
  }
  return true;
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:33,代码来源:ptzCameraClientExample.cpp

示例3: drawing

void drawing(ArNetPacket *packet)
{
  int numDrawings;
  int i;
  char name[512];
  char shape[512];
  long primary, size, layer, secondary;
  unsigned long refresh;
  numDrawings = packet->bufToByte4();
  ArLog::log(ArLog::Normal, "There are %d drawings", numDrawings);
  for (i = 0; i < numDrawings; i++)
  {
    packet->bufToStr(name, sizeof(name));
    packet->bufToStr(shape, sizeof(shape));
    primary = packet->bufToByte4();
    size = packet->bufToByte4();
    layer = packet->bufToByte4();
    refresh = packet->bufToByte4();
    secondary = packet->bufToByte4();
    ArLog::log(ArLog::Normal, "name %-20s shape %-20s", name, shape);
    ArLog::log(ArLog::Normal, 
           "\tprimary %08x size %2d layer %2d refresh %4u secondary %08x",
           primary, size, layer, refresh, secondary);
    client.addHandler(name, &drawingDataCB);
    client.request(name, refresh);
  }
  
}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:28,代码来源:infoDrawingClient.cpp

示例4: ArClientHandlerCamera

 ArClientHandlerCamera(ArClientBase *client, const char *cameraName) : 
   name(cameraName), myClient(client), request(client, cameraName) ,
   myCameraInfoReplyFunc(this, &ArClientHandlerCamera::handleCameraInfoReply),
   myCameraDataReplyFunc(this, &ArClientHandlerCamera::handleCameraDataReply)
 {
   myClient->addHandler((std::string("getCameraInfo")+name).c_str(), &myCameraInfoReplyFunc);
   myClient->addHandler((std::string("getCameraData")+name).c_str(), &myCameraDataReplyFunc);
 }
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:8,代码来源:ptzCameraClientExample.cpp

示例5: main

int main(int argc, char **argv)
{
  ArClientBase client;
  ArGlobalFunctor1<ArNetPacket *> testCB(&test);

  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArTime startTime;
  startTime.setToNow();
  if (!client.blockingConnect("localhost", 7273))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  }    
  printf("Took %ld msec to connect\n", startTime.mSecSince());
  
  client.runAsync();
  
  client.lock();
  client.addHandler("test", &testCB);
  client.addHandler("test2", &testCB);
  client.addHandler("test3", &testCB);
  client.logDataList();
  
  client.requestOnce("test");
  client.request("test2", 100);
  client.request("test3", -1);
  client.unlock();
  ArUtil::sleep(1000);
  printf("Changing speed\n");
  client.lock();
  client.request("test2", 300);
  client.unlock();
  ArUtil::sleep(1000);
  client.lock();
  client.requestStop("test2");
  client.unlock();
  
  ArUtil::sleep(1000);
  client.lock();
  client.disconnect();
  client.unlock();
  ArUtil::sleep(50);
  exit(0);
}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:45,代码来源:testClient.cpp

示例6: main

int main(int argc, char **argv)
{

  Aria::init();
  ArLog::init(ArLog::StdOut, ArLog::Normal);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }
  
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  ArGlobalFunctor1<ArNetPacket *> getModeDataListCB(&getModeDataList);
  ArGlobalFunctor1<ArNetPacket *> getModeInfoCB(&getModeInfo);
  client.addHandler("getModeDataList", &getModeDataListCB);
  client.requestOnce("getModeDataList");
  client.addHandler("getModeInfo", &getModeInfoCB);
  client.request("getModeInfo", -1);

  client.runAsync();
  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
    //printf("%d ms since last data\n", client.getLastPacketReceived().mSecSince());
  }
  Aria::shutdown();
  return 0;

}
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:44,代码来源:modeInfoClient.cpp

示例7: main

int main(int argc, char **argv)
{
  Aria::init();
  ArGlobalFunctor1<ArNetPacket *> clientListHandlerCB(&clientListHandler);
  ArGlobalFunctor1<ArNetPacket *> clientAddedHandlerCB(&clientAddedHandler);
  ArGlobalFunctor1<ArNetPacket *> clientRemovedHandlerCB(&clientRemovedHandler);
  ArNetPacket packet;

  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");

  client.addHandler("clientList", &clientListHandlerCB);
  client.requestOnce("clientList");
  client.addHandler("clientRemoved", &clientRemovedHandlerCB);
  client.request("clientRemoved", -1);
  client.addHandler("clientAdded", &clientAddedHandlerCB);
  client.request("clientAdded", -1);
  client.run();
  Aria::shutdown();
  return 0;
}
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:43,代码来源:switchWatcher.cpp

示例8: main

int main(int argc, char **argv)
{

  ArGlobalFunctor1<ArNetPacket *> getMapNameCB(handleGetMapName);
  ArGlobalFunctor1<ArNetPacket *> getMapCB(handleGetMap);

  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);

  ArArgumentParser parser(&argc, argv);
    
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    exit(1);
  } 

  client.addHandler("getMap", &getMapCB);
  client.addHandler("getMapName", &getMapNameCB);
  client.requestOnce("getMapName");
  start.setToNow();
  client.requestOnce("getMap");

  client.run();

}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:36,代码来源:mapClient.cpp

示例9: main

int main(int argc, char **argv)
{

  std::string hostname;
  ArGlobalFunctor1<ArNetPacket *> drawingCB(&drawing);
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);



  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  
  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 

  printf("Connected to server.\n");

  client.addHandler("listDrawings", &drawingCB);
  client.requestOnce("listDrawings");
  
  client.runAsync();
  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
    //printf("%d ms since last data\n", client.getLastPacketReceived().mSecSince());
  }
  Aria::shutdown();
  return 0;

}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:48,代码来源:infoDrawingClient.cpp

示例10: main

int main(int argc, char **argv)
{

  std::string hostname;
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);

  if (argc == 1)
    hostname = "localhost";
  else
    hostname = argv[1];
  if (!client.blockingConnect(hostname.c_str(), 7272))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  } 

  
  /*
  ArGlobalFunctor1<ArNetPacket *> getDirListingCB(&getDirListing);
  client.addHandler("getDirListing", &getDirListingCB);
  //client.requestOnceWithString("getDirListing", "");

  ArGlobalFunctor1<ArNetPacket *> getFileCB(&netGetFile);
  client.addHandler("getFile", &getFileCB);
  client.requestOnceWithString("getFile", "all.bob");

  ArGlobalFunctor1<ArNetPacket *> netPutFileCB(&netPutFile);
  client.addHandler("putFile", &netPutFileCB);
  putFile("doxygen.conf", "ArGH/DoxYGEN");
  */

  ArGlobalFunctor1<ArNetPacket *> deleteFileCB(&netDeleteFile);
  client.addHandler("deleteFile", &deleteFileCB);
  client.requestOnceWithString("deleteFile", "1/all.bob");

  client.runAsync();

  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
  }
  Aria::shutdown();
  return 0;

}
开发者ID:sauver,项目名称:sauver_sys,代码行数:46,代码来源:fileClientRaw.cpp

示例11: main

int main(int argc, char **argv)
{
  Aria::init();
  ArClientBase client;
  ArArgumentParser parser(&argc, argv);

  /* This will be used to connect our client to the server. 
   * It will get the hostname from the -host command line argument: */
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -host, -help, ARIA arguments, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    Aria::exit(0);
  }

  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    Aria::exit(1);
  } 

  printf("Connected to server.\n");
  client.setRobotName(client.getHost()); // include server name in log messages
  client.runAsync();
  ArNetPacket request;
//  request.
//  client.requestOnceByCommand(ArCommands::ENABLE, )


  ArClientHandlerRobotUpdate updates(&client);
//  client.requestOnce("enableMotor");

  ArGlobalFunctor1<ArNetPacket*> enableCB(&enable);
  ArGlobalFunctor1<ArNetPacket *> getFileCB(&netGetFile);
  ArGlobalFunctor1<ArNetPacket*> recieveDataCB(&recieveData);

  client.addHandler("requestEnableMotor", &enableCB);
  client.addHandler("handleCheckObjectData", &recieveDataCB);
  //client.addHandler("getFile", &getFileCB);

  client.requestOnce("requestEnableMotor");
  client.request("handleCheckObjectData", 10);
  updates.requestUpdates();
  if (checkObject)
    client.requestOnceWithString("getFile", "./image/ball.jpg");
  ArPose pose;
  namedWindow("image", 0);
  while (client.getRunningWithLock())
  {

      //client.requestOnce("sendData");

      if (checkObject) {
    //	  if (!a) {
              cout <<"OK"<<endl;
        //	  client.requestOnceWithString("getFile", "./image/ball.jpg");
              client.addHandler("getFile", &getFileCB);
//			  client.remHandler("getFile", &getFileCB);
          //}	else {
              //client.remHandler("getFile", &getFileCB);
          //}
          Mat image;
          image = imread("./image/ball.jpg", CV_LOAD_IMAGE_COLOR);
          
          imshow("image", image);
          char c = (char)waitKey(10);
          if( c == 27 )
            break;
      }

    ArUtil::sleep(200);
  }

//  client.requestStop("getFile");

  cout <<"Da tim thay qua bong o vi tri pose("<<pose.getX()<<", "<<pose.getY()<<")"<<endl;

  cout <<"Vi tri pose("<<pose.getX()<<", "<<pose.getY()<<")"<<endl;

  /* The client stopped running, due to disconnection from the server, general
   * Aria shutdown, or some other reason. */
  client.disconnect();
  Aria::exit(0);
  return 0;
}
开发者ID:quoioln,项目名称:my-thesis,代码行数:94,代码来源:client.cpp

示例12: Main

void NavigationClient::Main()
{

    std::cout << "Navigation client started" << std::endl;
    int argsNumber;
    argsNumber = 3;
    char *arguments[argsNumber];
    arguments[0]="./arg_test";
    arguments[1]="-host";
    //arguments[2]="10.41.42.1";
    //se puede poner también patrolbot
    arguments[2]="77.7.27.1";

  int robotCase, counter;
    
  ArClientBase client;
  ArPose pose(0, 0, 0);
  ArPose GoToPose(3000.0, 0.0, -90.0);
  ArNetPacket posePacket, directGoToPosePacket;

  ArArgumentParser parser(&argsNumber, arguments);posePacket.empty();
         
  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();
  
  headingsForBedroom.push_back(45);
  headingsForBedroom.push_back(25);
  headingsForBedroom.push_back(0);
  
 
  headingsForLiving.push_back(-20);
  headingsForLiving.push_back(-55);
  headingsForLiving.push_back(-80);
  headingsForLiving.push_back(-110);
  headingsForLiving.push_back(-140);
  
  openDoor = false;
  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed()) {
    clientConnector.logOptions();
    exit(0);
  }
  
  printf("Connecting...\n");
  if (!clientConnector.connectClient(&client)) {
    if (client.wasRejected())
      printf("Server rejected connection, exiting\n");
    else
      printf("Could not connect to server, exiting\n");
    
    exit(1);
  } 

  printf("Connected to server.\n");
  client.addHandler("pathPlannerStatus", new ArGlobalFunctor1<ArNetPacket*>(&handlePathPlannerStatus));
  client.addHandler("update", new ArGlobalFunctor1<ArNetPacket*>(&handleRobotUpdate));
  client.addHandler("goalName", new ArGlobalFunctor1<ArNetPacket*>(&handleGoalName));
  client.addHandler("getGoals", new  ArGlobalFunctor1<ArNetPacket*>(&handleGoalList));
  client.addHandler("getSensorCurrent", new ArGlobalFunctor1<ArNetPacket*>(&handleSensorCurrent));
  client.addHandler("getSensorList", new ArGlobalFunctor1<ArNetPacket*>(&handleSensorList));
  client.addHandler("getLocState", new ArGlobalFunctor1<ArNetPacket*>(&handleLocState));

  client.runAsync();

  client.requestOnce("getGoals");
  client.requestOnce("getSensorList");
  client.requestOnceWithString("getSensorCurrent", "lms2xx_1");
  // client.request("pathPlannerStatus", 5000);
  client.request("goalName", 1000);
  client.request("update", 1000);
  client.requestOnce("getLocState");
  
  sleep(2);
  int cont =0;
  while (!openDoor) {
    cont++;
    ArUtil::sleep(2000);
    client.requestOnceWithString("getSensorCurrent", "lms2xx_1");
  }

  printf("*** Door has been OPENED *** \n");
  sleep(2);

  if (client.dataExists("localizeToPose")) {
      printf(".. Server does have \"localizeToPose\" request.\n");
      posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_X());
      posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_Y());
      posePacket.byte4ToBuf(sharedMemory->getInstance().getLocalizationRobotPosition().get_Angle());
      
      client.requestOnce("localizeToPose", &posePacket);
      ArUtil::sleep(1500);
  }
  else
      printf(".. Server doesn't have that request.\n");

  
  for(;;){
        string action = sharedMemory->getInstance().getAction();
            
        if (action=="navigate"){
            cout<<"Starting: "<< action << "STATE in NavigationClient"<<endl;  
//.........这里部分代码省略.........
开发者ID:Miguel-Palacios,项目名称:Sabina2014,代码行数:101,代码来源:main.cpp


注:本文中的ArClientBase::addHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。