コード例 #1
0
ファイル: MainForm.cs プロジェクト: tora262/RFID-2018
        private void btnLut_click(object sender, EventArgs e)
        {
            cmd = new MySqlCommand("SELECT * FROM rfidreader.training", conn);
            MySqlDataReader myReader;
            Lut             lut;
            double          rssi1 = 0, rssi2 = 0, rssi3 = 0;
            int             cell = 0;

            try
            {
                OpenConnection();
                myReader = cmd.ExecuteReader();
                while (myReader.Read())
                {
                    lut = new Lut(myReader.GetInt16(1), myReader.GetDouble(2), myReader.GetDouble(3), myReader.GetDouble(4));
                    dataTraining.Add(lut);
                }
                ;
                CloseConnection();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
                CloseConnection();
            }
            lut = new Lut();
            while (count <= dataTraining.Count - 8)
            {
                for (int j = 0; j < 8; j++)
                {
                    lut    = dataTraining[j + count];
                    cell   = lut.getCell();
                    rssi1 += lut.getRssi1();
                    rssi2 += lut.getRssi2();
                    rssi3 += lut.getRssi3();
                }
                lut.setCell(cell);
                lut.setRssi1(rssi1 / 8);
                lut.setRssi2(rssi2 / 8);
                lut.setRssi3(rssi3 / 8);
                dataRssi.Add(lut);
                rssi1  = rssi2 = rssi3 = 0;
                count += 8;
            }
            //  MessageBox.Show(dataRssi.Count.ToString());
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: TrongkhanhBkhn/Nuclear
 private void btnLut_click(object sender, EventArgs e)
 {
     cmd = new MySqlCommand("SELECT * FROM rfidreader.training", conn);
     MySqlDataReader myReader;
     Lut lut;
     double rssi1 = 0, rssi2 = 0, rssi3 = 0;
     int cell = 0;
     try
     {
         OpenConnection();
         myReader = cmd.ExecuteReader();
         while (myReader.Read())
         {
             lut = new Lut(myReader.GetInt16(1), myReader.GetDouble(2), myReader.GetDouble(3), myReader.GetDouble(4));
             dataTraining.Add(lut);
         };
         CloseConnection();
     }
     catch (MySqlException ex)
     {
         MessageBox.Show(ex.Message);
         CloseConnection();
     }
     lut = new Lut();
     while (count <= dataTraining.Count -8 )
     {
         for (int j = 0; j < 8; j++)
         {
             lut = dataTraining[j + count];
             cell = lut.getCell();
             rssi1 += lut.getRssi1();
             rssi2 += lut.getRssi2();
             rssi3 += lut.getRssi3();
         }
         lut.setCell(cell);
         lut.setRssi1(rssi1 / 8);
         lut.setRssi2(rssi2 / 8);
         lut.setRssi3(rssi3 / 8);
         dataRssi.Add(lut);
         rssi1 = rssi2 = rssi3 = 0;
         count += 8;
     }
       //  MessageBox.Show(dataRssi.Count.ToString());
 }