internal static DDS.ReturnCode CopyIn(ReaderDataLifecycleQosPolicy from, ref v_readerLifecyclePolicyI_s to)
 {
     DDS.ReturnCode result = DDS.ReturnCode.Ok;
     if (from != null)
     {
         to.v.invalid_sample_visibility = (V_INVALIDSAMPLEVISIBILITYKIND)from.InvalidSampleVisibility.Kind;
         to.v.enable_invalid_samples    = from.EnableInvalidSamples;
         to.v.autopurge_dispose_all     = from.AutopurgeDisposeAll;
         result = DurationMarshaler.CopyIn(from.AutopurgeNowriterSamplesDelay, ref to.v.autopurge_nowriter_samples_delay);
         if (result == DDS.ReturnCode.Ok)
         {
             result = DurationMarshaler.CopyIn(from.AutopurgeDisposedSamplesDelay, ref to.v.autopurge_disposed_samples_delay);
         }
     }
     else
     {
         result = DDS.ReturnCode.BadParameter;
         ReportStack.Report(result, "ReaderDataLifecycleQosPolicy attribute may not be a null pointer.");
     }
     return(result);
 }
        internal static DDS.ReturnCode CopyIn(SchedulingQosPolicy from, ref v_schedulePolicyI_s to)
        {
            DDS.ReturnCode result = DDS.ReturnCode.Ok;
            if (from != null)
            {
                // Set scheduling_class field
                to.v.kind = (V_SCHEDULEKIND)from.SchedulingClass.Kind;

                // Set scheduling_priority_kind field
                to.v.priorityKind = (V_SCHEDULEPRIORITYKIND)from.SchedulingPriorityKind.Kind;

                // Set scheduling_priority field
                to.v.priority = from.SchedulingPriority;
            }
            else
            {
                result = DDS.ReturnCode.BadParameter;
                ReportStack.Report(result, "SchedulingQosPolicy attribute may not be a null pointer.");
            }
            return(result);
        }
