public void readSensorDataDDSWaitset(Demultiplexer <SensorData> distributor) { DDS.Duration_t timeout; timeout.nanosec = 0; timeout.sec = 10; DDS.DomainParticipant participant = DefaultParticipant.Instance; DefaultParticipant.RegisterType <SensorData, SensorDataTypeSupport>(); WaitsetSubscriber <SensorData> subscriber = new WaitsetSubscriber <SensorData>(participant, "Raw SensorData", null, timeout, distributor); subscriber.subscribe(); }
public void readSensorDataDDSListener(Demultiplexer <SensorData> distributor) { DDS.DomainParticipant participant = DefaultParticipant.Instance; DefaultParticipant.RegisterType <SensorData, SensorDataTypeSupport>(); ListenerSubscriber <SensorData> subscriber = new ListenerSubscriber <SensorData>(participant, "Raw SensorData", null, distributor); subscriber.subscribe(); /*DDS.DomainParticipant participant = DefaultParticipant.Instance; * DefaultParticipant.RegisterType<SensorData, SensorDataTypeSupport>(); * DDS.Topic topic = participant.create_topic("Raw SensorData", typeof(SensorData).ToString(), * DDS.DomainParticipant.TOPIC_QOS_DEFAULT, null, DDS.StatusMask.STATUS_MASK_NONE); * if (topic == null) * { * throw new ApplicationException("create_topic error"); * } * ListenerSubscriber2<SensorData> subscriber_A = * new ListenerSubscriber2<SensorData>(participant, topic, distributor, QueryHelpers.getDefaultSensorData); * subscriber_A.setContentFilter("filtered_topic_A", * "(sensor_id >= %0 and sensor_id <= %1) OR (sensor_id >= %2 and sensor_id <= %3) OR (sensor_id >= %4 and sensor_id <= %5)", * new DDS.StringWrapper[] { "10", "28", "47", "59", "88", "98" }); * var readerQoS_A = subscriber_A.getDataReaderQos(); * * DDS.TransportUnicastSettings_t[] arr_A = new DDS.TransportUnicastSettings_t[1]; * arr_A[0] = new DDS.TransportUnicastSettings_t(); * readerQoS_A.unicast.value.loan(arr_A, 1); * readerQoS_A.unicast.value.ensure_length(1, 1); * readerQoS_A.unicast.value.get_at(0).receive_port = 9000; * * var subscriber_B = new ListenerSubscriber2<SensorData>(participant, topic, distributor, QueryHelpers.getDefaultSensorData); * subscriber_B.setContentFilter("filtered_topic_B", * "(sensor_id = %0) OR (sensor_id = %1) OR (sensor_id >= %2 and sensor_id <= %3) OR (sensor_id >= %4 and sensor_id <= %5) OR (sensor_id >= %6 and sensor_id <= %7)", * new DDS.StringWrapper[] { "4", "8", "38", "44", "61", "75", "99", "106" }); * var readerQoS_B = subscriber_B.getDataReaderQos(); * * DDS.TransportUnicastSettings_t[] arr_B = new DDS.TransportUnicastSettings_t[1]; * arr_B[0] = new DDS.TransportUnicastSettings_t(); * readerQoS_B.unicast.value.loan(arr_B, 1); * readerQoS_B.unicast.value.ensure_length(1, 1); * readerQoS_B.unicast.value.get_at(0).receive_port = 8000; * * subscriber_A.subscribe(); * subscriber_B.subscribe();*/ }