/// <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);
        }
        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);
        }
Exemple #4
0
        /// <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);
        }