示例#1
0
        /// <summary>
        /// Gets the first block of the load profile data
        /// </summary>
        /// <param name="actualLimitingTable">The actual limiting table that applies to the data set</param>
        /// <param name="statusTable">The status table that applies to the data set</param>
        /// <param name="dataSetTable">The data set</param>
        /// <param name="setStatus">The status record for the data set at the time of the read</param>
        /// <returns>The first block of Load Profile Data</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 10/07/08 RCG 2.00.00 N/A    Created
        // 12/12/11 RCG 2.53.20        Modified for Extended LP and IP support

        private LPBlockDataRecord GetFirstBlock(StdTable61 actualLimitingTable, StdTable63 statusTable, StdTable64 dataSetTable, out LPSetStatusRecord setStatus)
        {
            LPBlockDataRecord FirstBlock          = null;
            LPSetActualLimits SetLimits           = actualLimitingTable.GetSetLimits(dataSetTable.DataSet);
            LPSetStatusRecord SetStatusBeforeRead = null;
            LPSetStatusRecord SetStatusAfterRead  = null;
            int    BlockReadRetries = 0;
            ushort FirsBlockIndex   = 0;

            do
            {
                SetStatusBeforeRead = statusTable.GetSetStatusRecord(dataSetTable.DataSet);

                if (SetStatusBeforeRead.DataListType == LPSetStatusRecord.ListType.Circular)
                {
                    FirsBlockIndex = (ushort)((SetStatusBeforeRead.LastBlockElement + 1) % SetStatusBeforeRead.NumberOfValidBlocks);
                }

                if (SetStatusBeforeRead.NumberOfValidBlocks > 1)
                {
                    FirstBlock = ReadLPBlock(dataSetTable, FirsBlockIndex, SetLimits.IntervalsPerBlock);
                }
                else
                {
                    // The first block is the last block so we need to use the number of valid intervals
                    FirstBlock = ReadLPBlock(dataSetTable, FirsBlockIndex, SetStatusBeforeRead.NumberOfValidIntervals);
                }

                SetStatusAfterRead = statusTable.GetSetStatusRecord(dataSetTable.DataSet);
            }while (BlockReadRetries < LP_READ_RETRIES && HasLastBlockRolledOver(SetStatusBeforeRead, SetStatusAfterRead));

            setStatus = SetStatusAfterRead;

            return(FirstBlock);
        }
示例#2
0
        /// <summary>
        /// Get the all of the Profile Data from the specified set of tables
        /// </summary>
        /// <param name="actualLimitingTable">The actual limiting table for the data set</param>
        /// <param name="controlTable">The control table for the data set</param>
        /// <param name="statusTable">The status table for the data set</param>
        /// <param name="dataSetTable">The data set table for the data set</param>
        /// <returns>The profile data that has been read.</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 12/06/11 RCG 2.53.20 N/A    Created
        // 06/15/12 jrf 2.60.32 199972 Adding logging statements to help debug issue next time we see it.
        //
        protected LoadProfileData GetProfileData(StdTable61 actualLimitingTable, StdTable62 controlTable, StdTable63 statusTable, StdTable64 dataSetTable)
        {
            LoadProfileData    LPData           = null;
            LPSetActualLimits  SetLimits        = actualLimitingTable.GetSetLimits(dataSetTable.DataSet);
            LPSetDataSelection SetDataSelection = controlTable.GetDataSelection(dataSetTable.DataSet);

            LPBlockDataRecord[] Blocks;
            LPBlockDataRecord   FirstBlock;
            LPBlockDataRecord   LastBlock;
            LPSetStatusRecord   SetStatus;
            ushort NumberOfBlocks;
            ushort FirstBlockIndex;

            m_Logger.WriteLine(Logger.LoggingLevel.Functional, "Getting Profile Data");
            SetStatus = statusTable.GetSetStatusRecord(dataSetTable.DataSet);

            m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Number of Blocks: " + SetStatus.NumberOfValidBlocks.ToString(CultureInfo.InvariantCulture));
            m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Number of Intervals: " + SetStatus.NumberOfValidIntervals.ToString(CultureInfo.InvariantCulture));
            if (SetStatus.NumberOfValidBlocks > 0 && SetStatus.NumberOfValidIntervals > 0)
            {
                OnShowProgress(new ShowProgressEventArgs(1, SetStatus.NumberOfValidBlocks, "Reading Load Profile data...", "Reading Load Profile data..."));

                // Read the first and last blocks
                GetFirstAndLastBlock(actualLimitingTable, statusTable, dataSetTable, out FirstBlock, out LastBlock, out SetStatus);

                // Read the rest of the blocks using the last block status
                NumberOfBlocks = SetStatus.NumberOfValidBlocks;
                Blocks         = new LPBlockDataRecord[NumberOfBlocks];

                Blocks[0] = FirstBlock;

                if (NumberOfBlocks > 1)
                {
                    Blocks[NumberOfBlocks - 1] = LastBlock;

                    FirstBlockIndex = (ushort)((SetStatus.LastBlockElement + 1) % NumberOfBlocks);

                    for (ushort RelativeBlockIndex = 1; RelativeBlockIndex < NumberOfBlocks - 1; RelativeBlockIndex++)
                    {
                        ushort ActualBlockIndex = (ushort)((FirstBlockIndex + RelativeBlockIndex) % NumberOfBlocks);

                        m_Logger.WriteLine(Logger.LoggingLevel.Detailed, "Reading Block # " + ActualBlockIndex.ToString(CultureInfo.InvariantCulture));
                        Blocks[RelativeBlockIndex] = ReadLPBlock(dataSetTable, ActualBlockIndex, SetLimits.IntervalsPerBlock);

                        OnStepProgress(new ProgressEventArgs());
                    }
                }

                OnHideProgress(new EventArgs());

                // Create the LoadProfileData object.
                LPData = CreateLoadProfileDataObject(Blocks, SetLimits, SetDataSelection);
            }

            return(LPData);
        }
