本文整理汇总了C++中imc::Message::setTimeStamp方法的典型用法代码示例。如果您正苦于以下问题:C++ Message::setTimeStamp方法的具体用法?C++ Message::setTimeStamp怎么用?C++ Message::setTimeStamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imc::Message
的用法示例。
在下文中一共展示了Message::setTimeStamp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
//.........这里部分代码省略.........
tmsg->text = argv[5];
}
else if (argc == 5)
{
tmsg->origin = "dune-sendmsg";
tmsg->text = argv[4];
}
}
if (strcmp(argv[3], "TrexCommand") == 0)
{
IMC::TrexCommand* tmsg = new IMC::TrexCommand;
msg = tmsg;
if (strcmp(argv[4], "DISABLE") == 0 || strcmp(argv[4], "1") == 0 )
tmsg->command = 1;
else if (strcmp(argv[4], "ENABLE") == 0 || strcmp(argv[4], "2") == 0 )
tmsg->command = 2;
}
if (strcmp(argv[3], "UASimulation") == 0)
{
IMC::UASimulation* tmsg = new IMC::UASimulation;
tmsg->setSource(atoi(argv[4]));
tmsg->setDestination(atoi(argv[5]));
tmsg->speed = atoi(argv[6]);
tmsg->type = IMC::UASimulation::UAS_DATA;
tmsg->data.assign(atoi(argv[7]), '0');
msg = tmsg;
}
if (strcmp(argv[3], "UsblConfig") == 0)
{
IMC::UsblConfig* tmsg = new IMC::UsblConfig;
msg = tmsg;
tmsg->op = IMC::UsblConfig::OP_SET_CFG;
IMC::UsblModem modem;
modem.name = argv[4];
modem.lat = atof(argv[5]);
modem.lon = atof(argv[6]);
modem.z = atof(argv[7]);
modem.z_units = static_cast<IMC::ZUnits>(1);
tmsg->modems.push_back(modem);
}
if (strcmp(argv[3], "VehicleCommand") == 0)
{
IMC::VehicleCommand* tmsg = new IMC::VehicleCommand;
msg = tmsg;
tmsg->type = IMC::VehicleCommand::VC_REQUEST;
tmsg->command = atoi(argv[4]);
if (tmsg->command == IMC::VehicleCommand::VC_EXEC_MANEUVER)
tmsg->maneuver.set(static_cast<IMC::Maneuver*>(IMC::Factory::produce(argv[5])));
}
if (strcmp(argv[3], "VehicleMedium") == 0)
{
IMC::VehicleMedium* tmsg = new IMC::VehicleMedium;
msg = tmsg;
tmsg->medium = atoi(argv[4]);
}
if (msg == NULL)
{
fprintf(stderr, "ERROR: unknown message '%s'\n", argv[3]);
return 1;
}
msg->setTimeStamp();
uint8_t bfr[1024] = {0};
uint16_t rv = IMC::Packet::serialize(msg, bfr, sizeof(bfr));
UDPSocket sock;
try
{
sock.write(bfr, rv, dest, port);
fprintf(stderr, "Raw:");
for (int i = 0; i < rv; ++i)
fprintf(stderr, " %02X", bfr[i]);
fprintf(stderr, "\n");
msg->toText(cerr);
}
catch (std::runtime_error& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return 1;
}
if (msg != NULL)
{
delete msg;
msg = NULL;
}
return 0;
}
示例3: dest
//.........这里部分代码省略.........
tmsg->op = atoi(argv[5]);
}
else if (strcmp(argv[3], "RegisterManeuver") == 0)
{
IMC::RegisterManeuver* tmsg = new IMC::RegisterManeuver;
msg = tmsg;
tmsg->mid = atoi(argv[4]);
}
else if (strcmp(argv[3], "Brake") == 0)
{
IMC::Brake* tmsg = new IMC::Brake;
msg = tmsg;
tmsg->op = atoi(argv[4]);
}
else if (strcmp(argv[3], "SetEntityParameters") == 0)
{
IMC::SetEntityParameters* tmsg = new IMC::SetEntityParameters;
msg = tmsg;
tmsg->name = argv[4];
IMC::EntityParameter param;
unsigned i = 4;
while (1)
{
if (argc >= (int)i + 2)
{
++i;
param.name = argv[i];
++i;
param.value = argv[i];
tmsg->params.push_back(param);
}
else
{
break;
}
}
}
else if (strcmp(argv[3], "PushEntityParameters") == 0)
{
IMC::PushEntityParameters* tmsg = new IMC::PushEntityParameters;
msg = tmsg;
tmsg->name = argv[4];
}
else if (strcmp(argv[3], "PopEntityParameters") == 0)
{
IMC::PopEntityParameters* tmsg = new IMC::PopEntityParameters;
msg = tmsg;
tmsg->name = argv[4];
}
else if (strcmp(argv[3], "IridiumMsgTx") == 0)
{
IMC::IridiumMsgTx* tmsg = new IMC::IridiumMsgTx;
msg = tmsg;
tmsg->req_id = atoi(argv[4]);
tmsg->ttl = atoi(argv[5]);
std::string hex = String::fromHex(argv[6]);
tmsg->data.assign(hex.begin(), hex.end());
}
if (msg == NULL)
{
fprintf(stderr, "ERROR: unknown message '%s'\n", argv[3]);
return 1;
}
msg->setTimeStamp();
uint8_t bfr[1024] = {0};
uint16_t rv = IMC::Packet::serialize(msg, bfr, sizeof(bfr));
UDPSocket sock;
try
{
sock.write((const char*)bfr, rv, dest, port);
fprintf(stderr, "Raw:");
for (int i = 0; i < rv; ++i)
fprintf(stderr, " %02X", bfr[i]);
fprintf(stderr, "\n");
msg->toText(cerr);
}
catch (std::runtime_error& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return 1;
}
if (msg != NULL)
{
delete msg;
msg = NULL;
}
return 0;
}
示例4: 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;
}