/// <summary> /// Checks to see if the item matches and then creates a ProgramValidationItem if it does not. /// </summary> /// <param name="item">The item to validate</param> /// <param name="meterTables">The table structure for the meter.</param> /// <param name="programTables">The table structure for the program.</param> /// <returns>Returns the ProgramValidationItem for the value if the items do not match, and null if the values match.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 05/23/07 RCG 8.10.05 Created // 12/18/13 jrf 3.50.16 TQ9560 Refactored retreival of a CentronTables value into its own method. protected override ProgramValidationItem ValidateItem(EDLValidationItem item, CentronTables meterTables, CentronTables programTables) { bool bItemsMatch = false; bool bCheckedInBaseClass = false; string strDisplayMeterValue = ""; string strDisplayProgramValue = ""; object objMeterValue; object objProgramValue; ProgramValidationItem InvalidItem = null; // Get the values objMeterValue = GetTableValue(item, meterTables); objProgramValue = GetTableValue(item, programTables); switch (item.Item) { case (long)CentronTblEnum.MFGTBL0_LOCK_SITESCAN_ERROR: { object ScrollMeterValue; object ScrollProgramValue; // Get the scroll values meterTables.GetValue(CentronTblEnum.MFGTBL0_SCROLL_SITESCAN_ERROR, item.Index, out ScrollMeterValue); programTables.GetValue(CentronTblEnum.MFGTBL0_SCROLL_SITESCAN_ERROR, item.Index, out ScrollProgramValue); strDisplayMeterValue = ConvertDisplayableErrors((bool)objMeterValue, (bool)ScrollMeterValue); strDisplayProgramValue = ConvertDisplayableErrors((bool)objProgramValue, (bool)ScrollProgramValue); if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } break; } default: { InvalidItem = base.ValidateItem(item, meterTables, programTables); bCheckedInBaseClass = true; break; } } if (bItemsMatch == false && bCheckedInBaseClass == false) { // There is a mismatch so add the item. InvalidItem = new ProgramValidationItem(item.Category, item.Name, strDisplayProgramValue, strDisplayMeterValue); } return(InvalidItem); }
/// <summary> /// Checks to see if the item matches and then creates a ProgramValidationItem if it does not. /// </summary> /// <param name="item">The item to validate</param> /// <param name="meterTables">The table structure for the meter.</param> /// <param name="programTables">The table structure for the program.</param> /// <returns>Returns the ProgramValidationItem for the value if the items do not match, and null if the values match.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 12/12/13 jrf 3.50.16 TQ 9560 Created. // protected override ProgramValidationItem ValidateItem(EDLValidationItem item, CentronTables meterTables, CentronTables programTables) { bool blnFoundItem = false; ProgramValidationItem InvalidItem = null; if (null != m_BridgeDevice) { blnFoundItem = m_BridgeDevice.ValidateItem(item, meterTables, programTables, out InvalidItem); } if (blnFoundItem == false) { // If we didn't find item check base method. InvalidItem = base.ValidateItem(item, meterTables, programTables); } return(InvalidItem); }
/// <summary> /// Gets a list of invalid exception items. /// </summary> /// <param name="meterTables">The table structure for the meter.</param> /// <param name="programTables">The table structure for the program.</param> /// <returns>The list of invalid items.</returns> // Revision History // MM/DD/YY Who Version Issue# Description // -------- --- ------- ------ ------------------------------------------- // 07/08/10 AF 2.42.03 Created // 03/06/12 AF 2.53.48 193820 We can no longer assume that the meter and program items will // be in the same order. We have to search both lists for mismatches // protected virtual List <ProgramValidationItem> GetInvalidExceptionItems(GatewayTables meterTables, GatewayTables programTables) { List <ProgramValidationItem> InvalidItems = new List <ProgramValidationItem>(); ProgramValidationItem ValidationItem = null; object objMeterValue; object objProgramValue; ushort usMeterHosts; ushort usProgramHosts; ushort usMeterEvents; ushort usProgramEvents; ushort usMaxHosts; ushort usMaxEvents; // We shouldn't validate this if Table 123 is not cached in the program. if (programTables.IsAllCached(123)) { // Get the number of exception hosts meterTables.GetValue(StdTableEnum.STDTBL121_NBR_EXCEPTION_HOSTS, null, out objMeterValue); programTables.GetValue(StdTableEnum.STDTBL121_NBR_EXCEPTION_HOSTS, null, out objProgramValue); usMeterHosts = (ushort)objMeterValue; usProgramHosts = (ushort)objProgramValue; // Get the number of exception events meterTables.GetValue(StdTableEnum.STDTBL121_NBR_EXCEPTION_EVENTS, null, out objMeterValue); programTables.GetValue(StdTableEnum.STDTBL121_NBR_EXCEPTION_EVENTS, null, out objProgramValue); usMeterEvents = (ushort)objMeterValue; usProgramEvents = (ushort)objProgramValue; // Determine the maximum values. if (usMeterHosts >= usProgramHosts) { usMaxHosts = usMeterHosts; } else { usMaxHosts = usProgramHosts; } if (usMeterEvents >= usProgramEvents) { usMaxEvents = usMeterEvents; } else { usMaxEvents = usProgramEvents; } // Verify each of the hosts for (int iHost = 0; iHost < usMaxHosts; iHost++) { bool meterValidHost = iHost < usMeterHosts; bool programValidHost = iHost < usProgramHosts; List <ushort> meterEventsList = new List <ushort>(); List <ushort> programEventsList = new List <ushort>(); List <ushort> invalidMeterItemsList = new List <ushort>(); List <ushort> invalidProgramItemsList = new List <ushort>(); // the event number is just an index used for labeling the invalid item int iEventNumber = 1; int[] iIndexer = { iHost }; string strCategory = "Exception Host " + (iHost + 1).ToString(CultureInfo.CurrentCulture); ValidationItem = ValidateItem(new EDLValidationItem((long)StdTableEnum.STDTBL123_APTITLE_NOTIFY, iIndexer, "Exception Host Aptitle", strCategory), meterTables, programTables); if (ValidationItem != null) { InvalidItems.Add(ValidationItem); } ValidationItem = ValidateItem(new EDLValidationItem((long)StdTableEnum.STDTBL123_MAX_NUMBER_OF_RETRIES, iIndexer, "Max Number of Retries", strCategory), meterTables, programTables); if (ValidationItem != null) { InvalidItems.Add(ValidationItem); } ValidationItem = ValidateItem(new EDLValidationItem((long)StdTableEnum.STDTBL123_RETRY_DELAY, iIndexer, "Retry Delay", strCategory), meterTables, programTables); if (ValidationItem != null) { InvalidItems.Add(ValidationItem); } ValidationItem = ValidateItem(new EDLValidationItem((long)StdTableEnum.STDTBL123_EXCLUSION_PERIOD, iIndexer, "Exclusion Period", strCategory), meterTables, programTables); if (ValidationItem != null) { InvalidItems.Add(ValidationItem); } if (meterValidHost == true) { for (int iEvent = 0; iEvent < usMeterEvents; iEvent++) { meterTables.GetValue(StdTableEnum.STDTBL123_EVENT_REPORTED, new int[] { iHost, iEvent }, out objMeterValue); meterEventsList.Add((ushort)objMeterValue); } } if (programValidHost == true) { for (int iEvent = 0; iEvent < usProgramEvents; iEvent++) { programTables.GetValue(StdTableEnum.STDTBL123_EVENT_REPORTED, new int[] { iHost, iEvent }, out objProgramValue); programEventsList.Add((ushort)objProgramValue); } } foreach (ushort item in meterEventsList) { if (!programEventsList.Contains(item)) { invalidMeterItemsList.Add(item); } } foreach (ushort item in invalidMeterItemsList) { string strMeterException = ""; if (EventDescriptions.TryGetValue((int)item, out strMeterException) == false) { // The TryGetValue failed so say it is an unknown event. strMeterException = "Unknown Event " + item.ToString(CultureInfo.InvariantCulture); } // We don't know which program item this belongs with so just make the program item blank InvalidItems.Add(new ProgramValidationItem(strCategory, "Event " + iEventNumber.ToString(CultureInfo.CurrentCulture), "", strMeterException)); iEventNumber++; } foreach (ushort item in programEventsList) { if (!meterEventsList.Contains(item)) { invalidProgramItemsList.Add(item); } } foreach (ushort item in invalidProgramItemsList) { string strProgramException = ""; if (EventDescriptions.TryGetValue((int)item, out strProgramException) == false) { // The TryGetValue failed so say it is an unknown event. strProgramException = "Unknown Event " + item.ToString(CultureInfo.InvariantCulture); } // We don't know which meter item this belongs with so just make the meter item blank InvalidItems.Add(new ProgramValidationItem(strCategory, "Event " + iEventNumber.ToString(CultureInfo.CurrentCulture), strProgramException, "")); iEventNumber++; } } } return(InvalidItems); }
protected ProgramValidationItem ValidateItem(EDLValidationItem item, GatewayTables meterTables, GatewayTables programTables) { bool bItemsMatch = false; string strDisplayMeterValue = ""; string strDisplayProgramValue = ""; object objMeterValue; object objProgramValue; ProgramValidationItem InvalidItem = null; // Get the values objMeterValue = GetTableValue(item, meterTables); objProgramValue = GetTableValue(item, programTables); switch (item.Item) { case (long)StdTableEnum.STDTBL34_SEC_DISP_SOURCES: { if (objMeterValue != null) { if (String.Compare(objMeterValue.ToString(), "3", StringComparison.OrdinalIgnoreCase) == 0) { strDisplayMeterValue = "No Display Item"; } else { int iIndex = Convert.ToInt32(objMeterValue.ToString(), CultureInfo.InvariantCulture); strDisplayMeterValue = "Comm. Status Field " + (iIndex + 1).ToString(CultureInfo.InvariantCulture); } } if (objProgramValue != null) { if (String.Compare(objProgramValue.ToString(), "3", StringComparison.OrdinalIgnoreCase) == 0) { strDisplayProgramValue = "No Display Item"; } else { int iIndex = Convert.ToInt32(objProgramValue.ToString(), CultureInfo.InvariantCulture); strDisplayProgramValue = "Comm. Status Field " + (iIndex + 1).ToString(CultureInfo.InvariantCulture); } } if (strDisplayMeterValue.Equals(strDisplayProgramValue)) { bItemsMatch = true; } break; } case (long)StdTableEnum.STDTBL123_APTITLE_NOTIFY: { if (objMeterValue != null) { strDisplayMeterValue = ESNConverter.Decode((byte[])objMeterValue); } if (objProgramValue != null) { strDisplayProgramValue = ESNConverter.Decode((byte[])objProgramValue); } if (strDisplayMeterValue.Equals(strDisplayProgramValue)) { bItemsMatch = true; } break; } case (long)StdTableEnum.STDTBL53_TIME_ZONE_OFFSET: { TimeSpan tsOffset; short sOffset; if (objMeterValue != null) { sOffset = (short)objMeterValue; tsOffset = TimeSpan.FromMinutes((double)sOffset); strDisplayMeterValue = "GMT " + tsOffset.Hours + ":00"; } if (objProgramValue != null) { sOffset = (short)objProgramValue; tsOffset = TimeSpan.FromMinutes((double)sOffset); strDisplayProgramValue = "GMT " + tsOffset.Hours + ":00"; } // Compare the values if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } break; } case (long)GatewayTblEnum.MFGTBL145_EXCEPTION_SECURITY_MODEL: { OpenWayMFGTable2193.SecurityFormat MeterValue = OpenWayMFGTable2193.SecurityFormat.None; OpenWayMFGTable2193.SecurityFormat ProgramValue = OpenWayMFGTable2193.SecurityFormat.None; if (objMeterValue != null) { MeterValue = (OpenWayMFGTable2193.SecurityFormat)(byte) objMeterValue; strDisplayMeterValue = OpenWayMFGTable2193.GetSecurityFormatString(MeterValue); } if (objProgramValue != null) { ProgramValue = (OpenWayMFGTable2193.SecurityFormat)(byte) objProgramValue; strDisplayProgramValue = OpenWayMFGTable2193.GetSecurityFormatString(ProgramValue); } bItemsMatch = ProgramValue == MeterValue; break; } case (long)GatewayTblEnum.MfgTbl145C1218OverZigBee: { bool bMeterValue = false; bool bProgramValue = false; strDisplayProgramValue = null; if (objMeterValue != null) { // We need to use the value of the bit bMeterValue = (bool)objMeterValue; } strDisplayMeterValue = bMeterValue.ToString(CultureInfo.CurrentCulture); if (objProgramValue != null) { bProgramValue = (bool)objProgramValue; strDisplayProgramValue = bProgramValue.ToString(CultureInfo.CurrentCulture); } bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); break; } case (long)GatewayTblEnum.MFGTBL145_REQUIRE_ENHANCED_SECURITY: { strDisplayProgramValue = null; if (objMeterValue != null) { strDisplayMeterValue = ((bool)objMeterValue).ToString(CultureInfo.CurrentCulture); } if (objProgramValue != null) { strDisplayProgramValue = ((bool)objProgramValue).ToString(CultureInfo.CurrentCulture); } bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); break; } case (long)GatewayTblEnum.MfgTbl58SecurityMode: { byte bySecurityMode; byte byDeviceAuthMode; byte byCBKEMode; // Get the Meter value if (objMeterValue != null && meterTables.IsCached((long)GatewayTblEnum.MfgTbl58DeviceAuthMode, null) && meterTables.IsCached((long)GatewayTblEnum.MfgTbl58CbkeMode, null)) { // We have already retrieved the Security Mode bySecurityMode = (byte)objMeterValue; // Get the other two modes meterTables.GetValue(GatewayTblEnum.MfgTbl58DeviceAuthMode, null, out objMeterValue); byDeviceAuthMode = (byte)objMeterValue; meterTables.GetValue(GatewayTblEnum.MfgTbl58CbkeMode, null, out objMeterValue); byCBKEMode = (byte)objMeterValue; // Get the HAN Profile Name strDisplayMeterValue = CHANMfgTable2106.GetHANSecurityProfile(bySecurityMode, byDeviceAuthMode, byCBKEMode); } // Get the Program value if (objProgramValue != null && programTables.IsCached((long)GatewayTblEnum.MfgTbl58DeviceAuthMode, null) && programTables.IsCached((long)GatewayTblEnum.MfgTbl58CbkeMode, null)) { // We have already retrieved the Security Mode bySecurityMode = (byte)objProgramValue; // Get the other two modes programTables.GetValue(GatewayTblEnum.MfgTbl58DeviceAuthMode, null, out objProgramValue); byDeviceAuthMode = (byte)objProgramValue; programTables.GetValue(GatewayTblEnum.MfgTbl58CbkeMode, null, out objProgramValue); byCBKEMode = (byte)objProgramValue; // Get the HAN Profile Name strDisplayProgramValue = CHANMfgTable2106.GetHANSecurityProfile(bySecurityMode, byDeviceAuthMode, byCBKEMode); } bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); break; } case (long)GatewayTblEnum.MfgTbl58InterPanMode: { bool blnSkipComparison = false; // Get the Meter value if (objMeterValue != null) { // Get the Inter PAN Mode description strDisplayMeterValue = CHANMfgTable2106.GetInterPANMode((byte)objMeterValue); } // Get the Program value if (objProgramValue != null) { // Get the Inter PAN Mode description strDisplayProgramValue = CHANMfgTable2106.GetInterPANMode((byte)objProgramValue); } else if (programTables.IsCached((long)GatewayTblEnum.MFGTBL2045_CE_VERSION_NUMBER, null)) { object objValue = null; programTables.GetValue(GatewayTblEnum.MFGTBL2045_CE_VERSION_NUMBER, null, out objValue); string strValue = objValue as string; string[] astrCEVersion = strValue.Split(new char[] { ' ', '.', '-' }); float fltCEVersion = Convert.ToSingle(astrCEVersion[0] + "." + astrCEVersion[1]); if (0 <= VersionChecker.CompareTo(fltCEVersion, CE_VERSION_LITHIUM_3_9)) { //Only skipping comparison if program value is null and program's CE version is Lithium or greater blnSkipComparison = true; } } if (true == blnSkipComparison) { bItemsMatch = true; } else { bItemsMatch = strDisplayMeterValue.Equals(strDisplayProgramValue); } break; } default: { // The GatewayTables object may return null so make sure we don't // cause an exception first. if (objMeterValue != null) { // Trim spaces and null characters so that they will display and validate correctly strDisplayMeterValue = objMeterValue.ToString().Trim(new char[] { ' ', '\0' }); } if (objProgramValue != null) { // Trim spaces and null characters so that they will display and validate correctly strDisplayProgramValue = objProgramValue.ToString().Trim(new char[] { ' ', '\0' }); } // Compare the values if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } break; } } if (bItemsMatch == false) { // There is a mismatch so add the item. InvalidItem = new ProgramValidationItem(item.Category, item.Name, strDisplayProgramValue, strDisplayMeterValue); } return(InvalidItem); }
/// <summary> /// Checks to see if the item matches and then creates a ProgramValidationItem if it does not. /// </summary> /// <param name="item">The item to validate</param> /// <param name="meterTables">The table structure for the meter.</param> /// <param name="programTables">The table structure for the program.</param> /// <returns>Returns the ProgramValidationItem for the value if the items do not match, and null if the values match.</returns> // Revision History // MM/DD/YY who Version Issue# Description // -------- --- ------- ------ --------------------------------------- // 05/23/07 RCG 8.10.05 Created // 03/26/12 AF 2.53.52 196102 Added the missing LED pulse weights // 04/19/12 jrf 2.53.56 195674 Modified to only check legacy voltage monitoring items when config is pre-Lithium. // 12/18/13 jrf 3.50.16 TQ9560 Refactored retreival of a CentronTables value into its own method. // protected override ProgramValidationItem ValidateItem(EDLValidationItem item, CentronTables meterTables, CentronTables programTables) { bool bItemsMatch = false; bool bCheckedInBaseClass = false; string strDisplayMeterValue = ""; string strDisplayProgramValue = ""; object objMeterValue; object objProgramValue; ProgramValidationItem InvalidItem = null; // Get the values objMeterValue = GetTableValue(item, meterTables); objProgramValue = GetTableValue(item, programTables); switch (item.Item) { case (long)CentronTblEnum.MFGTBL102_VH_LOW_THRESHOLD: case (long)CentronTblEnum.MFGTBL102_VH_HIGH_THRESHOLD: case (long)CentronTblEnum.MFGTBL102_RMS_VOLT_LOW_THRESHOLD: case (long)CentronTblEnum.MFGTBL102_RMS_VOLT_HIGH_THRESHOLD: { if (objMeterValue != null) { strDisplayMeterValue = objMeterValue.ToString() + "%"; } if (objProgramValue != null) { strDisplayProgramValue = objProgramValue.ToString() + "%"; } // Compare the values if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } else if (true == IsConfigVersionEqualOrGreaterThan(CE_VERSION_LITHIUM_3_9, programTables)) { //Ignoring comparison if values do not match and program's CE version is Lithium or greater bItemsMatch = true; } break; } case (long)CentronTblEnum.MFGTBL0_BLINK_MISSING_PHASES: { bool bMeterValue; bool bProgramValue; if (objMeterValue != null) { bMeterValue = (bool)objMeterValue; if (bMeterValue) { strDisplayMeterValue = "Blink Phase Indicator"; } else { strDisplayMeterValue = "Turn Off Phase Indicator"; } } if (objProgramValue != null) { bProgramValue = (bool)objProgramValue; if (bProgramValue) { strDisplayProgramValue = "Blink Phase Indicator"; } else { strDisplayProgramValue = "Turn Off Phase Indicator"; } } if (strDisplayProgramValue == strDisplayMeterValue) { bItemsMatch = true; } break; } case (long)CentronTblEnum.MFGTBL121_PULSE_OUTPUT1_QUANTITY_NORMAL: case (long)CentronTblEnum.MFGTBL121_PULSE_OUTPUT1_QUANTITY_TEST: { LEDQuantity MeterQuantity = null; LEDQuantity ProgramQuantity = null; if (objMeterValue != null) { MeterQuantity = new LEDQuantity((uint)objMeterValue); strDisplayMeterValue = MeterQuantity.Description; } if (objProgramValue != null) { ProgramQuantity = new LEDQuantity((uint)objProgramValue); strDisplayProgramValue = ProgramQuantity.Description; } if (strDisplayMeterValue == strDisplayProgramValue) { bItemsMatch = true; } break; } case (long)CentronTblEnum.MFGTBL121_FORM_1S_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_2S_C200_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_2S_C320_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_3S_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_4S_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_9S_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_12S_C200_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_12S_C320_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_16S_C200_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_16S_C320_PULSE_WEIGHT: case (long)CentronTblEnum.MFGTBL121_FORM_45S_PULSE_WEIGHT: { float fMeterValue = 0.0f; float fProgramValue = 0.0f; if (objMeterValue != null) { fMeterValue = (ushort)objMeterValue * 0.025f; strDisplayMeterValue = fMeterValue.ToString("F3", CultureInfo.CurrentCulture); } if (objProgramValue != null) { fProgramValue = (ushort)objProgramValue * 0.025f; strDisplayProgramValue = fProgramValue.ToString("F3", CultureInfo.CurrentCulture); } if (fMeterValue == fProgramValue) { bItemsMatch = true; } break; } default: { InvalidItem = base.ValidateItem(item, meterTables, programTables); bCheckedInBaseClass = true; break; } } if (bItemsMatch == false && bCheckedInBaseClass == false) { // There is a mismatch so add the item. InvalidItem = new ProgramValidationItem(item.Category, item.Name, strDisplayProgramValue, strDisplayMeterValue); } return(InvalidItem); }