public static bool SampleLostValid(DDS.IDataReader reader, int totalCount, int totalCountChange
                                           )
        {
            bool result = false;

            DDS.SampleLostStatus holder = new DDS.SampleLostStatus();
            DDS.ReturnCode       rc     = reader.GetSampleLostStatus(ref holder);
            if (rc == DDS.ReturnCode.Ok)
            {
                DDS.SampleLostStatus status = holder;
                if (status.TotalCount == totalCount)
                {
                    if (status.TotalCountChange == totalCountChange)
                    {
                        result = true;
                    }
                    else
                    {
                        System.Console.Error.WriteLine("sample_lost.TotalCountChange != '" + totalCountChange
                                                       + "', but '" + status.TotalCountChange + "'.");
                    }
                }
                else
                {
                    System.Console.Error.WriteLine("sample_lost.TotalCount != '" + totalCount + "', but '"
                                                   + status.TotalCount + "'.");
                }
            }
            else
            {
                System.Console.Error.WriteLine("get_sample_lost_status returned " + rc);
            }
            return(result);
        }
        public static bool StatussesValid(DDS.IDataReader reader, int rdmTotalCount, int rdmTotalCountChange
                                          , int riqsTotalCount, int riqsTotalCountChange, int srTotalCount, int srTotalCountChange
                                          , int lcActiveCount, int lcActiveCountChange, int lcInactiveCount, int lcInactiveCountChange
                                          , int smTotalCount, int smTotalCountChange, int smCurrentCount, int smCurrentCountChange
                                          , int slTotalCount, int slTotalCountChange
                                          )
        {
            bool result = false;

            if (RequestedDeadlineMissedValid(reader, rdmTotalCount, rdmTotalCountChange))
            {
                if (RequestedIncompatibleQosValid(reader, riqsTotalCount, riqsTotalCountChange))
                {
                    if (SampleRejectedValid(reader, srTotalCount, srTotalCountChange))
                    {
                        if (LivelinessChangedValid(reader, lcActiveCount, lcActiveCountChange, lcInactiveCount
                                                   , lcInactiveCountChange))
                        {
                            if (SubscriptionMatchValid(reader, smTotalCount, smTotalCountChange, smCurrentCount, smCurrentCountChange))
                            {
                                if (SampleLostValid(reader, slTotalCount, slTotalCountChange))
                                {
                                    result = true;
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
        public static bool RequestedIncompatibleQosValid(DDS.IDataReader reader, int totalCount
                                                         , int totalCountChange)
        {
            bool result = false;

            DDS.RequestedIncompatibleQosStatus holder = new DDS.RequestedIncompatibleQosStatus();
            DDS.ReturnCode rc = reader.GetRequestedIncompatibleQosStatus(ref holder);
            if (rc == DDS.ReturnCode.Ok)
            {
                DDS.RequestedIncompatibleQosStatus status = holder;
                if (status.TotalCount == totalCount)
                {
                    if (status.TotalCountChange == totalCountChange)
                    {
                        result = true;
                    }
                    else
                    {
                        System.Console.Error.WriteLine("requested_incompatible_qos.TotalCountChange != '"
                                                       + totalCountChange + "', but '" + status.TotalCountChange + "'.");
                    }
                }
                else
                {
                    System.Console.Error.WriteLine("requested_incompatible_qos.TotalCount != '" + totalCount
                                                   + "', but '" + status.TotalCount + "'.");
                }
            }
            else
            {
                System.Console.Error.WriteLine("get_requested_incompatible_qos_status returned "
                                               + rc);
            }
            return(result);
        }
        public virtual void OnDataAvailable(DDS.IDataReader reader)
        {
            onDataAvailableCalled = true;
            Semaphore sem = null;

            if (semaphores.TryGetValue(DDS.StatusKind.DataAvailable, out sem) == true)
            {
                sem.Release();
            }
        }
        public override void OnDataAvailable(DDS.IDataReader reader)
        {
            onDataAvailableCalled = true;
            Semaphore sem = null;

            if (semaphoresParticipant.TryGetValue(DDS.StatusKind.DataAvailable, out sem) == true)
            {
                sem.Release();
            }
        }
        public virtual void OnRequestedIncompatibleQos(DDS.IDataReader reader, DDS.RequestedIncompatibleQosStatus
                                                       status)
        {
            onRequestedIncompatibleQosCalled = true;
            riqStatus = status;
            Semaphore sem = null;

            if (semaphores.TryGetValue(DDS.StatusKind.RequestedIncompatibleQos, out sem) == true)
            {
                sem.Release();
            }
        }
        public virtual void OnSampleRejected(DDS.IDataReader reader, DDS.SampleRejectedStatus
                                             status)
        {
            onSampleRejectedCalled = true;
            srStatus = status;
            Semaphore sem = null;

            if (semaphores.TryGetValue(DDS.StatusKind.SampleRejected, out sem) == true)
            {
                sem.Release();
            }
        }
        public virtual void OnRequestedDeadlineMissed(DDS.IDataReader reader, DDS.RequestedDeadlineMissedStatus
                                                      status)
        {
            onRequestedDeadlineMissedCalled = true;
            rdmStatus = status;
            Semaphore sem = null;

            if (semaphores.TryGetValue(DDS.StatusKind.RequestedDeadlineMissed, out sem) == true)
            {
                sem.Release();
            }
        }
        public virtual void OnLivelinessChanged(DDS.IDataReader reader, DDS.LivelinessChangedStatus
                                                status)
        {
            onLivelinessChangedCalled = true;
            lcStatus = status;
            Semaphore sem = null;

            if (semaphores.TryGetValue(DDS.StatusKind.LivelinessChanged, out sem) == true)
            {
                sem.Release();
            }
        }
        public virtual void OnSubscriptionMatched(DDS.IDataReader reader, DDS.SubscriptionMatchedStatus
                                                  status)
        {
            onSubscriptionMatchCalled = true;
            smStatus = status;
            Semaphore sem = null;

            if (semaphores.TryGetValue(DDS.StatusKind.SubscriptionMatched, out sem) == true)
            {
                sem.Release();
            }
        }
        public static bool SubscriptionMatchValid(DDS.IDataReader reader, int totalCount,
                                                  int totalCountChange, int currentCount, int currentCountChange)
        {
            bool result = false;

            DDS.SubscriptionMatchedStatus holder = new DDS.SubscriptionMatchedStatus();
            DDS.ReturnCode rc = reader.GetSubscriptionMatchedStatus(ref holder);
            if (rc == DDS.ReturnCode.Ok)
            {
                DDS.SubscriptionMatchedStatus status = holder;
                if (status.TotalCount == totalCount)
                {
                    if (status.TotalCountChange == totalCountChange)
                    {
                        if (status.CurrentCount == currentCount)
                        {
                            if (status.CurrentCountChange == currentCountChange)
                            {
                                result = true;
                            }
                            else
                            {
                                System.Console.Error.WriteLine("subscription_match.CurrentCountChange != '" + currentCountChange
                                                               + "', but '" + status.CurrentCountChange + "'.");
                            }
                        }
                        else
                        {
                            System.Console.Error.WriteLine("subscription_match.CurrentCount != '" + currentCount
                                                           + "', but '" + status.CurrentCount + "'.");
                        }
                    }
                    else
                    {
                        System.Console.Error.WriteLine("subscription_match.TotalCountChange != '" + totalCountChange
                                                       + "', but '" + status.TotalCountChange + "'.");
                    }
                }
                else
                {
                    System.Console.Error.WriteLine("subscription_match.TotalCount != '" + totalCount
                                                   + "', but '" + status.TotalCount + "'.");
                }
            }
            else
            {
                System.Console.Error.WriteLine("get_subscription_match_status returned " + rc);
            }
            return(result);
        }
        public static bool LivelinessChangedValid(DDS.IDataReader reader, int activeCount,
                                                  int activeCountChange, int inactiveCount, int inactiveCountChange)
        {
            bool result = false;

            DDS.LivelinessChangedStatus holder = new DDS.LivelinessChangedStatus();
            DDS.ReturnCode rc = reader.GetLivelinessChangedStatus(ref holder);
            if (rc == DDS.ReturnCode.Ok)
            {
                DDS.LivelinessChangedStatus status = holder;
                if (status.AliveCount == activeCount)
                {
                    if (status.AliveCountChange == activeCountChange)
                    {
                        if (status.NotAliveCount == inactiveCount)
                        {
                            if (status.NotAliveCountChange == inactiveCountChange)
                            {
                                result = true;
                            }
                            else
                            {
                                System.Console.Error.WriteLine("liveliness_change.not_alive_count_change != '" +
                                                               inactiveCountChange + "', but '" + status.NotAliveCountChange + "'.");
                            }
                        }
                        else
                        {
                            System.Console.Error.WriteLine("liveliness_change.not_alive_count != '" + inactiveCount
                                                           + "', but '" + status.NotAliveCount + "'.");
                        }
                    }
                    else
                    {
                        System.Console.Error.WriteLine("liveliness_change.AliveCountChange != '" + activeCountChange
                                                       + "', but '" + status.AliveCountChange + "'.");
                    }
                }
                else
                {
                    System.Console.Error.WriteLine("liveliness_change.AliveCount != '" + activeCount
                                                   + "', but '" + status.AliveCount + "'.");
                }
            }
            else
            {
                System.Console.Error.WriteLine("get_liveliness_changed_status returned " + rc);
            }
            return(result);
        }
Beispiel #13
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.");
        }
Beispiel #14
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.");
 }
Beispiel #15
0
 public virtual void OnSampleRejected(DDS.IDataReader reader, DDS.SampleRejectedStatus
                                      status)
 {
     onSampleRejectedCalled = true;
     srStatus = status;
 }
Beispiel #16
0
 public virtual void OnLivelinessChanged(DDS.IDataReader reader, DDS.LivelinessChangedStatus
                                         status)
 {
     onLivelinessChangedCalled = true;
     lcStatus = status;
 }
Beispiel #17
0
 public virtual void OnDataAvailable(DDS.IDataReader reader)
 {
     onDataAvailableCalled = true;
 }
Beispiel #18
0
 public virtual void OnSubscriptionMatched(DDS.IDataReader reader, DDS.SubscriptionMatchedStatus
                                           status)
 {
     onSubscriptionMatchCalled = true;
     smStatus = status;
 }
Beispiel #19
0
 public virtual void OnRequestedIncompatibleQos(DDS.IDataReader reader, DDS.RequestedIncompatibleQosStatus
                                                status)
 {
     onRequestedIncompatibleQosCalled = true;
     riqStatus = status;
 }
Beispiel #20
0
        public override Test.Framework.TestResult Run()
        {
            mod.tstDataWriter         writer;
            mod.tstDataReader         reader;
            mod.tstDataReader         reader2;
            DDS.IReadCondition        condition;
            DDS.WaitSet               waitset;
            DDS.ISubscriber           subscriber;
            DDS.ICondition[]          activeConditions = null;
            Test.Framework.TestResult result;
            DDS.DataReaderQos         drQos;
            mod.tst[]        tstHolder;
            DDS.SampleInfo[] sampleInfoHolder;
            DDS.ITopic       topic;
            DDS.ReturnCode   rc;
            string           expResult = "ReadCondition test succeeded.";

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            writer     = (mod.tstDataWriter) this.ResolveObject("datawriter");
            reader     = (mod.tstDataReader) this.ResolveObject("datareader");
            subscriber = (DDS.ISubscriber) this.ResolveObject("subscriber");
            topic      = (DDS.ITopic) this.ResolveObject("topic");
            drQos      = (DDS.DataReaderQos) this.ResolveObject("datareaderQos");
            condition  = reader.CreateReadCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any,
                                                    DDS.InstanceStateKind.Any);
            if (condition == null)
            {
                result.Result = "Could not resolve reader condition.";
                return(result);
            }
            waitset = new DDS.WaitSet();
            rc      = waitset.AttachCondition(condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Could not attach condition.";
                return(result);
            }
            reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos); //, null, 0);
            if (reader2 == null)
            {
                result.Result = "Could not create datareader.";
                return(result);
            }

            activeConditions = new DDS.Condition[0];
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed(3).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (3).";
                return(result);
            }
            mod.tst data = new mod.tst();
            data.long_1 = 1;
            data.long_2 = 2;
            data.long_3 = 3;

            rc = writer.Write(data, 0);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataWriter.write failed.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "WaitSet.Wait failed.";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one.";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "WaitSet.Wait returned wrong condition.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "WaitSet.Wait failed(2).";
                return(result);
            }

            if (activeConditions.Length != 1)
            {
                result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(2).";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "WaitSet.Wait returned wrong condition(2).";
                return(result);
            }
            tstHolder        = new mod.tst[0];
            sampleInfoHolder = new DDS.SampleInfo[0];
            rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataReader.take failed.";
                return(result);
            }
            rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataReader.return_loan failed.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed.";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (2).";
                return(result);
            }
            rc = subscriber.DeleteDataReader(reader);
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "delete_datareader succeeded, but should not.";
                return(result);
            }
            rc = waitset.GetConditions(ref activeConditions);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "get_conditions failed.";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "Returned conditions not valid.";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "Returned condition does not equal set condition.";
                return(result);
            }
            DDS.IDataReader reader3 = condition.GetDataReader();
            if (reader != reader3)
            {
                result.Result = "ReadCondition.get_datareader failed.";
                return(result);
            }

            if (condition.GetInstanceStateMask() != DDS.InstanceStateKind.Any)
            {
                result.Result = "ReadCondition.get_instance_state_mask failed.";
                return(result);
            }

            if (condition.GetViewStateMask() != DDS.ViewStateKind.Any)
            {
                result.Result = "ReadCondition.get_view_state_mask failed.";
                return(result);
            }

            if (condition.GetSampleStateMask() != DDS.SampleStateKind.Any)
            {
                result.Result = "ReadCondition.get_sample_state_mask failed.";
                return(result);
            }
            rc = reader.DeleteReadCondition(condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_readcondition failed.";
                return(result);
            }
            rc = waitset.GetConditions(ref activeConditions);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "get_conditions failed(2).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "Returned conditions not valid(2).";
                return(result);
            }
            rc = subscriber.DeleteDataReader(reader);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_datareader failed.";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;

            return(result);
        }
