Exemplo n.º 1
0
        public ReturnCode SetQos(DataReaderQos qos)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();

            if (this.rlReq_isAlive)
            {
                result = QosManager.checkQos(qos);
                if (result == DDS.ReturnCode.Ok)
                {
                    using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                               new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
                    {
                        result = marshaler.CopyIn(qos);
                        if (result == ReturnCode.Ok)
                        {
                            result = uResultToReturnCode(
                                User.DataReader.SetQos(rlReq_UserPeer, marshaler.UserPtr));
                            if (result != ReturnCode.Ok)
                            {
                                ReportStack.Report(result, "Could not apply DataReaderQos.");
                            }
                        }
                        else
                        {
                            ReportStack.Report(result, "Could not copy DataReaderQos.");
                        }
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 2
0
        public ReturnCode SetDefaultDataReaderQos(DataReaderQos 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.DataReaderQosMarshaler marshaler =
                                   new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
                        {
                            result = marshaler.CopyIn(qos);
                            if (result == ReturnCode.Ok)
                            {
                                marshaler.CopyOut(ref defaultDataReaderQos);
                            }
                        }
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 3
0
        public ReturnCode GetQos(ref DataReaderQos qos)
        {
            ReturnCode result  = DDS.ReturnCode.AlreadyDeleted;
            IntPtr     userQos = IntPtr.Zero;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = uResultToReturnCode(
                    User.DataReader.GetQos(rlReq_UserPeer, ref userQos));
                if (result == ReturnCode.Ok)
                {
                    using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                               new OpenSplice.CustomMarshalers.DataReaderQosMarshaler(userQos, true))
                    {
                        marshaler.CopyOut(ref qos);
                    }
                }
                else
                {
                    ReportStack.Report(result, "Could not copy DataReaderQos.");
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 4
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.º 5
0
        internal Subscriber()
        {
            DDS.ReturnCode result;

            using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                       new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
            {
                result = marshaler.CopyIn(QosManager.defaultDataReaderQos);
                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref defaultDataReaderQos);
                }
            }
        }
Exemplo n.º 6
0
        public ReturnCode GetQos(ref DataReaderQos qos)
        {
            ReturnCode result;

            using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                       new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
            {
                result = Gapi.DataReader.get_qos(GapiPeer, marshaler.GapiPtr);
                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref qos);
                }
            }

            return(result);
        }
Exemplo n.º 7
0
        public ReturnCode SetDefaultDataReaderQos(DataReaderQos qos)
        {
            DDS.ReturnCode result;

            using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                       new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
            {
                result = marshaler.CopyIn(qos);
                if (result == DDS.ReturnCode.Ok)
                {
                    return(OpenSplice.Gapi.Subscriber.set_default_datareader_qos(
                               GapiPeer,
                               marshaler.GapiPtr));
                }
            }

            return(result);
        }
Exemplo n.º 8
0
        public ReturnCode CopyFromTopicQos(ref DataReaderQos dataReaderQos, TopicQos topicQos)
        {
            ReturnCode result = ReturnCode.Ok;

            if (dataReaderQos == null)
            {
                result = GetDefaultDataReaderQos(ref dataReaderQos);
            }

            if (result == ReturnCode.Ok)
            {
                using (OpenSplice.CustomMarshalers.TopicQosMarshaler marshaler =
                           new OpenSplice.CustomMarshalers.TopicQosMarshaler())
                {
                    result = marshaler.CopyIn(topicQos);
                    if (result == ReturnCode.Ok)
                    {
                        using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler dataReaderMarshaler =
                                   new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
                        {
                            result = dataReaderMarshaler.CopyIn(dataReaderQos);
                            if (result == ReturnCode.Ok)
                            {
                                result = OpenSplice.Gapi.Subscriber.copy_from_topic_qos(
                                    GapiPeer,
                                    dataReaderMarshaler.GapiPtr,
                                    marshaler.GapiPtr);

                                if (result == ReturnCode.Ok)
                                {
                                    dataReaderMarshaler.CopyOut(ref dataReaderQos);
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 9
0
        public IDataReader CreateDataReader(
            ITopicDescription topic,
            DataReaderQos qos,
            IDataReaderListener listener,
            StatusKind mask)
        {
            DataReader dataReader = null;

            if (topic != null)
            {
                SacsSuperClass superObj = (SacsSuperClass)topic;

                using (OpenSplice.CustomMarshalers.DataReaderQosMarshaler marshaler =
                           new OpenSplice.CustomMarshalers.DataReaderQosMarshaler())
                {
                    if (marshaler.CopyIn(qos) == ReturnCode.Ok)
                    {
                        if (listener != null)
                        {
                            OpenSplice.Gapi.gapi_dataReaderListener gapiListener;
                            DataReaderListenerHelper listenerHelper = new DataReaderListenerHelper();
                            listenerHelper.Listener = listener;
                            listenerHelper.CreateListener(out gapiListener);
                            using (DataReaderListenerMarshaler listenerMarshaler =
                                       new DataReaderListenerMarshaler(ref gapiListener))
                            {
                                IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                    GapiPeer,
                                    superObj.GapiPeer,
                                    marshaler.GapiPtr,
                                    listenerMarshaler.GapiPtr,
                                    mask);
                                if (gapiPtr != IntPtr.Zero)
                                {
                                    DDS.OpenSplice.DomainParticipant participantImpl;

                                    participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                                    TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                                    dataReader = tsFactory.CreateDataReader(gapiPtr);
                                    dataReader.SetListener(listenerHelper);
                                }
                            }
                        }
                        else
                        {
                            IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                GapiPeer,
                                superObj.GapiPeer,
                                marshaler.GapiPtr,
                                IntPtr.Zero,
                                mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                DDS.OpenSplice.DomainParticipant participantImpl;

                                participantImpl = topic.Participant as DDS.OpenSplice.DomainParticipant;
                                TypeSupportFactory tsFactory = participantImpl.GetTypeSupportFactory(topic.TypeName);
                                dataReader = tsFactory.CreateDataReader(gapiPtr);
                            }
                        }
                    }
                }
            }

            if (dataReader != null)
            {
                SubscriberQos subQos = null;
                ReturnCode    result = GetQos(ref subQos);
                if (result == ReturnCode.Ok)
                {
                    if (subQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataReader.Enable();
                    }
                }
            }

            return(dataReader);
        }