public ReturnCode GetMatchedSubscriptionData( ref SubscriptionBuiltinTopicData subscriptionData, InstanceHandle subscriptionHandle) { ReturnCode result = DDS.ReturnCode.BadParameter; ReportStack.Start(); if (this.rlReq_isAlive) { if (subscriptionHandle != InstanceHandle.Nil) { GCHandle dataGCHandle = GCHandle.Alloc(subscriptionData, GCHandleType.Normal); result = uResultToReturnCode( User.Writer.GetMatchedSubscriptionData( rlReq_UserPeer, subscriptionHandle, CopyMatchedSubscriptionData, GCHandle.ToIntPtr(dataGCHandle))); subscriptionData = dataGCHandle.Target as SubscriptionBuiltinTopicData; dataGCHandle.Free(); } else { result = ReturnCode.BadParameter; ReportStack.Report(result, "subscriptionHandle = DDS.InstanceHandle.Nil."); } } else { result = DDS.ReturnCode.AlreadyDeleted; } ReportStack.Flush(this, result != ReturnCode.Ok); return(result); }
public void TestGetKeyValue() { // Call GetKeyValue with HandleNil SubscriptionBuiltinTopicData data = default; SampleInfo info = new SampleInfo(); ReturnCode ret = _dr.GetKeyValue(ref data, InstanceHandle.HandleNil); Assert.AreEqual(ReturnCode.BadParameter, ret); DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN); Assert.IsNotNull(otherParticipant); otherParticipant.BindRtpsUdpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(otherParticipant, typeName); Assert.AreEqual(ReturnCode.Ok, result); var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName); Assert.IsNotNull(topic); var subscriber = otherParticipant.CreateSubscriber(); Assert.IsNotNull(subscriber); DataReaderQos drQos = TestHelper.CreateNonDefaultDataReaderQos(); DataReader dataReader = subscriber.CreateDataReader(topic, drQos); Assert.IsNotNull(dataReader); Thread.Sleep(500); // Get the for an existing instance ret = _dr.ReadNextSample(ref data, info); Assert.AreEqual(ReturnCode.Ok, ret); TestHelper.TestNonDefaultSubscriptionData(data); SubscriptionBuiltinTopicData aux = default; ret = _dr.GetKeyValue(ref aux, info.InstanceHandle); Assert.AreEqual(ReturnCode.Ok, ret); for (int i = 0; i < 3; i++) { Assert.AreEqual(data.Key.Value[i], aux.Key.Value[i]); } ret = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, ret); ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, ret); }
public void TestLookupInstance() { SubscriptionBuiltinTopicData data = default; SampleInfo info = new SampleInfo(); DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN); Assert.IsNotNull(otherParticipant); otherParticipant.BindRtpsUdpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(otherParticipant, typeName); Assert.AreEqual(ReturnCode.Ok, result); var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName); Assert.IsNotNull(topic); var subscriber = otherParticipant.CreateSubscriber(); Assert.IsNotNull(subscriber); DataReaderQos drQos = TestHelper.CreateNonDefaultDataReaderQos(); DataReader dataReader = subscriber.CreateDataReader(topic, drQos); Assert.IsNotNull(dataReader); int count = 200; ReturnCode ret = ReturnCode.NoData; while (ret != ReturnCode.Ok && count > 0) { Thread.Sleep(100); // Get the for an existing instance ret = _dr.ReadNextSample(ref data, info); count--; } Assert.AreEqual(ReturnCode.Ok, ret); TestHelper.TestNonDefaultSubscriptionData(data); // Lookup for an existing instance var handle = _dr.LookupInstance(data); Assert.AreNotEqual(InstanceHandle.HandleNil, handle); ret = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, ret); ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, ret); }
internal static V_RESULT CopyMatchedSubscriptionData(IntPtr info, IntPtr arg) { __SubscriptionBuiltinTopicData nativeImage = (__SubscriptionBuiltinTopicData)Marshal.PtrToStructure(info, typeof(__SubscriptionBuiltinTopicData)); GCHandle argGCHandle = GCHandle.FromIntPtr(arg); SubscriptionBuiltinTopicData to = argGCHandle.Target as SubscriptionBuiltinTopicData; SubscriptionBuiltinTopicDataMarshaler.CopyOut(ref nativeImage, ref to); argGCHandle.Target = to; return(V_RESULT.OK); }
public void TestTakeNextSample() { SubscriptionBuiltinTopicData data = default; SampleInfo infos = new SampleInfo(); ReturnCode ret = _dr.TakeNextSample(ref data, infos); Assert.AreEqual(ReturnCode.NoData, ret); DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN); Assert.IsNotNull(otherParticipant); otherParticipant.BindRtpsUdpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(otherParticipant, typeName); Assert.AreEqual(ReturnCode.Ok, result); var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName); Assert.IsNotNull(topic); var subscriber = otherParticipant.CreateSubscriber(); Assert.IsNotNull(subscriber); DataReaderQos drQos = TestHelper.CreateNonDefaultDataReaderQos(); DataReader dataReader = subscriber.CreateDataReader(topic, drQos); Assert.IsNotNull(dataReader); Thread.Sleep(500); ret = _dr.TakeNextSample(ref data, infos); Assert.AreEqual(ReturnCode.Ok, ret); TestHelper.TestNonDefaultSubscriptionData(data); ret = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, ret); ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, ret); }
public static void TestNonDefaultSubscriptionData(SubscriptionBuiltinTopicData data) { Assert.IsNotNull(data); Assert.IsNotNull(data.Deadline); Assert.IsNotNull(data.DestinationOrder); Assert.IsNotNull(data.Durability); Assert.IsNotNull(data.LatencyBudget); Assert.IsNotNull(data.Liveliness); Assert.IsNotNull(data.Ownership); Assert.IsNotNull(data.Reliability); Assert.IsNotNull(data.TimeBasedFilter); Assert.IsNotNull(data.UserData); Assert.IsNotNull(data.Key); Assert.IsNotNull(data.ParticipantKey); Assert.IsNotNull(data.GroupData); Assert.IsNotNull(data.Partition); Assert.IsNotNull(data.Presentation); Assert.IsNotNull(data.TopicData); Assert.IsFalse(string.IsNullOrWhiteSpace(data.TopicName)); Assert.IsFalse(string.IsNullOrWhiteSpace(data.TypeName)); Assert.IsNotNull(data.Deadline.Period); Assert.AreEqual(5, data.Deadline.Period.Seconds); Assert.AreEqual(Duration.ZeroNanoseconds, data.Deadline.Period.NanoSeconds); Assert.AreEqual(DestinationOrderQosPolicyKind.BySourceTimestampDestinationOrderQos, data.DestinationOrder.Kind); Assert.AreEqual(DurabilityQosPolicyKind.TransientLocalDurabilityQos, data.Durability.Kind); Assert.IsNotNull(data.LatencyBudget.Duration); Assert.AreEqual(5, data.LatencyBudget.Duration.Seconds); Assert.AreEqual((uint)5, data.LatencyBudget.Duration.NanoSeconds); Assert.AreEqual(LivelinessQosPolicyKind.ManualByParticipantLivelinessQos, data.Liveliness.Kind); Assert.IsNotNull(data.Liveliness.LeaseDuration); Assert.AreEqual(5, data.Liveliness.LeaseDuration.Seconds); Assert.AreEqual((uint)5, data.Liveliness.LeaseDuration.NanoSeconds); Assert.AreEqual(OwnershipQosPolicyKind.ExclusiveOwnershipQos, data.Ownership.Kind); Assert.AreEqual(ReliabilityQosPolicyKind.ReliableReliabilityQos, data.Reliability.Kind); Assert.IsNotNull(data.Reliability.MaxBlockingTime); Assert.AreEqual(5, data.Reliability.MaxBlockingTime.Seconds); Assert.AreEqual((uint)5, data.Reliability.MaxBlockingTime.NanoSeconds); Assert.AreEqual(1, data.UserData.Value.Count()); Assert.IsNotNull(data.TimeBasedFilter.MinimumSeparation); Assert.AreEqual(3, data.TimeBasedFilter.MinimumSeparation.Seconds); Assert.AreEqual((uint)3, data.TimeBasedFilter.MinimumSeparation.NanoSeconds); Assert.AreEqual(0x5, data.UserData.Value.First()); }
public ReturnCode GetMatchedSubscriptionData( ref SubscriptionBuiltinTopicData subscriptionData, InstanceHandle subscriptionHandle) { ReturnCode result; using (OpenSplice.CustomMarshalers.SubscriptionBuiltinTopicDataMarshaler marshaler = new OpenSplice.CustomMarshalers.SubscriptionBuiltinTopicDataMarshaler()) { result = Gapi.DataWriter.get_matched_subscription_data( GapiPeer, marshaler.GapiPtr, subscriptionHandle); if (result == ReturnCode.Ok) { marshaler.CopyOut(ref subscriptionData); } } return(result); }
public ReturnCode GetMatchedSubscriptionData( ref SubscriptionBuiltinTopicData subscriptionData, InstanceHandle subscriptionHandle) { ReturnCode result; using (OpenSplice.CustomMarshalers.SubscriptionBuiltinTopicDataMarshaler marshaler = new OpenSplice.CustomMarshalers.SubscriptionBuiltinTopicDataMarshaler()) { result = Gapi.DataWriter.get_matched_subscription_data( GapiPeer, marshaler.GapiPtr, subscriptionHandle); if (result == ReturnCode.Ok) { marshaler.CopyOut(ref subscriptionData); } } return result; }
internal static DDS.ReturnCode CopyIn(SubscriptionBuiltinTopicData from, IntPtr to) { DDS.ReturnCode result; if (from != null) { result = BuiltinTopicKeyMarshaler.CopyIn(from.Key, to, offset_key); if (result == DDS.ReturnCode.Ok) { result = BuiltinTopicKeyMarshaler.CopyIn(from.ParticipantKey, to, offset_participant_key); } if (result == DDS.ReturnCode.Ok) { IntPtr namePtr = Marshal.StringToHGlobalAnsi(from.TopicName); BaseMarshaler.Write(to, offset_topic_name, namePtr); IntPtr typeNamePtr = Marshal.StringToHGlobalAnsi(from.TypeName); BaseMarshaler.Write(to, offset_type_name, typeNamePtr); result = DurabilityQosPolicyMarshaler.CopyIn(from.Durability, to, offset_durability); } if (result == DDS.ReturnCode.Ok) { result = DeadlineQosPolicyMarshaler.CopyIn(from.Deadline, to, offset_deadline); } if (result == DDS.ReturnCode.Ok) { result = LatencyBudgetQosPolicyMarshaler.CopyIn(from.LatencyBudget, to, offset_latency_budget); } if (result == DDS.ReturnCode.Ok) { result = LivelinessQosPolicyMarshaler.CopyIn(from.Liveliness, to, offset_liveliness); } if (result == DDS.ReturnCode.Ok) { result = ReliabilityQosPolicyMarshaler.CopyIn(from.Reliability, to, offset_reliability); } if (result == DDS.ReturnCode.Ok) { result = OwnershipQosPolicyMarshaler.CopyIn(from.Ownership, to, offset_ownership); } if (result == DDS.ReturnCode.Ok) { result = DestinationOrderQosPolicyMarshaler.CopyIn(from.DestinationOrder, to, offset_destination_order); } if (result == DDS.ReturnCode.Ok) { result = UserDataQosPolicyMarshaler.CopyIn(from.UserData, to, offset_user_data); } if (result == DDS.ReturnCode.Ok) { result = TimeBasedFilterQosPolicyMarshaler.CopyIn(from.TimeBasedFilter, to, offset_time_based_filter); } if (result == DDS.ReturnCode.Ok) { result = PresentationQosPolicyMarshaler.CopyIn(from.Presentation, to, offset_presentation); } if (result == DDS.ReturnCode.Ok) { result = PartitionQosPolicyMarshaler.CopyIn(from.Partition, to, offset_partition); } if (result == DDS.ReturnCode.Ok) { result = TopicDataQosPolicyMarshaler.CopyIn(from.TopicData, to, offset_topic_data); } if (result == DDS.ReturnCode.Ok) { result = GroupDataQosPolicyMarshaler.CopyIn(from.GroupData, to, offset_group_data); } } else { result = DDS.ReturnCode.BadParameter; DDS.OpenSplice.OS.Report( DDS.OpenSplice.ReportType.OS_ERROR, "DDS.OpenSplice.CustomMarshalers.SubscriptionBuiltinTopicDataMarshaler.CopyIn", "DDS/OpenSplice/CustomMarshalers/QosToplevelMarshalers.cs", DDS.ErrorCode.InvalidValue, "SubscriptionBuiltinTopicData attribute may not be a null pointer."); } return result; }
internal void CopyOut(ref SubscriptionBuiltinTopicData to) { CopyOut(GapiPtr, ref to); }
internal DDS.ReturnCode CopyIn(SubscriptionBuiltinTopicData from) { cleanupRequired = true; return CopyIn(from, GapiPtr); }
internal static void CopyOut(IntPtr from, ref SubscriptionBuiltinTopicData to) { if (to == null) to = new SubscriptionBuiltinTopicData(); BuiltinTopicKeyMarshaler.CopyOut(from, ref to.Key, offset_key); BuiltinTopicKeyMarshaler.CopyOut(from, ref to.ParticipantKey, offset_participant_key); IntPtr namePtr = BaseMarshaler.ReadIntPtr(from, offset_topic_name); to.TopicName = Marshal.PtrToStringAnsi(namePtr); IntPtr typeNamePtr = BaseMarshaler.ReadIntPtr(from, offset_type_name); to.TypeName = Marshal.PtrToStringAnsi(typeNamePtr); DurabilityQosPolicyMarshaler.CopyOut(from, ref to.Durability, offset_durability); DeadlineQosPolicyMarshaler.CopyOut(from, ref to.Deadline, offset_deadline); LatencyBudgetQosPolicyMarshaler.CopyOut(from, ref to.LatencyBudget, offset_latency_budget); LivelinessQosPolicyMarshaler.CopyOut(from, ref to.Liveliness, offset_liveliness); ReliabilityQosPolicyMarshaler.CopyOut(from, ref to.Reliability, offset_reliability); OwnershipQosPolicyMarshaler.CopyOut(from, ref to.Ownership, offset_ownership); DestinationOrderQosPolicyMarshaler.CopyOut(from, ref to.DestinationOrder, offset_destination_order); UserDataQosPolicyMarshaler.CopyOut(from, ref to.UserData, offset_user_data); TimeBasedFilterQosPolicyMarshaler.CopyOut(from, ref to.TimeBasedFilter, offset_time_based_filter); PresentationQosPolicyMarshaler.CopyOut(from, ref to.Presentation, offset_presentation); PartitionQosPolicyMarshaler.CopyOut(from, ref to.Partition, offset_partition); TopicDataQosPolicyMarshaler.CopyOut(from, ref to.TopicData, offset_topic_data); GroupDataQosPolicyMarshaler.CopyOut(from, ref to.GroupData, offset_group_data); }
public override SubscriptionBuiltinTopicData CopyFrom(SubscriptionBuiltinTopicData other) { throw new NotImplementedException(); }
public void TestGetMatchedSubscriptionData() { // Initialize entities DataWriterQos dwQos = TestHelper.CreateNonDefaultDataWriterQos(); dwQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos; DataWriter writer = _publisher.CreateDataWriter(_topic, dwQos); Assert.IsNotNull(writer); // DCPSInfoRepo-based discovery generates Built-In Topic data once (inside the // info repo process) and therefore all known entities in the domain are // reflected in the Built-In Topics. RTPS discovery, on the other hand, follows // the DDS specification and omits "local" entities from the Built-In Topics. // The definition of "local" means those entities belonging to the same Domain // Participant as the given Built-In Topic Subscriber. // https://github.com/objectcomputing/OpenDDS/blob/master/docs/design/RTPS // OPENDDS ISSUE: GetMatchedSubscriptions returns local entities but GetMatchedSubscriptionData doesn't // because is looking in the Built-in topic. If not found in the built-in, shouldn't try to look locally? // WORKAROUND: Create another particpant for the DataReader. DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN); Assert.IsNotNull(otherParticipant); otherParticipant.BindRtpsUdpTransportConfig(); TestStructTypeSupport support = new TestStructTypeSupport(); string typeName = support.GetTypeName(); ReturnCode result = support.RegisterType(otherParticipant, typeName); Assert.AreEqual(ReturnCode.Ok, result); Topic otherTopic = otherParticipant.CreateTopic(nameof(TestGetMatchedSubscriptionData), typeName); Assert.IsNotNull(otherTopic); Subscriber subscriber = otherParticipant.CreateSubscriber(); Assert.IsNotNull(subscriber); DataReaderQos drQos = TestHelper.CreateNonDefaultDataReaderQos(); DataReader reader = subscriber.CreateDataReader(otherTopic, drQos); Assert.IsNotNull(reader); // Wait for subscriptions bool found = writer.WaitForSubscriptions(1, 5000); Assert.IsTrue(found); // Get the matched subscriptions List <InstanceHandle> list = new List <InstanceHandle>(); result = writer.GetMatchedSubscriptions(list); Assert.AreEqual(ReturnCode.Ok, result); Assert.AreEqual(1, list.Count); // Get the matched subscription data SubscriptionBuiltinTopicData data = default; result = writer.GetMatchedSubscriptionData(list.First(), ref data); Assert.AreEqual(ReturnCode.Ok, result); TestHelper.TestNonDefaultSubscriptionData(data); // Destroy the other participant result = otherParticipant.DeleteContainedEntities(); Assert.AreEqual(ReturnCode.Ok, result); result = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant); Assert.AreEqual(ReturnCode.Ok, result); }