public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null)
            {
                return("N/A");
            }

            if (values.Length <= 0)
            {
                return("N/A");
            }

            var    temp = (double)values[0];
            string unit;

            if (values[1].Equals("f"))
            {
                unit = "°F";
                temp = ConvertTemp.ConvertCelsiusToFahrenheit(temp);
            }
            else
            {
                unit = "°C";
            }

            return(temp + " " + unit);
        }
Ejemplo n.º 2
0
        private Double GetTemp()
        {
            Double result = 0.0;

            try
            {
                DirectoryInfo devicesDir = new DirectoryInfo("/sys/bus/w1/devices");

                //  Console.WriteLine("dir " + devicesDir.FullName);

                //Console.WriteLine("Address -" + address);
                foreach (var deviceDir in devicesDir.EnumerateDirectories(address))
                {
                    var w1slavetext =
                        deviceDir.GetFiles("w1_slave").FirstOrDefault().OpenText().ReadToEnd();
                    string temptext =
                        w1slavetext.Split(new string[] { "t=" }, StringSplitOptions.RemoveEmptyEntries)[1];

                    //  Console.WriteLine("temp " + temptext);

                    result = ConvertTemp.ConvertCelsiusToFahrenheit(double.Parse(temptext) / 1000);;

                    return(result);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(result);
        }
        public ActionResult GetFromCelsius(long c)
        {
            ConvertTemp.CelsiusToFahrenheit(c);
            ConvertTemp.CelsiusToKelvin(c);

            return(View());
        }
        public ActionResult GetFromKelvin(long k)
        {
            double kelvin = ConvertTemp.KelvinToCelsius(k);

            ConvertTemp.CelsiusToFahrenheit(kelvin);

            return(View());
        }
        public ActionResult GetFromFahrenheit(long f)
        {
            double celsius = ConvertTemp.FahrenheitToCelsius(f);

            ConvertTemp.CelsiusToKelvin(celsius);

            return(View());
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            double answer;

            Console.WriteLine("{0}={1}", 37,
                              answer = ConvertTemp.ConvertCelsiusToFahrenheit(37));
            Console.ReadLine();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            double c;

            Console.WriteLine("Informe a temparatura em graus C : ");
            c = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("{0} = {1}", c, ConvertTemp.ConverteCelsiusToFahrenheit(c));
            Console.ReadKey();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            double f;

            Console.WriteLine("Informe a temparatura em graus F : ");
            f = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("{0} = {1}", f, ConvertTemp.ConverteFahrenheitToCelsius(f));
            Console.ReadKey();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            double k;

            Console.WriteLine("Informe a temperatura em Kelvin :");
            k = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("{0} = {1}", k, ConvertTemp.ConverteKelvinToCelsius(k));
            Console.ReadKey();
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            double bala;

            Console.WriteLine("Informe o produto :");
            bala = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("{0} = {1}", C, ConvertTemp.ConverteBalaValor(bala));
            Console.ReadKey();
        }
Ejemplo n.º 11
0
        private void OnTick(object sender, object e)
        {
            // Status LEDs
            if (i++ % 5 == 0) // this is true every 500ms
            {
                // If you want an LED some where on the external enclosure, use a PWN PIN
                //hat.SetPwmDutyCycle(FEZHAT.PwmPin.Pwm6, AreLedsOn ? 1.0 : 0.0);

                // On-board LED
                hat.DIO24On = AreLedsOn;

                AreLedsOn = !AreLedsOn;
            }

            LightLevelReading = hat.GetLightLevel() * 100;

            TemperatureReading = ConvertTemp.ConvertCelsiusToFahrenheit(hat.GetTemperature());
        }
Ejemplo n.º 12
0
    private void ConvertTemp(ref SizingModel model)
    {
        //load Formula Temp, TempR
        var fTemp = UmbracoContext.ContentCache.GetById(1386).GetProperty("cal").Value.ToString();
        //calculate Temp
        var cTemp = new ConvertTemp {
            CTemp = model.CTemp, UnitTemp = model.UnitTemp
        };
        var parsefTemp = fTemp.Replace("$", "cTemp.");
        var reg        = new TypeRegistry();

        reg.RegisterSymbol("cTemp", cTemp);
        var process = new CompiledExpression(parsefTemp)
        {
            TypeRegistry   = reg,
            ExpressionType = CompiledExpressionType.StatementList
        };

        process.Compile();
        process.Eval();
        //Result
        model.Temp  = cTemp.Temp;
        model.TempR = cTemp.TempR;
    }
Ejemplo n.º 13
0
        private async void _timer_Tick(object sender, object e)
        {
            reading = new DhtReading();
            reading = await _dht.GetReadingAsync().AsTask();

            if (reading.IsValid)
            {
                txtTemp.Text = (reading.Temperature).ToString() + " °C" + "       " + (ConvertTemp.ConvertCelsiusToFahrenheit(reading.Temperature).ToString() + " °F");
            }
            else
            {
            }
        }
Ejemplo n.º 14
0
 public void TestMethod2()
 {
     Assert.AreEqual(ConvertTemp.TempConvert(1, "f"), (1 - 32) * (5 / 9));
 }
Ejemplo n.º 15
0
 public void TestMethod1()
 {
     Assert.AreEqual(ConvertTemp.TempConvert(1, "c"), 1 * (9 / 5) + 32);
 }