예제 #1
0
        private float calculDataconvertiTrame(IdMesure trame)
        {
            long  temp   = (int)Math.Pow(2, trame.nbData * 8);
            float calcul = trame.data / (float)temp * (trame.intervalleMax - trame.intervalleMin) + trame.intervalleMin;

            return(calcul);
        }
예제 #2
0
 private void MettreAJourGrid(IdMesure trame)
 {
     for (int i = 0; i < grid.Rows.Count; i++)
     {
         for (int j = 0; j < grid.Columns.Count; j++)
         {
             if (j == 0 && grid.Rows[i].Cells[j].Value.ToString() == trame.id.ToString())
             {
                 grid.Rows[i].Cells[j + 3].Value = trame.intervalleMin;
                 grid.Rows[i].Cells[j + 4].Value = trame.intervalleMax;
                 grid.Rows[i].Cells[j + 2].Value = trame.dataConverti;
                 if (trame.alarmeMin != 0 || trame.alarmeMax != 0)
                 {
                     if (trame.dataConverti <= trame.alarmeMin)
                     {
                         grid.Rows[i].Cells[j + 5].Value = "Trop faible !!";
                     }
                     else if (trame.dataConverti >= trame.alarmeMax)
                     {
                         grid.Rows[i].Cells[j + 5].Value = "Trop Haut !!";
                     }
                     else
                     {
                         grid.Rows[i].Cells[j + 5].Value = "Normal";
                     }
                 }
                 else
                 {
                     grid.Rows[i].Cells[j + 5].Value = "Alarme non défini";
                 }
                 if (trame.type == 1)
                 {
                     grid.Rows[i].Cells[j + 1].Value = "Température";
                 }
                 else if (trame.type == 2)
                 {
                     grid.Rows[i].Cells[j + 1].Value = "Humidité";
                 }
                 else if (trame.type == 3)
                 {
                     grid.Rows[i].Cells[j + 1].Value = "Pression atmosphérique";
                 }
                 else if (trame.type == 4)
                 {
                     grid.Rows[i].Cells[j + 1].Value = "Luminosité";
                 }
             }
         }
     }
 }
예제 #3
0
        public void placerTrameMesure(int id, int nbr, int type, ulong data)
        {
            bool placer = false;

            foreach (IdBase trame in listeTram)
            {
                if (trame.id == id && !placer)
                {
                    IdMesure trameCorrecte = (IdMesure)trame;
                    trameCorrecte.nbData       = nbr;
                    trameCorrecte.type         = type;
                    trameCorrecte.data         = data;
                    trameCorrecte.dataConverti = calculDataconvertiTrame(trameCorrecte);
                    placer = true;
                    MettreAJourGrid(trameCorrecte);
                    if (trameCorrecte.id == idgraphiqueAAfficher && graphiqueOuvert)
                    {
                        graphControl1.ajoutervaleur((int)trameCorrecte.dataConverti, trameCorrecte.id);
                    }
                }
            }
            if (!placer)
            {
                IdMesure trame = new IdMesure();
                trame.id           = id;
                trame.nbData       = nbr;
                trame.type         = type;
                trame.data         = data;
                trame.dataConverti = calculDataconvertiTrame(trame);
                listeTram.Add(trame);
                DataGridViewRow row = (DataGridViewRow)grid.Rows[0].Clone();
                row.Cells[0].Value = trame.id;
                row.Cells[1].Value = trame.type;
                row.Cells[3].Value = trame.intervalleMin;
                row.Cells[4].Value = trame.intervalleMax;
                gridRows++;
                grid.Height = boxheight * gridRows + 3;
                grid.Invoke((MethodInvoker)(() => grid.Rows.Add(row)));
                if (trame.id == idgraphiqueAAfficher && graphiqueOuvert)
                {
                    graphControl1.ajoutervaleur((int)trame.dataConverti, trame.id);
                }
            }
        }