TimeSeriesLibrary.TSLibrary.ConvertBlobToListLimited C# (CSharp) Method

ConvertBlobToListLimited() public method

This method creates a List of TimeSeriesValue objects from the given BLOB (byte array) of time series values. The method takes parameters for a maximum number of values, an earliest date, and a latest date, so that only a portion of the BLOB might be converted to the List. The sibling method ConvertBlobToListAll can convert the entire BLOB without any limits.
public ConvertBlobToListLimited ( TSDateCalculator timeStepUnit, short timeStepQuantity, int timeStepCount, System.DateTime blobStartDate, int nReqValues, System.DateTime reqStartDate, System.DateTime reqEndDate, Byte blobData, List &dateValueList, int compressionCode ) : int
timeStepUnit TSDateCalculator TSDateCalculator.TimeStepUnitCode value for Minute,Hour,Day,Week,Month, Year, or Irregular
timeStepQuantity short The number of the given unit that defines the time step. /// For instance, if the time step is 6 hours long, then this value is 6. If timeStepUnit is /// Irregular, then this value is ignored.
timeStepCount int the number of time steps that are stored in the blob
blobStartDate System.DateTime The DateTime value of the first time step in the BLOB. If /// timeStepUnit is Irregular, then this value is ignored.
nReqValues int The maximum number of time steps that should be added to dateValueList
reqStartDate System.DateTime The earliest date that will be added to dateValueList
reqEndDate System.DateTime The latest date that will be added to dateValueList
blobData Byte The BLOB (byte array) that this method will convert into a List
dateValueList List The List of TimeSeriesValues that this method will create from the BLOB.
compressionCode int a generation number that indicates what compression technique to use
return int
        public int ConvertBlobToListLimited(
            TSDateCalculator.TimeStepUnitCode timeStepUnit, short timeStepQuantity,
            int timeStepCount, DateTime blobStartDate,
            int nReqValues, DateTime reqStartDate, DateTime reqEndDate,
            Byte[] blobData, ref List<TimeSeriesValue> dateValueList, int compressionCode)
        {
            // Let the private core method do all the real work.
            // We pass it the 'applyLimits' value of true.
            return ConvertBlobToList(timeStepUnit, timeStepQuantity,
                        timeStepCount, blobStartDate, true,
                        nReqValues, reqStartDate, reqEndDate,
                        blobData, ref dateValueList, compressionCode);
        }

Usage Example

Ejemplo n.º 1
0
        // the maximum number of time steps to put into the series
        // The series of tests below is for ConvertBlobToListLimited and ConvertListToBlob.
        // The tests take advantage of the fact that the methods are designed so that
        // the series that is put into the BLOB must be identical to the series that
        // comes out of the BLOB.
        // This method is re-used by the actual test methods that follow.
        public void ConvertBlobLimited(List<TimeSeriesValue> inList,
                TSDateCalculator.TimeStepUnitCode timeStepUnit, short timeStepQuantity,
                DateTime blobStartDate,
                int nCutStart,          // the number of time steps that the test will truncate from the start of the series
                int nCutEnd,            // the number of time steps that the test will truncate from the end of the series
                int nMax)
        {
            TSLibrary tsLib = new TSLibrary();
            List<TimeSeriesValue> outList = new List<TimeSeriesValue>();
            int compressionCode;

            byte[] blobData = tsLib.ConvertListToBlobWithChecksum(timeStepUnit, timeStepQuantity,
                                inList.Count, inList.First().Date, inList.Last().Date, inList,
                                new TSTrace { TraceNumber = 1 }, out compressionCode);

            int ret = tsLib.ConvertBlobToListLimited(timeStepUnit, timeStepQuantity,
                            inList.Count, blobStartDate,
                            nMax, inList[nCutStart].Date, inList[inList.Count - nCutEnd - 1].Date,
                            blobData, ref outList, compressionCode);

            // The return value of the function must match the number of items in the original list
            Assert.AreEqual(ret, Math.Min(nMax, inList.Count - nCutStart - nCutEnd));
            // the count in both lists must match
            Assert.AreEqual(outList.Count, Math.Min(nMax, inList.Count - nCutStart - nCutEnd));

            // now check each item in the two lists
            Boolean AreEqual = true;
            for (int i = 0; i < ret; i++)
            {
                if (outList[i].ValueEquals(inList[i + nCutStart]) == false)
                    AreEqual = false;
            }

            Assert.IsTrue(AreEqual);
        }