Example #1
0
        /**
         * <summary>
         *   Returns the uncalibrated, unrounded raw value returned by the
         *   sensor, in the specified unit, as a floating point number.
         * <para>
         * </para>
         * <para>
         * </para>
         * </summary>
         * <returns>
         *   a floating point number corresponding to the uncalibrated, unrounded raw value returned by the
         *   sensor, in the specified unit, as a floating point number
         * </returns>
         * <para>
         *   On failure, throws an exception or returns <c>YSensor.CURRENTRAWVALUE_INVALID</c>.
         * </para>
         */
        public double get_currentRawValue()
        {
            double res;

            if (_func == null)
            {
                throw new YoctoApiProxyException("No Sensor connected");
            }
            res = _func.get_currentRawValue();
            if (res == YAPI.INVALID_DOUBLE)
            {
                res = Double.NaN;
            }
            return(res);
        }
Example #2
0
        private void DisplayValue(YSensor fct)
        {
            double value      = fct.get_currentValue();
            double rawvalue   = fct.get_currentRawValue();
            double resolution = fct.get_resolution();
            string valunit    = fct.get_unit();

            // displays the sensor value on the ui
            ValueDisplayUnits.Text = valunit;

            if (resolution != YSensor.RESOLUTION_INVALID)
            {  // if resolution is available on the device the use it to  round the value
                string format = "F" + ((int)-Math.Round(Math.Log10(resolution))).ToString();

                RawValueDisplay.Text = "(raw value: " + (resolution * Math.Round(rawvalue / resolution)).ToString(format) + ")";
                ValueDisplay.Text    = (resolution * Math.Round(value / resolution)).ToString(format);
            }
            else
            {
                ValueDisplay.Text    = value.ToString();
                RawValueDisplay.Text = "";
            }
        }