本文整理汇总了C++中ArNetPacket::byte4ToBuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket::byte4ToBuf方法的具体用法?C++ ArNetPacket::byte4ToBuf怎么用?C++ ArNetPacket::byte4ToBuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArNetPacket
的用法示例。
在下文中一共展示了ArNetPacket::byte4ToBuf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: laserRequest
//NEW LASER DATA REQUESt CAPABILITY
void laserRequest(ArServerClient *client, ArNetPacket *packet)
{
robot.lock();
ArNetPacket sending;
sending.empty();
ArLaser* laser = robot.findLaser(1);
if(!laser){
printf("Could not connect to Laser... exiting\n");
Aria::exit(1);}
laser->lockDevice();
const std::list<ArSensorReading*> *sensorReadings = laser->getRawReadings(); // see ArRangeDevice interface doc
sending.byte4ToBuf((ArTypes::Byte4)(sensorReadings->size()));
for (std::list<ArSensorReading*>::const_iterator it2= sensorReadings->begin(); it2 != sensorReadings->end(); ++it2){
ArSensorReading* laserRead =*it2;
sending.byte4ToBuf((ArTypes::Byte4)(laserRead->getRange()));
//printf("%i,%i:",laserRead->getRange(),laserRead->getIgnoreThisReading());
}
laser->unlockDevice();
robot.unlock();
sending.finalizePacket();
//sending.printHex();
client->sendPacketTcp(&sending);
}
示例2: getSensorCumulative
AREXPORT void ArServerInfoSensor::getSensorCumulative(ArServerClient *client,
ArNetPacket *packet)
{
ArRangeDevice *dev;
char sensor[512];
std::list<ArPoseWithTime *> *readings;
std::list<ArPoseWithTime *>::iterator it;
while (packet->getDataLength() > packet->getDataReadLength())
{
ArNetPacket sendPacket;
// find out the sensor they want
packet->bufToStr(sensor, sizeof(sensor));
myRobot->lock();
if ((dev = myRobot->findRangeDevice(sensor)) == NULL)
{
myRobot->unlock();
ArLog::log(ArLog::Verbose, "ArServerInfoSensor::getSensorCumulative: No sensor %s", sensor);
sendPacket.byte2ToBuf(-1);
sendPacket.strToBuf(sensor);
client->sendPacketUdp(&sendPacket);
continue;
}
myRobot->unlock();
dev->lockDevice();
readings = dev->getCumulativeBuffer();
if (readings == NULL)
{
dev->unlockDevice();
ArLog::log(ArLog::Verbose, "ArServerInfoSensor::getSensorCumulative: No current buffer for %s", sensor);
sendPacket.byte2ToBuf(0);
sendPacket.strToBuf(sensor);
client->sendPacketUdp(&sendPacket);
continue;
}
sendPacket.byte2ToBuf(readings->size());
sendPacket.strToBuf(sensor);
for (it = readings->begin(); it != readings->end(); it++)
{
sendPacket.byte4ToBuf(ArMath::roundInt((*it)->getX()));
sendPacket.byte4ToBuf(ArMath::roundInt((*it)->getY()));
}
dev->unlockDevice();
client->sendPacketUdp(&sendPacket);
}
}
示例3: exampleXDrawingNetCallback
void exampleXDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
ArNetPacket reply;
// X marks the spot. 2 line segments, so 4 vertices:
reply.byte4ToBuf(4);
// Segment 1:
reply.byte4ToBuf(-4250); // X1
reply.byte4ToBuf(250); // Y1
reply.byte4ToBuf(-3750); // X2
reply.byte4ToBuf(-250); // Y2
// Segment 2:
reply.byte4ToBuf(-4250); // X1
reply.byte4ToBuf(-250); // Y1
reply.byte4ToBuf(-3750); // X2
reply.byte4ToBuf(250); // Y2
client->sendPacketUdp(&reply);
}
示例4: update
AREXPORT void ArServerInfoRobot::update(ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket sending;
myRobot->lock();
ArServerMode *netMode;
if ((netMode = ArServerMode::getActiveMode()) != NULL)
{
sending.strToBuf(netMode->getStatus());
sending.strToBuf(netMode->getMode());
}
else
{
sending.strToBuf("Unknown status");
sending.strToBuf("Unknown mode");
}
//ArLog::log(ArLog::Normal,
// "ArServerInfoRobot::update() havestateofcharge = %d, soc = %f, real = %f, reg = %f",
// myRobot->haveStateOfCharge(),
// myRobot->getStateOfCharge(),
// myRobot->getRealBatteryVoltage(),
// myRobot->getBatteryVoltage());
if (myRobot->haveStateOfCharge())
sending.byte2ToBuf(ArMath::roundInt(myRobot->getStateOfCharge() * 10));
else if (myRobot->getRealBatteryVoltage() > 0)
sending.byte2ToBuf(ArMath::roundInt(
myRobot->getRealBatteryVoltage() * 10));
else
sending.byte2ToBuf(ArMath::roundInt(
myRobot->getBatteryVoltage() * 10));
sending.byte4ToBuf((int)myRobot->getX());
sending.byte4ToBuf((int)myRobot->getY());
sending.byte2ToBuf((int)myRobot->getTh());
sending.byte2ToBuf((int)myRobot->getVel());
sending.byte2ToBuf((int)myRobot->getRotVel());
sending.byte2ToBuf((int)myRobot->getLatVel());
sending.byteToBuf((char)myRobot->getTemperature());
//sending.byte2ToBuf((int)myRobot->getPayloadNumSlots());
myRobot->unlock();
client->sendPacketUdp(&sending);
}
示例5: activityTimeInfo
AREXPORT void ArServerInfoRobot::activityTimeInfo(
ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket sending;
// TODO Not entirely sure whether the robot needs to be locked here, but
// it seems like it shouldn't hurt.
//
myRobot->lock();
sending.byte4ToBuf(ArServerMode::getActiveModeActivityTimeSecSince());
myRobot->unlock();
client->sendPacketTcp(&sending);
} // end method activityTimeInfo
示例6: serverCycleCallback
AREXPORT void ArServerHandlerPopup::serverCycleCallback(void)
{
std::map<ArTypes::Byte4, PopupData *>::iterator it;
ArNetPacket sendingPacket;
PopupData *popupData;
int timeout;
std::list<ArTypes::Byte4> doneIDs;
std::list<PopupData *> donePopups;
myDataMutex.lock();
// only check it if we haven't checked it lately
if (myLastTimeCheck.mSecSince() > 1000)
{
myLastTimeCheck.setToNow();
for (it = myMap.begin(); it != myMap.end(); it++)
{
popupData = (*it).second;
if ((timeout = popupData->myPopupInfo->getTimeout()) > 0 &&
popupData->myStarted.secSince() >= timeout)
{
sendingPacket.empty();
sendingPacket.byte4ToBuf((*it).first);
sendingPacket.strToBuf(popupData->myPopupInfo->getTimeoutString());
myServer->broadcastPacketTcp(&sendingPacket, "popupClose");
doneIDs.push_back((*it).first);
donePopups.push_back(popupData);
}
}
}
while (doneIDs.begin() != doneIDs.end())
{
myMap.erase((*doneIDs.begin()));
doneIDs.pop_front();
}
myDataMutex.unlock();
std::list<PopupData *>::iterator donePopupIt;
while ((donePopupIt = donePopups.begin()) != donePopups.end())
{
popupData = (*donePopupIt);
if (popupData->myCallback != NULL)
popupData->myCallback->invoke(popupData->myID, -1);
delete popupData;
donePopups.pop_front();
}
}
示例7: main
int main(int argc, char **argv)
{
Aria::init();
//ArLog::init(ArLog::StdOut, ArLog::Verbose);
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);
}
client.runAsync();
ArNetPacket sending;
// We have to tell it what route we want to patrol
sending.strToBuf("hallways");
// tell it how much many times we want to patrol (<= 0 == forever)
sending.byte4ToBuf(0);
client.requestOnce("patrolRouteCount", &sending);
// note that there's also another call (patrol) that just has it always
// patrol forever but this gives you more options and is only
// slightly more complicated (just give it that byte4)
// you have to give the client some time to send the command
ArUtil::sleep(500);
Aria::shutdown();
return 0;
}
示例8: netPopupClicked
AREXPORT void ArServerHandlerPopup::netPopupClicked(ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket sendingPacket;
PopupData *popupData;
std::map<ArTypes::Byte4, PopupData *>::iterator it;
ArTypes::Byte4 id;
ArTypes::Byte button;
id = packet->bufToByte4();
button = packet->bufToByte();
myDataMutex.lock();
if ((it = myMap.find(id)) == myMap.end())
{
ArLog::log(ArLog::Verbose,
"Cannot close popup %u for client %s as it doesn't exist (anymore at least)",
id, client->getIPString());
myDataMutex.unlock();
}
else
{
popupData = (*it).second;
sendingPacket.byte4ToBuf(id);
if (button == 0)
sendingPacket.strToBuf(popupData->myPopupInfo->getButton0Pressed());
else if (button == 1)
sendingPacket.strToBuf(popupData->myPopupInfo->getButton1Pressed());
else if (button == 2)
sendingPacket.strToBuf(popupData->myPopupInfo->getButton2Pressed());
else
sendingPacket.strToBuf("Popup closed because of odd click");
myMap.erase(id);
myDataMutex.unlock();
if (popupData->myCallback != NULL)
popupData->myCallback->invoke(popupData->myID, button);
delete popupData;
myServer->broadcastPacketTcp(&sendingPacket, "popupClose");
}
}
示例9: exampleDotsDrawingNetCallback
void exampleDotsDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
ArNetPacket reply;
unsigned int tik = ArUtil::getTime() % 200;
double t = tik / 5.0;
// Three dots
reply.byte4ToBuf(3);
// Dot 1:
reply.byte4ToBuf(3000); // X coordinate (mm)
reply.byte4ToBuf((int) (sin(t) * 1000));// Y
// Dot 2:
reply.byte4ToBuf(3500); // X
reply.byte4ToBuf((int) (sin(t+500) * 1000));// Y
// Dot 3:
reply.byte4ToBuf(4000); // X
reply.byte4ToBuf((int) (sin(t+1000) * 1000));// Y
client->sendPacketUdp(&reply);
}
示例10: exampleHomeDrawingNetCallback
void exampleHomeDrawingNetCallback(ArServerClient* client, ArNetPacket* requestPkt) {
ArNetPacket reply;
// 7 Vertices
reply.byte4ToBuf(7);
// Centered on 0,0.
// X: Y:
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); // Vertex 1
reply.byte4ToBuf(-500); reply.byte4ToBuf(-500); // Vertex 2
reply.byte4ToBuf(500); reply.byte4ToBuf(-500); // Vertex 3
reply.byte4ToBuf(500); reply.byte4ToBuf(500); // Vertex 4
reply.byte4ToBuf(0); reply.byte4ToBuf(1000); // Vertex 5
reply.byte4ToBuf(-500); reply.byte4ToBuf(500); // Vertex 6
reply.byte4ToBuf(500); reply.byte4ToBuf(500); // Vertex 7
client->sendPacketUdp(&reply);
}
示例11: sendMapWithMaxCategory
AREXPORT void ArServerHandlerMap::sendMapWithMaxCategory(ArServerClient *client,
const char *maxCategory)
{
ArLog::LogLevel level = ArLog::Verbose;
ArLog::log(level,
"Starting sending map (%s) to client", maxCategory);
if (myMap == NULL)
{
ArLog::log(level,
"ArServerHandlerMap::sendMapWithMaxCategory() NULL map");
writeMapToClient("", client);
return;
}
myMap->lock();
// This functor is used to send the map header and objects in text format.
ArFunctor1<const char *> *textFunctor =
new ArFunctor2C<ArServerHandlerMap, const char *, ArServerClient *>
(this,
&ArServerHandlerMap::writeMapToClient,
NULL,
client);
// This functor is used to send the map data lines in binary format (since
// it is faster).
ArFunctor2<int, std::vector<ArLineSegment> *> *linesFunctor =
new ArFunctor3C<ArServerHandlerMap, int, std::vector<ArLineSegment> *, ArServerClient *>
(this,
&ArServerHandlerMap::writeLinesToClient,
0,
NULL,
client);
// This functor is used to send the map data points in binary format (since
// it is faster).
ArFunctor2<int, std::vector<ArPose> *> *pointsFunctor =
new ArFunctor3C<ArServerHandlerMap, int, std::vector<ArPose> *, ArServerClient *>
(this,
&ArServerHandlerMap::writePointsToClient,
0,
NULL,
client);
// Send the map up to but not including the DATA tag.
myMap->writeObjectsToFunctor(textFunctor,
"",
false,
maxCategory);
std::list<std::string> scanTypeList = myMap->getScanTypes();
if (!scanTypeList.empty()) {
// see if we want to send the lines and make sure we have lines
if (myDataToSend == LINES || myDataToSend == BOTH) {
for (std::list<std::string>::iterator iter = scanTypeList.begin();
iter != scanTypeList.end();
iter++) {
const char *scanType = (*iter).c_str();
if ((myMap->getLines(scanType) != NULL) &&
(!myMap->getLines(scanType)->empty())) {
myMap->writeLinesToFunctor(linesFunctor,
scanType,
textFunctor);
ArNetPacket sendPacket;
sendPacket.empty();
sendPacket.byte4ToBuf(0);
client->sendPacketTcp(&sendPacket);
}
}
}
if (myDataToSend == POINTS || myDataToSend == BOTH) {
// TODO This is different than getMapBinary -- in that DATA is not necessarily
// always sent. Is this going to be a problem?
for (std::list<std::string>::iterator iter = scanTypeList.begin();
iter != scanTypeList.end();
iter++) {
const char *scanType = (*iter).c_str();
if ((myMap->getPoints(scanType) != NULL) &&
(!myMap->getPoints(scanType)->empty())) {
myMap->writePointsToFunctor(pointsFunctor,
scanType,
textFunctor);
ArNetPacket sendPacket;
sendPacket.empty();
sendPacket.byte4ToBuf(0);
client->sendPacketTcp(&sendPacket);
}
}
}
} // end if scan types
//.........这里部分代码省略.........
示例12: serverGetMapBinary
AREXPORT void ArServerHandlerMap::serverGetMapBinary(ArServerClient *client,
ArNetPacket *packet)
{
ArLog::log(ArLog::Verbose, "Starting sending map (binary) to client");
if (myMap == NULL)
{
writeMapToClient("", client);
return;
}
myMap->lock();
// This functor is used to send the map header and objects in text format.
ArFunctor1<const char *> *textFunctor =
new ArFunctor2C<ArServerHandlerMap, const char *, ArServerClient *>
(this,
&ArServerHandlerMap::writeMapToClient,
NULL,
client);
// This functor is used to send the map data lines in binary format (since
// it is faster).
ArFunctor2<int, std::vector<ArLineSegment> *> *linesFunctor =
new ArFunctor3C<ArServerHandlerMap, int, std::vector<ArLineSegment> *, ArServerClient *>
(this,
&ArServerHandlerMap::writeLinesToClient,
0,
NULL,
client);
// This functor is used to send the map data points in binary format (since
// it is faster).
ArFunctor2<int, std::vector<ArPose> *> *pointsFunctor =
new ArFunctor3C<ArServerHandlerMap, int, std::vector<ArPose> *, ArServerClient *>
(this,
&ArServerHandlerMap::writePointsToClient,
0,
NULL,
client);
// Send the map up to but not including the DATA tag.
myMap->writeObjectsToFunctor(textFunctor,
"",
true, // Only send one scan type
ArMapInterface::MAP_CATEGORY_2D);
std::list<std::string> scanTypeList = myMap->getScanTypes();
bool isAnyLinesExist = false;
for (std::list<std::string>::iterator iter = scanTypeList.begin();
iter != scanTypeList.end();
iter++) {
const char *scanType = (*iter).c_str();
if ((myMap->getLines(scanType) != NULL) &&
(!myMap->getLines(scanType)->empty())) {
isAnyLinesExist = true;
break;
}
} // end for each scan type
// see if we want to send the lines and make sure we have lines
if ((myDataToSend == LINES || myDataToSend == BOTH) &&
isAnyLinesExist)
{
writeMapToClient("LINES", client);
/***
myMap->writeLinesToFunctor(linesFunctor,
NULL,
ARMAP_SUMMARY_SCAN_TYPE);
***/
for (std::list<std::string>::iterator iter = scanTypeList.begin();
iter != scanTypeList.end();
iter++) {
const char *scanType = (*iter).c_str();
ArLog::log(ArLog::Normal,
"ArServerHandlerMap::serverGetMapBinary() sending lines for %s",
scanType);
myMap->writeLinesToFunctor(linesFunctor, scanType, NULL);
} // end for each scan type
ArNetPacket sendPacket;
sendPacket.empty();
sendPacket.byte4ToBuf(0);
client->sendPacketTcp(&sendPacket);
/****/
}
// Always write the points (even if empty) because this signifies
// the end of the map for the client.
//if (myMap->getPoints()->begin() != myMap->getPoints()->end())
//{
writeMapToClient("DATA", client);
// if we want to send points then send 'em
if (myDataToSend == POINTS || myDataToSend == BOTH)
{
//.........这里部分代码省略.........
示例13: writeLinesToClient
/** @internal */
AREXPORT void ArServerHandlerMap::writeLinesToClient(
int lineCount,
std::vector<ArLineSegment> *lines,
ArServerClient *client)
{
ArNetPacket sendPacket;
// Should never happen...
if (lines == NULL) {
// Send 0 points just so the client doesn't hang
sendPacket.byte4ToBuf(0);
client->sendPacketTcp(&sendPacket);
return;
}
ArLog::log(ArLog::Verbose,
"ArServerHandlerMap::writeLinesToClient() pointCount = %i, vector size = %i",
lineCount, (int) lines->size());
// Neither should this, but just in case...
if (lineCount > (int) lines->size()) {
lineCount = lines->size();
}
int maxInPacketCount = 1000; // Maximum number of points sent in a packet
int currentCount = 0; // Number put into the current packet
int remainingCount = lineCount; // Total number of points remaining to be sent
bool isStartPacket = true; // Whether a new packet is being started
int totalCount = 0;
for (std::vector<ArLineSegment>::iterator lineIt = lines->begin();
lineIt != lines->end();
lineIt++)
{
// Start a new packet if the previous one was sent (or there is no
// previous one)
if (isStartPacket) {
isStartPacket = false;
sendPacket.empty();
currentCount = 0;
// Leftover points...
if (maxInPacketCount > remainingCount) {
maxInPacketCount = remainingCount;
}
// The first item in the packet is the number of points contained
sendPacket.byte4ToBuf(maxInPacketCount);
} // end if starting a new packet
// Add the current point to the packet (think that the test should
// always be true)
if (currentCount < maxInPacketCount) {
currentCount++;
remainingCount--;
sendPacket.byte4ToBuf(
ArMath::roundInt((*lineIt).getX1()));
sendPacket.byte4ToBuf(
ArMath::roundInt((*lineIt).getY1()));
sendPacket.byte4ToBuf(
ArMath::roundInt((*lineIt).getX2()));
sendPacket.byte4ToBuf(
ArMath::roundInt((*lineIt).getY2()));
}
// If the packet is full, send it and then start a new one
if (currentCount == maxInPacketCount) {
totalCount += currentCount;
client->sendPacketTcp(&sendPacket);
//ArUtil::sleep(1);
isStartPacket = true;
}
} // end for each point
ArLog::log(ArLog::Verbose,
"ArServerHandlerMap::writePointsToClient() totalCount = %i",
totalCount);
// Send 0 points to indicate that all have been sent
if (false) {
sendPacket.empty();
sendPacket.byte4ToBuf(0);
client->sendPacketTcp(&sendPacket);
}
} // end writePointsToClient
示例14: processPacket
AREXPORT void ArServerClient::processPacket(ArNetPacket *packet, bool tcp)
{
std::string str;
struct sockaddr_in sin;
unsigned int clientUdpPort;
ArNetPacket retPacket;
//printf("Command number %d\n", packet->getCommand());
// if we're in intro mode and received back the intro
if (myState == STATE_SENT_INTRO &&
packet->getCommand() == ArClientCommands::INTRODUCTION)
{
char user[512];
unsigned char password[16];
clientUdpPort = packet->bufToUByte2();
packet->bufToStr(user, sizeof(user));
packet->bufToData((char *)password, 16);
if (myRejecting != 0)
{
retPacket.empty();
retPacket.setCommand(ArServerCommands::REJECTED);
retPacket.byte2ToBuf(myRejecting);
retPacket.strToBuf(myRejectingString.c_str());
sendPacketTcp(&retPacket);
if (myRejecting == 2)
ArLog::log(ArLog::Normal,
"%sRejected connection from %s since we're using a central server at %s",
myLogPrefix.c_str(), getIPString(),
myRejectingString.c_str());
internalSwitchState(STATE_REJECTED);
return;
}
// if user info is NULL we're not checking passwords
if (myUserInfo != NULL &&
!myUserInfo->matchUserPassword(user, password, myPasswordKey.c_str(),
myServerKey.c_str(),
myLogPasswordFailureVerbosely))
{
retPacket.empty();
retPacket.setCommand(ArServerCommands::REJECTED);
retPacket.byte2ToBuf(1);
retPacket.strToBuf("");
sendPacketTcp(&retPacket);
ArLog::log(ArLog::Normal, "%sRejected user '%s' or password from %s",
myLogPrefix.c_str(), user, getIPString());
internalSwitchState(STATE_REJECTED);
return;
}
if (myUserInfo != NULL)
myGroups = myUserInfo->getUsersGroups(user);
else
myGroups.clear();
sin.sin_family = AF_INET;
sin.sin_addr = *myTcpSocket.inAddr();
sin.sin_port = ArSocket::hostToNetOrder(clientUdpPort);
if (myUserInfo != NULL)
ArLog::log(ArLog::Normal,
"%sClient connected from %s with user %s",
myLogPrefix.c_str(), getIPString(), user);
else
ArLog::log(ArLog::Normal,
"%sClient connected from %s", myLogPrefix.c_str(),
getIPString());
setUdpAddress(&sin);
// send that we've connected
retPacket.empty();
retPacket.setCommand(ArServerCommands::CONNECTED);
sendPacketTcp(&retPacket);
// note that we're connected
internalSwitchState(STATE_CONNECTED);
// send them the list
sendListPacket();
// send the udp introduction if we're using udp
if (!myTcpOnly)
{
retPacket.empty();
retPacket.setCommand(ArServerCommands::UDP_INTRODUCTION);
retPacket.byte4ToBuf(myIntroKey);
sendPacketUdp(&retPacket);
}
}
// if we aren't in intro mode and got an intro somethings wrong
else if (packet->getCommand() == ArClientCommands::INTRODUCTION)
{
ArLog::log(ArLog::Terse,
"%sReceived introduction when not in intro mode",
myLogPrefix.c_str());
return;
}
// if we got this over tcp then they only want tcp
else if (packet->getCommand() == ArClientCommands::UDP_INTRODUCTION)
{
if (!myTcpOnly)
{
ArLog::log(ArLog::Normal, "%sGot UDP introduction over tcp, assuming client only wants tcp data.", myLogPrefix.c_str());
myTcpOnly = true;
//.........这里部分代码省略.........
示例15: getCameraList
AREXPORT void ArServerHandlerCameraCollection::getCameraList(ArServerClient *client,
ArNetPacket *packet)
{
if (client == NULL) {
return; // Something very bad has happened...
}
ArNetPacket sendPacket;
if (myCameraCollection == NULL) {
sendPacket.byte2ToBuf(0);
client->sendPacketTcp(&sendPacket);
}
// This lack of recursive locks is troublesome... Data might
// change between calls...
std::list<std::string> cameraNames;
myCameraCollection->getCameraNames(cameraNames);
sendPacket.byte2ToBuf(cameraNames.size());
for (std::list<std::string>::iterator iter = cameraNames.begin();
iter != cameraNames.end();
iter++) {
const char *curName = iter->c_str();
sendPacket.strToBuf(curName);
// TODO: ArNetPacket will NOT behave correctly if the given str is NULL
// Fix this somehow...
sendPacket.strToBuf(myCameraCollection->getCameraType(curName));
sendPacket.strToBuf(myCameraCollection->getDisplayName(curName));
sendPacket.strToBuf(myCameraCollection->getDisplayType(curName));
// Send commands...
std::list<std::string> commands;
myCameraCollection->getCameraCommands(curName, commands);
sendPacket.byte2ToBuf(commands.size());
for (std::list<std::string>::iterator comIter = commands.begin();
comIter != commands.end();
comIter++) {
const char *curCommand = comIter->c_str();
sendPacket.strToBuf(curCommand);
sendPacket.strToBuf(myCameraCollection->getCommandName(curName, curCommand));
sendPacket.byte4ToBuf(myCameraCollection->getRequestInterval(curName, curCommand));
} // end for each command
// Send parameters...
std::list<std::string> params;
myCameraCollection->getParameterNames(curName, params);
sendPacket.byte2ToBuf(params.size());
ArConfigArg arg;
ArClientArg clientArg;
bool isSuccess = true;
for (std::list<std::string>::iterator paramIter = params.begin();
paramIter != params.end();
paramIter++) {
const char *paramName = paramIter->c_str();
isSuccess = myCameraCollection->getParameter(curName,
paramName,
arg);
if (!isSuccess) {
ArLog::log(ArLog::Normal,
"ArServerHandlerCameraCollection::getCameraList() could not find param %s", paramName);
continue;
}
// Add the current parameter to the packet
isSuccess = clientArg.createPacket(arg, &sendPacket);
} // end for each parameter
} // end for each camera
client->sendPacketTcp(&sendPacket);
} // end method getCameraList