/// <summary> /// Convert the given Metar.Temperature to desired unit. /// </summary> /// <param name="temp">Temperature to convert.</param> /// <param name="toUnit">Unit to convert the value to.</param> public static Temperature Temperature(Temperature temp, TempUnit toUnit) { //temp.Value = Temperature(temp.Value, temp.Unit, toUnit); temp.Value = Temperature(temp.Value, toUnit); temp.Unit = toUnit; return(temp); }
public void Trigger(int eventId, TempUnit unit) { triggerArgs.Reset(); triggerArgs.AddUnit(unit.key, unit.unit); triggerArgs.Trigger(this, _triggers, eventId); }
public void setTempUnit(int chn, TempUnit un) { if (chn >= 0 && chn < nChannels) { tempUnits[chn] = un; } }
public static extern int TC08GetTemp(short handle, float[] temp_buffer, int[] times_ms_buffer, int buffer_length, out short overflow_flag, short channel, TempUnit units, short fill_missing );
public void Act(IGameAction action, TempUnit unit) { if (action != null) { triggerArgs.Reset(); triggerArgs.AddUnit(unit); triggerArgs.Act(this, action); } }
/// <summary> /// Convert the given temperature value to desired unit. /// </summary> /// <param name="value">Value to convert.</param> /// <param name="toUnit">Unit to convert the value to.</param> public static double Temperature(double value, TempUnit toUnit) { if (toUnit == TempUnit.Fahrenheit) { return(((9.0 / 5.0) * value) + 32); } else { return((5.0 / 9.0) * (value - 32)); } }
public static float FromKelvin(float kelvin, TempUnit tempUnit) { switch (tempUnit) { case TempUnit.Celsius: return(TempConverter.KelvinToCelsius(kelvin)); case TempUnit.Fahrenheit: return(TempConverter.KelvinToFahrenheit(kelvin)); default: return(default); } }
public static double UniversalConversion(double temp, TempUnit from, TempUnit to) { if (from == TempUnit.Celsius) { if (to == TempUnit.Celsius) { return(temp); } if (to == TempUnit.Fahrenheit) { return(CelsiusToFahrenheit(temp)); } if (to == TempUnit.Kelvin) { return(CelsiusToKelvin(temp)); } } if (from == TempUnit.Fahrenheit) { if (to == TempUnit.Celsius) { return(FahrenheitToCelsius(temp)); } if (to == TempUnit.Fahrenheit) { return(temp); } if (to == TempUnit.Kelvin) { return(FahrenheitToKelvin(temp)); } } if (from == TempUnit.Kelvin) { if (to == TempUnit.Celsius) { return(KelvinToCelsius(temp)); } if (to == TempUnit.Fahrenheit) { return(KelvinToFarenheit(temp)); } if (to == TempUnit.Kelvin) { return(temp); } } return(temp); }
private void ddTemperature_OnSelectedIndexChange(object sender, EventArgs e) { if (ddTemperature.SelectedItem != null) { var newUnit = UnitParser.ParseTempUnit((string)ddTemperature.SelectedItem); _mTemperatureValue = ddTemperature.ConvertValue(_mActiveTempUnit, newUnit, _mTemperatureValue); if (!double.IsNaN(_mTemperatureValue)) { tbTemperature.Text = Parsing.DoubleToString(_mTemperatureValue); } _mActiveTempUnit = newUnit; Settings.Default.TMTempUnit = _mActiveTempUnit.ToString(); } }
private void ProcessLoadEvent(object sender, EventArgs e) { if (!DesignMode) { ddTemperature.Converter = StockConverters.GetConverterByName("Temperature"); _mActiveTempUnit = UnitParser.ParseTempUnit(Settings.Default.TMTempUnit); ddTemperature.SelectedItem = _mActiveTempUnit; _mActivePressureUnit = UnitParser.ParsePressureUnit(Settings.Default.TMPressureUnit); ddPressure.Converter = StockConverters.GetConverterByName("Pressure"); ddPressure.SelectedItem = _mActivePressureUnit; _mActiveVolumeUnit = UnitParser.ParseVolumeUnit(Settings.Default.TMVolumeUnit); ddTankVolume.Converter = StockConverters.GetConverterByName("Volume"); ddTankVolume.SelectedItem = _mActiveVolumeUnit; ddMass.Converter = StockConverters.GetConverterByName("Mass"); ddMass.SelectedItem = UnitParser.ParseMassUnit(Settings.Default.TMMassUnit); } }
public GetWeatherService(string apiKey, string inputLocation, string unit = "Celsius") { var defaultApiKey = AppDomain.CurrentDomain.GetData("DefaultWeatherApiKey").ToString(); _apiKey = ((apiKey == null || apiKey == "") ? defaultApiKey : apiKey); _location = inputLocation; switch (unit) { case "F": this._unit = TempUnit.F; break; case "K": this._unit = TempUnit.K; break; case "C": default: this._unit = TempUnit.C; break; } }
private void comboBox1_DropDownClosed(object sender, EventArgs e) { LastAnswer = true; if (TempUnit.Text == "Fahrenheit (°F)") { TempCalc = Double.Parse(TextResult.Text); TempCalc = TempCalc - 32; TempCalc = TempCalc * 0.55555555555555555555555555555555555; TempCalc = Math.Round(TempCalc, 2); Temp1.Text = TempCalc.ToString() + "°C"; TempCalc = TempCalc + 273.15; Temp2.Text = TempCalc.ToString() + "K"; } if (TempUnit.Text == "Celsius (°C)") { TempCalc = Double.Parse(TextResult.Text); TempCalc = TempCalc * 1.8; TempCalc = TempCalc + 32; TempCalc = Math.Round(TempCalc, 2); Temp1.Text = TempCalc.ToString() + "°F"; TempCalc = Double.Parse(TextResult.Text) + 273.15; TempCalc = Math.Round(TempCalc, 2); Temp2.Text = TempCalc.ToString() + "K"; } if (TempUnit.Text == "Kelvin (K)") { TempCalc = Double.Parse(TextResult.Text); TempCalc = TempCalc - 273.15; TempCalc = Math.Round(TempCalc, 2); Temp1.Text = TempCalc.ToString() + "°C"; TempCalc = TempCalc * 1.8; TempCalc = TempCalc + 32; TempCalc = Math.Round(TempCalc, 2); Temp2.Text = TempCalc.ToString() + "°F"; } TempUnit.Select(0, 0); }
public static extern short TC08GetSingle(short handle, float[] temp, short *overflow_flags, TempUnit units );
/// <summary> /// Read temperature from sensor /// </summary> /// <param name="unit">Temperature unit (°C or °F)</param> /// <returns>Temperature value</returns> public double ReadTemperature(TempUnit unit) { double temp; double d1 = 0, d2 = 0; // T = d1 + d2 * SOt // determinate d1, based on temperature unit and voltage if (unit == TempUnit.Celsius) { switch (this.voltage) { case Voltage.Vdd_5V: d1 = D1_VDD5V_C; break; case Voltage.Vdd_4V: d1 = D1_VDD4V_C; break; case Voltage.Vdd_3_5V: d1 = D1_VDD3_5V_C; break; case Voltage.Vdd_3V: d1 = D1_VDD3V_C; break; case Voltage.Vdd_2_5V: d1 = D1_VDD2_5V_C; break; default: break; } } else if (unit == TempUnit.Farenheit) { switch (this.voltage) { case Voltage.Vdd_5V: d1 = D1_VDD5V_F; break; case Voltage.Vdd_4V: d1 = D1_VDD4V_F; break; case Voltage.Vdd_3_5V: d1 = D1_VDD3_5V_F; break; case Voltage.Vdd_3V: d1 = D1_VDD3V_F; break; case Voltage.Vdd_2_5V: d1 = D1_VDD2_5V_F; break; default: break; } } // determinate d2, based on temperature unit and bit resolution byte status = this.ReadStatusRegister(); // less resolution : 8bit RH, 12bit Temp if ((status & LESS_RESOLUTION) != 0x00) { if (unit == TempUnit.Celsius) { d2 = D2_12BIT_C; } else if (unit == TempUnit.Farenheit) { d2 = D2_12BIT_F; } } // high resolution : 12bit RH, 14bit Temp else { if (unit == TempUnit.Celsius) { d2 = D2_14BIT_C; } else if (unit == TempUnit.Farenheit) { d2 = D2_14BIT_F; } } temp = d1 + d2 * this.ReadTemperatureRaw(); return(temp); }
public Temperature(double value, TempUnit unit, DateTime?time = null) { this.Value = value; this.Unit = unit; this.Time = time; }