Example #3
0
        public override Test.Framework.TestResult Run()
        {
            DDS.ISubscriber        subscriber;
            DDS.DataReaderQos      dataReaderQos = null;
            DDS.IDomainParticipant participant;
            DDS.DataReaderQos      qosHolder1 = null;
            DDS.ITopic             topic;
            string expResult = "copy_from_topic_qos rejects TOPIC_QOS_DEFAULT with correct code.";

            Test.Framework.TestResult result;
            DDS.ReturnCode            rc = DDS.ReturnCode.Error;
            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            subscriber  = (DDS.ISubscriber) this.ResolveObject("subscriber");
            participant = (DDS.IDomainParticipant) this.ResolveObject("participant");
            topic       = (DDS.ITopic) this.ResolveObject("topic");

            if (subscriber.GetDefaultDataReaderQos(ref dataReaderQos) != DDS.ReturnCode.Ok)
            {
                result.Result = "Could not retrieve default DataReaderQos";
                return(result);
            }

            dataReaderQos.History.Kind  = DDS.HistoryQosPolicyKind.KeepAllHistoryQos;
            dataReaderQos.History.Depth = 150;

            // TODO: JLS, Verify the intent of this BadParameter test.
            DDS.TopicQos topicQosHolder = null;
            rc = subscriber.CopyFromTopicQos(ref qosHolder1, topicQosHolder);
            if (rc != DDS.ReturnCode.BadParameter)
            {
                result.Result = "copy_from_topic_qos returns wrong code (RETCODE = " + rc + ").";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Example #4
0
            public void Run()
            {
                thread = new System.Threading.Thread(delegate()
                {
                    this.success = false;
                    DDS.ICondition[] attachedConditions = null;
                    DDS.ReturnCode rc = this.waitset.GetConditions(ref attachedConditions);
                    if (rc == DDS.ReturnCode.Ok)
                    {
                        DDS.ICondition[] activeConditions = new DDS.ICondition[0];
                        rc = this.waitset.Wait(ref activeConditions, new DDS.Duration(30, 0));
                        if (rc == DDS.ReturnCode.Ok)
                        {
                            if (activeConditions.Length != 0)
                            {
                                this.success = true;
                            }
                        }
                    }
                });

                thread.Start();
            }
Example #5
0
        private static void runListeners(Listener7 listener7, DDS.IEntity entity, int id)
        {
            DDS.ReturnCode rc = DDS.ReturnCode.Error;

            System.Console.Out.WriteLine("Thread {0} started...", id);
            System.Threading.Thread.Sleep(0);
            if (entity is DDS.IDomainParticipant)
            {
                DDS.IDomainParticipantListener listener     = new test.sacs.MyParticipantListener();
                DDS.IDomainParticipant         domainEntity = (DDS.IDomainParticipant)entity;
                rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable);
                if (rc == DDS.ReturnCode.Ok)
                {
                    rc = domainEntity.SetListener(null, 0);
                    if (rc == DDS.ReturnCode.Ok)
                    {
                        rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
                    }
                }
            }
            else
            {
                if (entity is DDS.IPublisher)
                {
                    DDS.IPublisherListener listener     = new test.sacs.MyPublisherListener();
                    DDS.IPublisher         domainEntity = (DDS.IPublisher)entity;
                    rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
                    if (rc == DDS.ReturnCode.Ok)
                    {
                        rc = domainEntity.SetListener(null, 0);
                        if (rc == DDS.ReturnCode.Ok)
                        {
                            rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
                        }
                    }
                }
                else
                {
                    if (entity is DDS.IDataWriter)
                    {
                        DDS.DataWriterListener listener     = new test.sacs.MyDataWriterListener();
                        DDS.IDataWriter        domainEntity = (DDS.IDataWriter)entity;
                        rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
                        if (rc == DDS.ReturnCode.Ok)
                        {
                            rc = domainEntity.SetListener(null, 0);
                            if (rc == DDS.ReturnCode.Ok)
                            {
                                rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
                            }
                        }
                    }
                    else
                    {
                        if (entity is DDS.IDataReader)
                        {
                            DDS.IDataReaderListener listener     = new test.sacs.MyDataReaderListener();
                            DDS.IDataReader         domainEntity = (DDS.IDataReader)entity;
                            rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
                            if (rc == DDS.ReturnCode.Ok)
                            {
                                rc = domainEntity.SetListener(null, 0);
                                if (rc == DDS.ReturnCode.Ok)
                                {
                                    rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos);
                                }
                            }
                        }
                        else
                        {
                            if (entity is DDS.ITopic)
                            {
                                DDS.TopicListener listener     = new test.sacs.MyTopicListener();
                                DDS.ITopic        domainEntity = (DDS.ITopic)entity;
                                rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic);
                                if (rc == DDS.ReturnCode.Ok)
                                {
                                    rc = domainEntity.SetListener(null, 0);
                                    if (rc == DDS.ReturnCode.Ok)
                                    {
                                        rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic);
                                    }
                                }
                            }
                            else
                            {
                                if (entity is DDS.ISubscriber)
                                {
                                    DDS.ISubscriberListener listener     = new test.sacs.MySubscriberListener();
                                    DDS.ISubscriber         domainEntity = (DDS.ISubscriber)entity;
                                    rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
                                    if (rc == DDS.ReturnCode.Ok)
                                    {
                                        rc = domainEntity.SetListener(null, 0);
                                        if (rc == DDS.ReturnCode.Ok)
                                        {
                                            rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders);
                                        }
                                    }
                                }
                                else
                                {
                                    System.Console.Out.WriteLine("Entity type: " + entity.ToString() + " not supported.");
                                }
                            }
                        }
                    }
                }
            }
            System.Console.Out.WriteLine("Thread " + id + " finished.");
        }
