/// <summary> /// Maps the specified table set to the corresponding table number /// </summary> /// <param name="set">The table set to map</param> /// <returns>The table number that maps to the set</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 12/06/11 RCG 2.53.14 N/A Created internal override ushort MapLPSetToTable(LPDataSet set) { ushort TableID = 0; switch (set) { case LPDataSet.Set1: { TableID = (ushort)MFGLPDataSet.Set1; break; } case LPDataSet.Set2: { TableID = (ushort)MFGLPDataSet.Set2; break; } case LPDataSet.Set3: { TableID = (ushort)MFGLPDataSet.Set3; break; } case LPDataSet.Set4: { TableID = (ushort)MFGLPDataSet.Set4; break; } } return(TableID); }
/// <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); LPDataSet DataSet = LPDataSet.Set1; LPBlockDataRecord FirstBlock; LPBlockDataRecord LastBlock; LPBlockDataRecord[] Blocks; LPSetStatusRecord SetStatus; LoadProfileData LPData = null; int StartBlockIndex; int EndBlockIndex; int FirstBlockIndex; SetStatus = statusTable.GetSetStatusRecord(DataSet); 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); }