Beispiel #1
0
        public static ReturnCode Take(
            DataReader reader,
            ref object[] data,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            ReturnCode result = ReturnCode.Ok;

            using (DataReaderMarshaler marshaler =
                       new DataReaderMarshaler(data, sampleInfos, ref maxSamples, ref result))
            {
                if (result == ReturnCode.Ok)
                {
                    result = Gapi.FooDataReader.take(
                        reader.GapiPeer,
                        marshaler.dataValuesPtr,
                        marshaler.sampleInfosPtr,
                        maxSamples,
                        sampleStates,
                        viewStates,
                        instanceStates);

                    marshaler.CopyOut(ref data, ref sampleInfos);
                }
            }
            return(result);
        }
Beispiel #2
0
 public static extern IntPtr create_querycondition(
     IntPtr _this,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states,
     string query_expression,
     IntPtr query_parameters);
Beispiel #3
0
        public IQueryCondition CreateQueryCondition(
                SampleStateKind sampleStates, 
                ViewStateKind viewStates,
                InstanceStateKind instanceStates, 
                string queryExpression, 
                params string[] queryParameters)
        {
            IQueryCondition queryCondition = null;

            using (SequenceStringMarshaler marshaler = new SequenceStringMarshaler())
            {
                if (marshaler.CopyIn(queryParameters) == DDS.ReturnCode.Ok)
                {
                    IntPtr gapiPtr = Gapi.DataReader.create_querycondition(
                            GapiPeer,
                            sampleStates,
                            viewStates,
                            instanceStates,
                            queryExpression,
                            marshaler.GapiPtr);

                    if (gapiPtr != IntPtr.Zero)
                    {
                        queryCondition = new QueryCondition(gapiPtr);
                    }
                }
            }

            return queryCondition;
        }
Beispiel #4
0
        public IQueryCondition CreateQueryCondition(
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates,
            string queryExpression,
            params string[] queryParameters)
        {
            IQueryCondition queryCondition = null;

            using (SequenceStringMarshaler marshaler = new SequenceStringMarshaler())
            {
                if (marshaler.CopyIn(queryParameters) == DDS.ReturnCode.Ok)
                {
                    IntPtr gapiPtr = Gapi.DataReader.create_querycondition(
                        GapiPeer,
                        sampleStates,
                        viewStates,
                        instanceStates,
                        queryExpression,
                        marshaler.GapiPtr);

                    if (gapiPtr != IntPtr.Zero)
                    {
                        queryCondition = new QueryCondition(gapiPtr);
                    }
                }
            }

            return(queryCondition);
        }
Beispiel #5
0
        public ReturnCode GetDataReaders(
            ref IDataReader[] readers,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            ReturnCode result = ReturnCode.Error;

            using (SequenceMarshaler <IDataReader, DataReader> marshaler =
                       new SequenceMarshaler <IDataReader, DataReader>())
            {
                result = Gapi.Subscriber.get_datareaders(
                    GapiPeer,
                    marshaler.GapiPtr,
                    sampleStates,
                    viewStates,
                    instanceStates);

                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref readers);
                }
            }

            return(result);
        }
Beispiel #6
0
        public static ReturnCode Take(
                DataReader reader, 
                ref object[] data, 
                ref SampleInfo[] sampleInfos, 
                int maxSamples,
                SampleStateKind sampleStates, 
                ViewStateKind viewStates, 
                InstanceStateKind instanceStates)
        {
            ReturnCode result = ReturnCode.Ok;
            using (DataReaderMarshaler marshaler = 
                    new DataReaderMarshaler(data, sampleInfos, ref maxSamples, ref result))
            {
                if (result == ReturnCode.Ok)
                {

                    result = Gapi.FooDataReader.take(
                            reader.GapiPeer,
                            marshaler.dataValuesPtr,
                            marshaler.sampleInfosPtr,
                            maxSamples,
                            sampleStates,
                            viewStates,
                            instanceStates);

                    marshaler.CopyOut(ref data, ref sampleInfos);
                }
            }
            return result;
        }
