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); }