示例#3
0
        /// <summary>
        /// Gets the load profile data between the specified dates.
        /// </summary>
        /// <param name="startDate">The start date of the load profile data to get.</param>
        /// <param name="endDate">The end date of the load profile data to get.</param>
        /// <param name="actualLimitingTable">The actual limiting table for the data set</param>
        /// <param name="controlTable">The control table for the data set</param>
        /// <param name="statusTable">The status table for the data set</param>
        /// <param name="dataSetTable">The data set table for the data set</param>
        /// <returns>The load profile data from the dates specified.</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 12/06/11 RCG 2.53.20 N/A    Created

        public LoadProfileData GetProfileData(DateTime startDate, DateTime endDate, StdTable61 actualLimitingTable, StdTable62 controlTable, StdTable63 statusTable, StdTable64 dataSetTable)
        {
            LPSetActualLimits SetLimits = actualLimitingTable.GetSetLimits(dataSetTable.DataSet);
            LPBlockDataRecord FirstBlock;
            LPBlockDataRecord LastBlock;

            LPBlockDataRecord[] Blocks;
            LPSetStatusRecord   SetStatus;
            LoadProfileData     LPData = null;

            int StartBlockIndex;
            int EndBlockIndex;
            int FirstBlockIndex;

            SetStatus = statusTable.GetSetStatusRecord(dataSetTable.DataSet);

            if (SetStatus != null)
            {
                if (SetStatus.NumberOfValidBlocks > 1 && SetStatus.NumberOfValidIntervals > 0)
                {
                    OnShowProgress(new ShowProgressEventArgs(1, 2, "Determining blocks to read...", "Determining blocks to read..."));

                    // Get the first and last blocks in order to determine the blocks we need to read.
                    GetFirstAndLastBlock(actualLimitingTable, statusTable, dataSetTable, out FirstBlock, out LastBlock, out SetStatus);

                    OnStepProgress(new ProgressEventArgs());

                    // Determine which blocks to read
                    StartBlockIndex = DetermineStartBlockIndex(SetLimits, SetStatus, FirstBlock, startDate);
                    EndBlockIndex   = DetermineEndBlockIndex(SetLimits, SetStatus, LastBlock, endDate);

                    Blocks          = new LPBlockDataRecord[EndBlockIndex - StartBlockIndex + 1];
                    FirstBlockIndex = (SetStatus.LastBlockElement + 1) % SetStatus.NumberOfValidBlocks;

                    OnHideProgress(new EventArgs());
                    OnShowProgress(new ShowProgressEventArgs(1, EndBlockIndex - StartBlockIndex, "Reading Load Profile data...", "Reading Load Profile data..."));

                    // Read the blocks
                    for (int RelativeBlockIndex = StartBlockIndex; RelativeBlockIndex <= EndBlockIndex; RelativeBlockIndex++)
                    {
                        int BlockArrayIndex = RelativeBlockIndex - StartBlockIndex;

                        OnStepProgress(new ProgressEventArgs());

                        // We already have the first and last blocks so just add those if included.
                        if (RelativeBlockIndex == 0)
                        {
                            Blocks[BlockArrayIndex] = FirstBlock;
                        }
                        else if (RelativeBlockIndex == SetStatus.NumberOfValidBlocks - 1)
                        {
                            // The last block
                            Blocks[BlockArrayIndex] = LastBlock;
                        }
                        else
                        {
                            // We need to read the block
                            ushort ActualBlockIndex = (ushort)((FirstBlockIndex + RelativeBlockIndex) % SetStatus.NumberOfValidBlocks);

                            Blocks[BlockArrayIndex] = ReadLPBlock(dataSetTable, ActualBlockIndex, SetLimits.IntervalsPerBlock);
                        }
                    }

                    OnStepProgress(new ProgressEventArgs("Creating Load Profile object..."));

                    // Create the LoadProfileData object.
                    LPData = CreateLoadProfileDataObject(Blocks, SetLimits, controlTable.GetDataSelection(dataSetTable.DataSet));

                    OnStepProgress(new ProgressEventArgs("Removing additional intervals..."));

                    // Trim out intervals that were not requested.
                    LPData.Intervals.RemoveAll(delegate(LPInterval interval) { return(interval.Time < startDate || interval.Time > endDate); });

                    OnHideProgress(new EventArgs());
                }
                else if (SetStatus.NumberOfValidBlocks == 1)
                {
                    OnShowProgress(new ShowProgressEventArgs(1, 3, "Reading Load Profile data...", "Reading Load Profile data..."));

                    // Just get the first block the trim will take care of anything outside the range
                    FirstBlock = GetFirstBlock(actualLimitingTable, statusTable, dataSetTable, out SetStatus);

                    OnStepProgress(new ProgressEventArgs());

                    LPData = CreateLoadProfileDataObject(new LPBlockDataRecord[] { FirstBlock }, SetLimits, controlTable.GetDataSelection(dataSetTable.DataSet));

                    OnStepProgress(new ProgressEventArgs());

                    // Trim out intervals that were not requested.
                    LPData.Intervals.RemoveAll(delegate(LPInterval interval) { return(interval.Time < startDate || interval.Time > endDate); });

                    OnStepProgress(new ProgressEventArgs());
                    OnHideProgress(new EventArgs());
                }
            }

            return(LPData);
        }