Beispiel #7
0
 public static extern IntPtr create_querycondition(
     IntPtr _this,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states,
     string query_expression,
     IntPtr query_parameters);
Beispiel #8
0
 public static extern ReturnCode take(
     IntPtr _this,
     IntPtr data_values,
     IntPtr info_seq,
     int max_samples,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #9
0
 public static extern ReturnCode read(
     IntPtr _this,
     IntPtr data_values,
     IntPtr info_seq,
     int max_samples,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #10
0
 public static uint StateMask(
     SampleStateKind sampleStates,
     ViewStateKind viewStates,
     InstanceStateKind instanceStates)
 {
     return((uint)(sampleStates & SAMPLE_STATE_FLAGS) |
            ((uint)(viewStates & VIEW_STATE_FLAGS) << 2) |
            ((uint)(instanceStates & INSTANCE_STATE_FLAGS) << 4));
 }
Beispiel #11
0
 public static extern ReturnCode read_next_instance(
     IntPtr _this,
     IntPtr data_values,
     IntPtr info_seq,
     int max_samples,
     InstanceHandle a_handle,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #12
0
 public ReturnCode Take(
     ref FDM[] dataValues,
     ref SampleInfo[] sampleInfos,
     SampleStateKind sampleStates,
     ViewStateKind viewStates,
     InstanceStateKind instanceStates)
 {
     return(Take(ref dataValues, ref sampleInfos, Length.Unlimited, sampleStates,
                 viewStates, instanceStates));
 }
        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);
        }
Beispiel #14
0
 internal QueryCondition(
     DataReader dataReader,
     SampleStateKind sampleState,
     ViewStateKind viewState,
     InstanceStateKind instanceState,
     string queryExpression,
     string[] queryParameters)
     : base(dataReader, sampleState, viewState, instanceState)
 {
     this.queryExpression = queryExpression;
     this.queryParameters = queryParameters;
 }
 internal ReadCondition(
     DataReader dataReader,
     SampleStateKind sampleState,
     ViewStateKind viewState,
     InstanceStateKind instanceState)
 {
     this.dataReader    = dataReader;
     this.sampleState   = sampleState;
     this.viewState     = viewState;
     this.instanceState = instanceState;
     this.MyDomainId    = dataReader.MyDomainId;
 }
Beispiel #16
0
        public IReadCondition CreateReadCondition(
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            ReadCondition readCondition = null;
            ReturnCode    result        = DDS.ReturnCode.AlreadyDeleted;
            IntPtr        uQuery;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    if (SampleStateMaskIsValid(sampleStates) &&
                        ViewStateMaskIsValid(viewStates) &&
                        InstanceStateMaskIsValid(instanceStates))
                    {
                        uint stateMask = StateMask(sampleStates, viewStates, instanceStates);
                        uQuery = User.Query.New(rlReq_UserPeer, null, "1=1", IntPtr.Zero, 0, stateMask);
                        if (uQuery != IntPtr.Zero)
                        {
                            readCondition = new ReadCondition(this, sampleStates, viewStates, instanceStates);
                            result        = readCondition.init(uQuery);
                            if (result == ReturnCode.Ok)
                            {
                                conditionList.Add(readCondition);
                            }
                            else
                            {
                                ReportStack.Report(result, "Could not create ReadCondition.");
                                readCondition = null;
                            }
                        }
                        else
                        {
                            result = DDS.ReturnCode.Error;
                            ReportStack.Report(result, "Unable to create ReadCondition in kernel.");
                        }
                    }
                    else
                    {
                        result = DDS.ReturnCode.BadParameter;
                        ReportStack.Report(result, "One mor more of your SampleState/ViewState/InstanceState masks are invalid.");
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(readCondition);
        }
        public ReturnCode Take(
            ref T[] dataValues,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            var        objectValues = (object[])((object)dataValues);
            ReturnCode result       = FooDataReader.Take(
                this, ref objectValues, ref sampleInfos, maxSamples, sampleStates, viewStates, instanceStates);

            dataValues = (T[])((object)objectValues);
            return(result);
        }
        public ReturnCode Read(
            ref T[] dataValues,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            // dataValues.Cast<object>().ToArray()
            var        objectValues = (object[])((object)dataValues);
            ReturnCode result       = FooDataReader.Read(
                this, ref objectValues, ref sampleInfos, maxSamples, sampleStates, viewStates, instanceStates);

            dataValues = (T[])((object)objectValues);
            return(result);
        }
        internal ReturnCode CheckReaderPreConditions(
            T[] data,
            SampleInfo[] sampleInfos,
            int maxSamples,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            ReturnCode result;

            if (maxSamples >= Length.Unlimited)
            {
                if (DataReader.SampleStateMaskIsValid(sampleStates) &&
                    DataReader.ViewStateMaskIsValid(viewStates) &&
                    DataReader.InstanceStateMaskIsValid(instanceStates))
                {
                    if ((data == null && sampleInfos == null) ||
                        (data != null && sampleInfos != null && data.Length == sampleInfos.Length))
                    {
                        if (data == null || data.Length == 0 ||
                            maxSamples == DDS.Length.Unlimited || data.Length >= maxSamples)
                        {
                            result = DDS.ReturnCode.Ok;
                        }
                        else
                        {
                            result = DDS.ReturnCode.PreconditionNotMet;
                        }
                    }
                    else
                    {
                        result = DDS.ReturnCode.PreconditionNotMet;
                    }
                }
                else
                {
                    result = DDS.ReturnCode.BadParameter;
                }
            }
            else
            {
                result = DDS.ReturnCode.BadParameter;
            }
            return(result);
        }
        /// <summary>
        /// This operation returns the set of instance_states that are taken into account to
        /// determine the trigger_value of the ReadCondition.
        /// </summary>
        /// <returns>The instance_states specified when the ReadCondition was created.</returns>
        public InstanceStateKind GetInstanceStateMask()
        {
            bool isAlive;
            InstanceStateKind isk = 0;

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

            return(isk);
        }
Beispiel #21
0
        public IReadCondition CreateReadCondition(
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            IReadCondition readCondition = null;

            IntPtr gapiPtr = Gapi.DataReader.create_readcondition(
                GapiPeer,
                sampleStates,
                viewStates,
                instanceStates);

            if (gapiPtr != IntPtr.Zero)
            {
                readCondition = new ReadCondition(gapiPtr);
            }

            return(readCondition);
        }
Beispiel #22
0
        public ReturnCode Take(
            ref FDM[] dataValues,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            object[]   objectValues = dataValues;
            ReturnCode result       =
                DDS.OpenSplice.FooDataReader.Take(
                    this,
                    ref objectValues,
                    ref sampleInfos,
                    maxSamples,
                    sampleStates,
                    viewStates,
                    instanceStates);

            dataValues = (FDM[])objectValues;
            return(result);
        }
        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);
        }
