package Logger; import com.rti.dds.domain.DomainParticipant; import com.rti.dds.infrastructure.RETCODE_NO_DATA; import com.rti.dds.infrastructure.ResourceLimitsQosPolicy; import com.rti.dds.publication.builtin.PublicationBuiltinTopicData; import com.rti.dds.publication.builtin.PublicationBuiltinTopicDataDataReader; import com.rti.dds.publication.builtin.PublicationBuiltinTopicDataSeq; import com.rti.dds.subscription.DataReader; import com.rti.dds.subscription.DataReaderListener; import com.rti.dds.subscription.DataReaderQos; import com.rti.dds.subscription.InstanceStateKind; import com.rti.dds.subscription.LivelinessChangedStatus; import com.rti.dds.subscription.RequestedDeadlineMissedStatus; import com.rti.dds.subscription.RequestedIncompatibleQosStatus; import com.rti.dds.subscription.SampleInfo; import com.rti.dds.subscription.SampleInfoSeq; import com.rti.dds.subscription.SampleLostStatus; import com.rti.dds.subscription.SampleRejectedStatus; import com.rti.dds.subscription.SampleStateKind; import com.rti.dds.subscription.Subscriber; import com.rti.dds.subscription.SubscriptionMatchedStatus; import com.rti.dds.subscription.ViewStateKind; import com.rti.dds.topic.TopicQos; public class TopicListener implements DataReaderListener { Logger logger; TopicListener(Logger l) { super(); logger = l; } @Override public void on_data_available(DataReader arg0) { PublicationBuiltinTopicDataDataReader reader = (PublicationBuiltinTopicDataDataReader) arg0; PublicationBuiltinTopicDataSeq data_seq = new PublicationBuiltinTopicDataSeq(); SampleInfoSeq info_seq = new SampleInfoSeq(); boolean noData = false; while(noData == false) { try { reader.take(data_seq, info_seq, ResourceLimitsQosPolicy.LENGTH_UNLIMITED, SampleStateKind.ANY_SAMPLE_STATE, ViewStateKind.ANY_VIEW_STATE, InstanceStateKind.ANY_INSTANCE_STATE); for(int i = 0; i < info_seq.size(); i++) { SampleInfo sa = (SampleInfo)info_seq.get(i); //boolean alive = 0 != ( InstanceStateKind.ALIVE_INSTANCE_STATE & sa.instance_state); //boolean newView = 0 != (ViewStateKind.NEW_VIEW_STATE & sa.view_state); //boolean notRead = 0 != (SampleStateKind.NOT_READ_SAMPLE_STATE & sa.sample_state); //System.out.println("Publication instance is " + (alive?"":"NOT ")+ "alive, view is " + (newView?"":"NOT ")+"new, sample is " + (notRead?"NOT ":"") + "read"); if (sa.valid_data) { final PublicationBuiltinTopicData id = (PublicationBuiltinTopicData) data_seq.get(i); //System.out.println("Topic data qos policy: " + id.topic_data); //System.out.println("Ownership data qos policy: " + id.ownership); //System.out.println(id.topic_name+","+id.type_name+","+id.type_code); TopicQos topicQOS = DomainParticipant.TOPIC_QOS_DEFAULT; topicQOS.deadline.copy_from(id.deadline); topicQOS.destination_order.copy_from(id.destination_order); topicQOS.durability.copy_from(id.durability); topicQOS.durability_service.copy_from(id.durability_service); topicQOS.latency_budget.copy_from(id.latency_budget); topicQOS.lifespan.copy_from(id.lifespan); topicQOS.liveliness.copy_from(id.liveliness); topicQOS.ownership.copy_from(id.ownership); topicQOS.reliability.copy_from(id.reliability); //DataReaderQos drQOS = new DataReaderQos(); DataReaderQos drQOS = Subscriber.DATAREADER_QOS_DEFAULT; /* drQOS.availability.copy_from(def.availability); drQOS.deadline.copy_from(def.deadline); drQOS.destination_order.copy_from(def.destination_order); drQOS.durability.copy_from(def.durability); drQOS.history.copy_from(def.history); drQOS.latency_budget.copy_from(def.latency_budget); drQOS.liveliness.copy_from(def.liveliness); drQOS.multicast.kind.copy_from(def.multicast.kind); drQOS.ownership.copy_from(def.ownership); drQOS.property.copy_from(def.property); drQOS.protocol.copy_from(def.protocol); drQOS.reader_data_lifecycle.autopurge_disposed_samples_delay.copy_from(def.reader_data_lifecycle.autopurge_disposed_samples_delay); drQOS.reader_data_lifecycle.autopurge_nowriter_samples_delay.copy_from(def.reader_data_lifecycle.autopurge_nowriter_samples_delay); //drQOS.reader_resource_limits.pull_from_nativeI(arg0); copy_from(def.reader_resource_limits); drQOS.reader_resource_limits.disable_fragmentation_support = def.reader_resource_limits.disable_fragmentation_support; drQOS.reader_resource_limits.dynamically_allocate_fragmented_samples = def.reader_resource_limits.dynamically_allocate_fragmented_samples; drQOS.reader_resource_limits.initial_fragmented_samples = def.reader_resource_limits.initial_fragmented_samples; drQOS.reader_resource_limits.initial_infos = def.reader_resource_limits.initial_infos; drQOS.reader_resource_limits.initial_outstanding_reads = def.reader_resource_limits.initial_outstanding_reads; drQOS.reader_resource_limits.initial_remote_virtual_writers = def.reader_resource_limits.initial_remote_virtual_writers; drQOS.reader_resource_limits.initial_remote_virtual_writers_per_instance = def.reader_resource_limits.initial_remote_virtual_writers_per_instance; drQOS.reader_resource_limits.initial_remote_writers = def.reader_resource_limits.initial_remote_writers; drQOS.reader_resource_limits.initial_remote_writers_per_instance = def.reader_resource_limits.initial_remote_writers_per_instance; drQOS.reader_resource_limits.max_app_ack_response_length = def.reader_resource_limits.max_app_ack_response_length; drQOS.reader_resource_limits.max_fragmented_samples = def.reader_resource_limits.max_fragmented_samples; drQOS.reader_resource_limits.max_fragmented_samples_per_remote_writer = def.reader_resource_limits.max_fragmented_samples_per_remote_writer; drQOS.reader_resource_limits.max_fragments_per_sample = def.reader_resource_limits.max_fragments_per_sample; drQOS.reader_resource_limits.max_infos = def.reader_resource_limits.max_infos; drQOS.reader_resource_limits.max_outstanding_reads = def.reader_resource_limits.max_outstanding_reads; drQOS.reader_resource_limits.max_query_condition_filters = def.reader_resource_limits.max_query_condition_filters; drQOS.reader_resource_limits.max_remote_virtual_writers = def.reader_resource_limits.max_remote_virtual_writers; drQOS.reader_resource_limits.max_remote_virtual_writers_per_instance = def.reader_resource_limits.max_remote_virtual_writers_per_instance; drQOS.reader_resource_limits.max_remote_writers = def.reader_resource_limits.max_remote_writers; drQOS.reader_resource_limits.max_remote_writers_per_instance = def.reader_resource_limits.max_remote_writers_per_instance; drQOS.reader_resource_limits.max_remote_writers_per_sample = def.reader_resource_limits.max_remote_writers_per_sample; drQOS.reader_resource_limits.max_samples_per_read = def.reader_resource_limits.max_samples_per_read; drQOS.reader_resource_limits.max_samples_per_remote_writer = def.reader_resource_limits.max_samples_per_remote_writer; drQOS.reader_resource_limits.max_total_instances = def.reader_resource_limits.max_total_instances; drQOS.reliability.copy_from(def.reliability); drQOS.resource_limits.copy_from(def.resource_limits); drQOS.service.copy_from(def.service); drQOS.subscription_name.copy_from(def.subscription_name); drQOS.time_based_filter.minimum_separation.copy_from(def.time_based_filter.minimum_separation); drQOS.transport_selection.enabled_transports.copy_from(def.transport_selection.enabled_transports); drQOS.type_consistency.copy_from(def.type_consistency); drQOS.type_support.cdr_padding_kind.copy_from(def.type_support.cdr_padding_kind); //drQOS.unicast.value. copy_from(def.unicast.value); drQOS.user_data.copy_from(def.user_data); */ //drQOS.availability.copy_from(id.availability); drQOS.deadline.copy_from(id.deadline); drQOS.destination_order.copy_from(id.destination_order); drQOS.durability.copy_from(id.durability); //drQOS.encapsulation.copy_from(id.encapsulation); //drQOS.history.copy_from(id.history); drQOS.latency_budget.copy_from(id.latency_budget); drQOS.liveliness.copy_from(id.liveliness); //drQOS.multicast.copy_from(id.multicast); drQOS.ownership.copy_from(id.ownership); drQOS.property.copy_from(id.property); //drQOS.protocol.copy_from(id.protocol); //drQOS.reader_data_lifecycle.copy_from(id.reader_data_lifecycle); //drQOS.reader_resource_limits.copy_from(id.reader_resource_limits); drQOS.reliability.copy_from(id.reliability); //drQOS.resource_limits.copy_from(id.resource_limits); drQOS.service.copy_from(id.service); //drQOS.subscription_name.copy_from(id.subscription_name); //drQOS.time_based_filter.copy_from(id.time_based_filter); //drQOS.transport_selection.copy_from(id.transport_selection); //drQOS.type_consistency.copy_from(id.type_consistency); //drQOS.type_support.copy_from(id.type_support); //drQOS.unicast.copy_from(id.unicast); drQOS.user_data.copy_from(id.user_data); logger.processDiscoveredTopic(id.topic_name, id.type_name, id.type_code, topicQOS, drQOS); } } } catch (RETCODE_NO_DATA ret) { noData = true; } finally { reader.return_loan(data_seq, info_seq); } } } @Override public void on_liveliness_changed(DataReader arg0, LivelinessChangedStatus arg1) { // TODO Auto-generated method stub } @Override public void on_requested_deadline_missed(DataReader arg0, RequestedDeadlineMissedStatus arg1) { // TODO Auto-generated method stub } @Override public void on_requested_incompatible_qos(DataReader arg0, RequestedIncompatibleQosStatus arg1) { // TODO Auto-generated method stub } @Override public void on_sample_lost(DataReader arg0, SampleLostStatus arg1) { // TODO Auto-generated method stub } @Override public void on_sample_rejected(DataReader arg0, SampleRejectedStatus arg1) { // TODO Auto-generated method stub } @Override public void on_subscription_matched(DataReader arg0, SubscriptionMatchedStatus arg1) { // TODO Auto-generated method stub } }