/// <summary>
        /// This operation returns the Entity associated with the StatusCondition or a
        /// null Entity.
        /// </summary>
        /// <returns>IEntity - a pointer to the Entity associated with the StatusCondition.</returns>
        public IEntity GetEntity()
        {
            IntPtr  gapiPtr = OpenSplice.Gapi.StatusCondition.get_entity(GapiPeer);
            IEntity entity  = SacsSuperClass.fromUserData(gapiPtr) as IEntity;

            return(entity);
        }
        public IDomainParticipant LookupParticipant(string domainId)
        {
            IntPtr             gapiDP      = OpenSplice.Gapi.DomainParticipantFactory.lookup_participant(GapiPeer, domainId);
            IDomainParticipant participant = (IDomainParticipant)SacsSuperClass.fromUserData(gapiDP);

            return(participant);
        }
Exemple #3
0
        internal static void CopyOut(IntPtr from, ref TInterface[] to, int offset)
        {
            // Get _length field
            int length = BaseMarshaler.ReadInt32(from, offset + offset__length);

            // Initialize managed array to the correct size.
            // Initialize managed array to the correct size.
            if (to == null || to.Length != length)
            {
                to = new TInterface[length];
            }

            if (length > 0)
            {
                // Read the buffer pointer containing the sequence content
                IntPtr arrayPtr = BaseMarshaler.ReadIntPtr(from, offset + offset__buffer);

                for (int index = 0; index < length; index++)
                {
                    // Loop through the string pointers, deallocating each
                    IntPtr GapiPtr = BaseMarshaler.ReadIntPtr(arrayPtr, Size * index);
                    to[index] = (TInterface)(T)SacsSuperClass.fromUserData(GapiPtr);
                }
            }
        }
        internal new void DeleteEntityAction(IntPtr entityData, IntPtr userData)
        {
            // Translate the UserData pointer into a valid C# language object.
            SacsSuperClass entity = SacsSuperClass.fromUserData(entityData);

            // If the UserData contained a valid object, then destruct it.
            if (entity != null)
            {
                entity.Dispose();
            }
        }
        internal ReturnCode trigger(IntPtr context)
        {
            ReturnCode result;

            lock (this)
            {
                result = SacsSuperClass.uResultToReturnCode(
                    DDS.OpenSplice.User.WaitSet.Notify(rlReq_UserPeer, context));
                if (result != ReturnCode.Ok)
                {
                    ReportStack.Report(result, "WaitSet notify failed ");
                }
            }
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// This operation safely detaches the application from all domains it is currently
        /// participating in.
        /// </summary>
        /// <remarks>
        /// @note This is a proprietary OpenSplice extension.
        ///
        /// This operation safely detaches the application from all domains it is currently
        /// participating in. When this operation has been performed successfully,
        /// the application is no longer connected to any Domain.
        /// - For Federated domains finishing this operation successfully means that all shared
        /// memory segments have been safely un-mapped from the application process.
        /// - For SingleProcess mode domains this means all services for all domains have been
        /// stopped. This allows graceful termination of the OSPL services that run as threads
        /// within the application. Graceful termination of services in this mode would for
        /// instance allow durability flushing of persistent data and networking termination
        /// announcement over the network.
        ///
        /// When this call returns further access to all domains will be denied and it will
        /// not be possible for the application to open or re-open any DDS domain.
        ///
        /// The behavior of the DetachAllDomains operation is determined by the blockOperations
        /// and deleteEntities parameters:<br>
        /// - blockOperations:
        ///     This parameter specifies if the application wants any DDS operation to be blocked
        ///     or not while detaching. When true, any DDS operation called during this operation
        ///     will be blocked and remain blocked forever (so also after the detach operation has
        ///     completed and returns to the caller). When false, any DDS operation called during
        ///     this operation may return AlreadyDeleted. Please note that a listener
        ///     callback is not considered an operation in progress. Of course, if a DDS operation
        ///     is called from within the listener callback, that operation will be blocked
        ///     during the detaching if this attribute is set to true.
        /// - deleteEntities:
        ///     This parameter specifies if the application wants the DDS entities created by
        ///     the application to be deleted (synchronously) while detaching from the domain or
        ///     not. If true, all application entities are guaranteed to be deleted when the call
        ///     returns. If false, application entities will not explicitly be deleted by this
        ///     operation. In case of federated mode, the splice-daemon will delete them
        ///     asynchronously after this operation has returned. In case of SingleProcess mode
        ///     this attribute is ignored and clean up will always be performed, as this cannot
        ///     be delegated to a different process.
        ///
        /// @note In federated mode when the DetachAllDomains operation is called with
        /// blockOperations is false and deleteEntities is false then the DDS operations
        /// which are in progress and which are waiting for some condition to become true
        /// or waiting for an event to occur while the detach operation is performed may be
        /// blocked.
        /// </remarks>
        /// @param blockOperations
        ///   Indicates whether the application wants any operations that are called while
        ///   detaching to be blocked or not.
        /// @param deleteEntities
        ///   Indicates whether the application DDS entities in the 'connected' domains must
        ///   be deleted synchronously during detaching.
        /// @return DDS.ReturnCode Ok - The application is detached from all domains
        public ReturnCode DetachAllDomains(bool blockOperations, bool deleteEntities)
        {
            uint flags = 0;

            if (blockOperations)
            {
                flags |= DDS.OpenSplice.User.u.BLOCK_OPERATIONS;
            }
            if (deleteEntities)
            {
                flags |= DDS.OpenSplice.User.u.DELETE_ENTITIES;
            }

            return(SacsSuperClass.uResultToReturnCode(DDS.OpenSplice.User.u.userDetach(flags)));
        }
        /**
         * Condition specific callback from GuardConditions to WaitSet.
         */
        internal ReturnCode wlReq_DetachGuardCondition(IGuardCondition guardCond)
        {
            ReturnCode result;

            Debug.Assert(guardList.Contains(guardCond));
            result = SacsSuperClass.uResultToReturnCode(
                DDS.OpenSplice.User.WaitSet.Notify(rlReq_UserPeer, IntPtr.Zero));
            if (result == DDS.ReturnCode.Ok)
            {
                guardList.Remove(guardCond);
            }
            else
            {
                ReportStack.Report(result, "Could not detach GuardCondition from WaitSet.");
            }
            return(result);
        }
Exemple #8
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.");
            }
        }
        /**
         * Condition specific callback from non-GuardConditions to WaitSet.
         */
        internal ReturnCode wlReq_DetachGeneralCondition(ICondition condition, IntPtr uCondition)
        {
            ReturnCode result;

            Debug.Assert(conditionList.Contains(condition));
            result = SacsSuperClass.uResultToReturnCode(
                DDS.OpenSplice.User.WaitSet.Detach(
                    rlReq_UserPeer, uCondition));
            if (result == DDS.ReturnCode.Ok)
            {
                conditionList.Remove(condition);
                MyDomainId = DDS.OpenSplice.User.WaitSet.GetDomainId(rlReq_UserPeer);
            }
            else
            {
                ReportStack.Report(result, "Could not detach Condition from WaitSet.");
            }
            return(result);
        }
        /// <summary>
        /// This operation allows an application thread to wait for the occurrence of at least one
        /// of the conditions that is attached to the WaitSet.
        /// </summary>
        /// <param name="activeConditions">a sequence which is used to pass the list of all the attached
        /// conditions that have a trigger_value of true.</param>
        /// <param name="timeout">the maximum duration to block for the wait, after which the application thread
        /// is unblocked. The special constant Infinite can be used when the maximum waiting time does not
        /// need to be bounded.</param>
        /// <returns>Possible return codes for the operation are:
        /// Ok, Error, OutOfResources, Timeout or PreconditionNotMet</returns>
        public ReturnCode Wait(ref ICondition[] activeConditions, Duration timeout)
        {
            ReturnCode result = DDS.ReturnCode.Ok;

            ReportStack.Start();
            WaitActionArg arg = new WaitActionArg(activeConditions);

            if (QosManager.countErrors(timeout) > 0)
            {
                result = DDS.ReturnCode.BadParameter;
                ReportStack.Report(result, "Duration timeout incorrect");
            }

            while (result == DDS.ReturnCode.Ok && arg.nrTriggeredConditions == 0)
            {
                lock (this)
                {
                    arg.maxConditions  = conditionList.Count + guardList.Count;
                    arg.attachedGuards = guardList.ToArray();
                    if (activeConditions == null)
                    {
                        activeConditions = new ICondition[arg.maxConditions];
                    }
                }

                GCHandle argGCHandle = GCHandle.Alloc(arg, GCHandleType.Normal);

                V_RESULT uResult = DDS.OpenSplice.User.WaitSet.WaitAction2(
                    rlReq_UserPeer,
                    WaitAction,
                    GCHandle.ToIntPtr(argGCHandle),
                    timeout.OsDuration);

                if (uResult == V_RESULT.DETACHING)
                {
                    arg = (WaitActionArg)argGCHandle.Target;
                    lock (this)
                    {
                        foreach (ICondition cond in conditionList)
                        {
                            Condition condImpl = cond as Condition;
                            if (condImpl.IsAlive() == DDS.ReturnCode.AlreadyDeleted)
                            {
                                arg.Add(cond);
                            }
                        }
                    }
                    result = DDS.ReturnCode.Ok;
                }
                else
                {
                    result = SacsSuperClass.uResultToReturnCode(uResult);
                    arg    = (WaitActionArg)argGCHandle.Target;
                }

                argGCHandle.Free();

                activeConditions = arg.Finalize();
            }
            ReportStack.Flush(this, (result != ReturnCode.Ok) && (result != ReturnCode.Timeout));

            return(result);
        }