/// <summary> /// Reads the TOO for the TOU Demand LIDs and set the value into the Demand Measurement /// </summary> /// <exception cref="PSEMException">Exception on read</exception> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 09/27/06 KRC 7.36 Created // 12/01/06 jrf 8.00 The dtTOOTOUDemand must be reset to the // MeterReferenceTime for each TOU rate. // 05/15/08 mrj 1.50.25 Bug itron00107508, set date to UTC // private void ReadTOOTOUMaxDemand() { PSEMResponse PSEMResult = PSEMResponse.Ok; byte[] Data = null; LID[] arLids = new LID[m_uiTOURates]; DateTime dtTOOTOUDemand = m_ANSIDevice.UTCMeterReferenceTime; uint uiMeterSeconds = 0; if (true == m_ANSIDevice.ValidateDemand(TotalMaxDemandLID) && m_uiTOURates > 0) { // Calculate the Base LID for the TOO of the TOU LID LID TOOTOUBaseMaxDemandLID = m_ANSIDevice.CreateLID((TOUBaseMaxDemandLID.lidValue & (uint)DefinedLIDs.WhichDemandFormat.WHICH_FORMAT_MASK_OUT) | (uint)DefinedLIDs.WhichDemandFormat.TOO_DATA); arLids = BuildTOOTOULIDArray(TOOTOUBaseMaxDemandLID); // Retrieve TOU Demand LIDs PSEMResult = m_ANSIDevice.m_lidRetriever.RetrieveMulitpleLIDs(arLids, out Data); PSEMBinaryReader TOOValues = m_ANSIDevice.m_lidRetriever.DataReader; if (PSEMResponse.Ok == PSEMResult) { for (uint uiCount = 0; uiCount < m_uiTOURates; uiCount++) { // Reset to reference time dtTOOTOUDemand = m_ANSIDevice.UTCMeterReferenceTime; uiMeterSeconds = TOOValues.ReadUInt32(); // Add the seconds to the reference time dtTOOTOUDemand = dtTOOTOUDemand.AddSeconds((double)uiMeterSeconds); // Now convert to Local Time (Handles cases where Time is in UTC) dtTOOTOUDemand = m_ANSIDevice.GetLocalDeviceTime(dtTOOTOUDemand); m_TOUMaxDemandMeasurements[(int)uiCount].TimeOfOccurrence = dtTOOTOUDemand; } } else { throw new PSEMException(PSEMException.PSEMCommands.PSEM_READ, PSEMResult, "Error Reading TOU TOO Values; Base LID = " + TOOTOUBaseMaxDemandLID.ToString()); } } }
/// <summary> /// Reads the Max Demand LID and set the value into the Demand Measurement /// </summary> /// <exception cref="PSEMException">Exception on read</exception> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ --------------------------------------------- // 09/27/06 KRC 7.35 Created // 05/15/08 mrj 1.50.25 Bug itron00107508, set date to UTC // private void ReadTOOTotalMaxDemand() { PSEMResponse PSEMResult = PSEMResponse.Ok; byte[] Data = null; uint uiMeterSeconds; DateTime dtTOODemand = m_ANSIDevice.UTCMeterReferenceTime; LID TOOMaxDemandLID = m_ANSIDevice.CreateLID((TotalMaxDemandLID.lidValue & (uint)DefinedLIDs.WhichDemandFormat.WHICH_FORMAT_MASK_OUT) | (uint)DefinedLIDs.WhichDemandFormat.TOO_DATA); PSEMResult = m_ANSIDevice.m_lidRetriever.RetrieveLID(TOOMaxDemandLID, out Data); if (PSEMResponse.Ok == PSEMResult) { uiMeterSeconds = m_ANSIDevice.m_lidRetriever.DataReader.ReadUInt32(); // Add the seconds to the reference time dtTOODemand = dtTOODemand.AddSeconds((double)uiMeterSeconds); // Covert the time to Local (if needed - Method checks firmware version) dtTOODemand = m_ANSIDevice.GetLocalDeviceTime(dtTOODemand); m_MaxDemandMeasurement.TimeOfOccurrence = dtTOODemand; } else { throw new PSEMException(PSEMException.PSEMCommands.PSEM_READ, PSEMResult, "Error Reading Time of Occurence Value; LID = " + TOOMaxDemandLID.ToString()); } }