/// <summary> /// Determines the size of the table. /// </summary> /// <param name="table0">The Table 0 object for the current device.</param> /// <param name="table2409">The Table 61 object for the current device.</param> /// <returns>The size of the table in bytes.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 12/06/11 RCG 2.53.14 N/A Created private static uint DetermineTableSize(CTable00 table0, OpenWayMFGTable2409 table2409) { uint uiTableSize = 0; LPSetActualLimits SetLimits; if (table0.IsTableUsed((ushort)MFGLPDataSet.Set1)) { SetLimits = table2409.Set1ActualLimits; uiTableSize += LPSetDataSelection.Size(SetLimits.NumberOfChannels, SetLimits.IncludeScalarDivisor, true); } if (table0.IsTableUsed((ushort)MFGLPDataSet.Set2)) { SetLimits = table2409.Set2ActualLimits; uiTableSize += LPSetDataSelection.Size(SetLimits.NumberOfChannels, SetLimits.IncludeScalarDivisor, true); } if (table0.IsTableUsed((ushort)MFGLPDataSet.Set3)) { SetLimits = table2409.Set3ActualLimits; uiTableSize += LPSetDataSelection.Size(SetLimits.NumberOfChannels, SetLimits.IncludeScalarDivisor, true); } if (table0.IsTableUsed((ushort)MFGLPDataSet.Set4)) { SetLimits = table2409.Set4ActualLimits; uiTableSize += LPSetDataSelection.Size(SetLimits.NumberOfChannels, SetLimits.IncludeScalarDivisor, true); } return(uiTableSize); }
/// <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); }
/// <summary> /// Determines the channel name for each of the channels. /// </summary> /// <param name="setDataSelection">The data set to determine the names for.</param> /// <returns>The list of channel names.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 10/03/08 RCG 2.00.00 N/A Created // 12/12/11 RCG 2.53.20 Modified for Extended LP and IP support private List <string> DetermineChannelNames(LPSetDataSelection setDataSelection) { List <string> ChannelNames = new List <string>(); foreach (uint CurrentLID in setDataSelection.SourceLIDs) { uint ModifiedLID = CurrentLID; if ((CurrentLID & (uint)DefinedLIDs.BaseLIDs.COMPONENT_MASK) == (uint)DefinedLIDs.BaseLIDs.ENERGY_DATA) { // The source LID numbers are for the raw values we need them to be secondary for this // to work correctly. ModifiedLID = (CurrentLID & (uint)DefinedLIDs.WhichEnergyFormat.WHICH_FORMAT_MASK_OUT) | (uint)DefinedLIDs.WhichEnergyFormat.SECONDARY_DATA; } LID ChannelLid = CreateLID(ModifiedLID); ChannelNames.Add(ChannelLid.lidDescription); } return(ChannelNames); }
/// <summary> /// Determines the pulse weights for each channel. /// </summary> /// <param name="setLimits">The set limits for the data set</param> /// <param name="setDataSelection">The data selection for the data set</param> /// <returns>The list of pulse weights.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 10/03/08 RCG 2.00.00 N/A Created // 12/12/11 RCG 2.53.20 Modified for Extended LP and IP support private List <float> DeterminePulseWeights(LPSetActualLimits setLimits, LPSetDataSelection setDataSelection) { List <float> PulseWeights = new List <float>(); if (setDataSelection != null && setLimits.IncludeScalarDivisor) { // We have all the data we need to determine the pulse weights for (int iChannel = 0; iChannel < setLimits.NumberOfChannels; iChannel++) { // Make sure that we get a float value. PulseWeights.Add((float)setDataSelection.Scalars[iChannel] / (float)setDataSelection.Divisors[iChannel]); } } else { // We don't have the data we need so just use 1.0 so that the raw data is used. for (int iChannel = 0; iChannel < setLimits.NumberOfChannels; iChannel++) { PulseWeights.Add(1.0f); } } return(PulseWeights); }
/// <summary> /// Adds the channels to the LoadProfilData object. /// </summary> /// <param name="loadProfileData">The LoadProfileData object to add the channels to.</param> /// <param name="setLimits">The set limits for the data set</param> /// <param name="setDataSelection">The data selection for the data set</param> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 10/03/08 RCG 2.00.00 N/A Created // 12/12/11 RCG 2.53.20 Modified for Extended LP and IP support private void AddChannels(ref LoadProfileData loadProfileData, LPSetActualLimits setLimits, LPSetDataSelection setDataSelection) { List <string> ChannelNames = DetermineChannelNames(setDataSelection); List <float> PulseWeights = DeterminePulseWeights(setLimits, setDataSelection); for (int iChannel = 0; iChannel < setLimits.NumberOfChannels; iChannel++) { loadProfileData.AddChannel(ChannelNames[iChannel], PulseWeights[iChannel], 1.0f); } }
/// <summary> /// Creates the LoadProfileData object from the specified blocks. /// </summary> /// <param name="loadProfileBlocks">The list of blocks to use to create the object ordered by date.</param> /// <param name="setLimits">The set limits for the data set</param> /// <param name="setDataSelection">The data selection for the data set</param> /// <returns>The LoadProfileData object.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 10/03/08 RCG 2.00.00 N/A Created // 12/12/11 RCG 2.53.20 Modified for Extended LP and IP support private LoadProfileData CreateLoadProfileDataObject(LPBlockDataRecord[] loadProfileBlocks, LPSetActualLimits setLimits, LPSetDataSelection setDataSelection) { LoadProfileData LPData = new LoadProfilePulseData(setLimits.IntervalLength); AddChannels(ref LPData, setLimits, setDataSelection); AddIntervals(ref LPData, loadProfileBlocks); return(LPData); }