private void CalWorker_DoWork(object sender, DoWorkEventArgs e) { string command; for (; ;) { if (CalWorker.CancellationPending) { e.Cancel = true; return; } /////////// for (int k = 0; k < 4; k++) { R_J10x[k] = 0; } temperature = 0; // for (int p = 0; p < AVG_SAMPLES; p++) // { // MessageBox.Show(therm.Measure().ToString()); //Thread.Sleep(100); temperature = therm.Measure(); // } // temperature = temperature / AVG_SAMPLES; // MessageBox.Show(temperature.ToString()); for (int k = 0; k < 4; k++) { command = "SPA" + Convert.ToString(k * 4, 2).PadLeft(4, '0');; // MessageBox.Show(command); tools.send_commnad(command, 1); Thread.Sleep(SAMPLE_DELAY); for (int p = 0; p < AVG_SAMPLES; p++) { // MessageBox.Show(command + "\n" + tools.read_command("RUC01", 1)); R_J10x[k] += convert_data_to_R(Convert.ToDouble(tools.read_command("RUC01", 1)), 1.25, 10000); //Thread.Sleep(SAMPLE_DELAY * 10); } R_J10x[k] = R_J10x[k] / AVG_SAMPLES; } for (int k = 0; k < 4; k++) { R_J10x_q[k] = R_J10x[k]; } temperature_q = temperature; CalWorker.ReportProgress(0); //Thread.Sleep(100); ////////// } }
private void Heater_Calibrator_FormClosing(object sender, FormClosingEventArgs e) { tools.send_commnad("RK0", 0); tools.Close_Devices(); }