本文整理汇总了C++中ArNetPacket::uByteToBuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket::uByteToBuf方法的具体用法?C++ ArNetPacket::uByteToBuf怎么用?C++ ArNetPacket::uByteToBuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArNetPacket
的用法示例。
在下文中一共展示了ArNetPacket::uByteToBuf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: batteryInfo
AREXPORT void ArServerInfoRobot::batteryInfo(ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket sending;
myRobot->lock();
if (myRobot->haveStateOfCharge())
{
// this is a temporary workaround since the config packet reader
// in this aria doesn't get these values from the firmware
if (myRobot->getStateOfChargeLow() <= 0 &&
myRobot->getStateOfChargeShutdown() <= 0)
{
sending.doubleToBuf(20);
sending.doubleToBuf(3);
}
else
{
sending.doubleToBuf(myRobot->getStateOfChargeLow());
sending.doubleToBuf(myRobot->getStateOfChargeShutdown());
}
// voltage is really state of charge
sending.uByteToBuf(1);
}
else
{
const ArRobotConfigPacketReader *reader;
reader = myRobot->getOrigRobotConfig();
if (reader != NULL && reader->hasPacketArrived())
{
if (reader->getLowBattery() != 0)
sending.doubleToBuf(reader->getLowBattery() * .1);
else
sending.doubleToBuf(11.5);
if (reader->getShutdownVoltage() != 0)
sending.doubleToBuf(reader->getShutdownVoltage() * .1);
else
sending.doubleToBuf(11);
}
else
{
sending.doubleToBuf(11.5);
sending.doubleToBuf(11);
}
// voltage is voltage, not state of charge
sending.uByteToBuf(0);
}
myRobot->unlock();
client->sendPacketTcp(&sending);
}
示例2: finishConstructor
AREXPORT void ArHybridForwarderVideo::finishConstructor(void)
{
myClient->lock();
mySendVideoSizeCB = new ArFunctor2C<ArHybridForwarderVideo, ArServerClient*,
ArNetPacket *>(this, &ArHybridForwarderVideo::sendVideoSize);
mySendVideoCB = new ArFunctor2C<ArHybridForwarderVideo, ArServerClient*,
ArNetPacket *>(this, &ArHybridForwarderVideo::sendVideo);
myReceiveVideoSizeCB = new ArFunctor1C<ArHybridForwarderVideo,
ArNetPacket *>(this, &ArHybridForwarderVideo::receiveVideoSize);
myReceiveVideoCB = new ArFunctor1C<ArHybridForwarderVideo,
ArNetPacket *>(this, &ArHybridForwarderVideo::receiveVideo);
myClientCycleCB = new ArFunctorC<ArHybridForwarderVideo>(
this, &ArHybridForwarderVideo::clientCycleCallback);
myReqSent = false;
myLastReqSent.setToNow();
myLastReceivedVideo.setToNow();
myVideoRequestTime = 100;
myForwardingVideo = false;
if (myClient != NULL && myServer != NULL && myClient->isConnected())
{
myClient->addCycleCallback(myClientCycleCB);
if (myClient->dataExists("videoSize"))
{
myServer->addData("videoSize",
"gets the width and height of the video data",
mySendVideoSizeCB,
"none", "uByte2: width, uByte2: height",
"Video", "RETURN_SINGLE");
myClient->addHandler("videoSize", myReceiveVideoSizeCB);
myClient->requestOnce("videoSize");
}
if (myClient->dataExists("sendVideo"))
{
ArLog::log(ArLog::Normal, "Forwarding video.");
myForwardingVideo = true;
myClient->addHandler("sendVideo", myReceiveVideoCB);
ArNetPacket packet;
packet.uByteToBuf(90);
myClient->requestOnce("sendVideo", &packet);
myIsSendVideoAvailable =
myServer->addData("sendVideo", "gets video from the robot's camera (you should requestOnce this, you shouldn't request it, since you could easily fill the bandwidth that way)",
mySendVideoCB, "uByte: quality (0 - 100)",
"out: uByte2: width, uByte2: height, (len - readLen)*uByte: jpegData", "Video", "RETURN_VIDEO");
}
}
myClient->unlock();
}
示例3: batteryInfo
AREXPORT void ArServerInfoRobot::batteryInfo(ArServerClient *client,
ArNetPacket *packet)
{
ArNetPacket sending;
myRobot->lock();
if (myRobot->haveStateOfCharge())
{
sending.doubleToBuf(myRobot->getStateOfChargeLow());
sending.doubleToBuf(myRobot->getStateOfChargeShutdown());
// voltage is really state of charge
sending.uByteToBuf(1);
}
else
{
const ArRobotConfigPacketReader *reader;
reader = myRobot->getOrigRobotConfig();
if (reader != NULL && reader->hasPacketArrived())
{
if (reader->getLowBattery() != 0)
sending.doubleToBuf(reader->getLowBattery() * .1);
else
sending.doubleToBuf(11.5);
if (reader->getShutdownVoltage() != 0)
sending.doubleToBuf(reader->getShutdownVoltage() * .1);
else
sending.doubleToBuf(11);
}
else
{
sending.doubleToBuf(11.5);
sending.doubleToBuf(11);
}
// voltage is voltage, not state of charge
sending.uByteToBuf(0);
}
myRobot->unlock();
client->sendPacketTcp(&sending);
}