Ejemplo n.º 1
0
        /// <summary>
        /// This method is used to retrieve the current value of the display item.  Note that
        /// this method does not cache any values.  Therefore each time it is called, the meter
        /// will be interrogated to get the actual value that would be shown on the meter's display
        /// </summary>
        /// <remarks >
        /// MM/DD/YY who Version Issue# Description
        /// -------- --- ------- ------ ---------------------------------------
        /// 12/15/06 mah 8.00.00  N/A   Created
        /// </remarks>
        protected void GetDisplayItemValue(ref SCSDevice device)
        {
            String strValue;

            switch (RegisterClass)
            {
            case SCSDisplayClass.EnergyValue: strValue = GetEnergyValue(ref device);
                break;

            case SCSDisplayClass.InstantaneousValue:

                int nAddress = device.TranslateDisplayAddress(this);

                if (nAddress != 0)
                {
                    strValue = device.ReadFloatingPointValue(nAddress).ToString("######0.000", CultureInfo.InvariantCulture);

                    if (strValue.Length > 0)
                    {
                        // Now that we have a value that we can display we need to format it to match
                        // the display format currently configured in the meter

                        strValue = FormatDisplayValue(strValue, device.DemandFormat);
                    }
                }
                else
                {
                    strValue = "";
                }

                break;

            case SCSDisplayClass.DemandValue: strValue = GetDemandValue(ref device);
                break;

            case SCSDisplayClass.MaxDemandValue: strValue = GetMaxDemandValue(ref device);
                break;

            case SCSDisplayClass.CumulativeValue: strValue = GetCumulativeValue(ref device);
                break;

            case SCSDisplayClass.IntegerBCD: strValue = GetBCDValue(ref device);
                break;

            case SCSDisplayClass.DateValue: strValue = GetDateValue(ref device);
                break;

            case SCSDisplayClass.TimeValue: strValue = GetTimeValue(ref device);
                break;

            case SCSDisplayClass.ASCIIValue: strValue = GetAsciiValue(ref device);
                break;

            case SCSDisplayClass.FixedBCD: strValue = GetFixedBCDValue(ref device);
                break;

            case SCSDisplayClass.FloatingPointBCD: strValue = device.ReadFloatingBCDValue(device.TranslateDisplayAddress(this), 4);
                break;

            case SCSDisplayClass.TotalContinuousCumulativeValue: strValue = GetCCumValue(ref device);
                break;

            case SCSDisplayClass.BinaryValue: strValue = GetBinaryValue(ref device);
                break;

            case SCSDisplayClass.ExtendedBCDValue: strValue = GetFixedBCDValue(ref device);
                break;

            case SCSDisplayClass.TOUContinuousCumulativeValue: strValue = GetCCumValue(ref device);
                break;

            default:
                strValue = "";
                break;
            }

            Value = strValue;
        }