Example #6
0
 public void Run()
 {
     System.Console.Out.WriteLine("Thread " + this.id + " started...");
     System.Threading.Thread.Sleep(0);
     if (this.entity is DDS.IDomainParticipant)
     {
         DDS.IDomainParticipantListener listener     = new test.sacs.MyParticipantListener();
         DDS.IDomainParticipant         domainEntity = (DDS.IDomainParticipant) this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
             }
         }
     }
     else if (this.entity is DDS.IPublisher)
     {
         DDS.IPublisherListener listener     = new test.sacs.MyPublisherListener();
         DDS.IPublisher         domainEntity = (DDS.IPublisher) this.entity;
         this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
             }
         }
     }
     else if (this.entity is DDS.IDataWriter)
     {
         DDS.DataWriterListener listener     = new test.sacs.MyDataWriterListener();
         DDS.IDataWriter        domainEntity = (DDS.IDataWriter) this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
             }
         }
     }
     else if (this.entity is DDS.IDataReader)
     {
         DDS.IDataReaderListener listener     = new test.sacs.MyDataReaderListener();
         DDS.IDataReader         domainEntity = (DDS.IDataReader) this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos);
             }
         }
     }
     else if (this.entity is DDS.ITopic)
     {
         DDS.TopicListener listener     = new test.sacs.MyTopicListener();
         DDS.ITopic        domainEntity = (DDS.ITopic) this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic);
             }
         }
     }
     else if (this.entity is DDS.ISubscriber)
     {
         DDS.ISubscriberListener listener     = new test.sacs.MySubscriberListener();
         DDS.ISubscriber         domainEntity = (DDS.ISubscriber) this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders);
             }
         }
     }
     else
     {
         System.Console.Out.WriteLine("Entity type: " + this.entity.ToString() + " not supported.");
     }
     System.Console.Out.WriteLine("Thread " + this.id + " finished.");
 }
Example #7
0
        public override Test.Framework.TestResult Run()
        {
            DDS.IDomainParticipant               participant;
            DDS.ITopic                           topic;
            DDS.IPublisher                       publisher;
            DDS.ISubscriber                      subscriber;
            mod.tstDataWriter                    writer;
            mod.tstDataReader                    reader;
            Test.Framework.TestResult            result;
            test.sacs.Listener7.ListenerThread[] threads;
            string expResult = "Listener multithread test succeeded.";

            DDS.ReturnCode[] results;

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                                                   Test.Framework.TestVerdict.Fail);
            participant = (DDS.IDomainParticipant) this.ResolveObject("participant");
            writer      = (mod.tstDataWriter) this.ResolveObject("datawriter");
            reader      = (mod.tstDataReader) this.ResolveObject("datareader");
            topic       = (DDS.ITopic) this.ResolveObject("topic");
            publisher   = (DDS.IPublisher) this.ResolveObject("publisher");
            subscriber  = (DDS.ISubscriber) this.ResolveObject("subscriber");

            threads = new test.sacs.Listener7.ListenerThread[6];
            int i = 0;

            threads[i] = new test.sacs.Listener7.ListenerThread(this, participant, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, writer, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, reader, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, topic, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, subscriber, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, publisher, i);
            for (int j = 0; j < threads.Length; j++)
            {
                threads[j].Start();
            }
            results = new DDS.ReturnCode[threads.Length];
            for (int j = 0; j < threads.Length; j++)
            {
                try
                {
                    threads[j].Join();
                    results[j] = threads[j].GetResult();
                }
                catch (System.Exception e)
                {
                    result.Result = string.Format("Thread {0} could not be joined. Exception: {1}", j, e);
                    return(result);
                }
            }
            for (int j = 0; j < results.Length; j++)
            {
                if (results[j] != DDS.ReturnCode.Ok)
                {
                    result.Result = string.Format("Listener thread {0} failed.", j);
                    return(result);
                }
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Example #8
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult  result;
            Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass;
            string expResult = "Resolving GuardCondition succeeded.";

            DDS.ICondition[] holder     = null;
            DDS.ReturnCode[] resultCode = new DDS.ReturnCode[] { DDS.ReturnCode.Error, DDS.ReturnCode.Error, DDS.ReturnCode.Error };
            DDS.ReturnCode   ddsReturnCode;
            bool             continueTesting = true;

            DDS.GuardCondition condition1 = (DDS.GuardCondition)ResolveObject("condition1");
            DDS.GuardCondition condition2 = (DDS.GuardCondition)ResolveObject("condition2");
            DDS.GuardCondition condition3 = (DDS.GuardCondition)ResolveObject("condition3");
            DDS.WaitSet        waitset    = new DDS.WaitSet();
            resultCode[0] = waitset.AttachCondition(condition1);
            resultCode[1] = waitset.AttachCondition(condition2);
            resultCode[2] = waitset.AttachCondition(condition3);

            if (resultCode[0] != 0 || resultCode[1] != 0 || resultCode[2] != 0)
            {
                result = new Test.Framework.TestResult("attached guardconditions to a waitset", "attach_condition returned RETCODE: "
                                                       + resultCode[0] + " " + resultCode[1] + " " + resultCode[2], expVerdict, Test.Framework.TestVerdict.Fail);
                continueTesting = false;
            }
            else
            {
                result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK"
                                                       , expVerdict, Test.Framework.TestVerdict.Pass);
            }
            if (continueTesting)
            {
                ddsReturnCode = waitset.GetConditions(ref holder);
                if (ddsReturnCode != DDS.ReturnCode.Ok)
                {
                    result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE: "
                                                           + ddsReturnCode, expVerdict, Test.Framework.TestVerdict.Fail);
                }
                else
                {
                    result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK"
                                                           , expVerdict, Test.Framework.TestVerdict.Pass);
                }
                if (holder.Length != 3)
                {
                    result = new Test.Framework.TestResult(expResult, "Did not resolve 3 GuardCondition objects"
                                                           , expVerdict, Test.Framework.TestVerdict.Fail);
                }
                else
                {
                    if ((holder[0] != condition1) && (holder[1] != condition1) && (holder[2] != condition1))
                    {
                        result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (1)"
                                                               , expVerdict, Test.Framework.TestVerdict.Fail);
                        return(result);
                    }
                    if ((holder[0] != condition2) && (holder[1] != condition2) && (holder[2] != condition2))
                    {
                        result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (2)"
                                                               , expVerdict, Test.Framework.TestVerdict.Fail);
                        return(result);
                    }
                    if ((holder[0] != condition3) && (holder[1] != condition3) && (holder[2] != condition3))
                    {
                        result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (3)"
                                                               , expVerdict, Test.Framework.TestVerdict.Fail);
                        return(result);
                    }
                    result = new Test.Framework.TestResult(expResult, "Resolved 3 GuardCondition objects"
                                                           , expVerdict, Test.Framework.TestVerdict.Pass);
                }
            }
            return(result);
        }
