/// <summary> /// Creates a new sensor. /// </summary> /// <param name="sensorType">Sensor type.</param> /// <param name="initialMeasurement">Initial measurement.</param> /// <param name="isRelative">If set to <c>true</c> is relative.</param> protected Sensor(ESensorType sensorType, Scalar initialMeasurement, bool isRelative = true) { type = sensorType; _measurement = initialMeasurement; this.isRelative = isRelative; supportedUnits = new List <Unit>(SensorUtils.GetSensorTypeUnitMapping()[type]).ToArray(); }
/// <summary> /// Formats this sensor's measurement into a user friendly string. /// </summary> /// <returns>The formatted string.</returns> /// <param name="includeUnit">If set to <c>true</c> include unit.</param> public string ToFormattedString(bool includeUnit) { if (isOverloaded || !(this is ManualSensor) && !(unit == Units.Vacuum.IN_HG || unit == Units.Pressure.IN_HG) && (measurement.ConvertTo(maxMeasurement.unit).amount > maxMeasurement.amount || measurement.ConvertTo(minMeasurement.unit).amount < minMeasurement.amount)) { return("OL"); } else { return(SensorUtils.ToFormattedString(measurement, includeUnit)); } }
/// <summary> /// Builds a formatted string of this sensor's measurement. /// </summary> /// <remarks> /// The string will NOT include the sensor's unit. /// </remarks> /// <returns>The formatted string.</returns> /// <param name="sensor">Sensor.</param> public static string ToFormattedString(this Sensor sensor, bool includeUnit = false) { return(SensorUtils.ToFormattedString(sensor.measurement, includeUnit)); }