示例#1
0
        /// <summary>
        /// This operation creates a new IDomainParticipant which will join the domain
        /// identified by domainId, with the desired DomainParticipantQos and attaches
        /// the specified IDomainParticipantListener to it and uses the given communication
        /// StatusKind mask.
        /// </summary>
        /// <remarks>
        /// <i><b>Identifying the Domain</b></i><br>
        /// The IDomainParticipant will attach to the Domain that is specified by the
        /// domainId parameter. This parameter consists of an integer specified in the Id tag
        /// in the configuration file. Note that to make multiple connections to a Domain (create
        /// multiple Participants for the same Domain) within a single process, all of the
        /// Participants must use the same identification (i.e. all use the same domain Id).
        ///
        /// The constant DDS.DomainId.Default can be used for this parameter. If this is done
        /// the value of Id tag from the configuration file specified by the environment variable
        /// called OSPL_URI will be used.
        ///
        /// It is recommended to use this domain Id in conjunction with the OSPL_URI
        /// environment variable instead of hard-coding a domain Id into your application,
        /// since this gives you much more flexibility in the deployment phase of your product.<br>
        /// See also Section 1.3.2.1, The OSPL_URI environment variable, in the Deployment
        /// Guide.
        ///
        /// <i><b>Communication Status</b></i><br>
        /// For each communication status, the StatusChangedFlag flag is initially set to
        /// false. It becomes true whenever that communication status changes. For each
        /// communication status activated in the mask , the associated
        /// IDomainParticipantListener operation is invoked and the communication
        /// status is reset to false , as the listener implicitly accesses the status which is passed
        /// as a parameter to that operation. The fact that the status is reset prior to calling the
        /// listener means that if the application calls the Get<status_name>Status from
        /// inside the listener it will see the status already reset.
        ///
        /// The following statuses are applicable to the IDomainParticipant
        /// - DDS.StatusKind InconsistentTopic (propagated)
        /// - DDS.StatusKind OfferedDeadlineMissed (propagated)
        /// - DDS.StatusKind RequestedDeadlineMissed (propagated)
        /// - DDS.StatusKind OfferedIncompatibleQos (propagated)
        /// - DDS.StatusKind RequestedIncompatibleQos (propagated)
        /// - DDS.StatusKind SampleLost (propagated)
        /// - DDS.StatusKind SampleRejected (propagated)
        /// - DDS.StatusKind DataOnReaders (propagated)
        /// - DDS.StatusKind DataAvailable (propagated)
        /// - DDS.StatusKind LivelinessLost (propagated)
        /// - DDS.StatusKind LivelinessChanged (propagated)
        /// - DDS.StatusKind PublicationMatched (propagated)
        /// - DDS.StatusKind SubscriptionMatched (propagated)
        ///
        /// Be aware that the PublicationMatched and SubscriptionMatched
        /// statuses are not applicable when the infrastructure does not have the
        /// information available to determine connectivity. This is the case when OpenSplice
        /// is configured not to maintain discovery information in the Networking Service. (See
        /// the description for the NetworkingService/Discovery/enabled property in
        /// the Deployment Manual for more information about this subject.) In this case the
        /// operation will return NULL.
        ///
        /// Status bits are declared as a constant and can be used by the application in an OR
        /// operation to create a tailored mask. The special constant 0 can
        /// be used to indicate that the created entity should not respond to any of its available
        /// statuses. The DDS will therefore attempt to propagate these statuses to its factory.
        ///
        /// <i><b>Status Propagation</b></i><br>
        /// The Data Distribution Service will trigger the most specific and relevant Listener.<br>
        /// In other words, in case a communication status is also activated on the Listener of
        /// a contained entity, the Listener on that contained entity is invoked instead of the
        /// IDomainParticipantListener. This means that a status change on a contained
        /// entity only invokes the IDomainParticipantListener if the contained entity
        /// itself does not handle the trigger event generated by the status change.
        ///
        /// The statuses DataOnReaders and DataAvailable are
        /// “Read Communication Statuses” and are an exception to all other plain
        /// communication statuses: they have no corresponding status structure that can be
        /// obtained with a Get<status_name>Status operation and they are mutually
        /// exclusive. When new information becomes available to a IDataReader, the Data
        /// Distribution Service will first look in an attached and activated
        /// ISubscriberListener or IDomainParticipantListener (in that order) for the
        /// DataOnReaders. In case the DataOnReaders can not be
        /// handled, the Data Distribution Service will look in an attached and activated
        /// IDataReaderListener, ISubscriberListener or IDomainParticipantListener for
        /// the DataAvailable (in that order).
        /// </remarks>
        /// @param domainId The ID of the Domain to which the IDomainParticipant is joined.
        ///                 This should be the ID as specified in the configuration file.
        /// @param qos      a DomainParticipantQos for the new IDomainParticipant. When
        ///                 this set of QosPolicy settings is inconsistent, no
        ///                 IDomainParticipant is created.
        /// @param listener A IDomainParticipantListener instance which will be attached to
        ///                 the new IDomainParticipant. It is permitted to use null as the
        ///                 value of the listener: this behaves as a IDomainParticipantListener
        ///                 whose operations perform no action.
        /// @param mask     A bit-mask in which each bit enables the invocation of the
        ///                 IDomainParticipantListener for a certain status.
        /// @return The newly created IDomainParticipant. In case of an error a null is returned.
        public IDomainParticipant CreateParticipant(
            DomainId domainId,
            DomainParticipantQos qos,
            IDomainParticipantListener listener,
            StatusKind mask)
        {
            DomainParticipant participant = null;
            ReturnCode        result;

            ReportStack.Start();
            result = QosManager.checkQos(qos);
            if (result == DDS.ReturnCode.Ok)
            {
                if (domainId != DDS.DomainId.Invalid)
                {
                    lock (singleton_lock)
                    {
                        participant = new OpenSplice.DomainParticipant();
                        result      = participant.init(domainId, qos);
                        if (result == ReturnCode.Ok)
                        {
                            result = participant.SetListener(listener, mask);
                        }
                        else
                        {
                            participant = null;
                        }

                        if (result == ReturnCode.Ok)
                        {
                            participantList.Add(participant);
                            if (myQos.EntityFactory.AutoenableCreatedEntities)
                            {
                                result = participant.Enable();
                            }
                        }
                    }
                }
                else
                {
                    ReportStack.Report(DDS.ReturnCode.BadParameter,
                                       "DomainParticipant is using an invalid domain identifier (" + domainId + ").");
                }
            }

            if (result != ReturnCode.Ok && participant != null)
            {
                // Ignore result because we prefer the original error.
                DeleteParticipant(participant);
                participant = null;
            }

            ReportStack.Flush(null, result != ReturnCode.Ok);
            return(participant);
        }
