本文整理汇总了C++中Component::DiscoveryService方法的典型用法代码示例。如果您正苦于以下问题:C++ Component::DiscoveryService方法的具体用法?C++ Component::DiscoveryService怎么用?C++ Component::DiscoveryService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::DiscoveryService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VerifyAgainstLog
////////////////////////////////////////////////////////////////////////////////////
///
/// \brief Test method to verify ability to read/write message data from
/// an example wireshark log provided for testing systems for the JAUS
/// Interoperability Challenge hosted at several AUVSI competitions.
///
////////////////////////////////////////////////////////////////////////////////////
void VerifyAgainstLog()
{
Packet::List packets;
Packet::List::iterator packet;
Component component;
component.DiscoveryService()->SetSubsystemIdentification(Subsystem::OCU, "OCP");
component.AddService(new LocalPoseSensor());
component.AddService(new VelocityStateSensor());
component.AddService(new ListManager());
component.AddService(new TestLocalWaypointListDriver());
Packet::LoadWiresharkCapturePacketExport("logs/example-capture.txt", packets);
Address cop(42, 1, 1);
Address sim(6000, 1, 1);
//Packet::LoadWiresharkCapturePacketExport("logs/example_capture-2.txt", packets);
Message::List messages;
Message::List::iterator message;
// Delete UDP header data to get to just the JAUS message.
for(packet = packets.begin(); packet != packets.end();)
{
// Delete UDP header data.
packet->Delete(43);
// Read message header data.
Header jausHeader;
if(jausHeader.Read(*packet))
{
UShort messageCode = 0;
packet->Read(messageCode, Header::PayloadOffset);
Message* jausMessage = component.TransportService()->CreateMessage(messageCode);
if(jausMessage)
{
packet->SetReadPos(0);
if(jausMessage->Read(*packet))
{
messages.push_back(jausMessage);
if(jausMessage->GetMessageCode() == SET_ELEMENT)
{
Element::List::iterator m;
SetElement* setElement = (SetElement *)jausMessage;
for(m = setElement->GetElementList()->begin();
m != setElement->GetElementList()->end();
m++)
{
UShort code = 0;
m->mPayload.SetReadPos(0);
m->mPayload.Read(code);
Message* element = component.TransportService()->CreateMessage(code);
if(element)
{
element->CopyHeaderData(jausMessage);
if(element->ReadMessageBody(m->mPayload))
{
messages.push_back(element);
}
else
{
std::cout << "Failed to Read Message Data [" << std::hex << element->GetMessageCode() << "]:\n";
delete element;
}
}
}
}
}
else
{
std::cout << "Failed to Read Message Data [" << std::hex << jausMessage->GetMessageCode() << "]:\n";
}
}
else
{
std::cout << "Unknown Message Type [" << std::hex << messageCode << "]:\n";
}
}
else
{
std::cout << "Bad Header!\n";
}
packet++;
}
component.Initialize(cop);
message = messages.begin();
for(message = messages.begin();
message != messages.end();
message++)
{
//(*message)->Print();
if((*message)->GetSourceID() == cop)
{
//.........这里部分代码省略.........