Exemplo n.º 1
0
        public ReturnCode WaitForHistoricalData(Duration maxWait)
        {
            ReturnCode result;

            ReportStack.Start();
            if (QosManager.countErrors(maxWait) > 0)
            {
                result = DDS.ReturnCode.BadParameter;
            }
            else
            {
                if (this.rlReq_isAlive)
                {
                    result = uResultToReturnCode(
                        User.DataReader.WaitForHistoricalData(rlReq_UserPeer, maxWait.OsDuration));
                }
                else
                {
                    result = DDS.ReturnCode.AlreadyDeleted;
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 2
0
        internal override ReturnCode wlReq_deinit()
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            if (writerList.Count == 0)
            {
                IPublisherListener pubListener = listener as IPublisherListener;
                if (pubListener != null)
                {
                    this.SetListener(pubListener, (DDS.StatusKind) 0);
                }
                this.DisableCallbacks();
                result = base.wlReq_deinit();
                if (result == DDS.ReturnCode.Ok)
                {
                    this.participant = null;
                }
            }
            else
            {
                result = DDS.ReturnCode.PreconditionNotMet;
                ReportStack.Report(result, "Publisher " + this + " cannot be deleted since it still contains " +
                                   writerList.Count + " DataWriters.");
            }
            return(result);
        }
Exemplo n.º 3
0
        public ReturnCode SetDefaultDataWriterQos(DataWriterQos qos)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    result = QosManager.checkQos(qos);
                    if (result == DDS.ReturnCode.Ok)
                    {
                        using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler =
                                   new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
                        {
                            result = marshaler.CopyIn(qos);
                            if (result == ReturnCode.Ok)
                            {
                                marshaler.CopyOut(ref defaultDataWriterQos);
                            }
                        }
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 4
0
        public ReturnCode GetMatchedSubscriptionData(
            ref SubscriptionBuiltinTopicData subscriptionData,
            InstanceHandle subscriptionHandle)
        {
            ReturnCode result = DDS.ReturnCode.BadParameter;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                if (subscriptionHandle != InstanceHandle.Nil)
                {
                    GCHandle dataGCHandle = GCHandle.Alloc(subscriptionData, GCHandleType.Normal);
                    result = uResultToReturnCode(
                        User.Writer.GetMatchedSubscriptionData(
                            rlReq_UserPeer,
                            subscriptionHandle,
                            CopyMatchedSubscriptionData,
                            GCHandle.ToIntPtr(dataGCHandle)));
                    subscriptionData = dataGCHandle.Target as SubscriptionBuiltinTopicData;
                    dataGCHandle.Free();
                }
                else
                {
                    result = ReturnCode.BadParameter;
                    ReportStack.Report(result, "subscriptionHandle = DDS.InstanceHandle.Nil.");
                }
            }
            else
            {
                result = DDS.ReturnCode.AlreadyDeleted;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 5
0
        public virtual InstanceHandle RegisterInstance(
            T instanceData,
            Time sourceTimestamp)
        {
            ReturnCode     result = DDS.ReturnCode.BadParameter;
            InstanceHandle handle = DDS.InstanceHandle.Nil;

            ReportStack.Start();
            if ((sourceTimestamp == Time.Current) ||
                (QosManager.countErrors(sourceTimestamp) == 0))
            {
                long     uHandle     = handle;
                GCHandle tmpGCHandle = GCHandle.Alloc(instanceData, GCHandleType.Normal);
                result = uResultToReturnCode(
                    User.Writer.RegisterInstance(
                        rlReq_UserPeer,
                        sampleMarshaler.CopyIn,
                        GCHandle.ToIntPtr(tmpGCHandle),
                        sourceTimestamp.OsTimeW,
                        ref uHandle));
                handle = uHandle;
                tmpGCHandle.Free();
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(handle);
        }
Exemplo n.º 6
0
        public virtual ReturnCode Write(
            T instanceData,
            InstanceHandle instanceHandle,
            Time sourceTimestamp)
        {
            ReturnCode result = DDS.ReturnCode.BadParameter;

            ReportStack.Start();
            if ((sourceTimestamp == Time.Current) ||
                (QosManager.countErrors(sourceTimestamp)) == 0)
            {
                GCHandle tmpGCHandle = GCHandle.Alloc(instanceData, GCHandleType.Normal);
                result = uResultToReturnCode(
                    User.Writer.Write(
                        rlReq_UserPeer,
                        sampleMarshaler.CopyIn,
                        GCHandle.ToIntPtr(tmpGCHandle),
                        sourceTimestamp.OsTimeW,
                        instanceHandle));
                tmpGCHandle.Free();
            }
            ReportStack.Flush(this, (result != ReturnCode.Ok) && (result != ReturnCode.Timeout));

            return(result);
        }
Exemplo n.º 7
0
        internal ReturnCode init(Topic relatedTopic)
        {
            ReturnCode result;

            MyDomainId = relatedTopic.MyDomainId;

            this.relatedTopic = relatedTopic;
            lock (relatedTopic)
            {
                if (relatedTopic.rlReq_isAlive)
                {
                    result = relatedTopic.ValidateFilter(filterExpression, filterParameters);
                    if (result == DDS.ReturnCode.Ok)
                    {
                        ITopicDescriptionImpl relatedTopicDescr = relatedTopic as ITopicDescriptionImpl;
                        relatedTopicDescr.wlReq_IncrNrUsers();
                        this.topicExpression = relatedTopicDescr.rlReq_TopicExpression + " where " + this.filterExpression;
                        this.typeSupport     = relatedTopicDescr.rlReq_TypeSupport;
                        result = base.init(IntPtr.Zero, false);
                    }
                }
                else
                {
                    result = DDS.ReturnCode.BadParameter;
                    ReportStack.Report(result, "ContentFilteredTopic \"" + topicName + "\" is referring to an already deleted topic.");
                }
            }
            return(result);
        }
Exemplo n.º 8
0
        public ReturnCode SetExpressionParameters(params string[] expressionParameters)
        {
            ReturnCode result = DDS.ReturnCode.Unsupported;

            ReportStack.Start();

//            using (SequenceStringToArrMarshaler marshaler = new SequenceStringToArrMarshaler())
//            {
//                result = WriteLock();
//                if (result == DDS.ReturnCode.Ok)
//                {
//                    result = marshaler.CopyIn(expressionParameters);
//                    if (result == ReturnCode.Ok)
//                    {
//                        result = uResultToReturnCode(
//                                User.ContentFilteredTopic.Set(rlReq_UserPeer, marshaler.UserPtr, (uint) expressionParameters.Length));
//                        if (result == ReturnCode.Ok)
//                        {
//                            marshaler.CopyOut(ref this.filterParameters); // Make deep copy.
//                        }
//                    }
//                    WriteUnlock();
//                }
//            }
            ReportStack.Report(result, "Operation not yet supported.");
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 9
0
        internal override ReturnCode wlReq_deinit()
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            if (nrUsers > 0)
            {
                result = DDS.ReturnCode.PreconditionNotMet;
                ReportStack.Report(result, "Topic \"" + topicName + "\" still in use by " + nrUsers + " Writers/Readers.");
            }
            else
            {
                ITopicListener tpListener = listener as ITopicListener;
                if (tpListener != null)
                {
                    this.SetListener(tpListener, (DDS.StatusKind) 0);
                }
                this.DisableCallbacks();
                result = base.wlReq_deinit();
                if (result == DDS.ReturnCode.Ok)
                {
                    this.domainParticipant = null;
                    this.topicName         = null;
                    this.typeName          = null;
                    this.typeSupport       = null;
                    this.topicExpression   = null;
                }
            }
            return(result);
        }
Exemplo n.º 10
0
        internal override ReturnCode wlReq_deinit()
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            if (conditionList.Count == 0)
            {
                IDataReaderListener drListener = listener as IDataReaderListener;
                if (drListener != null)
                {
                    this.SetListener(drListener, (DDS.StatusKind) 0);
                }
                this.DisableCallbacks();

                result = base.wlReq_deinit();
                if (result == DDS.ReturnCode.Ok)
                {
                    if (this.topic != null)
                    {
                        result = this.topic.DecrNrUsers();
                        if (result == DDS.ReturnCode.Ok)
                        {
                            this.topic = null;
                        }
                        this.subscriber = null;
                    }
                }
            }
            else
            {
                result = DDS.ReturnCode.PreconditionNotMet;
                ReportStack.Report(result, "DataReader " + this + " cannot be deleted since it still contains " +
                                   conditionList.Count + " Read/QueryConditions.");
            }
            return(result);
        }
Exemplo n.º 11
0
        public ReturnCode CopyFromTopicQos(ref DataWriterQos dataWriterQos, TopicQos topicQos)
        {
            ReturnCode result = DDS.ReturnCode.BadParameter;

            ReportStack.Start();
            if (topicQos != null)
            {
                if (dataWriterQos == null)
                {
                    GetDefaultDataWriterQos(ref dataWriterQos);
                }
                dataWriterQos.Durability        = topicQos.Durability;
                dataWriterQos.Deadline          = topicQos.Deadline;
                dataWriterQos.LatencyBudget     = topicQos.LatencyBudget;
                dataWriterQos.Liveliness        = topicQos.Liveliness;
                dataWriterQos.Reliability       = topicQos.Reliability;
                dataWriterQos.DestinationOrder  = topicQos.DestinationOrder;
                dataWriterQos.History           = topicQos.History;
                dataWriterQos.ResourceLimits    = topicQos.ResourceLimits;
                dataWriterQos.TransportPriority = topicQos.TransportPriority;
                dataWriterQos.Lifespan          = topicQos.Lifespan;
                dataWriterQos.Ownership         = topicQos.Ownership;
                result = DDS.ReturnCode.Ok;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 12
0
        internal ReturnCode init(DomainParticipant participant, string name, PublisherQos qos)
        {
            ReturnCode result;

            ReportStack.Start();
            MyDomainId = participant.MyDomainId;
            using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                       new OpenSplice.CustomMarshalers.PublisherQosMarshaler())
            {
                result = marshaler.CopyIn(qos);
                if (result == ReturnCode.Ok)
                {
                    IntPtr uPublisher = User.Publisher.New(participant.rlReq_UserPeer, name, marshaler.UserPtr, 0);
                    if (uPublisher != IntPtr.Zero)
                    {
                        result = base.init(uPublisher);
                    }
                    else
                    {
                        result = DDS.ReturnCode.Error;
                        ReportStack.Report(result, "Could not create Publisher.");
                    }
                }
            }

            if (result == ReturnCode.Ok)
            {
                this.participant = participant;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 13
0
        public virtual ReturnCode ReturnLoan(
            ref T[] data,
            ref SampleInfo[] sampleInfos)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    if (data != null && sampleInfos != null)
                    {
                        if (data.Length == sampleInfos.Length)
                        {
                            data        = null;
                            sampleInfos = null;
                            result      = DDS.ReturnCode.Ok;
                        }
                        else
                        {
                            result = DDS.ReturnCode.PreconditionNotMet;
                            ReportStack.Report(result, "data and sampleInfo arrays have unequal length");
                        }
                    }
                    else
                    {
                        result = DDS.ReturnCode.PreconditionNotMet;
                        ReportStack.Report(result, "data and/or sampleInfo arrays may not be null");
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 14
0
        public ReturnCode SetQos(PublisherQos qos)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = QosManager.checkQos(qos);
                if (result == DDS.ReturnCode.Ok)
                {
                    using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                               new OpenSplice.CustomMarshalers.PublisherQosMarshaler())
                    {
                        result = marshaler.CopyIn(qos);
                        if (result == ReturnCode.Ok)
                        {
                            result = uResultToReturnCode(
                                User.Publisher.SetQos(rlReq_UserPeer, marshaler.UserPtr));
                            if (result != ReturnCode.Ok)
                            {
                                ReportStack.Report(result, "Could not apply PublisherQos.");
                            }
                        }
                        else
                        {
                            ReportStack.Report(result, "Could not copy PublisherQos.");
                        }
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 15
0
        public ReturnCode GetQos(ref PublisherQos qos)
        {
            IntPtr     userQos = IntPtr.Zero;
            ReturnCode result  = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = uResultToReturnCode(
                    User.Publisher.GetQos(rlReq_UserPeer, ref userQos));
                if (result == ReturnCode.Ok)
                {
                    using (OpenSplice.CustomMarshalers.PublisherQosMarshaler marshaler =
                               new OpenSplice.CustomMarshalers.PublisherQosMarshaler(userQos, true))
                    {
                        marshaler.CopyOut(ref qos);
                    }
                }
                else
                {
                    ReportStack.Report(result, "Could not copy PublisherQos.");
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 16
0
        public ReturnCode GetMatchedPublications(ref InstanceHandle[] publicationHandles)
        {
            ReturnCode result;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                List <InstanceHandle> handleList = new List <InstanceHandle>();
                GCHandle listGCHandle            = GCHandle.Alloc(handleList, GCHandleType.Normal);
                result = uResultToReturnCode(
                    User.Reader.GetMatchedPublications(
                        rlReq_UserPeer,
                        CopyMatchedPublication,
                        GCHandle.ToIntPtr(listGCHandle)));
                handleList         = listGCHandle.Target as List <InstanceHandle>;
                publicationHandles = handleList.ToArray();
                listGCHandle.Free();
            }
            else
            {
                result = DDS.ReturnCode.AlreadyDeleted;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 17
0
        public ReturnCode DeleteContainedEntities()
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    result = DDS.ReturnCode.Ok;
                    foreach (DataWriter dw in writerList)
                    {
                        result = dw.deinit();
                        if (result != DDS.ReturnCode.Ok)
                        {
                            break;
                        }
                    }

                    if (result == DDS.ReturnCode.Ok)
                    {
                        writerList.Clear();
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 18
0
        public ReturnCode NotifyDataReaders()
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    foreach (DataReader dr in readerList)
                    {
                        if (dr != null)
                        {
                            if ((dr.StatusChanges & StatusKind.DataAvailable) != 0)
                            {
                                DDS.IDataReaderListener readerListener = dr.Listener;
                                if (readerListener != null)
                                {
                                    readerListener.OnDataAvailable(dr);
                                }
                            }
                        }
                        else
                        {
                            result = DDS.ReturnCode.Error;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 19
0
        public ReturnCode GetMatchedPublicationData(
            ref PublicationBuiltinTopicData publicationData,
            InstanceHandle publicationHandle)
        {
            ReturnCode result;

            ReportStack.Start();
            if (publicationHandle != InstanceHandle.Nil)
            {
                if (this.rlReq_isAlive)
                {
                    GCHandle dataGCHandle = GCHandle.Alloc(publicationData, GCHandleType.Normal);
                    result = uResultToReturnCode(
                        User.Reader.GetMatchedPublicationData(
                            rlReq_UserPeer,
                            publicationHandle,
                            CopyMatchedPublicationData,
                            GCHandle.ToIntPtr(dataGCHandle)));
                    publicationData = dataGCHandle.Target as PublicationBuiltinTopicData;
                    dataGCHandle.Free();
                }
                else
                {
                    result = DDS.ReturnCode.AlreadyDeleted;
                }
            }
            else
            {
                result = DDS.ReturnCode.BadParameter;
                ReportStack.Report(result, "publication_handle 'HANDLE_NIL' is invalid.");
            }

            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 20
0
        internal ReturnCode init(
            IntPtr uTopic,
            DomainParticipant participant,
            string topicName,
            string typeName,
            TypeSupport ts)
        {
            MyDomainId = participant.MyDomainId;

            ReturnCode result = base.init(uTopic);

            if (result == DDS.ReturnCode.Ok)
            {
                this.domainParticipant = participant;
                this.topicName         = topicName;
                this.typeName          = typeName;
                this.typeSupport       = ts;
                this.topicExpression   = "select * from " + topicName;
            }
            else
            {
                ReportStack.Report(result, "Could not create Topic" + topicName + ".");
            }


            return(result);
        }
Exemplo n.º 21
0
        public ReturnCode GetSampleLostStatus(ref SampleLostStatus status)
        {
            ReturnCode result;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                if (status == null)
                {
                    status = new SampleLostStatus();
                }
                GCHandle statusGCHandle = GCHandle.Alloc(status, GCHandleType.Normal);
                result = uResultToReturnCode(
                    User.Reader.GetSampleLostStatus(
                        rlReq_UserPeer, 1, SampleLostStatusMarshaler.CopyOut, GCHandle.ToIntPtr(statusGCHandle)));
                status = statusGCHandle.Target as SampleLostStatus;
                statusGCHandle.Free();
            }
            else
            {
                result = DDS.ReturnCode.AlreadyDeleted;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 22
0
        public ReturnCode DeleteContainedEntities()
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    result = DDS.ReturnCode.Ok;
                    foreach (ReadCondition rc in conditionList)
                    {
                        result = rc.deinit();
                        if (result != DDS.ReturnCode.Ok)
                        {
                            break;
                        }
                    }

                    if (result == DDS.ReturnCode.Ok)
                    {
                        conditionList.Clear();
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 23
0
        public ReturnCode DeleteDataWriter(IDataWriter dataWriter)
        {
            DataWriter dwObj  = dataWriter as DataWriter;
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    if (dwObj != null)
                    {
                        if (writerList.Remove(dwObj))
                        {
                            result = dwObj.deinit();
                            if (result != ReturnCode.Ok)
                            {
                                writerList.Add(dwObj);
                            }
                        }
                        else
                        {
                            /* The DataWriter can be AlreadyDeleted, or it can be from another
                             * Publisher. Its liveliness cannot be modified without the lock
                             * of its factory, so we are safe checking it here since we hold
                             * the lock to this factory. If the DataWriter is from another
                             * publisher, then the result may be PRECONDITION_NOT_MET while
                             * it should have been BAD_PARAMETER, but such a Use Case has
                             * an inherent race-condition anyway, and the result of such
                             * a test is by definition undefined.
                             */
                            if (dwObj.rlReq_isAlive)
                            {
                                result = ReturnCode.PreconditionNotMet;
                                ReportStack.Report(result, "DataWriter " + dwObj + " unknown to Publisher " + this + ".");
                            }
                            else
                            {
                                // ALREADY_DELETED may only apply to the Publisher in this context,
                                // so for a deleted datawriter use BAD_PARAMETER instead.
                                result = DDS.ReturnCode.BadParameter;
                                ReportStack.Report(result, "DataWriter " + dwObj + " was already deleted.");
                            }
                        }
                    }
                    else
                    {
                        result = ReturnCode.BadParameter;
                        ReportStack.Report(result, "datawriter is invalid (null), or not of type " +
                                           "DDS::OpenSplice::DataWriter.");
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 24
0
        public ReturnCode DeleteReadCondition(IReadCondition condition)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    ReadCondition condObj = condition as ReadCondition;
                    if (condObj != null)
                    {
                        if (conditionList.Remove(condObj))
                        {
                            result = condObj.deinit();
                            if (result != DDS.ReturnCode.Ok)
                            {
                                conditionList.Add(condObj);
                            }
                        }
                        else
                        {
                            /* The ReadCondition can be AlreadyDeleted, or it can be from another
                             * DataReader. Its liveliness cannot be modified without the lock
                             * of its factory, so we are safe checking it here since we hold
                             * the lock to this factory. If the ReadCondition is from another
                             * DataReader, then the result may be PRECONDITION_NOT_MET while
                             * it should have been BAD_PARAMETER, but such a Use Case has
                             * an inherent race-condition anyway, and the result of such
                             * a test is by definition undefined.
                             */
                            if (condObj.rlReq_isAlive)
                            {
                                result = ReturnCode.PreconditionNotMet;
                                ReportStack.Report(result, "ReadCondition " + condObj + " unknown to DataReader " + this + ".");
                            }
                            else
                            {
                                // ALREADY_DELETED may only apply to the DataReader in this context,
                                // so for a deleted readcondition use BAD_PARAMETER instead.
                                result = DDS.ReturnCode.BadParameter;
                                ReportStack.Report(result, "ReadCondition " + condObj + " was already deleted.");
                            }
                        }
                    }
                    else
                    {
                        result = DDS.ReturnCode.BadParameter;
                        ReportStack.Report(result, "ReadCondition " + condObj + " is of unknown type.");
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 25
0
        public ReturnCode Enable()
        {
            ReportStack.Start();

            DDS.ReturnCode result = uResultToReturnCode(
                User.Entity.Enable(rlReq_UserPeer));

            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 26
0
        public ReturnCode EndCoherentChanges()
        {
            ReportStack.Start();
            ReturnCode result = SacsSuperClass.uResultToReturnCode(
                User.Publisher.CoherentEnd(rlReq_UserPeer));

            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 27
0
        internal virtual ReturnCode init(Subscriber subscriber, DataReaderQos drQos, ITopicDescriptionImpl aTopic, string drName)
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            MyDomainId = subscriber.MyDomainId;

            using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler qosMarshaler =
                       new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
            {
                result = qosMarshaler.CopyIn(drQos);
                if (result == ReturnCode.Ok)
                {
                    using (SequenceStringToCValueArrMarshaler paramsMarshaler = new SequenceStringToCValueArrMarshaler())
                    {
                        string[] _params = aTopic.rlReq_TopicExpressionParameters;
                        result = paramsMarshaler.CopyIn(_params);
                        if (result == ReturnCode.Ok)
                        {
                            IntPtr uReader = User.DataReader.NewBySQL(
                                subscriber.rlReq_UserPeer,
                                drName,
                                aTopic.rlReq_TopicExpression,
                                paramsMarshaler.UserPtr,
                                _params == null ? 0 : Convert.ToUInt32(_params.Length),
                                qosMarshaler.UserPtr);
                            if (uReader != IntPtr.Zero)
                            {
                                result = base.init(uReader);
                            }
                            else
                            {
                                ReportStack.Report(result, "Could not allocate memory.");
                                result = DDS.ReturnCode.OutOfResources;
                            }
                        }
                        else
                        {
                            ReportStack.Report(result, "Could not create DataReader.");
                        }
                    }
                }
                else
                {
                    ReportStack.Report(result, "Could not copy DataReaderQos.");
                }
            }
            if (result == ReturnCode.Ok)
            {
                this.subscriber = subscriber;
                this.topic      = aTopic;
                aTopic.wlReq_IncrNrUsers();
            }

            return(result);
        }
Exemplo n.º 28
0
        public virtual ReturnCode TakeNextInstance(
            ref T[] data,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            InstanceHandle instanceHandle,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            ReturnCode result;

            ReportStack.Start();
            IntPtr sampleList = Common.SampleList.New(0);

            if (sampleList == IntPtr.Zero)
            {
                result = DDS.ReturnCode.OutOfResources;
                ReportStack.Report(result, "Unable to allocate sampleList.");
            }
            else
            {
                lock (this)
                {
                    if (this.rlReq_isAlive)
                    {
                        result = CheckReaderPreConditions(data, sampleInfos, maxSamples, sampleStates, viewStates, instanceStates);
                        if (result == DDS.ReturnCode.Ok)
                        {
                            uint mask    = StateMask(sampleStates, viewStates, instanceStates);
                            int  realMax = RealMaxSamples(data, maxSamples);
                            Common.SampleList.Reset(sampleList, realMax);
                            result = uResultToReturnCode(
                                User.Reader.TakeNextInstance(
                                    rlReq_UserPeer,
                                    instanceHandle,
                                    mask,
                                    Common.SampleList.ReaderAction,
                                    sampleList, DDS.Duration.Zero.OsDuration));
                        }
                    }
                    else
                    {
                        result = DDS.ReturnCode.AlreadyDeleted;
                    }
                }
                if (result == DDS.ReturnCode.Ok || result == ReturnCode.NoData)
                {
                    result = ReaderCopy(sampleList, ref data, ref sampleInfos);
                }
                Common.SampleList.Free(sampleList);
            }
            ReportStack.Flush(this, (result != ReturnCode.Ok) && (result != ReturnCode.NoData));
            return(result);
        }
Exemplo n.º 29
0
        public virtual ReturnCode TakeNextInstanceWithCondition(
            ref T[] data,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            InstanceHandle instanceHandle,
            IReadCondition condition)
        {
            ReturnCode    result;
            ReadCondition rcObj = condition as ReadCondition;

            ReportStack.Start();
            if (rcObj == null)
            {
                result = DDS.ReturnCode.BadParameter;
                ReportStack.Report(result, "condition is invalid (null), or not of type " +
                                   "DDS::OpenSplice::ReadCondition.");
            }
            else
            {
                IntPtr sampleList = Common.SampleList.New(0);
                if (sampleList == IntPtr.Zero)
                {
                    result = DDS.ReturnCode.OutOfResources;
                    ReportStack.Report(result, "Unable to allocate sampleList.");
                }
                else
                {
                    lock (this)
                    {
                        if (this.rlReq_isAlive)
                        {
                            result = wlReq_CheckReaderPreConditions(data, sampleInfos, maxSamples, rcObj);
                            if (result == DDS.ReturnCode.Ok)
                            {
                                int realMax = RealMaxSamples(data, maxSamples);
                                Common.SampleList.Reset(sampleList, realMax);
                                result = rcObj.TakeNextInstance(instanceHandle, sampleList);
                            }
                        }
                        else
                        {
                            result = DDS.ReturnCode.AlreadyDeleted;
                        }
                    }
                    if (result == DDS.ReturnCode.Ok || result == ReturnCode.NoData)
                    {
                        result = ReaderCopy(sampleList, ref data, ref sampleInfos);
                    }
                    Common.SampleList.Free(sampleList);
                }
            }
            ReportStack.Flush(this, (result != ReturnCode.Ok) && (result != ReturnCode.NoData));
            return(result);
        }
Exemplo n.º 30
0
        public ReturnCode WaitForHistoricalDataWithCondition(
            string filterExpression,
            string[] filterParameters,
            Time minSourceTimeStamp,
            Time maxSourceTimeStamp,
            ResourceLimitsQosPolicy resourceLimits,
            Duration maxWait)
        {
            ReturnCode result;

            ReportStack.Start();
            if (QosManager.countErrors(minSourceTimeStamp) > 0 ||
                QosManager.countErrors(maxSourceTimeStamp) > 0 ||
                QosManager.countErrors(resourceLimits) > 0 ||
                QosManager.countErrors(maxWait) > 0)
            {
                result = DDS.ReturnCode.BadParameter;
                ReportStack.Report(result, "Invalid function parameter(s) passed.");
            }
            else
            {
                if (this.rlReq_isAlive)
                {
                    using (SequenceStringToArrMarshaler marshaler = new SequenceStringToArrMarshaler())
                    {
                        result = marshaler.CopyIn(filterParameters);
                        if (result == ReturnCode.Ok)
                        {
                            uint length = filterParameters == null ? 0 : (uint)filterParameters.Length;
                            result = uResultToReturnCode(
                                User.DataReader.WaitForHistoricalDataWithCondition(
                                    rlReq_UserPeer,
                                    filterExpression,
                                    marshaler.UserPtr,
                                    length,
                                    minSourceTimeStamp.OsTimeW,
                                    maxSourceTimeStamp.OsTimeW,
                                    resourceLimits.MaxSamples,
                                    resourceLimits.MaxInstances,
                                    resourceLimits.MaxSamplesPerInstance,
                                    maxWait.OsDuration));
                        }
                    }
                }
                else
                {
                    result = DDS.ReturnCode.AlreadyDeleted;
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }