本文整理汇总了C++中ArNetPacket类的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket类的具体用法?C++ ArNetPacket怎么用?C++ ArNetPacket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArNetPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: userTask
void ArServerInfoRobot::userTask(void)
{
ArServerMode *netMode;
ArNetPacket sending;
if ((netMode = ArServerMode::getActiveMode()) != NULL)
{
myStatus = netMode->getStatus();
myExtendedStatus = netMode->getExtendedStatus();
if (myExtendedStatus.empty())
myExtendedStatus = myStatus;
myMode = netMode->getMode();
}
else
{
myStatus = "Unknown status";
myExtendedStatus = "Unknown extended status";
myMode = "Unknown mode";
}
if (myStatus != myOldStatus || myMode != myOldMode ||
myExtendedStatus != myOldExtendedStatus)
{
sending.strToBuf(myStatus.c_str());
sending.strToBuf(myMode.c_str());
sending.strToBuf(myExtendedStatus.c_str());
myServer->broadcastPacketTcp(&sending, "updateStrings");
}
myOldStatus = myStatus;
myOldMode = myMode;
myOldExtendedStatus = myExtendedStatus;
}
示例2: netPopupList
AREXPORT void ArServerHandlerPopup::netPopupList(ArServerClient *client,
ArNetPacket *packet)
{
ArLog::log(ArLog::Normal, "Sending popup list");
std::map<ArTypes::Byte4, PopupData *>::iterator it;
ArNetPacket sendingPacket;
PopupData *popupData;
myDataMutex.lock();
for (it = myMap.begin(); it != myMap.end(); it++)
{
popupData = (*it).second;
sendingPacket.empty();
ArLog::log(ArLog::Normal, "Sending popup %d", popupData->myID);
buildPacket(&sendingPacket, popupData);
sendingPacket.setCommand(myServer->findCommandFromName("popupCreate"));
client->sendPacketTcp(&sendingPacket);
}
sendingPacket.empty();
client->sendPacketTcp(&sendingPacket);
ArLog::log(ArLog::Normal, "Sent popups");
myDataMutex.unlock();
}
示例3: cameraInfo
AREXPORT void ArServerHandlerCamera::cameraInfo(ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket send;
myRobot->lock();
int minPan = ArMath::roundInt(myCamera->getMaxNegPan());
int maxPan = ArMath::roundInt(myCamera->getMaxPosPan());
int minTilt = ArMath::roundInt(myCamera->getMaxNegTilt());
int maxTilt = ArMath::roundInt(myCamera->getMaxPosTilt());
int minZoom = 0;
int maxZoom = 100;
bool isZoomAvailable = myCamera->canZoom();
//ArLog::log(ArLog::Normal, "minPan %d maxPan %d minTilt %d maxTilt %d minZoom %d maxZoom %d isZoomAvailable %d", minPan, maxPan, minTilt, maxTilt, minZoom, maxZoom, isZoomAvailable);
myRobot->unlock();
send.byte2ToBuf(minPan);
send.byte2ToBuf(maxPan);
send.byte2ToBuf(minTilt);
send.byte2ToBuf(maxTilt);
send.byte2ToBuf(minZoom);
send.byte2ToBuf(maxZoom);
send.byteToBuf(isZoomAvailable);
client->sendPacketUdp(&send);
} // end method cameraInfo
示例4: closePopup
AREXPORT void ArServerHandlerPopup::closePopup(ArTypes::Byte4 id,
const char *closeMessage)
{
ArNetPacket sendingPacket;
PopupData *popupData;
std::map<ArTypes::Byte4, PopupData *>::iterator it;
myDataMutex.lock();
if ((it = myMap.find(id)) == myMap.end())
{
ArLog::log(ArLog::Verbose,
"Cannot close popup %u as it doesn't exist (anymore at least)",
id);
myDataMutex.unlock();
}
else
{
popupData = (*it).second;
sendingPacket.byte4ToBuf(id);
sendingPacket.strToBuf(closeMessage);
myMap.erase(id);
myDataMutex.unlock();
delete popupData;
if (popupData->myCallback != NULL)
popupData->myCallback->invoke(popupData->myID, -2);
myServer->broadcastPacketTcp(&sendingPacket, "popupClose");
}
}
示例5: sendPoseRobot
void sendPoseRobot(ArServerClient* client, ArNetPacket* packet) {
ArNetPacket reply;
ArPose pose = gotoGoal.getPose();
reply.doubleToBuf(pose.getX());
reply.doubleToBuf(pose.getY());
client->sendPacketUdp(&reply);
}
示例6: getSensorList
AREXPORT void ArServerInfoSensor::getSensorList(ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket sendPacket;
std::list<ArRangeDevice *> *devList;
std::list<ArRangeDevice *>::iterator it;
myRobot->lock();
devList = myRobot->getRangeDeviceList();
if (devList == NULL)
{
myRobot->unlock();
client->sendPacketUdp(&sendPacket);
return;
}
sendPacket.byte2ToBuf(devList->size());
for (it = devList->begin(); it != devList->end(); it++)
{
sendPacket.strToBuf((*it)->getName());
}
myRobot->unlock();
client->sendPacketUdp(&sendPacket);
}
示例7: requestOnceWithString
AREXPORT bool ArCentralForwarder::requestOnceWithString(const char *name, const char *str)
{
ArNetPacket tempPacket;
tempPacket.strToBuf(str);
return requestOnce(name, &tempPacket);
}
示例8: testFunction
void testFunction(ArServerClient *client, ArNetPacket *packet)
{
ArNetPacket sending;
printf("responding to a packet of command %d\n", packet->getCommand());
sending.strToBuf ("Laser data");
client->sendPacketTcp(&sending);
}
示例9: netRangeDeviceCumulative
AREXPORT void ArServerInfoDrawings::netRangeDeviceCumulative(
ArServerClient *client, ArNetPacket *packet, ArRangeDevice *device)
{
ArNetPacket sendPacket;
std::list<ArPoseWithTime *> *readings;
std::list<ArPoseWithTime *>::iterator it;
device->lockDevice();
readings = device->getCumulativeBuffer();
if (readings == NULL)
{
ArLog::log(ArLog::Verbose, "ArServerInfoDrawing::netRangeDeviceCumulative: No cumulative buffer for %s", device->getName());
device->unlockDevice();
sendPacket.byte4ToBuf(0);
client->sendPacketUdp(&sendPacket);
return;
}
sendPacket.byte4ToBuf(readings->size());
for (it = readings->begin(); it != readings->end(); it++)
{
sendPacket.byte4ToBuf(ArMath::roundInt((*it)->getX()));
sendPacket.byte4ToBuf(ArMath::roundInt((*it)->getY()));
}
device->unlockDevice();
client->sendPacketUdp(&sendPacket);
}
示例10: writeMapToClient
/** @internal */
AREXPORT void ArServerHandlerMap::writeMapToClient(const char *line,
ArServerClient *client)
{
ArNetPacket sendPacket;
sendPacket.strToBuf(line);
client->sendPacketTcp(&sendPacket);
}
示例11: serverGetGoals
/** @internal */
AREXPORT void ArServerHandlerMap::serverGetGoals(ArServerClient *client,
ArNetPacket *packet)
{
std::list<ArMapObject *>::iterator objIt;
ArMapObject* obj;
ArPose goal;
ArNetPacket sendPacket;
for (objIt = myMap->getMapObjects()->begin();
objIt != myMap->getMapObjects()->end();
objIt++)
{
//
// Get the forbidden lines and fill the occupancy grid there.
//
obj = (*objIt);
if (obj == NULL)
break;
if (strcasecmp(obj->getType(), "GoalWithHeading") == 0 ||
strcasecmp(obj->getType(), "Goal") == 0)
{
sendPacket.strToBuf(obj->getName());
}
}
client->sendPacketTcp(&sendPacket);
}
示例12: getConfigSectionFlags
AREXPORT void ArServerHandlerConfig::getConfigSectionFlags(
ArServerClient *client, ArNetPacket *packet)
{
ArLog::log(ArLog::Normal, "Config section flags requested.");
ArNetPacket sending;
std::list<ArConfigSection *> *sections = myConfig->getSections();
std::list<ArConfigSection *>::iterator sIt;
sending.byte4ToBuf(sections->size());
for (sIt = sections->begin(); sIt != sections->end(); sIt++)
{
ArConfigSection *section = (*sIt);
if (section == NULL)
{
sending.strToBuf("");
sending.strToBuf("");
}
else
{
sending.strToBuf(section->getName());
sending.strToBuf(section->getFlags());
}
}
client->sendPacketTcp(&sending);
}
示例13: sendInput
void AriaClientDriver::sendInput()
{
/* This method is called by the main function to send a ratioDrive
* request with our current velocity values. If the server does
* not support the ratioDrive request, then we abort now: */
if(!myClient->dataExists("ratioDrive")) return;
/* Construct a ratioDrive request packet. It consists
* of three doubles: translation ratio, rotation ratio, and an overall scaling
* factor. */
ArNetPacket packet;
packet.doubleToBuf(myTransRatio);
packet.doubleToBuf(myRotRatio);
packet.doubleToBuf(myMaxVel); // use half of the robot's maximum.
packet.doubleToBuf(myLatRatio);
if (myPrinting)
printf("Sending\n");
myClient->requestOnce("ratioDrive", &packet);
myTransRatio = 0;
myRotRatio = 0;
myLatRatio = 0;
}
示例14: space
void InputHandler::space(void)
{
ArNetPacket packet;
packet.doubleToBuf(0.00001);
myClient->requestOnce("setVel", &packet);
myClient->requestOnce("deltaHeading", &packet);
}
示例15: serverMappingStatus
AREXPORT void ArServerHandlerMapping::serverMappingStatus(
ArServerClient *client, ArNetPacket *packet)
{
ArNetPacket sendPacket;
sendPacket.strToBuf(myMapName.c_str());
client->sendPacketTcp(&sendPacket);
}