Beispiel #21
0
 public virtual void OnSampleLost(DDS.IDataReader reader, DDS.SampleLostStatus status
                                  )
 {
     onSampleLostCalled = true;
     slStatus           = status;
 }
Beispiel #22
0
        public override Test.Framework.TestResult Run()
        {
            mod.tstDataWriter         writer;
            mod.tstDataReader         reader;
            mod.tstDataReader         reader2;
            DDS.IQueryCondition       condition;
            DDS.WaitSet               waitset;
            DDS.ISubscriber           subscriber;
            DDS.ICondition[]          activeConditions = new DDS.Condition[0];
            Test.Framework.TestResult result;
            DDS.DataReaderQos         drQos = null;
            mod.tst[]        tstHolder;
            DDS.SampleInfo[] sampleInfoHolder;
            string[]         queryParams;
            DDS.ITopic       topic;
            DDS.ReturnCode   rc;
            string           expression;

            string[] ssHolder;
            string   expResult = "QueryCondition test succeeded.";

            result = new Test.Framework.TestResult(expResult, string.Empty, Test.Framework.TestVerdict
                                                   .Pass, Test.Framework.TestVerdict.Fail);
            writer         = (mod.tstDataWriter) this.ResolveObject("datawriter");
            reader         = (mod.tstDataReader) this.ResolveObject("datareader");
            subscriber     = (DDS.ISubscriber) this.ResolveObject("subscriber");
            topic          = (DDS.ITopic) this.ResolveObject("topic");
            drQos          = (DDS.DataReaderQos) this.ResolveObject("datareaderQos");
            expression     = "long_1=%0";
            queryParams    = new string[1];
            queryParams[0] = "1";
            condition      = reader.CreateQueryCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any,
                                                         DDS.InstanceStateKind.Any, expression, queryParams);
            if (condition == null)
            {
                result.Result = "Could not create query condition.";
                return(result);
            }
            waitset = new DDS.WaitSet();
            rc      = waitset.AttachCondition(condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Could not attach condition.";
                return(result);
            }
            reader2 = (mod.tstDataReader)subscriber.CreateDataReader(topic, drQos); //, null, 0);
            if (reader2 == null)
            {
                result.Result = "Could not create datareader.";
                return(result);
            }

            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed(3).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (3).";
                return(result);
            }
            mod.tst data = new mod.tst();
            data.long_1 = 2;
            data.long_2 = 2;
            data.long_3 = 3;

            rc = writer.Write(data, 0);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataWriter.write failed.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed(3).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (4).";
                return(result);
            }
            data        = new mod.tst();
            data.long_1 = 1;
            data.long_2 = 2;
            data.long_3 = 3;

            rc = writer.Write(data, 0);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataWriter.write failed.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "WaitSet.Wait failed. ";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one.";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "WaitSet.Wait returned wrong condition.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "WaitSet.Wait failed(2).";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(2).";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "WaitSet.Wait returned wrong condition(2).";
                return(result);
            }
            tstHolder        = new mod.tst[0];
            sampleInfoHolder = new DDS.SampleInfo[0];

            rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataReader.take failed.";
                return(result);
            }
            rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataReader.return_loan failed.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed.";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (2).";
                return(result);
            }
            rc = subscriber.DeleteDataReader(reader);
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "delete_datareader succeeded, but should not.";
                return(result);
            }
            rc = waitset.GetConditions(ref activeConditions);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "get_conditions failed.";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "Returned conditions not valid.";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "Returned condition does not equal set condition.";
                return(result);
            }
            DDS.IDataReader reader3 = condition.GetDataReader();
            if (reader != reader3)
            {
                result.Result = "ReadCondition.get_datareader failed.";
                return(result);
            }

            if (condition.GetInstanceStateMask() != DDS.InstanceStateKind.Any)
            {
                result.Result = "ReadCondition.get_instance_state_mask failed.";
                return(result);
            }

            if (condition.GetViewStateMask() != DDS.ViewStateKind.Any)
            {
                result.Result = "ReadCondition.get_view_state_mask failed.";
                return(result);
            }

            if (condition.GetSampleStateMask() != DDS.SampleStateKind.Any)
            {
                result.Result = "ReadCondition.get_sample_state_mask failed.";
                return(result);
            }
            rc = reader.DeleteReadCondition(condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_readcondition failed.";
                return(result);
            }
            rc = waitset.GetConditions(ref activeConditions);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "get_conditions failed(2).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "Returned conditions not valid(2).";
                return(result);
            }
            queryParams    = new string[1];
            queryParams[0] = "1";
            condition      = reader.CreateQueryCondition(DDS.SampleStateKind.Any, DDS.ViewStateKind.Any,
                                                         DDS.InstanceStateKind.Any, "long_1=%0", queryParams);
            if (condition == null)
            {
                result.Result = "Could not create query condition.";
                return(result);
            }
            rc = waitset.AttachCondition(condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "Could not attach condition.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed(q1).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (q1).";
                return(result);
            }

            data        = new mod.tst();
            data.long_1 = 1;
            data.long_2 = 2;
            data.long_3 = 3;

            rc = writer.Write(data, 0);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataWriter.write failed(2).";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "WaitSet.Wait failed (q2). ";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(q2).";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "WaitSet.Wait returned wrong condition(q2).";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "WaitSet.Wait failed(2).";
                return(result);
            }
            if (activeConditions.Length != 1)
            {
                result.Result = "WaitSet.Wait returned no or multiple conditions where it should return one(q3).";
                return(result);
            }
            if (activeConditions[0] != condition)
            {
                result.Result = "WaitSet.Wait returned wrong condition(q3).";
                return(result);
            }
            tstHolder        = new mod.tst[0];
            sampleInfoHolder = new DDS.SampleInfo[0];

            rc = reader.TakeWithCondition(ref tstHolder, ref sampleInfoHolder, 1, condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataReader.take failed(q1).";
                return(result);
            }
            rc = reader.ReturnLoan(ref tstHolder, ref sampleInfoHolder);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "tstDataReader.return_loan failed.";
                return(result);
            }
            rc = waitset.Wait(ref activeConditions, new DDS.Duration(3, 0));
            if (rc != DDS.ReturnCode.Timeout)
            {
                result.Result = "WaitSet.Wait failed(q5).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "WaitSet.Wait returned conditions where it shouldn't (q6).";
                return(result);
            }
            string expression2 = condition.GetQueryExpression();

            if (!expression.Equals(expression2))
            {
                result.Result = "QueryCondition.get_query_expression does not work properly.";
                return(result);
            }
            ssHolder = new string[0];
            rc       = condition.GetQueryParameters(ref ssHolder);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "QueryCondition.get_query_parameters call failed.";
                return(result);
            }
            string[] queryParams2 = ssHolder;
            if (queryParams2 == null)
            {
                result.Result = "QueryCondition.get_query_parameters does not work properly (1).";
                return(result);
            }
            if (queryParams2.Length != queryParams.Length)
            {
                result.Result = "QueryCondition.get_query_parameters does not work properly (2).";
                return(result);
            }
            if (!queryParams2[0].Equals(queryParams[0]))
            {
                result.Result = "QueryCondition.get_query_parameters does not work properly (3).";
                return(result);
            }
            queryParams[0] = "5";
            rc             = condition.SetQueryParameters(queryParams);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "QueryCondition.set_query_parameters does not work properly.";
                return(result);
            }
            rc = condition.GetQueryParameters(ref ssHolder);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "QueryCondition.get_query_parameters call failed (1).";
                return(result);
            }
            queryParams2 = ssHolder;
            if (queryParams2 == null)
            {
                result.Result = "QueryCondition.get_query_parameters does not work properly (1).";
                return(result);
            }
            if (queryParams2.Length != queryParams.Length)
            {
                result.Result = "QueryCondition.get_query_parameters does not work properly (2).";
                return(result);
            }
            if (!queryParams2[0].Equals(queryParams[0]))
            {
                result.Result = "QueryCondition.get_query_parameters does not work properly (3).";
                return(result);
            }
            rc = condition.SetQueryParameters(null);
            if (rc == DDS.ReturnCode.Ok)
            {
                result.Result = "QueryCondition.set_query_parameters does not work properly (2).";
                this.testFramework.TestMessage(Test.Framework.TestMessage.Note, "See OSPL-2628: Query parameter checking should be added.");
                result.ExpectedVerdict = Test.Framework.TestVerdict.Fail;
                return(result);
            }
            rc = reader.DeleteReadCondition(condition);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_readcondition failed(q7).";
                return(result);
            }
            rc = waitset.GetConditions(ref activeConditions);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "get_conditions failed(q7).";
                return(result);
            }
            if (activeConditions.Length != 0)
            {
                result.Result = "Returned conditions not valid(q7).";
                return(result);
            }
            rc = subscriber.DeleteDataReader(reader);
            if (rc != DDS.ReturnCode.Ok)
            {
                result.Result = "delete_datareader failed.";
                return(result);
            }
            result.Result  = expResult;
            result.Verdict = Test.Framework.TestVerdict.Pass;
            return(result);
        }