Example #9
0
        public override Test.Framework.TestResult Run()
        {
            DDS.IDomainParticipant    participant;
            DDS.ITopicDescription     topic;
            DDS.ITopicDescription     topic2;
            DDS.IDataReader           reader;
            DDS.ISubscriber           subscriber;
            Test.Framework.TestResult result;
            string topicName;
            string expResult = "Builtin subscriber test succeeded.";

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            participant = (DDS.IDomainParticipant) this.ResolveObject("participant");

            subscriber = participant.BuiltInSubscriber;
            if (subscriber == null)
            {
                result.Result = "Builtin subscriber could not be resolved.";
                return(result);
            }
            topicName = "DCPSTopic";
            reader    = subscriber.LookupDataReader(topicName);
            if (reader == null)
            {
                result.Result = "Builtin datareader for " + topicName + " could not be resolved.";
                return(result);
            }
            if (reader == null)
            {
                result.Result          = "Builtin datareader for " + topicName + " could not be resolved.";
                result.ExpectedVerdict = Test.Framework.TestVerdict.Fail;
                return(result);
            }
            else
            {
                DDS.ITopicBuiltinTopicDataDataReader dcpsTopReader = reader as DDS.ITopicBuiltinTopicDataDataReader;
                DDS.TopicBuiltinTopicData[]          dataSeq       = null;
                DDS.SampleInfo[] infoSeq = null;
                DDS.ReturnCode   retcode = dcpsTopReader.Read(
                    ref dataSeq,
                    ref infoSeq,
                    DDS.Length.Unlimited,
                    DDS.SampleStateKind.NotRead,
                    DDS.ViewStateKind.Any,
                    DDS.InstanceStateKind.Any);
                if (retcode == DDS.ReturnCode.Ok)
                {
                    for (int i = 0; i < dataSeq.Length; i++)
                    {
                        System.Console.WriteLine("Found: topic " + dataSeq[i].Name);
                    }
                    retcode = dcpsTopReader.ReturnLoan(ref dataSeq, ref infoSeq);
                    if (retcode != DDS.ReturnCode.Ok)
                    {
                        result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                        return(result);
                    }
                }
                else
                {
                    result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                    return(result);
                }
            }

            topic = reader.GetTopicDescription();
            if (topic == null)
            {
                result.Result = "Builtin topic for datareader of " + topicName + " could not be resolved.";
                return(result);
            }
            topic2 = participant.LookupTopicDescription(topicName);
            if (topic2 == null)
            {
                result.Result = "Builtin topic " + topicName + " could not be resolved.";
                return(result);
            }
            if (topic != topic2)
            {
                result.Result = "Builtin topics of " + topicName + " do not match.";
                return(result);
            }
            topicName = "DCPSParticipant";
            reader    = subscriber.LookupDataReader(topicName);
            if (reader == null)
            {
                result.Result          = "Builtin datareader for " + topicName + " could not be resolved.";
                result.ExpectedVerdict = Test.Framework.TestVerdict.Fail;
                return(result);
            }
            else
            {
                DDS.IParticipantBuiltinTopicDataDataReader dcpsPubReader = reader as DDS.IParticipantBuiltinTopicDataDataReader;
                DDS.ParticipantBuiltinTopicData[]          dataSeq       = null;
                DDS.SampleInfo[] infoSeq = null;
                DDS.ReturnCode   retcode = dcpsPubReader.Read(
                    ref dataSeq,
                    ref infoSeq,
                    DDS.Length.Unlimited,
                    DDS.SampleStateKind.NotRead,
                    DDS.ViewStateKind.Any,
                    DDS.InstanceStateKind.Any);
                if (retcode == DDS.ReturnCode.Ok)
                {
                    for (int i = 0; i < dataSeq.Length; i++)
                    {
                        System.Console.WriteLine("Found: Participant for node " + dataSeq[i].Key[0]);
                    }
                    retcode = dcpsPubReader.ReturnLoan(ref dataSeq, ref infoSeq);
                    if (retcode != DDS.ReturnCode.Ok)
                    {
                        result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                        return(result);
                    }
                }
                else
                {
                    result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                    return(result);
                }
            }
            topic = reader.GetTopicDescription();
            if (topic == null)
            {
                result.Result = "Builtin topic for datareader of " + topicName + " could not be resolved.";
                return(result);
            }
            topic2 = participant.LookupTopicDescription(topicName);
            if (topic2 == null)
            {
                result.Result = "Builtin topic " + topicName + " could not be resolved.";
                return(result);
            }
            if (topic != topic2)
            {
                result.Result = "Builtin topics of " + topicName + " do not match.";
                return(result);
            }
            topicName = "DCPSPublication";
            reader    = subscriber.LookupDataReader(topicName);
            if (reader == null)
            {
                result.Result          = "Builtin datareader for " + topicName + " could not be resolved.";
                result.ExpectedVerdict = Test.Framework.TestVerdict.Fail;
                return(result);
            }
            else
            {
                DDS.IPublicationBuiltinTopicDataDataReader dcpsDPReader = reader as DDS.IPublicationBuiltinTopicDataDataReader;
                DDS.PublicationBuiltinTopicData[]          dataSeq      = null;
                DDS.SampleInfo[] infoSeq = null;
                DDS.ReturnCode   retcode = dcpsDPReader.Read(
                    ref dataSeq,
                    ref infoSeq,
                    DDS.Length.Unlimited,
                    DDS.SampleStateKind.NotRead,
                    DDS.ViewStateKind.Any,
                    DDS.InstanceStateKind.Any);
                if (retcode == DDS.ReturnCode.Ok)
                {
                    for (int i = 0; i < dataSeq.Length; i++)
                    {
                        System.Console.WriteLine("Found: Writer for topic " + dataSeq[i].TopicName);
                    }
                    retcode = dcpsDPReader.ReturnLoan(ref dataSeq, ref infoSeq);
                    if (retcode != DDS.ReturnCode.Ok)
                    {
                        result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                        return(result);
                    }
                }
                else
                {
                    result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                    return(result);
                }
            }
            topic = reader.GetTopicDescription();
            if (topic == null)
            {
                result.Result = "Builtin topic for datareader of " + topicName + " could not be resolved.";
                return(result);
            }
            topic2 = participant.LookupTopicDescription(topicName);
            if (topic2 == null)
            {
                result.Result = "Builtin topic " + topicName + " could not be resolved.";
                return(result);
            }
            if (topic != topic2)
            {
                result.Result = "Builtin topics of " + topicName + " do not match.";
                return(result);
            }
            topicName = "DCPSSubscription";
            reader    = subscriber.LookupDataReader(topicName);
            if (reader == null)
            {
                result.Result          = "Builtin datareader for " + topicName + " could not be resolved.";
                result.ExpectedVerdict = Test.Framework.TestVerdict.Fail;
                return(result);
            }
            else
            {
                DDS.ISubscriptionBuiltinTopicDataDataReader dcpsSubReader = reader as DDS.ISubscriptionBuiltinTopicDataDataReader;
                DDS.SubscriptionBuiltinTopicData[]          dataSeq       = null;
                DDS.SampleInfo[] infoSeq = null;
                DDS.ReturnCode   retcode = dcpsSubReader.Read(
                    ref dataSeq,
                    ref infoSeq,
                    DDS.Length.Unlimited,
                    DDS.SampleStateKind.NotRead,
                    DDS.ViewStateKind.Any,
                    DDS.InstanceStateKind.Any);
                if (retcode == DDS.ReturnCode.Ok)
                {
                    for (int i = 0; i < dataSeq.Length; i++)
                    {
                        System.Console.WriteLine("Found: Reader for topic " + dataSeq[i].TopicName);
                    }
                    retcode = dcpsSubReader.ReturnLoan(ref dataSeq, ref infoSeq);
                    if (retcode != DDS.ReturnCode.Ok)
                    {
                        result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                        return(result);
                    }
                }
                else
                {
                    result.Result = "Returncode not Ok, instead ReturnCode = " + retcode;
                    return(result);
                }
            }
            topic = reader.GetTopicDescription();
            if (topic == null)
            {
                result.Result = "Builtin topic for datareader of " + topicName + " could not be resolved.";
                return(result);
            }
            topic2 = participant.LookupTopicDescription(topicName);
            if (topic2 == null)
            {
                result.Result = "Builtin topic " + topicName + " could not be resolved.";
                return(result);
            }
            if (topic != topic2)
            {
                result.Result = "Builtin topics of " + topicName + " do not match.";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Example #10
0
        private static void runListeners(Listener7 listener7, DDS.IEntity entity, int id)
        {
            DDS.ReturnCode rc = DDS.ReturnCode.Error;

            System.Console.Out.WriteLine("Thread {0} started...", id);
            System.Threading.Thread.Sleep(0);
            if (entity is DDS.IDomainParticipant)
            {
                DDS.IDomainParticipantListener listener = new test.sacs.MyParticipantListener();
                DDS.IDomainParticipant domainEntity = (DDS.IDomainParticipant)entity;
                rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable);
                if (rc == DDS.ReturnCode.Ok)
                {
                    rc = domainEntity.SetListener(null, 0);
                    if (rc == DDS.ReturnCode.Ok)
                    {
                        rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
                    }
                }
            }
            else
            {
                if (entity is DDS.IPublisher)
                {
                    DDS.IPublisherListener listener = new test.sacs.MyPublisherListener();
                    DDS.IPublisher domainEntity = (DDS.IPublisher)entity;
                    rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
                    if (rc == DDS.ReturnCode.Ok)
                    {
                        rc = domainEntity.SetListener(null, 0);
                        if (rc == DDS.ReturnCode.Ok)
                        {
                            rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
                        }
                    }
                }
                else
                {
                    if (entity is DDS.IDataWriter)
                    {
                        DDS.DataWriterListener listener = new test.sacs.MyDataWriterListener();
                        DDS.IDataWriter domainEntity = (DDS.IDataWriter)entity;
                        rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
                        if (rc == DDS.ReturnCode.Ok)
                        {
                            rc = domainEntity.SetListener(null, 0);
                            if (rc == DDS.ReturnCode.Ok)
                            {
                                rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
                            }
                        }
                    }
                    else
                    {
                        if (entity is DDS.IDataReader)
                        {
                            DDS.IDataReaderListener listener = new test.sacs.MyDataReaderListener();
                            DDS.IDataReader domainEntity = (DDS.IDataReader)entity;
                            rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
                            if (rc == DDS.ReturnCode.Ok)
                            {
                                rc = domainEntity.SetListener(null, 0);
                                if (rc == DDS.ReturnCode.Ok)
                                {
                                    rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos);
                                }
                            }
                        }
                        else
                        {
                            if (entity is DDS.ITopic)
                            {
                                DDS.TopicListener listener = new test.sacs.MyTopicListener();
                                DDS.ITopic domainEntity = (DDS.ITopic)entity;
                                rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic);
                                if (rc == DDS.ReturnCode.Ok)
                                {
                                    rc = domainEntity.SetListener(null, 0);
                                    if (rc == DDS.ReturnCode.Ok)
                                    {
                                        rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic);
                                    }
                                }
                            }
                            else
                            {
                                if (entity is DDS.ISubscriber)
                                {
                                    DDS.ISubscriberListener listener = new test.sacs.MySubscriberListener();
                                    DDS.ISubscriber domainEntity = (DDS.ISubscriber)entity;
                                    rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
                                    if (rc == DDS.ReturnCode.Ok)
                                    {
                                        rc = domainEntity.SetListener(null, 0);
                                        if (rc == DDS.ReturnCode.Ok)
                                        {
                                            rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders);
                                        }
                                    }
                                }
                                else
                                {
                                    System.Console.Out.WriteLine("Entity type: " + entity.ToString() + " not supported.");
                                }
                            }
                        }
                    }
                }
            }
            System.Console.Out.WriteLine("Thread " + id + " finished.");
        }