示例#2
0
 internal ContentFilteredTopic(
     string typeName,
     string topicName,
     DomainParticipant domainParticipant,
     string filterExpression,
     string[] filterParameters)
 {
     this.typeName          = typeName;
     this.topicName         = topicName;
     this.domainParticipant = domainParticipant;
     this.filterExpression  = filterExpression;
     this.filterParameters  = filterParameters;
 }
示例#3
0
 internal MultiTopic(
     string typeName,
     string topicName,
     DomainParticipant domainParticipant,
     TypeSupport typeSupport,
     string subscriptionExpression,
     string[] subscriptionParameters)
 {
     this.typeName               = typeName;
     this.topicName              = topicName;
     this.domainParticipant      = domainParticipant;
     this.typeSupport            = typeSupport;
     this.subscriptionExpression = subscriptionExpression;
     this.subscriptionParameters = subscriptionParameters;
     MyDomainId = domainParticipant.MyDomainId;
 }
示例#4
0
        public IDomainParticipant GetParticipant()
        {
            bool isAlive;
            DomainParticipant participantObj = null;

            ReportStack.Start();
            lock (this)
            {
                isAlive = this.rlReq_isAlive;
                if (isAlive)
                {
                    participantObj = participant;
                }
            }
            ReportStack.Flush(this, !isAlive);

            return(participantObj);
        }
        public IDomainParticipant CreateParticipant(
            DomainId domainId,
            IDomainParticipantListener listener,
            StatusKind mask)
        {
            IDomainParticipant participant = null;
            string className = null;

             
            if (listener != null)
            {
                OpenSplice.Gapi.gapi_domainParticipantListener gapiListener;
                DomainParticipantListenerHelper listenerHelper = new DomainParticipantListenerHelper();
                listenerHelper.Listener = listener;
                listenerHelper.CreateListener(out gapiListener);
                using (DomainParticipantListenerMarshaler listenerMarshaler = 
                        new DomainParticipantListenerMarshaler(ref gapiListener))
                {
                    // Invoke the corresponding gapi function.
                    IntPtr gapiParticipant = OpenSplice.Gapi.DomainParticipantFactory.create_participant(
                            GapiPeer,
                            domainId,
                            OpenSplice.Gapi.NativeConstants.GapiParticipantQosDefault,
                            listenerMarshaler.GapiPtr,
                            mask,
                            IntPtr.Zero,
                            IntPtr.Zero,
                            IntPtr.Zero,
                            className);
                    if (gapiParticipant != IntPtr.Zero)
                    {
                        participant = new OpenSplice.DomainParticipant(gapiParticipant, listenerHelper);
                    }
                }
            }
            else
            {
                // Invoke the corresponding gapi function.
                IntPtr gapiParticipant = OpenSplice.Gapi.DomainParticipantFactory.create_participant(
                    GapiPeer,
                    domainId,
                    OpenSplice.Gapi.NativeConstants.GapiParticipantQosDefault,
                    IntPtr.Zero,
                    mask,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    className);

                if (gapiParticipant != IntPtr.Zero)
                {
                    participant = new OpenSplice.DomainParticipant(gapiParticipant);
                }
            }
            
            if (participant != null)
            {
                DomainParticipantFactoryQos dpfQos = null;
                ReturnCode result = GetQos(ref dpfQos);
                if (result == ReturnCode.Ok)
                {
                    if (dpfQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        participant.Enable();
                    }
                }
            }       
                
            return participant;
        }
