コード例 #1
0
 protected override double convertValue(string sHexVal, int index)
 {
     return((double)RQCompressedHex.convertToInt(sHexVal));
 }
コード例 #2
0
        private void interpretMonitoringString(string monStr, long timestamp)
        {
            // Tracer.Trace("MON: " + monStr);

            int j = 0;

            for (int i = 1; i < monStr.Length && j < monitorStringValueNames.GetLength(0); i += 2)
            {
                string sHexVal   = monStr.Substring(i, 2);
                string valueName = monitorStringValueNames[j];

                RQMeasuredValue measuredValue = new RQMeasuredValue();
                bool            mustAdd       = false;

                if (m_measuredValues.ContainsKey(valueName))
                {
                    measuredValue = (RQMeasuredValue)m_measuredValues[valueName];
                }
                else
                {
                    measuredValue = new RQMeasuredValue();
                    mustAdd       = true;
                }

                lock (measuredValue)
                {
                    measuredValue.timestamp   = timestamp;
                    measuredValue.valueName   = valueName;
                    measuredValue.stringValue = sHexVal;
                    measuredValue.intValue    = Int32.Parse(sHexVal, NumberStyles.HexNumber);
                    switch (monitorStringValueConverters[j])
                    {
                    default:
                        measuredValue.doubleValue = (double)measuredValue.intValue;
                        break;

                    case 1:
                        measuredValue.doubleValue = RQVoltage.convertToMainVoltage(sHexVal);
                        break;

                    case 2:
                        measuredValue.doubleValue = RQVoltage.convertToInternalVoltage(sHexVal);
                        break;

                    case 3:
                        measuredValue.doubleValue = RQTemperature.convertToCelcius(sHexVal);
                        break;

                    case 4:
                        measuredValue.intValue    = RQCompressedHex.convertToInt(sHexVal);
                        measuredValue.doubleValue = (double)measuredValue.intValue;
                        break;
                    }
                }

                if (mustAdd)
                {
                    m_measuredValues.Add(valueName, measuredValue);
                }

                // Tracer.Trace(valueName + "=" + sHexVal + "=" + measuredValue.doubleValue);
                j++;
            }
        }