Beispiel #24
0
        public ReturnCode ReadNextInstance(
            ref Msg[] dataValues,
            ref SampleInfo[] sampleInfos,
            int maxSamples,
            InstanceHandle instanceHandle,
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates)
        {
            object[]   objectValues = dataValues;
            ReturnCode result       =
                DDS.OpenSplice.FooDataReader.ReadNextInstance(
                    this,
                    ref objectValues,
                    ref sampleInfos,
                    maxSamples,
                    instanceHandle,
                    sampleStates,
                    viewStates,
                    instanceStates);

            dataValues = (Msg[])objectValues;
            return(result);
        }
Beispiel #25
0
 public static extern ReturnCode take_next_instance(
     IntPtr _this,
     IntPtr data_values,
     IntPtr info_seq,
     int max_samples,
     InstanceHandle a_handle,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #26
0
        public ReturnCode GetDataReaders(
                ref IDataReader[] readers, 
                SampleStateKind sampleStates,
                ViewStateKind viewStates, 
                InstanceStateKind instanceStates)
        {
            ReturnCode result = ReturnCode.Error;

            using (SequenceMarshaler<IDataReader, DataReader> marshaler =
                    new SequenceMarshaler<IDataReader, DataReader>())
            {
                result = Gapi.Subscriber.get_datareaders(
                        GapiPeer,
                        marshaler.GapiPtr,
                        sampleStates,
                        viewStates,
                        instanceStates);

                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref readers);
                }
            }

            return result;
        }
