Example #1
0
        internal int Offset(IValueIter vi)
        {
            // Find which of the mOffset correspond
            // to this ValueIter. Use cache info when available.
            int iterIdx = vi.GetIndexCache(this);

            if (iterIdx != -1)
            {
                return(mStartOffset[iterIdx]);
            }

            // Not in the cache, so do a sequential
            // search for the right mOffset.
            for (int i = 0; i < mValueIter.Length; i++)
            {
                if (vi.Equals(mValueIter[i]))
                {
                    vi.SetIndexCache(this, i);
                    return(mStartOffset[i]);
                }
            }

            // Attempt to use this Index on a Variable or Timeseries
            // that is not part of the Iter object.
            throw new Exception("Variable not accessible with this index");
        }
Example #2
0
 internal Timestamps(IValueIter parent, int size)
 {
     mParent        = parent;
     mStartDateTime = new DateTime(1971, 1, 1);
     mLength        = size;
     mTotalLength   = mLength;
 }
Example #3
0
 internal Timestamps(IValueIter parent, int size )
 {
     mParent = parent;
     mStartDateTime = new DateTime(1971,1,1);
     mLength = size;
     mTotalLength = mLength;
 }
Example #4
0
 internal Timestamps(IValueIter parent, DateTime [] array)
 {
     // Make a copy of the provided DateTime array.
     mParent      = parent;
     mTimestamps  = (DateTime[])array.Clone();
     mLength      = array.Length;
     mTotalLength = mLength;
 }
Example #5
0
 internal Timestamps( IValueIter parent, DateTime []array )
 {
     // Make a copy of the provided DateTime array.
     mParent = parent;
     mTimestamps = (DateTime[])array.Clone();
     mLength = array.Length;
     mTotalLength = mLength;
 }
Example #6
0
 internal Timestamps(IValueIter parent, Timestamps timestamps)
 {
     // Reference on same data of an existing Timestamps.
     mParent        = parent;
     mTimestamps    = timestamps.mTimestamps;
     mStartDateTime = timestamps.mStartDateTime;
     mLength        = timestamps.Length;
     mTotalLength   = mLength;
 }
Example #7
0
 internal Timestamps( IValueIter parent, Timestamps timestamps )
 {
     // Reference on same data of an existing Timestamps.
     mParent = parent;
     mTimestamps = timestamps.mTimestamps;
     mStartDateTime = timestamps.mStartDateTime;
     mLength = timestamps.Length;
     mTotalLength = mLength;
 }
Example #8
0
 internal bool IsSyncWith(IValueIter otherObject)
 {
     // TODO Check for sync. For now assume all input
     // are synchronized.
     return(true);
 }
Example #9
0
 internal bool IsSyncWith(IValueIter otherObject)
 {
     // TODO Check for sync. For now assume all input
     // are synchronized.
     return true;
 }
Example #10
0
        internal Index(params IValueIter[] list)
        {
            // Handle special case of empty list.
            if (list.Length == 0)
            {
                mLeftToIterate = 0;
                return;
            }


            // Each ValueIter have a corresponding "offset" maintained
            // locally in the Index object.
            mStartOffset = new int[list.Length];

            // Validate all synchronized.
            // At the same time, identify the common range.
            int        begCommonRange;
            int        endCommonRange;
            IValueIter valueIter = list[0];

            endCommonRange  = valueIter.GetEndTimestampOffset();
            begCommonRange  = valueIter.GetStartTimestampOffset();
            mStartOffset[0] = begCommonRange;
            if (list.Length > 1)
            {
                Timestamps refTimestamps = valueIter.GetTimestamps();
                for (int i = 1; i < list.Length; i++)
                {
                    valueIter = list[i];
                    if (!valueIter.GetTimestamps().Equals(refTimestamps))
                    {
                        throw new Exception("Iteration possible only for synchronized Timeseries and Variable");
                    }
                    int temp = valueIter.GetStartTimestampOffset();
                    if (temp > begCommonRange)
                    {
                        begCommonRange = temp;
                    }
                    mStartOffset[i] = temp;
                    temp            = valueIter.GetEndTimestampOffset();
                    if (temp < endCommonRange)
                    {
                        endCommonRange = temp;
                    }
                }
            }

            // The number of elements left to be iterated.
            mLeftToIterate = endCommonRange - begCommonRange + 1;

            // Handle case of an empty ValueIter or no common range.
            if (mLeftToIterate <= 0)
            {
                mLeftToIterate = 0;
                return;
            }

            // Now that the common range is known, adjust the starting
            // offset for each ValueIter.
            for (int i = 0; i < list.Length; i++)
            {
                mStartOffset[i] = begCommonRange - mStartOffset[i];
            }

            // Calculate the starting offset for the timestamp array.
            mTimestampOffset = begCommonRange;

            // Keep a reference on the list of ValueIter
            mValueIter = list;
        }
Example #11
0
        internal int Offset(IValueIter vi)
        {
            // Find which of the mOffset correspond
            // to this ValueIter. Use cache info when available.
            int iterIdx = vi.GetIndexCache(this);
            if (iterIdx != -1)
                return mStartOffset[iterIdx];

            // Not in the cache, so do a sequential
            // search for the right mOffset.
            for (int i = 0; i < mValueIter.Length; i++)
            {
                if (vi.Equals(mValueIter[i]))
                {
                    vi.SetIndexCache(this, i);
                    return mStartOffset[i];
                }
            }

            // Attempt to use this Index on a Variable or Timeseries
            // that is not part of the Iter object.
            throw new Exception("Variable not accessible with this index");
        }