示例#1
0
        public bool Gravar(string temperatura, int porta, bool mensagem = true)
        {
            //converte a temperatua em double
            var temp = ToDouble(temperatura, 2);

            if (temp <= 0 | temp > 50)
            {
                if (mensagem)
                {
                    MessageBox.Show($"Temperatura Inválida: {temperatura} °C");
                }
                return(false);
            }
            var reg = new Registro();

            //grava no banco de dados
            DB.Linha l = new DB.Linha();
            l.Add("temperatura", temperatura);
            l.Add("porta", porta);

            var gravou = banco.Cadastro(l.Celulas, "dlmdev", "iot_log_temperaturas");

            reg.temperatura = temp;
            reg.porta       = porta;

            return(gravou > 0);
        }
示例#2
0
        public Registro(DB.Linha l)
        {
            this.ano         = l.Get("ano").Int;
            this.mes         = l.Get("mes").Int;
            this.dia         = l.Get("dia").Int;
            this.hora_dt     = l.Get("hora").Data;
            this.temperatura = l.Get("temperatura").Double();
            this.porta       = l.Get("porta").Int;


            if (temperatura <= 35)
            {
                //Hipotermia
                cor = Brushes.Blue.Clone();
            }
            else if (temperatura <= 37.5)
            {
                //Normal
                cor = Brushes.Green.Clone();
            }
            else if (temperatura <= 39.5)
            {
                //Febre
                cor = Brushes.Orange.Clone();
            }
            else if (temperatura <= 41)
            {
                //Febre alta
                cor = Brushes.OrangeRed.Clone();
            }
            else
            {
                //Hipertermia
                cor = Brushes.Red.Clone();
            }
            cor.Opacity = .3;
        }