Beispiel #23
0
 private void PrintStatusses(DDS.IDataReader reader)
 {
     DDS.ReturnCode rc;
     DDS.RequestedDeadlineMissedStatus rdmsHolder = new DDS.RequestedDeadlineMissedStatus();
     rc = reader.GetRequestedDeadlineMissedStatus(ref rdmsHolder);
     DDS.RequestedDeadlineMissedStatus rdms = rdmsHolder;
     if (rc != DDS.ReturnCode.Ok)
     {
         System.Console.Error.WriteLine("Unable to resolve status!");
         return;
     }
     DDS.RequestedIncompatibleQosStatus riqsHolder = new DDS.RequestedIncompatibleQosStatus();
     rc = reader.GetRequestedIncompatibleQosStatus(ref riqsHolder);
     DDS.RequestedIncompatibleQosStatus riqs = riqsHolder;
     if (rc != DDS.ReturnCode.Ok)
     {
         System.Console.Error.WriteLine("Unable to resolve status!");
         return;
     }
     DDS.SampleRejectedStatus srsHolder = new DDS.SampleRejectedStatus();
     rc = reader.GetSampleRejectedStatus(ref srsHolder);
     DDS.SampleRejectedStatus srs = srsHolder;
     if (rc != DDS.ReturnCode.Ok)
     {
         System.Console.Error.WriteLine("Unable to resolve status!");
         return;
     }
     DDS.LivelinessChangedStatus lcsHolder = new DDS.LivelinessChangedStatus();
     rc = reader.GetLivelinessChangedStatus(ref lcsHolder);
     DDS.LivelinessChangedStatus lcs = lcsHolder;
     if (rc != DDS.ReturnCode.Ok)
     {
         System.Console.Error.WriteLine("Unable to resolve status!");
         return;
     }
     DDS.SubscriptionMatchedStatus smsHolder = new DDS.SubscriptionMatchedStatus();
     rc = reader.GetSubscriptionMatchedStatus(ref smsHolder);
     DDS.SubscriptionMatchedStatus sms = smsHolder;
     if (rc != DDS.ReturnCode.Ok)
     {
         System.Console.Error.WriteLine("Unable to resolve status!");
         return;
     }
     DDS.SampleLostStatus slsHolder = new DDS.SampleLostStatus();
     rc = reader.GetSampleLostStatus(ref slsHolder);
     DDS.SampleLostStatus sls = slsHolder;
     if (rc != DDS.ReturnCode.Ok)
     {
         System.Console.Error.WriteLine("Unable to resolve status!");
         return;
     }
     System.Console.Out.WriteLine("requested_deadline_missed.TotalCount         : " +
                                  rdms.TotalCount);
     System.Console.Out.WriteLine("requested_deadline_missed.TotalCountChange  : " +
                                  rdms.TotalCountChange);
     System.Console.Out.WriteLine("requested_deadline_missed.LastInstanceHandle: " +
                                  rdms.LastInstanceHandle);
     System.Console.Out.WriteLine("requested_incompatible_qos.TotalCount        : " +
                                  riqs.TotalCount);
     System.Console.Out.WriteLine("requested_incompatible_qos.TotalCountChange : " +
                                  riqs.TotalCountChange);
     System.Console.Out.WriteLine("requested_incompatible_qos.LastPolicyId     : " +
                                  riqs.LastPolicyId);
     System.Console.Out.WriteLine("sample_rejected.TotalCount                   : " +
                                  srs.TotalCount);
     System.Console.Out.WriteLine("sample_rejected.TotalCountChange            : " +
                                  srs.TotalCountChange);
     System.Console.Out.WriteLine("sample_rejected.LastInstanceHandle          : " +
                                  srs.LastInstanceHandle);
     System.Console.Out.WriteLine("liveliness_changed.AliveCount                : " +
                                  lcs.AliveCount);
     System.Console.Out.WriteLine("liveliness_changed.AliveCountChange         : " +
                                  lcs.AliveCountChange);
     System.Console.Out.WriteLine("liveliness_changed.not_alive_count            : " +
                                  lcs.NotAliveCount);
     System.Console.Out.WriteLine("liveliness_changed.not_alive_count_change     : " +
                                  lcs.NotAliveCountChange);
     System.Console.Out.WriteLine("subscription_match.TotalCount                : " +
                                  sms.TotalCount);
     System.Console.Out.WriteLine("subscription_match.TotalCountChange         : " +
                                  sms.TotalCountChange);
     System.Console.Out.WriteLine("subscription_match.last_publication_handle    : " +
                                  sms.LastPublicationHandle);
     System.Console.Out.WriteLine("sample_lost.TotalCount                       : " +
                                  sls.TotalCount);
     System.Console.Out.WriteLine("sample_lost.TotalCountChange                : " +
                                  sls.TotalCountChange + "\n");
 }
Beispiel #24
0
 public virtual void OnRequestedDeadlineMissed(DDS.IDataReader reader, DDS.RequestedDeadlineMissedStatus
                                               status)
 {
     onRequestedDeadlineMissedCalled = true;
     rdmStatus = status;
 }