Пример #1
0
 protected override double convertValue(string sHexVal, int index)
 {
     return((double)RQCompressedHex.convertToInt(sHexVal));
 }
Пример #2
0
        /// <summary>
        /// only needed when controller is in RC mode, sending constant stream of data for monitoring purposes.
        /// when grabbed, controller is queried via m_queryQueue
        /// </summary>
        /// <param name="monStr"></param>
        /// <param name="timestamp"></param>
        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 = 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++;
            }
        }