Example #11
0
 public void Run()
 {
     System.Console.Out.WriteLine("Thread " + this.id + " started...");
     System.Threading.Thread.Sleep(0);
     if (this.entity is DDS.IDomainParticipant)
     {
         DDS.IDomainParticipantListener listener = new test.sacs.MyParticipantListener();
         DDS.IDomainParticipant domainEntity = (DDS.IDomainParticipant)this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.DataAvailable);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
             }
         }
     }
     else if (this.entity is DDS.IPublisher)
     {
         DDS.IPublisherListener listener = new test.sacs.MyPublisherListener();
         DDS.IPublisher domainEntity = (DDS.IPublisher)this.entity;
         this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
             }
         }
     }
     else if (this.entity is DDS.IDataWriter)
     {
         DDS.DataWriterListener listener = new test.sacs.MyDataWriterListener();
         DDS.IDataWriter domainEntity = (DDS.IDataWriter)this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.RequestedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.RequestedIncompatibleQos);
             }
         }
     }
     else if (this.entity is DDS.IDataReader)
     {
         DDS.IDataReaderListener listener = new test.sacs.MyDataReaderListener();
         DDS.IDataReader domainEntity = (DDS.IDataReader)this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.OfferedIncompatibleQos);
             }
         }
     }
     else if (this.entity is DDS.ITopic)
     {
         DDS.TopicListener listener = new test.sacs.MyTopicListener();
         DDS.ITopic domainEntity = (DDS.ITopic)this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.InconsistentTopic);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.InconsistentTopic);
             }
         }
     }
     else if (this.entity is DDS.ISubscriber)
     {
         DDS.ISubscriberListener listener = new test.sacs.MySubscriberListener();
         DDS.ISubscriber domainEntity = (DDS.ISubscriber)this.entity;
         this.rc = (domainEntity).SetListener(listener, DDS.StatusKind.OfferedDeadlineMissed);
         if (this.rc == DDS.ReturnCode.Ok)
         {
             this.rc = domainEntity.SetListener(null, 0);
             if (this.rc == DDS.ReturnCode.Ok)
             {
                 this.rc = domainEntity.SetListener(listener, DDS.StatusKind.DataOnReaders);
             }
         }
     }
     else
     {
         System.Console.Out.WriteLine("Entity type: " + this.entity.ToString() + " not supported.");
     }
     System.Console.Out.WriteLine("Thread " + this.id + " finished.");
 }
