本文整理汇总了C++中imc::Message::getSerializationSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::getSerializationSize方法的具体用法?C++ Message::getSerializationSize怎么用?C++ Message::getSerializationSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imc::Message
的用法示例。
在下文中一共展示了Message::getSerializationSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
sendMsg(IMC::Message& msg, UDPSocket& sock, Address& dest, int port)
{
DUNE::Utils::ByteBuffer bb;
msg.setTimeStamp();
IMC::Packet::serialize(&msg, bb);
sock.write((const uint8_t*)bb.getBuffer(), msg.getSerializationSize(), dest, port);
msg.toText(std::cout);
}
示例2: dest
//.........这里部分代码省略.........
std::istream* is;
if (file.isDirectory())
{
file = file / "Data.lsf";
if (!file.isFile())
file += ".gz";
}
if (!file.isFile())
{
std::cerr << file << " does not exist\n";
return 1;
}
Compression::Methods method = Compression::Factory::detect(file.c_str());
if (method == METHOD_UNKNOWN)
is = new std::ifstream(file.c_str(), std::ios::binary);
else
is = new Compression::FileInput(file.c_str(), method);
IMC::Message* m;
m = IMC::Packet::deserialize(*is);
if (!m)
{
std::cerr << file << " contains no messages\n";
delete is;
continue;
}
DUNE::Utils::ByteBuffer bb;
double time_origin = m->getTimeStamp();
if (begin >= 0)
{
do
{
if (m->getTimeStamp() - time_origin >= begin)
break;
delete m;
m = IMC::Packet::deserialize(*is);
}
while (m);
if (!m)
{
std::cerr << "no messages for specified time range" << std::endl;
return 1;
}
}
else
begin = 0;
double start_time = Clock::getSinceEpoch();
double now = start_time;
do
{
double msg_ts = m->getTimeStamp();
double vtime = msg_ts - time_origin;
m->setTimeStamp(start_time + vtime);
double future = 0;
if (speed > 0 && vtime >= begin)
{
// Delay time to mimic behavior at specified speed
future = start_time + vtime / speed - begin;
double delay_time = (future - now);
if (delay_time > 0)
Delay::wait(delay_time);
}
now = Clock::getSinceEpoch();
if (vtime >= begin
&& (src == 0xFFFF || src == m->getSource())
&& (dst == 0xFFFF || dst == m->getDestination())
&& (!filtering || filter[m->getName()]))
{
// Send message
IMC::Packet::serialize(m, bb);
sock.write(bb.getBuffer(), m->getSerializationSize(), dest, port);
if (verbose >= 1)
std::cout << (begin + now - start_time) << ' ' << vtime << ' ' << now - future << " : " << m->getName() << '\n';
if (verbose >= 2)
m->toText(std::cout);
}
delete m;
if (end >= 0 && vtime >= end)
break;
}
while ((m = IMC::Packet::deserialize(*is)) != 0);
delete is;
}
return 0;
}