示例#6
0
        /**
         * Register the four builtin topics:
         *     "DDS::ParticipantBuiltinTopicData"
         *     "DDS::TopicBuiltinTopicData"
         *     "DDS::PublicationBuiltinTopicData"
         *     "DDS::SubscriptionBuiltinTopicData"
         */
        internal static ReturnCode BuiltinTopicRegisterTypeSupport(DomainParticipant participant)
        {
            ReturnCode result;

            DDS.ParticipantBuiltinTopicDataTypeSupport DDSParticipant =
                    new DDS.ParticipantBuiltinTopicDataTypeSupport();
            result = DDSParticipant.RegisterType(participant, DDSParticipant.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                        DDS.OpenSplice.ReportType.OS_ERROR,
                        "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                        "DDS/OpenSplice/DomainParticipant.cs",
                        DDS.ErrorCode.Error,
                        "Failed to register builtin topic: DCPSParticipant");
            } else {
               participant.ParticipantDataMarshaler = DatabaseMarshaler.GetMarshaler(
                       participant, DDSParticipant.TypeSpec);
            }

            DDS.TopicBuiltinTopicDataTypeSupport DDSTopic =
                    new DDS.TopicBuiltinTopicDataTypeSupport();
            result = DDSTopic.RegisterType(participant, DDSTopic.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                        DDS.OpenSplice.ReportType.OS_ERROR,
                        "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                        "DDS/OpenSplice/DomainParticipant.cs",
                        DDS.ErrorCode.Error,
                        "Failed to register builtin topic: DCPSTopic");
            } else {
               participant.TopicDataMarshaler = DatabaseMarshaler.GetMarshaler(
                       participant, DDSTopic.TypeSpec);
            }

            DDS.PublicationBuiltinTopicDataTypeSupport DDSPublication =
                    new DDS.PublicationBuiltinTopicDataTypeSupport();
            result = DDSPublication.RegisterType(participant, DDSPublication.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                        DDS.OpenSplice.ReportType.OS_ERROR,
                        "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                        "DDS/OpenSplice/DomainParticipant.cs",
                        DDS.ErrorCode.Error,
                        "Failed to register builtin topic: DCPSPublication");
            }

            DDS.SubscriptionBuiltinTopicDataTypeSupport DDSSubscription =
                    new DDS.SubscriptionBuiltinTopicDataTypeSupport();
            result = DDSSubscription.RegisterType(participant, DDSSubscription.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                        DDS.OpenSplice.ReportType.OS_ERROR,
                        "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                        "DDS/OpenSplice/DomainParticipant.cs",
                        DDS.ErrorCode.Error,
                        "Failed to register builtin topic: DCPSSubscription");
            }
            return result;
        }