Example #12
0
        public override Test.Framework.TestResult Run()
        {
            DDS.IDomainParticipant participant;
            DDS.ITopic topic;
            DDS.IPublisher publisher;
            DDS.ISubscriber subscriber;
            mod.tstDataWriter writer;
            mod.tstDataReader reader;
            Test.Framework.TestResult result;
            test.sacs.Listener7.ListenerThread[] threads;
            string expResult = "Listener multithread test succeeded.";
            DDS.ReturnCode[] results;

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict.Pass,
                Test.Framework.TestVerdict.Fail);
            participant = (DDS.IDomainParticipant)this.ResolveObject("participant");
            writer = (mod.tstDataWriter)this.ResolveObject("datawriter");
            reader = (mod.tstDataReader)this.ResolveObject("datareader");
            topic = (DDS.ITopic)this.ResolveObject("topic");
            publisher = (DDS.IPublisher)this.ResolveObject("publisher");
            subscriber = (DDS.ISubscriber)this.ResolveObject("subscriber");
                        
            threads = new test.sacs.Listener7.ListenerThread[6];
            int i = 0;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, participant, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, writer, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, reader, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, topic, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, subscriber, i);
            i++;
            threads[i] = new test.sacs.Listener7.ListenerThread(this, publisher, i);
            for (int j = 0; j < threads.Length; j++)
            {
                threads[j].Start();
            }
            results = new DDS.ReturnCode[threads.Length];
            for (int j = 0; j < threads.Length; j++)
            {
                try
                {
                    threads[j].Join();
                    results[j] = threads[j].GetResult();
                }
                catch (System.Exception e)
                {
                    result.Result = string.Format("Thread {0} could not be joined. Exception: {1}", j, e);
                    return result;
                }
            }
            for (int j = 0; j < results.Length; j++)
            {
                if (results[j] != DDS.ReturnCode.Ok)
                {
                    result.Result = string.Format("Listener thread {0} failed.", j);
                    return result;
                }
            }
            result.Result = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return result;
        }
