Exemplo n.º 1
0
        public ITopicDescription LookupTopicDescription(string name)
        {
            ITopicDescription topicDesc = null;

            IntPtr gapiPtr = Gapi.DomainParticipant.lookup_topicdescription(
                GapiPeer,
                name);

            if (gapiPtr != IntPtr.Zero)
            {
                // if the lookup fails, then we don't have a managed object for gapi object yet
                topicDesc = SacsSuperClass.fromUserData(gapiPtr) as ITopicDescription;

                if (topicDesc == null)
                {
                    if (IsBuiltinTopic(name))
                    {
                        topicDesc = BuiltinTopicCreateWrapper(name);
                    }
                    else
                    {
                        DDS.OpenSplice.OS.Report(
                            DDS.OpenSplice.ReportType.OS_ERROR,
                            "DDS.OpenSplice.DomainParticipant.LookupTopicDescription",
                            "DDS/OpenSplice/DomainParticipant.cs",
                            DDS.ErrorCode.EntityUnknown,
                            "TopicDescription Entity has no C# wrapper.");
                    }
                }
            }

            return(topicDesc);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This operation returns the DataReader associated with the ReadCondition.
        /// </summary>
        /// <returns>The DataReader associated with the ReadCondition.</returns>
        public IDataReader GetDataReader()
        {
            IntPtr      gapiPtr    = Gapi.ReadCondition.get_datareader(GapiPeer);
            IDataReader dataReader = SacsSuperClass.fromUserData(gapiPtr) as IDataReader;

            return(dataReader);
        }
Exemplo n.º 3
0
        public ITopicDescription GetTopicDescription()
        {
            IntPtr gapiPtr = Gapi.DataReader.get_topicdescription(GapiPeer);

            ITopicDescription topicDesc = SacsSuperClass.fromUserData(gapiPtr) as ITopicDescription;

            return(topicDesc);
        }
Exemplo n.º 4
0
        public IDomainParticipant GetParticipant()
        {
            IntPtr gapiPtr = Gapi.Publisher.get_participant(GapiPeer);

            IDomainParticipant domainParticipant = SacsSuperClass.fromUserData(gapiPtr)
                                                   as IDomainParticipant;

            return(domainParticipant);
        }
Exemplo n.º 5
0
        public IDataReader LookupDataReader(string topicName)
        {
            IntPtr gapiPtr = Gapi.Subscriber.lookup_datareader(
                GapiPeer,
                topicName);

            IDataReader dataReader = SacsSuperClass.fromUserData(gapiPtr) as IDataReader;

            return(dataReader);
        }
Exemplo n.º 6
0
        public IDataWriter LookupDataWriter(string topicName)
        {
            IntPtr gapiPtr = Gapi.Publisher.lookup_datawriter(
                GapiPeer,
                topicName);

            IDataWriter dataWriter = SacsSuperClass.fromUserData(gapiPtr) as IDataWriter;

            return(dataWriter);
        }
Exemplo n.º 7
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.º 8
0
        internal virtual ReturnCode Take(IntPtr sampleList)
        {
            uint mask = DataReader.StateMask(sampleState, viewState, instanceState);

            return(SacsSuperClass.uResultToReturnCode(
                       User.Reader.Take(
                           dataReader.rlReq_UserPeer,
                           mask,
                           Common.SampleList.ReaderAction,
                           sampleList, DDS.Duration.Zero.OsDuration)));
        }
Exemplo n.º 9
0
 internal static void Flush(SacsSuperClass obj, bool valid)
 {
     if (FlushRequired(valid) != 0)
     {
         StackFrame callStack = new StackFrame(1, true);
         int        domainId  = -1;
         if (obj != null)
         {
             domainId = obj.MyDomainId;
         }
         Flush(valid, getContext(callStack), getFileName(callStack), callStack.GetFileLineNumber(), domainId);
     }
 }
Exemplo n.º 10
0
        public ReturnCode BeginCoherentChanges()
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = SacsSuperClass.uResultToReturnCode(
                    User.Publisher.CoherentBegin(rlReq_UserPeer));
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

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

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = SacsSuperClass.uResultToReturnCode(
                    User.Publisher.Suspend(rlReq_UserPeer));
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 12
0
        public ITypeSupport LookupTypeSupport(string registeredTypeName)
        {
            ITypeSupport typeSupport = null;

            IntPtr gapiPtr = Gapi.DomainParticipant.lookup_typesupport(
                GapiPeer,
                registeredTypeName);

            if (gapiPtr != IntPtr.Zero)
            {
                typeSupport = SacsSuperClass.fromUserData(gapiPtr) as ITypeSupport;
            }

            return(typeSupport);
        }
Exemplo n.º 13
0
 static ErrorInfo()
 {
     IntPtr ptr = OpenSplice.Gapi.ErrorInfo.alloc();
     super = new SacsSuperClass();
     if (ptr != IntPtr.Zero)
     {
         super.SetPeer(ptr, true);
     }
     else
     {
         // Gapi already logged that the ErrorInfo has not been created
         // successfully. Now create a deliberate null pointer exception
         // to let the current constructor fail.
         throw new System.NullReferenceException("gapi_errorInfo__alloc returned a NULL pointer.");
     }
 }
Exemplo n.º 14
0
        internal static SacsSuperClass fromUserData(IntPtr gapiPtr)
        {
            SacsSuperClass entity = null;

            // Check whether the gapiPtr contains a valid pointer.
            if (gapiPtr != IntPtr.Zero)
            {
                // get the user data out of the gapi object
                IntPtr managedIntPtr = Gapi.Entity.get_user_data(gapiPtr);

                // Check whether the userData contains a valid pointer.
                if (managedIntPtr != IntPtr.Zero)
                {
                    // If so, get the relevant C# Object.
                    GCHandle tmpGCHandle = GCHandle.FromIntPtr(managedIntPtr);
                    entity = tmpGCHandle.Target as SacsSuperClass;
                }
            }

            return(entity);
        }
Exemplo n.º 15
0
        /// <summary>
        /// This operation sets the list of communication statuses that are taken into account to
        /// determine the trigger_value of the StatusCondition.
        /// </summary>
        /// <param name="mask">A bit mask in which each bit sets the status which is taken into
        /// account to determine the trigger_value of the StatusCondition</param>
        /// <returns>ReturnCode - Possible return codes of the operation are: Ok, Error or AlreadyDeleted.</returns>
        public ReturnCode SetEnabledStatuses(StatusKind mask)
        {
            uint       vMask;
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    vMask  = vEventMarshaler.vEventMaskFromStatusMask(mask);
                    result = SacsSuperClass.uResultToReturnCode(
                        User.StatusCondition.SetMask(rlReq_UserPeer, vMask));
                    if (result == DDS.ReturnCode.Ok)
                    {
                        enabledStatusMask = mask;
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 16
0
        public ReturnCode GetDataReaders(
            ref IDataReader[] readers,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                IntPtr iterp = IntPtr.Zero;
                uint   mask  = DataReader.StateMask(sampleStates, viewStates, instanceStates);

                result = uResultToReturnCode(User.Subscriber.GetDataReaders(this.rlReq_UserPeer, mask, ref iterp));
                if (result == ReturnCode.Ok)
                {
                    int length = Database.c.iterLength(iterp);
                    if (readers == null || readers.Length != length)
                    {
                        readers = new IDataReader[length];
                    }
                    for (int i = 0; i < length; i++)
                    {
                        IntPtr ureader = Database.c.iterTakeFirst(iterp);

                        readers [i] = SacsSuperClass.fromUserData(ureader) as IDataReader;
                    }
                    Database.c.iterFree(iterp);
                }
            }

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

            return(result);
        }
        internal void EventHandler(IntPtr EventPtr, IntPtr arg)
        {
            const uint topicTrigger  = (uint)(V_EVENT.INCONSISTENT_TOPIC | V_EVENT.ALL_DATA_DISPOSED);
            const uint writerTrigger = (uint)(V_EVENT.OFFERED_DEADLINE_MISSED | V_EVENT.LIVELINESS_LOST |
                                              V_EVENT.OFFERED_INCOMPATIBLE_QOS | V_EVENT.PUBLICATION_MATCHED);
            const uint readerTrigger = (uint)(V_EVENT.SAMPLE_REJECTED | V_EVENT.LIVELINESS_CHANGED |
                                              V_EVENT.SAMPLE_LOST | V_EVENT.REQUESTED_DEADLINE_MISSED |
                                              V_EVENT.REQUESTED_INCOMPATIBLE_QOS | V_EVENT.SUBSCRIPTION_MATCHED);

            // The DATA_AVAILABLE and DATA_ON_READERS events are left out of the readerTrigger because
            // they don't have a v_readerStatus that has to be copied.

            Debug.Assert(EventPtr != IntPtr.Zero);
            v_listenerEvent listenerEvent = Marshal.PtrToStructure(EventPtr, listenerEventType) as v_listenerEvent;

            if (listenerEvent.kind == (uint)V_EVENT.TRIGGER)
            {
                // Nothing to deliver, so ignore.
                return;
            }

            ListenerEvent ev = new ListenerEvent(listenerEvent.kind);

            ev.Source = SacsSuperClass.fromUserData(listenerEvent.source) as Entity;
            if (ev.Source == null)
            {
                // Apparently the Source Entity has already been deleted.
                return;
            }
            if ((listenerEvent.kind & (uint)(V_EVENT.OBJECT_DESTROYED | V_EVENT.PREPARE_DELETE)) == 0)
            {
                ev.Target = SacsSuperClass.fromUserData(listenerEvent.userData) as Entity;
                if (listenerEvent.eventData != IntPtr.Zero)
                {
                    if ((listenerEvent.kind & topicTrigger) != 0)
                    {
                        v_topicStatus vTopicStatus = (v_topicStatus)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_topicStatus)) as v_topicStatus;
                        TopicStatus   topicStatus  = new TopicStatus();
                        vTopicStatusMarshaler.CopyOut(ref vTopicStatus, topicStatus);
                        ev.Status = topicStatus;
                    }
                    else if ((listenerEvent.kind & writerTrigger) != 0)
                    {
                        v_writerStatus vWriterStatus = (v_writerStatus)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_writerStatus)) as v_writerStatus;
                        WriterStatus   writerStatus  = new WriterStatus();
                        vWriterStatusMarshaler.CopyOut(ref vWriterStatus, writerStatus);
                        ev.Status = writerStatus;
                    }
                    else if ((listenerEvent.kind & readerTrigger) != 0)
                    {
                        v_readerStatus vReaderStatus = (v_readerStatus)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_readerStatus)) as v_readerStatus;
                        ReaderStatus   readerStatus  = new ReaderStatus();
                        vReaderStatusMarshaler.CopyOut(ref vReaderStatus, readerStatus);
                        ev.Status = readerStatus;
                    }
                    else
                    {
                        v_status     vStatus = (v_status)Marshal.PtrToStructure(listenerEvent.eventData, typeof(v_status)) as v_status;
                        EntityStatus status  = new EntityStatus();
                        vStatusMarshaler.CopyOut(ref vStatus, status);
                        ev.Status = status;
                    }
                }
                else
                {
                    ev.Status = null;
                }
            }

            Events.Add(ev);
        }
Exemplo n.º 18
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)
                                {
                                    TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                                              as OpenSplice.TypeSupport;
                                    dataReader = typeSupport.CreateDataReader(gapiPtr);
                                    dataReader.SetListener(listenerHelper);
                                }
                            }
                        }
                        else
                        {
                            IntPtr gapiPtr = Gapi.Subscriber.create_datareader(
                                GapiPeer,
                                superObj.GapiPeer,
                                marshaler.GapiPtr,
                                IntPtr.Zero,
                                mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                                          as OpenSplice.TypeSupport;
                                dataReader = typeSupport.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);
        }
Exemplo n.º 19
0
        public IDataReader CreateDataReader(
            ITopicDescription topic,
            IDataReaderListener listener,
            StatusKind mask)
        {
            DataReader dataReader = null;

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

                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,
                            IntPtr.Zero,
                            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,
                        IntPtr.Zero,
                        IntPtr.Zero,
                        StatusKind.Any);
                    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);
        }