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;

};
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.requestOnce("reloadConfig");


  ArTime start;
  start.setToNow();
  while (Aria::getRunning() && client.isConnected())
  {
    client.loopOnce();
    ArUtil::sleep(ArMath::random() % 10000);
    client.requestOnce("reloadConfig");
  }
  Aria::shutdown();
  return 0;
}
void PtzCameraExample::run()
{
  enum { MinPan, MaxPan, Center1, MinTilt, MaxTilt, Center2} stage;
  stage = MinPan;
  while(myClient->isConnected()) 
  {
    mutex.lock();
    for(std::set<ArClientHandlerCamera*>::const_iterator i = myCameras.begin(); i != myCameras.end(); ++i)
    {
      ArClientHandlerCamera* c = (*i);
      c->lock();
      switch(stage)
      {
        case MinPan:
          c->request.requestPanTiltAbs(c->minPan, 0);
          stage = MaxPan;
          break;
        case MaxPan:
          c->request.requestPanTiltAbs(c->maxPan, 0);
          stage = Center1;
          break;
        case Center1:
          c->request.requestPanTiltAbs(0, 0);
          stage = MinTilt;
          break;
        case MinTilt:
          c->request.requestPanTiltAbs(0, c->minTilt);
          stage = MaxTilt;
          break;
        case MaxTilt:
          c->request.requestPanTiltAbs(0, c->maxTilt);
          stage = Center2;
          break;
        case Center2:
          c->request.requestPanTiltAbs(0, 0);
          stage = MinPan;
      }
      c->unlock();
    }
    mutex.unlock();
    ArUtil::sleep(3000);
  }
}