Example #13
0
        public override Test.Framework.TestResult Run()
        {
            Test.Framework.TestResult result;
            Test.Framework.TestVerdict expVerdict = Test.Framework.TestVerdict.Pass;
            string expResult = "Resolving GuardCondition succeeded.";
			DDS.ICondition[] holder = null;
            DDS.ReturnCode[] resultCode = new DDS.ReturnCode[] { DDS.ReturnCode.Error, DDS.ReturnCode.Error, DDS.ReturnCode.Error };
            DDS.ReturnCode ddsReturnCode;
            bool continueTesting = true;
            DDS.GuardCondition condition1 = (DDS.GuardCondition)ResolveObject("condition1");
            DDS.GuardCondition condition2 = (DDS.GuardCondition)ResolveObject("condition2");
            DDS.GuardCondition condition3 = (DDS.GuardCondition)ResolveObject("condition3");
            DDS.WaitSet waitset = new DDS.WaitSet();
            resultCode[0] = waitset.AttachCondition(condition1);
            resultCode[1] = waitset.AttachCondition(condition2);
            resultCode[2] = waitset.AttachCondition(condition3);

            if (resultCode[0] != 0 || resultCode[1] != 0 || resultCode[2] != 0)
            {
                result = new Test.Framework.TestResult("attached guardconditions to a waitset", "attach_condition returned RETCODE: "
                     + resultCode[0] + " " + resultCode[1] + " " + resultCode[2], expVerdict, Test.Framework.TestVerdict.Fail);
                continueTesting = false;
            }
            else
            {
                result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK"
                    , expVerdict, Test.Framework.TestVerdict.Pass);
            }
            if (continueTesting)
            {
                ddsReturnCode = waitset.GetConditions(ref holder);
                if (ddsReturnCode != DDS.ReturnCode.Ok)
                {
                    result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE: "
                         + ddsReturnCode, expVerdict, Test.Framework.TestVerdict.Fail);
                }
                else
                {
                    result = new Test.Framework.TestResult(expResult, "get_conditions returned RETCODE_OK"
                        , expVerdict, Test.Framework.TestVerdict.Pass);
                }
                if (holder.Length != 3)
                {
                    result = new Test.Framework.TestResult(expResult, "Did not resolve 3 GuardCondition objects"
                        , expVerdict, Test.Framework.TestVerdict.Fail);
                }
                else
                {
                    if ((holder[0] != condition1) && (holder[1] != condition1) && (holder[2] != condition1))
                    {
                        result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (1)"
                            , expVerdict, Test.Framework.TestVerdict.Fail);
                        return result;
                    }
                    if ((holder[0] != condition2) && (holder[1] != condition2) && (holder[2] != condition2))
                    {
                        result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (2)"
                            , expVerdict, Test.Framework.TestVerdict.Fail);
                        return result;
                    }
                    if ((holder[0] != condition3) && (holder[1] != condition3) && (holder[2] != condition3))
                    {
                        result = new Test.Framework.TestResult(expResult, "Resolved GuardCondition objects not OK (3)"
                            , expVerdict, Test.Framework.TestVerdict.Fail);
                        return result;
                    }
                    result = new Test.Framework.TestResult(expResult, "Resolved 3 GuardCondition objects"
                        , expVerdict, Test.Framework.TestVerdict.Pass);
                }
            }
            return result;
        }