示例#7
0
        /**
         * Register the four builtin topics:
         *     "DDS::ParticipantBuiltinTopicData"
         *     "DDS::TopicBuiltinTopicData"
         *     "DDS::PublicationBuiltinTopicData"
         *     "DDS::SubscriptionBuiltinTopicData"
         */
        internal static ReturnCode BuiltinTopicRegisterTypeSupport(DomainParticipant participant)
        {
            ReturnCode result;

            DDS.ParticipantBuiltinTopicDataTypeSupport DDSParticipant =
                new DDS.ParticipantBuiltinTopicDataTypeSupport();
            result = DDSParticipant.RegisterType(participant, DDSParticipant.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSParticipant");
            }
            else
            {
                participant.ParticipantDataMarshaler = DatabaseMarshaler.GetMarshaler(
                    participant, DDSParticipant.TypeSpec);
            }

            DDS.TopicBuiltinTopicDataTypeSupport DDSTopic =
                new DDS.TopicBuiltinTopicDataTypeSupport();
            result = DDSTopic.RegisterType(participant, DDSTopic.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSTopic");
            }
            else
            {
                participant.TopicDataMarshaler = DatabaseMarshaler.GetMarshaler(
                    participant, DDSTopic.TypeSpec);
            }

            DDS.PublicationBuiltinTopicDataTypeSupport DDSPublication =
                new DDS.PublicationBuiltinTopicDataTypeSupport();
            result = DDSPublication.RegisterType(participant, DDSPublication.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSPublication");
            }

            DDS.SubscriptionBuiltinTopicDataTypeSupport DDSSubscription =
                new DDS.SubscriptionBuiltinTopicDataTypeSupport();
            result = DDSSubscription.RegisterType(participant, DDSSubscription.TypeName);
            if (result != ReturnCode.Ok)
            {
                DDS.OpenSplice.OS.Report(
                    DDS.OpenSplice.ReportType.OS_ERROR,
                    "DDS.OpenSplice.DomainParticipant.builtinTopicRegisterTypeSupport",
                    "DDS/OpenSplice/DomainParticipant.cs",
                    DDS.ErrorCode.Error,
                    "Failed to register builtin topic: DCPSSubscription");
            }
            return(result);
        }
        public IDomainParticipant CreateParticipant(
            string domainId,
            IDomainParticipantListener listener,
            StatusKind mask)
        {
            IDomainParticipant participant = null;

            if (listener != null)
            {
                OpenSplice.Gapi.gapi_domainParticipantListener gapiListener;
                DomainParticipantListenerHelper listenerHelper = new DomainParticipantListenerHelper();
                listenerHelper.Listener = listener;
                listenerHelper.CreateListener(out gapiListener);
                using (DomainParticipantListenerMarshaler listenerMarshaler =
                           new DomainParticipantListenerMarshaler(ref gapiListener))
                {
                    // Invoke the corresponding gapi function.
                    IntPtr gapiParticipant = OpenSplice.Gapi.DomainParticipantFactory.create_participant(
                        GapiPeer,
                        domainId,
                        OpenSplice.Gapi.NativeConstants.GapiParticipantQosDefault,
                        listenerMarshaler.GapiPtr,
                        mask,
                        IntPtr.Zero,
                        IntPtr.Zero,
                        IntPtr.Zero);
                    if (gapiParticipant != IntPtr.Zero)
                    {
                        participant = new OpenSplice.DomainParticipant(gapiParticipant, listenerHelper);
                    }
                }
            }
            else
            {
                // Invoke the corresponding gapi function.
                IntPtr gapiParticipant = OpenSplice.Gapi.DomainParticipantFactory.create_participant(
                    GapiPeer,
                    domainId,
                    OpenSplice.Gapi.NativeConstants.GapiParticipantQosDefault,
                    IntPtr.Zero,
                    mask,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero);

                if (gapiParticipant != IntPtr.Zero)
                {
                    participant = new OpenSplice.DomainParticipant(gapiParticipant);
                }
            }

            if (participant != null)
            {
                DomainParticipantFactoryQos dpfQos = null;
                ReturnCode result = GetQos(ref dpfQos);
                if (result == ReturnCode.Ok)
                {
                    if (dpfQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        participant.Enable();
                    }
                }
            }

            return(participant);
        }