Exemple #1
0
        /// <summary>
        /// Gets the original data values by expanding
        /// sequences and applying scale and offset.
        /// </summary>
        /// <returns>A list of the original data values.</returns>
        private IList <object> GetOriginalValues()
        {
            IList <object> values         = new List <object>();
            VectorElement  valuesVector   = SeriesValues;
            StorageMethods storageMethods = Definition.StorageMethodID;

            bool    incremented = (storageMethods & StorageMethods.Increment) != 0;
            dynamic start, count, increment;

            bool    scaled = (storageMethods & StorageMethods.Scaled) != 0;
            dynamic offset = ((object)SeriesOffset != null) ? SeriesOffset.Get() : 0;
            dynamic scale  = ((object)SeriesScale != null) ? SeriesScale.Get() : 1;
            dynamic value;

            if (!scaled)
            {
                offset = 0;
                scale  = 1;
            }

            if (incremented)
            {
                start     = valuesVector.Get(0);
                count     = valuesVector.Get(1);
                increment = valuesVector.Get(2);

                for (int i = 0; i < count; i++)
                {
                    values.Add((object)(start + (i * increment)));
                }
            }
            else
            {
                for (int i = 0; i < valuesVector.Size; i++)
                {
                    values.Add(valuesVector.Get(i));
                }
            }

            if (valuesVector.TypeOfValue != PhysicalType.Timestamp)
            {
                for (int i = 0; i < values.Count; i++)
                {
                    value     = values[i];
                    values[i] = offset + (value * scale);
                }

                ApplyTransducerRatio(values);
            }

            return(values);
        }
Exemple #2
0
        /// <summary>
        /// Gets the original data values by expanding
        /// sequences and applying scale and offset.
        /// </summary>
        /// <returns>A list of the original data values.</returns>
        private IList <object> GetOriginalValues()
        {
            IList <object> values         = new List <object>();
            VectorElement  valuesVector   = SeriesValues;
            StorageMethods storageMethods = Definition.StorageMethodID;

            bool incremented = (storageMethods & StorageMethods.Increment) != 0;

            bool    scaled = (storageMethods & StorageMethods.Scaled) != 0;
            dynamic offset = SeriesOffset != null?SeriesOffset.Get() : 0;

            dynamic scale = SeriesScale != null?SeriesScale.Get() : 1;

            dynamic value;

            if (!scaled)
            {
                offset = 0;
                scale  = 1;
            }

            if (incremented)
            {
                dynamic rateCount = valuesVector.Get(0);

                if (rateCount > 0)
                {
                    dynamic zero  = rateCount - rateCount;
                    dynamic one   = rateCount / rateCount;
                    dynamic start = zero;

                    for (int i = 0; i < rateCount; i++)
                    {
                        int     countIndex     = i * 2 + 1;
                        int     incrementIndex = i * 2 + 2;
                        dynamic count          = valuesVector.Get(countIndex);
                        dynamic increment      = valuesVector.Get(incrementIndex);

                        for (dynamic j = zero; j < count; j += one)
                        {
                            values.Add((object)(start + j * increment));
                        }

                        start = count * increment;
                    }
                }
            }
            else
            {
                for (int i = 0; i < valuesVector.Size; i++)
                {
                    values.Add(valuesVector.Get(i));
                }
            }

            if (valuesVector.TypeOfValue != PhysicalType.Timestamp)
            {
                for (int i = 0; i < values.Count; i++)
                {
                    value     = values[i];
                    values[i] = offset + value * scale;
                }

                ApplyTransducerRatio(values);
            }

            return(values);
        }