/** Clear (put to default) the information. */ public void clear() { m_expectsInlineQos = false; m_guid.copy(new GUID()); m_unicastLocatorList.clear(); m_multicastLocatorList.clear(); m_key.copy(new InstanceHandle()); m_RTPSParticipantKey.copy(new InstanceHandle()); m_typeName = ""; m_topicName = ""; m_userDefinedId = 0; m_qos.copy(new ReaderQos()); m_isAlive = true; m_topicKind = NO_KEY; m_parameterList.deleteParams(); m_parameterList.resetList(); }
public boolean readFromCDRMessage(CacheChange change) { this.m_mutex.lock(); try { SerializedPayload payload = change.getSerializedPayload(); payload.updateSerializer(); BinaryInputStream bis = new BinaryInputStream(payload.getBuffer()); ParameterList parameterList = new ParameterList(); try { parameterList.deserialize(payload.getSerializer(), bis, ""); } catch (IOException e) { logger.error(e.getMessage()); return false; // e.printStackTrace(); } for (Parameter param : parameterList.getParameters()) { switch (param.getParameterId()) { case PID_DURABILITY: { DurabilityQosPolicy p = (DurabilityQosPolicy) param; this.m_qos.durability.copy(p); break; } case PID_DURABILITY_SERVICE: { DurabilityServiceQosPolicy p = (DurabilityServiceQosPolicy) param; this.m_qos.durabilityService.copy(p); break; } case PID_DEADLINE: { DeadLineQosPolicy p = (DeadLineQosPolicy) param; this.m_qos.deadline.copy(p); break; } case PID_LATENCY_BUDGET: { LatencyBudgetQosPolicy p = (LatencyBudgetQosPolicy) param; this.m_qos.latencyBudget.copy(p); break; } case PID_LIVELINESS: { LivelinessQosPolicy p = (LivelinessQosPolicy) param; this.m_qos.liveliness.copy(p); break; } case PID_RELIABILITY: { ReliabilityQosPolicy p = (ReliabilityQosPolicy) param; this.m_qos.reliability.copy(p); break; } case PID_LIFESPAN: { LifespanQosPolicy p = (LifespanQosPolicy) param; this.m_qos.lifespan.copy(p); break; } case PID_USER_DATA: { UserDataQosPolicy p = (UserDataQosPolicy) param; this.m_qos.userData.copy(p); break; } case PID_TIME_BASED_FILTER: { TimeBasedFilterQosPolicy p = (TimeBasedFilterQosPolicy) param; this.m_qos.timeBasedFilter.copy(p); break; } case PID_OWNERSHIP: { OwnershipQosPolicy p = (OwnershipQosPolicy) param; this.m_qos.ownership.copy(p); break; } case PID_DESTINATION_ORDER: { DestinationOrderQosPolicy p = (DestinationOrderQosPolicy) param; this.m_qos.destinationOrder.copy(p); break; } case PID_PRESENTATION: { PresentationQosPolicy p = (PresentationQosPolicy) param; this.m_qos.presentation.copy(p); break; } case PID_PARTITION: { PartitionQosPolicy p = (PartitionQosPolicy) param; this.m_qos.partition.copy(p); break; } case PID_TOPIC_DATA: { TopicDataQosPolicy p = (TopicDataQosPolicy) param; this.m_qos.topicData.copy(p); break; } case PID_GROUP_DATA: { GroupDataQosPolicy p = (GroupDataQosPolicy) param; this.m_qos.groupData.copy(p); break; } case PID_TOPIC_NAME: { ParameterString p = (ParameterString) param; this.m_topicName = new String(p.getString()); break; } case PID_TYPE_NAME: { ParameterString p = (ParameterString) param; this.m_typeName = new String(p.getString()); break; } case PID_PARTICIPANT_GUID: { ParameterGuid pGuid = (ParameterGuid) param; this.m_RTPSParticipantKey = new InstanceHandle(pGuid.getGUID()); break; } case PID_ENDPOINT_GUID: { ParameterGuid pGuid = (ParameterGuid) param; this.m_guid.copy(pGuid.getGUID()); break; } case PID_UNICAST_LOCATOR: { ParameterLocator p = (ParameterLocator) param; this.m_unicastLocatorList.pushBack(p.getLocator()); break; } case PID_MULTICAST_LOCATOR: { ParameterLocator p = (ParameterLocator) param; this.m_multicastLocatorList.pushBack(p.getLocator()); break; } case PID_EXPECTS_INLINE_QOS: { ParameterBool p = (ParameterBool) param; this.m_expectsInlineQos = p.getBool(); break; } case PID_KEY_HASH: { ParameterKey p = (ParameterKey) param; this.m_key.copy(p.getKey()); this.m_guid.copy(this.m_key.toGUID()); break; } default: logger.debug("Parameter with ID {} NOT CONSIDERED", param.getParameterId()); break; } } if (this.m_guid.getEntityId().getValue(3) == 0x04) { this.m_topicKind = NO_KEY; } else if (this.m_guid.getEntityId().getValue(3) == 0x07) { this.m_topicKind = TopicKind.WITH_KEY; } } finally { this.m_mutex.unlock(); } return true; }
/** * Convert the data to a parameter list to send this information as a RTPS message. * * @return The ParameterList */ public ParameterList toParameterList() { m_parameterList.deleteParams(); for (Locator lit : m_unicastLocatorList) { ParameterLocator p = new ParameterLocator(PID_UNICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, lit); m_parameterList.addParameter(p); } for (Locator lit : m_multicastLocatorList) { ParameterLocator p = new ParameterLocator(PID_MULTICAST_LOCATOR, PARAMETER_LOCATOR_LENGTH, lit); m_parameterList.addParameter(p); } { ParameterBool p = new ParameterBool(PID_EXPECTS_INLINE_QOS, PARAMETER_BOOL_LENGTH, m_expectsInlineQos); m_parameterList.addParameter(p); } { ParameterGuid p = new ParameterGuid(PID_PARTICIPANT_GUID, PARAMETER_GUID_LENGTH, m_RTPSParticipantKey); m_parameterList.addParameter(p); } { ParameterString p = new ParameterString(PID_TOPIC_NAME, (short) 0, m_topicName); m_parameterList.addParameter(p); } { ParameterString p = new ParameterString(PID_TYPE_NAME, (short) 0, m_typeName); m_parameterList.addParameter(p); } { ParameterKey p = new ParameterKey(PID_KEY_HASH, (short) 16, m_key); m_parameterList.addParameter(p); } { ParameterGuid p = new ParameterGuid(PID_ENDPOINT_GUID, (short) 16, m_guid); m_parameterList.addParameter(p); } { ParameterProtocolVersion p = new ParameterProtocolVersion(PID_PROTOCOL_VERSION, (short) 4); m_parameterList.addParameter(p); } { ParameterVendorId p = new ParameterVendorId(PID_VENDORID, (short) 4); m_parameterList.addParameter(p); } if (m_qos.durability.parent.getSendAlways() || m_qos.durability.parent.hasChanged) { DurabilityQosPolicy p = new DurabilityQosPolicy(); p.copy(m_qos.durability); m_parameterList.addParameter(p); } if (m_qos.durabilityService.parent.getSendAlways() || m_qos.durabilityService.parent.hasChanged) { DurabilityServiceQosPolicy p = new DurabilityServiceQosPolicy(); p.copy(m_qos.durabilityService); m_parameterList.addParameter(p); } if (m_qos.deadline.parent.getSendAlways() || m_qos.deadline.parent.hasChanged) { DeadLineQosPolicy p = new DeadLineQosPolicy(); p.copy(m_qos.deadline); m_parameterList.addParameter(p); } if (m_qos.latencyBudget.parent.getSendAlways() || m_qos.latencyBudget.parent.hasChanged) { LatencyBudgetQosPolicy p = new LatencyBudgetQosPolicy(); p.copy(m_qos.latencyBudget); m_parameterList.addParameter(p); } if (m_qos.liveliness.parent.getSendAlways() || m_qos.liveliness.parent.hasChanged) { LivelinessQosPolicy p = new LivelinessQosPolicy(); p.copy(m_qos.liveliness); m_parameterList.addParameter(p); } if (m_qos.reliability.parent.getSendAlways() || m_qos.reliability.parent.hasChanged) { ReliabilityQosPolicy p = new ReliabilityQosPolicy(); p.copy(m_qos.reliability); m_parameterList.addParameter(p); } if (m_qos.lifespan.parent.getSendAlways() || m_qos.lifespan.parent.hasChanged) { LifespanQosPolicy p = new LifespanQosPolicy(); p.copy(m_qos.lifespan); m_parameterList.addParameter(p); } if (m_qos.userData.parent.getSendAlways() || m_qos.userData.parent.hasChanged) { UserDataQosPolicy p = new UserDataQosPolicy(); p.copy(m_qos.userData); m_parameterList.addParameter(p); } if (m_qos.timeBasedFilter.parent.getSendAlways() || m_qos.timeBasedFilter.parent.hasChanged) { TimeBasedFilterQosPolicy p = new TimeBasedFilterQosPolicy(); p.copy(m_qos.timeBasedFilter); m_parameterList.addParameter(p); } if (m_qos.ownership.parent.getSendAlways() || m_qos.ownership.parent.hasChanged) { OwnershipQosPolicy p = new OwnershipQosPolicy(); p.copy(m_qos.ownership); m_parameterList.addParameter(p); } if (m_qos.destinationOrder.parent.getSendAlways() || m_qos.destinationOrder.parent.hasChanged) { DestinationOrderQosPolicy p = new DestinationOrderQosPolicy(); p.copy(m_qos.destinationOrder); m_parameterList.addParameter(p); } if (m_qos.presentation.parent.getSendAlways() || m_qos.presentation.parent.hasChanged) { PresentationQosPolicy p = new PresentationQosPolicy(); p.copy(m_qos.presentation); m_parameterList.addParameter(p); } if (m_qos.partition.parent.getSendAlways() || m_qos.partition.parent.hasChanged) { PartitionQosPolicy p = new PartitionQosPolicy(); p.copy(m_qos.partition); m_parameterList.addParameter(p); } if (m_qos.topicData.parent.getSendAlways() || m_qos.topicData.parent.hasChanged) { TopicDataQosPolicy p = new TopicDataQosPolicy(); p.copy(m_qos.topicData); m_parameterList.addParameter(p); } if (m_qos.groupData.parent.getSendAlways() || m_qos.groupData.parent.hasChanged) { GroupDataQosPolicy p = new GroupDataQosPolicy(); p.copy(m_qos.groupData); m_parameterList.addParameter(p); } if (m_qos.timeBasedFilter.parent.getSendAlways() || m_qos.timeBasedFilter.parent.hasChanged) { TimeBasedFilterQosPolicy p = new TimeBasedFilterQosPolicy(); p.copy(m_qos.timeBasedFilter); m_parameterList.addParameter(p); } this.m_parameterList.addSentinel(); logger.debug( "DiscoveredReaderData converted to ParameterList with {} parameters", m_parameterList.getParameters().size()); return this.m_parameterList; }