本文整理汇总了C++中WaitSet_var类的典型用法代码示例。如果您正苦于以下问题:C++ WaitSet_var类的具体用法?C++ WaitSet_var怎么用?C++ WaitSet_var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WaitSet_var类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_setup
void test_setup(const DomainParticipant_var& dp,
const MessageTypeSupport_var& ts, const Publisher_var& pub,
const Subscriber_var& sub, const char* topicName, DataWriter_var& dw,
DataReader_var& dr)
{
Topic_var topic = dp->create_topic(topicName, ts->get_type_name(),
TOPIC_QOS_DEFAULT, 0,
DEFAULT_STATUS_MASK);
DataWriterQos dw_qos;
pub->get_default_datawriter_qos(dw_qos);
dw_qos.history.kind = KEEP_ALL_HISTORY_QOS;
dw = pub->create_datawriter(topic, dw_qos, 0, DEFAULT_STATUS_MASK);
DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
dr_qos.history.kind = KEEP_ALL_HISTORY_QOS;
dr = sub->create_datareader(topic, dr_qos, 0, DEFAULT_STATUS_MASK);
StatusCondition_var dw_sc = dw->get_statuscondition();
dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
WaitSet_var ws = new WaitSet;
ws->attach_condition(dw_sc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
ws->wait(active, infinite);
ws->detach_condition(dw_sc);
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:28,代码来源:QueryConditionTest.cpp
示例2: wait_match
void wait_match(const DataReader_var& dr, int n)
{
StatusCondition_var condition = dr->get_statuscondition();
condition->set_enabled_statuses(SUBSCRIPTION_MATCHED_STATUS);
WaitSet_var ws = new DDS::WaitSet;
ws->attach_condition(condition);
ConditionSeq conditions;
SubscriptionMatchedStatus ms = {0, 0, 0, 0, 0};
const Duration_t timeout = {1, 0};
while (dr->get_subscription_matched_status(ms) == RETCODE_OK
&& ms.current_count != n) {
ws->wait(conditions, timeout);
}
ws->detach_condition(condition);
}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:15,代码来源:RtpsDiscoveryTest.cpp
示例3: waitForMatch
void waitForMatch(const DataWriter_var& dw, int count = 1)
{
StatusCondition_var sc = dw->get_statuscondition();
sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
WaitSet_var ws = new WaitSet;
ws->attach_condition(sc);
const Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
PublicationMatchedStatus pubmatched;
while (dw->get_publication_matched_status(pubmatched) == RETCODE_OK
&& pubmatched.current_count != count) {
ws->wait(active, infinite);
}
ws->detach_condition(sc);
}
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:15,代码来源:MultiTopicTest.cpp
示例4: waitForSample
bool waitForSample(const DataReader_var& dr)
{
ReadCondition_var dr_rc = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ALIVE_INSTANCE_STATE);
WaitSet_var ws = new WaitSet;
ws->attach_condition(dr_rc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
ReturnCode_t ret = ws->wait(active, infinite);
ws->detach_condition(dr_rc);
dr->delete_readcondition(dr_rc);
if (ret != RETCODE_OK) {
cout << "ERROR: wait(rc) failed" << endl;
return false;
}
return true;
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:17,代码来源:QueryConditionTest.cpp
示例5: run_test
int run_test(int argc, ACE_TCHAR *argv[])
{
using namespace DDS;
using namespace OpenDDS::DCPS;
WaitSet_var ws = new WaitSet;
DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv);
DomainParticipant_var dp = dpf->create_participant(23,
PARTICIPANT_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Messenger::MessageTypeSupport_var ts = new Messenger::MessageTypeSupportImpl;
ts->register_type(dp, ts->get_type_name());
Topic_var topic = dp->create_topic("MyTopic", ts->get_type_name(),
TOPIC_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Publisher_var pub = dp->create_publisher(PUBLISHER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
TransportImpl_rch pub_tport =
TheTransportFactory->create_transport_impl(1, AUTO_CONFIG);
PublisherImpl* pub_impl = dynamic_cast<PublisherImpl*> (pub.in());
pub_impl->attach_transport(pub_tport.in());
DataWriter_var dw = pub->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
StatusCondition_var cond = dw->get_statuscondition();
cond->set_enabled_statuses(OFFERED_INCOMPATIBLE_QOS_STATUS);
ws->attach_condition(cond);
Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
TransportImpl_rch sub_tport =
TheTransportFactory->create_transport_impl(2, AUTO_CONFIG);
SubscriberImpl* sub_impl = dynamic_cast<SubscriberImpl*> (sub.in());
sub_impl->attach_transport(sub_tport.in());
DataReaderQos dr_qos;
sub->get_default_datareader_qos(dr_qos);
dr_qos.durability.kind = PERSISTENT_DURABILITY_QOS;
Waiter w(ws);
w.activate();
DataReader_var dr = sub->create_datareader(topic, dr_qos, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
w.wait();
bool passed = (w.result() == RETCODE_OK);
ws->detach_condition(cond);
dp->delete_contained_entities();
dpf->delete_participant(dp);
return passed ? 0 : 1;
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:46,代码来源:StatusConditionTest.cpp
示例6: main
int
main (
int ,
char *[])
{
/* Generic DDS entities */
DomainParticipant_var participant;
Topic_var chatMessageTopic;
Topic_var nameServiceTopic;
Subscriber_var chatSubscriber;
DataReader_ptr parentReader;
QueryCondition_var singleUser;
ReadCondition_var newUser;
StatusCondition_var leftUser;
WaitSet_var userLoadWS;
LivelinessChangedStatus livChangStatus;
/* QosPolicy holders */
TopicQos setting_topic_qos;
TopicQos reliable_topic_qos;
SubscriberQos sub_qos;
DataReaderQos message_qos;
/* DDS Identifiers */
DomainId_t domain = NULL;
ReturnCode_t status;
ConditionSeq guardList;
/* Type-specific DDS entities */
ChatMessageTypeSupport_var chatMessageTS;
NameServiceTypeSupport_var nameServiceTS;
NameServiceDataReader_var nameServer;
ChatMessageDataReader_var loadAdmin;
ChatMessageSeq msgList;
NameServiceSeq nsList;
SampleInfoSeq infoSeq;
SampleInfoSeq infoSeq2;
/* Others */
StringSeq args;
char * chatMessageTypeName = NULL;
char * nameServiceTypeName = NULL;
bool closed = false;
CORBA::Long prevCount = 0;
DWORD tid;
HANDLE tHandle = INVALID_HANDLE_VALUE;
/* Create a DomainParticipant (using the 'TheParticipantFactory' convenience macro). */
participant = TheParticipantFactory->create_participant (
domain,
PARTICIPANT_QOS_DEFAULT,
NULL,
STATUS_MASK_NONE);
checkHandle(participant.in(), "DDS::DomainParticipantFactory::create_participant");
/* Register the required datatype for ChatMessage. */
chatMessageTS = new ChatMessageTypeSupport();
checkHandle(chatMessageTS.in(), "new ChatMessageTypeSupport");
chatMessageTypeName = chatMessageTS->get_type_name();
status = chatMessageTS->register_type(participant.in(), chatMessageTypeName);
checkStatus(status, "Chat::ChatMessageTypeSupport::register_type");
/* Register the required datatype for NameService. */
nameServiceTS = new NameServiceTypeSupport();
checkHandle(nameServiceTS.in(), "new NameServiceTypeSupport");
nameServiceTypeName = nameServiceTS->get_type_name();
status = nameServiceTS->register_type(participant.in(), nameServiceTypeName);
checkStatus(status, "Chat::NameServiceTypeSupport::register_type");
/* Set the ReliabilityQosPolicy to RELIABLE. */
status = participant->get_default_topic_qos(reliable_topic_qos);
checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
reliable_topic_qos.reliability.kind = RELIABLE_RELIABILITY_QOS;
/* Make the tailored QoS the new default. */
status = participant->set_default_topic_qos(reliable_topic_qos);
checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");
/* Use the changed policy when defining the ChatMessage topic */
chatMessageTopic = participant->create_topic(
"Chat_ChatMessage",
chatMessageTypeName,
reliable_topic_qos,
NULL,
STATUS_MASK_NONE);
checkHandle(chatMessageTopic.in(), "DDS::DomainParticipant::create_topic (ChatMessage)");
/* Set the DurabilityQosPolicy to TRANSIENT. */
status = participant->get_default_topic_qos(setting_topic_qos);
checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
setting_topic_qos.durability.kind = TRANSIENT_DURABILITY_QOS;
/* Create the NameService Topic. */
nameServiceTopic = participant->create_topic(
"Chat_NameService",
nameServiceTypeName,
setting_topic_qos,
NULL,
STATUS_MASK_NONE);
//.........这里部分代码省略.........
开发者ID:xrl,项目名称:opensplice_dds,代码行数:101,代码来源:UserLoad.cpp
示例7: run_filtering_test
bool run_filtering_test(const DomainParticipant_var& dp,
const MessageTypeSupport_var& ts, const Publisher_var& pub,
const Subscriber_var& sub)
{
DataWriter_var dw;
DataReader_var dr;
test_setup(dp, ts, pub, sub, "MyTopic2", dw, dr);
MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw);
Message sample;
sample.key = 1;
ReturnCode_t ret = mdw->write(sample, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
if (!waitForSample(dr)) return false;
ReadCondition_var dr_qc = dr->create_querycondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ALIVE_INSTANCE_STATE, "key > 1", DDS::StringSeq());
if (!dr_qc.in()) {
cout << "ERROR: failed to create QueryCondition" << endl;
return false;
}
WaitSet_var ws = new WaitSet;
ws->attach_condition(dr_qc);
ConditionSeq active;
Duration_t three_sec = {3, 0};
ret = ws->wait(active, three_sec);
// expect a timeout because the sample doesn't match the query string
if (ret != RETCODE_TIMEOUT) {
cout << "ERROR: wait(qc) should have timed out" << endl;
return false;
}
ws->detach_condition(dr_qc);
MessageDataReader_var mdr = MessageDataReader::_narrow(dr);
MessageSeq data;
SampleInfoSeq infoseq;
ret = mdr->take_w_condition(data, infoseq, LENGTH_UNLIMITED, dr_qc);
if (ret != RETCODE_NO_DATA) {
cout << "ERROR: take_w_condition(qc) shouldn't have returned data" << endl;
return false;
}
SampleInfo info;
if (mdr->take_next_sample(sample, info) != RETCODE_OK) {
cout << "ERROR: take_next_sample() should have returned data" << endl;
return false;
}
sample.key = 2;
if (mdw->write(sample, HANDLE_NIL) != RETCODE_OK) return false;
if (!waitForSample(dr)) return false;
ws->attach_condition(dr_qc);
ret = ws->wait(active, three_sec);
if (ret != RETCODE_OK) {
cout << "ERROR: wait(qc) should not time out" << endl;
return false;
}
ws->detach_condition(dr_qc);
ret = mdr->take_w_condition(data, infoseq, LENGTH_UNLIMITED, dr_qc);
if (ret != RETCODE_OK) {
cout << "ERROR: take_w_condition(qc) should have returned data" << endl;
return false;
}
dr->delete_readcondition(dr_qc);
return true;
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:69,代码来源:QueryConditionTest.cpp
示例8: run_sorting_test
bool run_sorting_test(const DomainParticipant_var& dp,
const MessageTypeSupport_var& ts, const Publisher_var& pub,
const Subscriber_var& sub)
{
DataWriter_var dw;
DataReader_var dr;
test_setup(dp, ts, pub, sub, "MyTopic", dw, dr);
ReturnCode_t ret = RETCODE_OK;
MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw);
Message sample;
sample.key = 0;
sample.name = "data_X";
sample.nest.value = B;
for (int i(0); i < 20; ++i, ++sample.key) {
//replace the 'X' with a random letter
sample.name.inout()[5] = static_cast<char>((rand() % 26) + 'A');
ret = mdw->write(sample, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
if (!(i % 4)) { //once in a while write more than 1 sample per instance
Message sample2(sample);
sample2.nest.value = A;
sample2.name.inout()[5] = static_cast<char>((rand() % 26) + 'A');
ret = mdw->write(sample2, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
sample2.nest.value = C;
ret = mdw->write(sample2, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
}
}
DDS::StringSeq empty_query_params;
ReadCondition_var dr_qc = dr->create_querycondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ALIVE_INSTANCE_STATE, "ORDER BY name, nest.value",
empty_query_params);
WaitSet_var ws = new WaitSet;
ws->attach_condition(dr_qc);
MessageDataReader_var mdr = MessageDataReader::_narrow(dr);
Duration_t five_seconds = {5, 0};
bool passed = true, done = false;
while (!done) {
ConditionSeq active;
ret = ws->wait(active, five_seconds);
if (ret == RETCODE_TIMEOUT) {
cout << "timeout ";
done = true; //continue to try and read
} else if (ret != RETCODE_OK) {
passed = false;
break;
}
cout << "wait returned" << endl;
MessageSeq data;
SampleInfoSeq info;
ret = mdr->take_w_condition(data, info, LENGTH_UNLIMITED, dr_qc);
if (ret == RETCODE_NO_DATA) {
// fall-through
} else if (ret != RETCODE_OK) {
cout << "ERROR: take_w_condition returned " << ret << endl;
passed = false;
done = true;
} else {
char largest = 0;
for (CORBA::ULong i(0); i < data.length(); ++i) {
cout << "Info:\tinstance_handle = " << info[i].instance_handle <<
"\tsample_rank = " << info[i].sample_rank << '\n';
if (info[i].valid_data) {
cout << "Data:\tkey = " << data[i].key <<
" \tname = " << data[i].name <<
"\tnest.value = " << data[i].nest.value <<
'\n';
if (data[i].name[5] >= largest) {
largest = data[i].name[5];
} else {
cout << "ERROR: data is not sorted for key: " <<
data[i].key << endl;
passed = false;
}
}
cout << endl;
}
}
}
MessageSeq data;
SampleInfoSeq info;
ret = mdr->take_w_condition(data, info, LENGTH_UNLIMITED, dr_qc);
if (ret != RETCODE_NO_DATA) {
cout << "WARNING: there is still data in the reader\n";
}
ws->detach_condition(dr_qc);
dr->delete_readcondition(dr_qc);
return passed;
}
开发者ID:svn2github,项目名称:OpenDDS,代码行数:94,代码来源:QueryConditionTest.cpp
示例9: run_test_instance
int run_test_instance(DDS::DomainParticipant_ptr dp)
{
using namespace DDS;
using namespace OpenDDS::DCPS;
using namespace Messenger;
WaitSet_var ws = new WaitSet;
MessageTypeSupport_var ts = new MessageTypeSupportImpl;
ts->register_type(dp, "");
CORBA::String_var type_name = ts->get_type_name();
Topic_var topic = dp->create_topic("MyTopic", type_name,
TOPIC_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Publisher_var pub = dp->create_publisher(PUBLISHER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
DataWriter_var dw = pub->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
DataReader_var dr = sub->create_datareader(topic, DATAREADER_QOS_DEFAULT, 0,
::OpenDDS::DCPS::DEFAULT_STATUS_MASK);
StatusCondition_var dw_sc = dw->get_statuscondition();
dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS);
ws->attach_condition(dw_sc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
ReturnCode_t ret = ws->wait(active, infinite);
if (ret != RETCODE_OK) return ret;
ret = ws->detach_condition(dw_sc);
if (ret != RETCODE_OK) return ret;
MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw);
Message msg = {0};
for (int i(0); i < 12; ++i) {
++msg.subject_id;
ret = mdw->write(msg, HANDLE_NIL);
if (ret != RETCODE_OK) return ret;
}
ReadCondition_var dr_rc = dr->create_readcondition(NOT_READ_SAMPLE_STATE,
NEW_VIEW_STATE, ALIVE_INSTANCE_STATE);
ReadCondition_var dr_rc2 = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, NOT_ALIVE_DISPOSED_INSTANCE_STATE);
ws->attach_condition(dr_rc);
ws->attach_condition(dr_rc2);
MessageDataReader_var mdr = MessageDataReader::_narrow(dr);
bool passed = true, done = false;
while (!done) {
ret = ws->wait(active, infinite);
if (ret != RETCODE_OK) {
passed = false;
break;
}
cout << "wait returned" << endl;
for (CORBA::ULong i(0); i < active.length(); ++i) {
if (active[i] == dr_rc) {
// To test both take_w_condition and
// take_next_instance_w_condition, we'll limit the "take" to 3
// samples and then use take_next_instance_w_condition.
MessageSeq data;
SampleInfoSeq info;
ret = mdr->take_w_condition(data, info, 3, dr_rc);
if (ret == RETCODE_NO_DATA) break;
if (ret != RETCODE_OK) {
cout << "ERROR: take_w_condition returned " << ret << endl;
passed = false;
done = true;
}
InstanceHandle_t handle = HANDLE_NIL;
received_data(data, mdw, msg);
handle = info[info.length() - 1].instance_handle;
if (handle == HANDLE_NIL) {
cout << "ERROR: instance handle is nil" << endl;
passed = false;
done = true;
break;
}
cout << "testing take_instance_w_condition" << endl;
while (true) {
ret = mdr->take_instance_w_condition(data, info, 1,
handle, dr_rc);
if (ret == RETCODE_NO_DATA) break;
if (ret != RETCODE_OK) {
cout << "ERROR: take_instance_w_condition returned "
<< ret << endl;
passed = false;
done = true;
break;
}
received_data(data, mdw, msg);
}
} else if (active[i] == dr_rc2) {
cout << "an instance has been disposed, exiting" << endl;
done = true;
}
}
}
//.........这里部分代码省略.........
开发者ID:oschwaldp-oci,项目名称:OpenDDS,代码行数:101,代码来源:ReadConditionTest.cpp
示例10: run_multitopic_test
bool run_multitopic_test(const Publisher_var& pub, const Subscriber_var& sub)
{
DomainParticipant_var sub_dp = sub->get_participant();
// Writer-side setup
Writer<LocationInfo> location(pub, "Location", sub_dp);
Writer<PlanInfo> flightplan(pub, "FlightPlan", sub_dp);
Writer<MoreInfo> more(pub, "More", sub_dp);
Writer<UnrelatedInfo> unrelated(pub, "Unrelated", sub_dp);
MoreInfoDataWriter_var midw = MoreInfoDataWriter::_narrow(more.dw_);
// Reader-side setup
ResultingTypeSupport_var ts_res = new ResultingTypeSupportImpl;
check(ts_res->register_type(sub_dp, ""));
CORBA::String_var type_name = ts_res->get_type_name();
MoreInfo mi;
DDS::DataReader_var dr;
for (int i = 0; i < N_ITERATIONS; ++i) {
MultiTopic_var mt = sub_dp->create_multitopic("MyMultiTopic", type_name,
"SELECT flight_name, x, y, z AS height, more, misc "
"FROM Location NATURAL JOIN FlightPlan NATURAL JOIN More NATURAL JOIN "
"Unrelated WHERE height < 1000 AND x<23", StringSeq());
if (!mt) return false;
dr = sub->create_datareader(mt, DATAREADER_QOS_DEFAULT,
0, DEFAULT_STATUS_MASK);
// Write samples (Location)
waitForMatch(location.dw_);
LocationInfoDataWriter_var locdw =
LocationInfoDataWriter::_narrow(location.dw_);
LocationInfo sample = {100, 97, 23, 2, 3}; // filtered out (x < 23)
ReturnCode_t ret = locdw->write(sample, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
LocationInfo sample2 = {100, 96, 1, 2, 3000}; // filtered out (height < 1000)
ret = locdw->write(sample2, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
LocationInfo sample3 = {100, 99, 1, 2, 3};
ret = locdw->write(sample3, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
LocationInfo sample3_5 = {100, 98, 4, 5, 6};
ret = locdw->write(sample3_5, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Write samples (FlightPlan)
waitForMatch(flightplan.dw_);
PlanInfoDataWriter_var pidw = PlanInfoDataWriter::_narrow(flightplan.dw_);
PlanInfo sample4;
sample4.flight_id1 = 100;
sample4.flight_id2 = 99;
sample4.flight_name = "Flight 100-99";
sample4.tailno = "N12345";
ret = pidw->write(sample4, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
PlanInfo sample4_1(sample4);
sample4_1.flight_id2 = 97;
sample4_1.flight_name = "Flight 100-97";
ret = pidw->write(sample4_1, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
PlanInfo sample4_2(sample4);
sample4_2.flight_id2 = 96;
sample4_2.flight_name = "Flight 100-96";
ret = pidw->write(sample4_2, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Write samples (More)
waitForMatch(more.dw_);
mi.flight_id1 = 12345;
mi.more = "Shouldn't see this";
ret = midw->write(mi, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
mi.flight_id1 = 100;
mi.more = "Extra info for all flights with id1 == 100";
ret = midw->write(mi, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Write samples (Unrelated)
waitForMatch(unrelated.dw_);
UnrelatedInfoDataWriter_var uidw =
UnrelatedInfoDataWriter::_narrow(unrelated.dw_);
UnrelatedInfo ui;
ui.misc = "Misc";
ret = uidw->write(ui, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
// Read resulting samples
WaitSet_var ws = new WaitSet;
ReadCondition_var rc = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ANY_INSTANCE_STATE);
ws->attach_condition(rc);
Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC};
ConditionSeq active;
//.........这里部分代码省略.........
开发者ID:oschwaldp-oci,项目名称:OpenDDS,代码行数:101,代码来源:MultiTopicTest.cpp
示例11: run_test
//.........这里部分代码省略.........
return false;
}
if (!read_subscription_bit(dp_pub->get_builtin_subscriber(), dp_pub, sub_repo_id, sub_ih, TestConfig::DATA_READER_USER_DATA(), TestConfig::TOPIC_DATA())) {
return false;
}
// Wait for the reader to associate with the writer.
WriterSync::wait_match(dw);
// Remove the writer and its topic, then re-create them. The writer's
// participant should still have discovery info about the reader so that
// the association between the new writer and old reader can be established.
recreate_data_writer_and_topic(dw, dr);
// Wait for the reader to associate with the writer.
WriterSync::wait_match(dw);
// The new writer is associated with the reader, but the reader may still
// also be associated with the old writer.
wait_match(dr, 1);
// Get the new instance handle as pub_ih
if (!read_publication_bit(bit_sub, dp_sub, pub_repo_id, pub_ih, TestConfig::DATA_WRITER_USER_DATA(), TestConfig::TOPIC_DATA(), 1, 2)) {
return false;
}
TestMsgDataWriter_var tmdw = TestMsgDataWriter::_narrow(dw);
const TestMsg msg = {42};
tmdw->write(msg, HANDLE_NIL);
ReadCondition_var rc = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ALIVE_INSTANCE_STATE);
WaitSet_var waiter = new WaitSet;
waiter->attach_condition(rc);
ConditionSeq activeConditions;
const Duration_t timeout = { 90, 0 };
ReturnCode_t result = waiter->wait(activeConditions, timeout);
waiter->detach_condition(rc);
if (result != RETCODE_OK) {
ACE_DEBUG((LM_ERROR,
"ERROR: %P TestMsg reader could not wait for condition: %d\n", result));
return false;
}
TestMsgDataReader_var tmdr = TestMsgDataReader::_narrow(dr);
TestMsgSeq data;
SampleInfoSeq infos;
ReturnCode_t ret = tmdr->read_w_condition(data, infos, LENGTH_UNLIMITED, rc);
if (ret != RETCODE_OK) {
ACE_DEBUG((LM_ERROR, "ERROR: %P could not read TestMsg: %d\n", ret));
return false;
}
bool ok = false;
for (CORBA::ULong i = 0; i < data.length(); ++i) {
if (infos[i].valid_data) {
ok = true;
ACE_DEBUG((LM_DEBUG, "%P Read data sample: %d\n", data[i].value));
}
}
if (!ok) {
ACE_DEBUG((LM_ERROR, "ERROR: %P no valid data from TestMsg data reader\n"));
}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:67,代码来源:RtpsDiscoveryTest.cpp
示例12: read_subscription_bit
bool read_subscription_bit(const Subscriber_var& bit_sub,
const DomainParticipant_var& publisher,
const OpenDDS::DCPS::RepoId& subscriber_repo_id,
InstanceHandle_t& handle,
int user_data,
int topic_data,
bool ignored_subscription = false)
{
OpenDDS::DCPS::Discovery_rch disc =
TheServiceParticipant->get_discovery(publisher->get_domain_id());
OpenDDS::DCPS::DomainParticipantImpl* publisher_impl =
dynamic_cast<OpenDDS::DCPS::DomainParticipantImpl*>(publisher.in());
DataReader_var dr = bit_sub->lookup_datareader(BUILT_IN_SUBSCRIPTION_TOPIC);
if (!ignored_subscription) {
ReadCondition_var rc = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ALIVE_INSTANCE_STATE);
WaitSet_var waiter = new WaitSet;
waiter->attach_condition(rc);
ConditionSeq activeConditions;
Duration_t forever = { DURATION_INFINITE_SEC,
DURATION_INFINITE_NSEC };
ReturnCode_t result = waiter->wait(activeConditions, forever);
waiter->detach_condition(rc);
if (result != RETCODE_OK) {
ACE_DEBUG((LM_ERROR,
"ERROR: %P (subscription BIT) could not wait for condition: %d\n", result));
return false;
}
} else {
ACE_OS::sleep(1);
}
SubscriptionBuiltinTopicDataDataReader_var pub_bit =
SubscriptionBuiltinTopicDataDataReader::_narrow(dr);
SubscriptionBuiltinTopicDataSeq data;
SampleInfoSeq infos;
ReturnCode_t ret =
pub_bit->read(data, infos, LENGTH_UNLIMITED,
ANY_SAMPLE_STATE, ANY_VIEW_STATE, ALIVE_INSTANCE_STATE);
if (ignored_subscription && (ret != RETCODE_NO_DATA)) {
ACE_DEBUG((LM_ERROR, "ERROR: %P could not read ignored subscription BIT: %d\n",
ret));
return false;
} else if (ret != RETCODE_OK && ret != RETCODE_NO_DATA) {
ACE_DEBUG((LM_ERROR, "ERROR: %P could not read subscription BIT: %d\n", ret));
return false;
}
int num_valid = 0;
bool found_subscriber = false;
for (CORBA::ULong i = 0; i < data.length(); ++i) {
if (infos[i].valid_data) {
++num_valid;
OpenDDS::DCPS::RepoId repo_id =
disc->bit_key_to_repo_id(publisher_impl,
OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC,
data[i].participant_key);
OpenDDS::DCPS::GuidConverter converter(repo_id);
ACE_DEBUG((LM_DEBUG,
"%P Read Subscription BIT with key: %x %x %x and handle %d\n"
"\tParticipant's GUID=%C\n\tTopic: %C\tType: %C\n",
data[i].key.value[0], data[i].key.value[1],
data[i].key.value[2], infos[i].instance_handle,
std::string(converter).c_str (), data[i].topic_name.in(),
data[i].type_name.in()));
if (repo_id == subscriber_repo_id) {
found_subscriber = true;
if (data[i].user_data.value.length() != 1) {
ACE_ERROR_RETURN((LM_ERROR,
"ERROR: %P subscription [%d] user data length %d "
"not expected length of 1\n",
i,
data[i].user_data.value.length()),
false);
}
if (data[i].topic_data.value.length() != 1) {
ACE_ERROR_RETURN((LM_ERROR,
"ERROR: %P subscription [%d] topic data length %d "
"not expected length of 1\n",
i,
data[i].topic_data.value.length()),
false);
}
if (data[i].user_data.value[0] != user_data) {
ACE_ERROR_RETURN((LM_ERROR,
"ERROR: %P subscription [%d] user data value %d "
"not expected value %d\n",
i,
data[i].user_data.value[0],
user_data),
false);
}
if (data[i].topic_data.value[0] != topic_data) {
ACE_ERROR_RETURN((LM_ERROR,
"ERROR: %P subscription [%d] topic data value %d "
//.........这里部分代码省略.........
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:101,代码来源:RtpsDiscoveryTest.cpp
示例13: read_participant_bit
bool read_participant_bit(const Subscriber_var& bit_sub,
const DomainParticipant_var& dp,
const OpenDDS::DCPS::RepoId& other_dp_repo_id,
int user_data)
{
OpenDDS::DCPS::Discovery_rch disc =
TheServiceParticipant->get_discovery(dp->get_domain_id());
OpenDDS::DCPS::DomainParticipantImpl* dp_impl =
dynamic_cast<OpenDDS::DCPS::DomainParticipantImpl*>(dp.in());
DataReader_var dr = bit_sub->lookup_datareader(BUILT_IN_PARTICIPANT_TOPIC);
ReadCondition_var rc = dr->create_readcondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ALIVE_INSTANCE_STATE);
WaitSet_var waiter = new WaitSet;
waiter->attach_condition(rc);
ConditionSeq activeConditions;
Duration_t forever = { DURATION_INFINITE_SEC,
DURATION_INFINITE_NSEC };
ReturnCode_t result = waiter->wait(activeConditions, forever);
waiter->detach_condition(rc);
if (result != RETCODE_OK) {
ACE_ERROR_RETURN((LM_ERROR, "ERROR: %P could not wait for condition: %d\n", result), false);
}
ParticipantBuiltinTopicDataDataReader_var part_bit =
ParticipantBuiltinTopicDataDataReader::_narrow(dr);
ParticipantBuiltinTopicDataSeq data;
SampleInfoSeq infos;
ReturnCode_t ret =
part_bit->read_w_condition(data, infos, LENGTH_UNLIMITED, rc);
if (ret != RETCODE_OK) {
ACE_DEBUG((LM_ERROR, "ERROR: %P could not read participant BIT: %d\n", ret));
return false;
}
bool found_other_dp = false;
int num_valid = 0;
for (CORBA::ULong i = 0; i < data.length(); ++i) {
if (infos[i].valid_data) {
++num_valid;
OpenDDS::DCPS::RepoId repo_id =
disc->bit_key_to_repo_id(dp_impl,
OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC,
data[i].key);
OpenDDS::DCPS::GuidConverter converter(repo_id);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("%P ")
ACE_TEXT("Read Participant BIT GUID=%C handle=%d\n"),
std::string(converter).c_str(), infos[i].instance_handle));
if (repo_id == other_dp_repo_id) {
if (data[i].user_data.value.length() != 1) {
ACE_ERROR_RETURN((LM_ERROR,
"ERROR: %P participant[%d] user data length %d "
"not expected length of 1\n",
i,
data[i].user_data.value.length()),
false);
}
if (data[i].user_data.value[0] != user_data) {
ACE_ERROR_RETURN((LM_ERROR,
"ERROR: %P participant[%d] user data value %d "
"not expected value %d\n",
i,
data[i].user_data.value[0],
user_data),
false);
}
found_other_dp = true;
}
}
}
if (num_valid != 1) {
ACE_DEBUG((LM_ERROR, "ERROR: %P expected to discover 1 other participant, found %d\n", data.length ()));
}
part_bit->return_loan(data, infos);
if (!found_other_dp) {
ACE_ERROR_RETURN((LM_ERROR, "ERROR: %P did not find expected participant\n"), false);
}
return true;
}
开发者ID:yanbodiaoweng,项目名称:DDS,代码行数:91,代码来源:RtpsDiscoveryTest.cpp
示例14: run_change_parameter_test
bool run_change_parameter_test(const DomainParticipant_var& dp,
const MessageTypeSupport_var& ts, const Publisher_var& pub,
const Subscriber_var& sub)
{
DataWriter_var dw;
DataReader_var dr;
test_setup(dp, ts, pub, sub, "MyTopic3", dw, dr);
MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw);
Message sample;
sample.key = 3;
ReturnCode_t ret = mdw->write(sample, HANDLE_NIL);
if (ret != RETCODE_OK) return false;
if (!waitForSample(dr)) return false;
DDS::StringSeq params(1);
params.length(1);
params[0] = "2";
ReadCondition_var dr_qc = dr->create_querycondition(ANY_SAMPLE_STATE,
ANY_VIEW_STATE, ALIVE_INSTANCE_STATE, "key = %0", params);
if (!dr_qc.in()) {
cout << "ERROR: failed to create QueryCondition" << endl;
return false;
}
QueryCondition_var query_cond = QueryCondition::_narrow(dr_qc);
CORBA::String_var expr = query_cond->get_query_expression();
if (std::string("key = %0") != expr.in()) {
cout << "ERROR: get_query_expression() query expression should match " << endl;
return false;
}
params = DDS::StringSeq();
ret = query_cond->get_query_parameters(params);
if (ret != RETCODE_OK) {
cout << "ERROR: get_query_parameters() failed " << endl;
return false;
} else if (params.length() != 1 || std::string(params[0]) != "2") {
cout << "ERROR: get_query_parameters() query parameters doesn't match " << endl;
return false;
}
WaitSet_var ws = new WaitSet;
ws->attach_condition(dr_qc);
ConditionSeq active;
Duration_t three_sec = {3, 0};
ret = ws->wait(active, three_sec);
// expect a timeout because the sample doesn't match the query string
if (ret != RETCODE_TIMEOUT) {
cout << "ERROR: wait(qc) should have timed out" << endl;
return false;
}
ws->detach_condition(dr_qc);
MessageDataReader_var mdr = MessageDataReader::_narrow(dr);
MessageSeq data;
SampleInfoSeq infoseq;
ret = mdr->take_w_condition(data, infoseq, LENGTH_UNLIMITED, dr_qc);
if (ret != RETCODE_NO_DATA) {
cout << "ERROR: take_w_condition(qc) shouldn't have returned data" << endl;
return false;
}
params = DDS::StringSeq(1);
params.length(1);
params[0] = "3";
ret = query_cond->set_query_parameters(params);
params = DDS::StringSeq();
ret = query_cond->get_query_parameters(params);
if (ret != RETCODE_OK) {
cout << "ERROR: get_query_parameters() failed " << endl;
return false;
} else if (params.length() != 1 || std::string(params[0]) != "3") {
cout << "ERROR: get_query_parameters() query parameters doesn't match " << endl;
return false;
}
ws->attach_condition(dr_qc);
ret = ws->wait(active, three_sec);
if (ret != RETCODE_OK) {
cout << "ERROR: wait(qc) should not time out" << endl;
return false;
}
ws->detach_condition(dr_qc);
ret = mdr->take_w_condition(data, infoseq, LENGTH_UNLIMITED, dr_qc);
if (ret != RETCODE_OK) {
cout << "ERROR: take_w_condition(qc) should have returned data" << endl;
return false;
}
dr->delete_readcondition(dr_qc);
return true;
}
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:95,代码来源:QueryConditionTest.cpp
注:本文中的WaitSet_var类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论