Beispiel #27
0
        public IReadCondition CreateReadCondition(
                SampleStateKind sampleStates, 
                ViewStateKind viewStates,
                InstanceStateKind instanceStates)
        {
            IReadCondition readCondition = null;

            IntPtr gapiPtr = Gapi.DataReader.create_readcondition(
                    GapiPeer,
                    sampleStates,
                    viewStates,
                    instanceStates);

            if (gapiPtr != IntPtr.Zero)
            {
                readCondition = new ReadCondition(gapiPtr);
            }

            return readCondition;
        }
Beispiel #28
0
 public static extern ReturnCode get_datareaders(
     IntPtr _this,
     IntPtr readers,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #29
0
 public static extern ReturnCode get_datareaders(
     IntPtr _this,
     IntPtr readers,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #30
0
 public static extern IntPtr create_readcondition(
     IntPtr _this,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #31
0
 public static bool InstanceStateMaskIsValid(InstanceStateKind mask)
 {
     return(((mask == InstanceStateKind.Any) || ((mask & ~INSTANCE_STATE_FLAGS) == 0)));
 }
Beispiel #32
0
 public static extern IntPtr create_readcondition(
     IntPtr _this,
     SampleStateKind sample_states,
     ViewStateKind view_states,
     InstanceStateKind instance_states);
Beispiel #33
0
        public IQueryCondition CreateQueryCondition(
            SampleStateKind sampleStates,
            ViewStateKind viewStates,
            InstanceStateKind instanceStates,
            string queryExpression,
            params string[] queryParameters)
        {
            QueryCondition queryCondition = null;
            ReturnCode     result         = DDS.ReturnCode.AlreadyDeleted;
            IntPtr         uQuery;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    using (SequenceStringToArrMarshaler marshaler = new SequenceStringToArrMarshaler())
                    {
                        result = marshaler.CopyIn(queryParameters);
                        if (result == ReturnCode.Ok)
                        {
                            if (SampleStateMaskIsValid(sampleStates) &&
                                ViewStateMaskIsValid(viewStates) &&
                                InstanceStateMaskIsValid(instanceStates))
                            {
                                uint stateMask = StateMask(sampleStates, viewStates, instanceStates);
                                uQuery = User.Query.New(
                                    rlReq_UserPeer,
                                    null,
                                    queryExpression,
                                    marshaler.UserPtr,
                                    queryParameters != null ? (uint)queryParameters.Length : 0,
                                    stateMask);
                                if (uQuery != IntPtr.Zero)
                                {
                                    queryCondition = new QueryCondition(
                                        this,
                                        sampleStates,
                                        viewStates,
                                        instanceStates,
                                        queryExpression,
                                        queryParameters);
                                    result = queryCondition.init(uQuery);
                                    if (result == ReturnCode.Ok)
                                    {
                                        conditionList.Add(queryCondition);
                                    }
                                    else
                                    {
                                        ReportStack.Report(result, "Could not create QueryCondition.");
                                        queryCondition = null;
                                    }
                                }
                                else
                                {
                                    result = DDS.ReturnCode.Error;
                                    ReportStack.Report(result, "Unable to create QueryCondition in kernel.");
                                }
                            }
                            else
                            {
                                result = DDS.ReturnCode.BadParameter;
                                ReportStack.Report(result, "One mor more of your SampleState/ViewState/InstanceState masks are invalid.");
                            }
                        }
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(queryCondition);
        }