public AbstractConnectedDevice( final Subscriber subscriber, final Publisher publisher, final EventLoop eventLoop) { super(subscriber, publisher, eventLoop); DeviceConnectivityTypeSupport.register_type( domainParticipant, DeviceConnectivityTypeSupport.get_type_name()); deviceConnectivityTopic = TopicUtil.findOrCreateTopic( domainParticipant, DeviceConnectivityTopic.VALUE, DeviceConnectivityTypeSupport.class); deviceConnectivityWriter = (DeviceConnectivityDataWriter) publisher.create_datawriter_with_profile( deviceConnectivityTopic, QosProfiles.ice_library, QosProfiles.state, null, StatusKind.STATUS_MASK_NONE); if (null == deviceConnectivityWriter) { throw new RuntimeException("unable to create writer"); } deviceConnectivity = new DeviceConnectivity(); deviceConnectivity.type = getConnectionType(); deviceConnectivity.state = getState(); }
@Override public void start(final Publisher publisher, final EventLoop eventLoop) { this.eventLoop = eventLoop; VitalModelImpl.this.publisher = publisher; DomainParticipant participant = publisher.get_participant(); ice.GlobalAlarmLimitObjectiveTypeSupport.register_type( participant, ice.GlobalAlarmLimitObjectiveTypeSupport.get_type_name()); globalAlarmLimitTopic = TopicUtil.findOrCreateTopic( participant, ice.GlobalAlarmLimitObjectiveTopic.VALUE, ice.GlobalAlarmLimitObjectiveTypeSupport.class); writer = (ice.GlobalAlarmLimitObjectiveDataWriter) publisher.create_datawriter_with_profile( globalAlarmLimitTopic, QosProfiles.ice_library, QosProfiles.state, null, StatusKind.STATUS_MASK_NONE); }
/** * Create abstract data writer and check for errors * * @param publisher Publisher to build data writer from * @param topic Topic to write to * @return DDS DataWriter * @throws IOException */ public DataWriter createWriter(final Publisher publisher, final Topic topic) throws IOException { DataWriterQos dataWriterQos; if (System.getProperty("dds.batch") != null) { int batchMicros = Integer.parseInt(System.getProperty("dds.batch")); dataWriterQos = new DataWriterQos(); participant.get_default_datawriter_qos(dataWriterQos); dataWriterQos.batch.enable = true; dataWriterQos.batch.max_flush_delay.sec = 0; // = new Duration_t(0, 5000000); dataWriterQos.batch.max_flush_delay.nanosec = batchMicros * 1000; if (System.getProperty("dds.batch.data") != null) { dataWriterQos.batch.max_data_bytes = Integer.parseInt(System.getProperty("dds.batch.data")); } if (System.getProperty("dds.batch.samples") != null) { dataWriterQos.batch.max_samples = Integer.parseInt(System.getProperty("dds.batch.samples")); } dataWriterQos.history.kind = HistoryQosPolicyKind.KEEP_ALL_HISTORY_QOS; System.err.println("Flush delay: " + dataWriterQos.batch.max_flush_delay); } else { dataWriterQos = Publisher.DATAWRITER_QOS_USE_TOPIC_QOS; } final DataWriter parentWriter = publisher.create_datawriter(topic, dataWriterQos, null, StatusKind.STATUS_MASK_NONE); if (parentWriter == null) { throw new IOException("Could not create DataWriter"); } return parentWriter; }
@Override public void stop() { publisher.delete_datawriter(writer); publisher.get_participant().delete_topic(globalAlarmLimitTopic); }