void Test::DataReaderListener::display_partitions ( DDS::DataReader_ptr reader) const { // Display requested partition. DDS::Subscriber_var subscriber (reader->get_subscriber ()); DDS::SubscriberQos sub_qos; subscriber->get_qos (sub_qos); DDS::PartitionQosPolicy const & partition = sub_qos.partition; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Requested Partition\n") ACE_TEXT ("Partition\tName\n") ACE_TEXT ("=========\t====\n"))); CORBA::ULong const len = partition.name.length (); if (len == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("** Zero length partition name ") ACE_TEXT ("sequence (default) **\n"))); for (CORBA::ULong i = 0; i != len; ++i) { char const * s = partition.name[i]; ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %u\t\t%s\n"), i, *s == 0 ? "\"\"" : s)); } }
bool wait_subscription_matched_status(const Options& /*opts*/, const DDS::DataReader_ptr r) { // To check the match status ? DDS::SubscriptionMatchedStatus matches = {0, 0, 0, 0, 0}; TEST_ASSERT((r->get_subscription_matched_status(matches) == ::DDS::RETCODE_OK)); // Block until Subscriber is available DDS::StatusCondition_var condition = r->get_statuscondition(); condition->set_enabled_statuses(DDS::PUBLICATION_MATCHED_STATUS | DDS::SUBSCRIPTION_MATCHED_STATUS // | DDS::REQUESTED_INCOMPATIBLE_QOS_STATUS // | DDS::OFFERED_INCOMPATIBLE_QOS_STATUS ); DDS::WaitSet_var ws = new DDS::WaitSet; ws->attach_condition(condition); // int duration = opts.test_duration; DDS::Duration_t timeout = { DDS::DURATION_INFINITE_SEC, DDS::DURATION_INFINITE_NSEC // (duration < 0) ? DDS::DURATION_INFINITE_SEC : duration, // (duration < 0) ? DDS::DURATION_INFINITE_NSEC : 0 }; DDS::ConditionSeq conditions; int status = ws->wait(conditions, timeout); ws->detach_condition(condition); if (status != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t)") ACE_TEXT(" ERROR: wait failed: %p\n")), false); } return true; }
void DataReaderListenerImpl4::read(::DDS::DataReader_ptr reader) { ::T4::Foo4DataReader_var foo_dr = ::T4::Foo4DataReader::_narrow(reader); if (CORBA::is_nil(foo_dr)) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ::T4::Foo4DataReader::_narrow failed.\n"))); return; } DDS::TopicDescription_var td = reader->get_topicdescription(); CORBA::String_var topic = td->get_name(); ::T4::Foo4DataReaderImpl* dr_servant = dynamic_cast< ::T4::Foo4DataReaderImpl*>(foo_dr.in()); ::T4::Foo4Seq foo(num_ops_per_thread_); ::DDS::SampleInfoSeq si(num_ops_per_thread_); DDS::ReturnCode_t status = dr_servant->read(foo, si, num_ops_per_thread_, ::DDS::NOT_READ_SAMPLE_STATE, ::DDS::ANY_VIEW_STATE, ::DDS::ANY_INSTANCE_STATE); if (status == ::DDS::RETCODE_OK) { for (CORBA::ULong i = 0; i < si.length(); ++i) { if (si[i].valid_data) { ++num_samples_; const CORBA::ULong len = foo[i].values.length(); ACE_OS::printf("%s foo4[%u]: length = %u\n", topic.in(), i, len); for (CORBA::ULong j = 0; j < len; ++j) { ACE_OS::printf("\tfoo4[%u][%u]: value = %f\n", i, j, foo[i].values[j]); } } } } else if (status == ::DDS::RETCODE_NO_DATA) { ACE_OS::printf("read returned ::DDS::RETCODE_NO_DATA\n") ; } else { ACE_OS::printf("read - Error: %d\n", status) ; } }
void DataReaderListenerImpl::on_data_available(DDS::DataReader_ptr reader) { DDS::DataReaderQos qos; reader->get_qos(qos); const bool durable = qos.durability.kind > DDS::VOLATILE_DURABILITY_QOS; try { MessageDataReader_var message_dr = MessageDataReader::_narrow(reader); if (CORBA::is_nil(message_dr)) { cerr << "read: _narrow failed." << endl; exit(1); } Messenger::Message message; DDS::SampleInfo si; DDS::ReturnCode_t status = message_dr->take_next_sample(message, si); if (status == DDS::RETCODE_OK) { if (si.valid_data) { if (durable) ++num_reads_; ACE_DEBUG((LM_INFO, "(%P|%t) DataReaderListenerImpl[%@]::on_data_available - %C count = %d\n", this, durable ? "Durable " : "Volatile", message.count)); if (durable && (message.count != num_reads_)) { ACE_DEBUG((LM_INFO, "(%P|%t) ERROR: durable reader received out-of-order data (msg count = %d and num_reads = %d)\n", message.count, num_reads_)); ok_ = false; } else if (!durable) { if (last_non_durable_ && message.count != last_non_durable_ + 1) { ACE_DEBUG((LM_INFO, "(%P|%t) ERROR: volatile reader received out-of-order data\n")); ok_ = false; } last_non_durable_ = message.count; } } } else if (status == DDS::RETCODE_NO_DATA) { cerr << "ERROR: reader received DDS::RETCODE_NO_DATA!" << endl; ok_ = false; } else { cerr << "ERROR: read Message: Error: " << status << endl; ok_ = false; } } catch (CORBA::Exception& e) { cerr << "Exception caught in read:" << endl << e << endl; exit(1); } }
void DataReaderListenerImpl1::read(::DDS::DataReader_ptr reader) { ::T1::Foo1DataReader_var foo_dr = ::T1::Foo1DataReader::_narrow(reader); if (CORBA::is_nil(foo_dr)) { ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ::T1::FooDataReader::_narrow failed.\n"))); return; } DDS::TopicDescription_var td = reader->get_topicdescription(); CORBA::String_var topic = td->get_name(); ::T1::Foo1DataReaderImpl* dr_servant = dynamic_cast<T1::Foo1DataReaderImpl*>(foo_dr.in()); ::T1::Foo1Seq foo(num_ops_per_thread_); ::DDS::SampleInfoSeq si(num_ops_per_thread_); DDS::ReturnCode_t status = dr_servant->read(foo, si, num_ops_per_thread_, ::DDS::NOT_READ_SAMPLE_STATE, ::DDS::ANY_VIEW_STATE, ::DDS::ANY_INSTANCE_STATE); if (status == ::DDS::RETCODE_OK) { for (CORBA::ULong i = 0; i < si.length(); ++i) { if (si[i].valid_data) { ++num_samples_; ACE_OS::printf("%s foo1[%d]: c = %c, x = %f y = %f, key = %d\n", topic.in(), i, foo[i].c, foo[i].x, foo[i].y, foo[i].key); } } } else if (status == ::DDS::RETCODE_NO_DATA) { ACE_OS::printf("read returned ::DDS::RETCODE_NO_DATA\n") ; } else { ACE_OS::printf("read - Error: %d\n", status) ; } }
void DataReaderListenerImpl::on_liveliness_changed ( DDS::DataReader_ptr reader, const DDS::LivelinessChangedStatus & status) throw (CORBA::SystemException) { ++ num_liveliness_change_callbacks_; const OpenDDS::DCPS::RepoId id = dynamic_cast<OpenDDS::DCPS::DomainParticipantImpl*>(reader->get_subscriber()->get_participant())->get_repoid(status.last_publication_handle); OpenDDS::DCPS::GuidConverter converter(id); ACE_DEBUG((LM_INFO, "%T DataReaderListenerImpl::on_liveliness_changed #%d\n" " alive_count = %d\n" " not_alive_count = %d\n" " alive_count_change = %d\n" " not_alive_count_change = %d\n" " last_publication_handle = %d (%s)\n", num_liveliness_change_callbacks_, status.alive_count, status.not_alive_count, status.alive_count_change, status.not_alive_count_change, status.last_publication_handle, OPENDDS_STRING(converter).c_str())); }
std::string MultiTopicDataReaderBase::topicNameFor(DDS::DataReader_ptr reader) { DDS::TopicDescription_var td = reader->get_topicdescription(); CORBA::String_var topic = td->get_name(); return topic.in(); }