private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { //clear legends chart1.Legends.Clear(); //if they want to see all files graphed together if (comboBox1.Text == "Show All") { showAll(); } else { //show single selected data set in chart1 chart1.Series.Clear(); chart1.Series.Add(comboBox1.Text); chart1.Series[comboBox1.Text].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; chart1.Series[comboBox1.Text].BorderWidth = myBorderWidth; foreach (DataRow asdf in dataSet1.Tables[comboBox1.Text].Rows) { try { COMMS.Output(asdf[0].ToString() + ", " + asdf[1].ToString()); if (asdf[0] is string) { if (asdf[0].ToString() == "permeability") { labelPerm.Text = "Permeability: " + asdf[1] + " Darcies"; } if (asdf[0].ToString() == "weight") { labelTotalWeight.Text = "Total Weight: " + asdf[1] + " g"; } if (asdf[0].ToString() == "time") { labelTotalTime.Text = "Total Time: " + asdf[1] + " Secs"; } if (asdf[0].ToString() == "flow") { labelFlow.Text = "Total Flow: " + asdf[1] + " ML/Min"; } } double testForNumeric = Convert.ToDouble(asdf[0]);//will not go past this if it's not a number chart1.Series[comboBox1.Text].Points.AddXY(Convert.ToDouble(asdf[0]), Convert.ToDouble(asdf[1])); } catch (Exception) { } } } //add a legend and axis titles. chart1.Legends.Add("s"); chart1.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Arial", 12F); chart1.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Arial", 12F); chart1.ChartAreas[0].AxisY.Title = "Weight (Grams)"; chart1.ChartAreas[0].AxisX.Title = "Time (Seconds)"; }
private void backgroundWorkerReadScale_DoWork(object sender, DoWorkEventArgs e) { while (true) { if (testStopped) { Debug.WriteLine("RETURN; hit"); Debug.WriteLine("RETURN; hit"); Debug.WriteLine("RETURN; hit"); return; } if (openValve1) { COMMS.openValve4(); openValve1 = false; } if (closeValve1) { COMMS.closeValve4(); closeValve1 = false; } scaleReading = COMMS.ReadScaleAWS(); if (scaleReading.Length > 4) { //lastValidScaleReading = filterReading(scaleReading); lastValidScaleReading = CommonClass.filterRegex(scaleReading); backgroundWorkerReadScale.ReportProgress(0); } if (testStopped) { Debug.WriteLine("testStopped hit"); Debug.WriteLine("testStopped hit"); Debug.WriteLine("testStopped hit"); return; } if ((backgroundWorkerReadScale.CancellationPending == true)) { Debug.WriteLine("e.Cancel ; hit"); Debug.WriteLine("e.Cancel ; hit"); Debug.WriteLine("e.Cancel ; hit"); e.Cancel = true; //break; return; } Thread.Sleep(150); } }
private void SetupForm_Load(object sender, EventArgs e) { //autoFindBoardPort(); if (settings.maxRepetitions > 1) { label17.Text = "The program will run up to " + settings.maxRepetitions + " rounds until the value is within " + settings.stabilizeWithin.ToString() + "g of the mean."; } else { label17.Text = ""; label18.Text = ""; } COMMS.autoFindPort(); if (COMMS.connected == false) { Close(); return; } //string testThatCOMworks = COMMS.ReadScale().ToString(); //reads the first weight value which will be first data point. try { textBox1.Text = settings.timerTimeMinutes.ToString(); } catch (Exception) { } try { textBoxSeconds.Text = settings.timerTimeSeconds.ToString(); } catch (Exception) { } try { textBox2.Text = settings.dataAcquisitionInterval.ToString(); } catch (Exception) { } if (settings.upperSelected) { radioButton1.Checked = true; textBoxHeight.Text = settings.upperHeight; } else if (settings.middleSelected) { radioButton2.Checked = true; textBoxHeight.Text = settings.middleHeight; } else if (settings.lowerSelected) { radioButton3.Checked = true; textBoxHeight.Text = settings.lowerHeight; } textBoxThickness.Text = settings.sampleThickness; textBoxDiameter.Text = settings.diameter; textBoxViscosity.Text = settings.viscosity; //textBoxHeight.Text = settings.height; loadPathString(); /* //new atira * //COMMS.openValve2();// we open valve 2 here so that the user has time to fill up the reservoir before starting the test * COMMS.closeValve2(); * Thread.Sleep(800); * COMMS.openValve1(); * Thread.Sleep(800); * COMMS.closeValve3(); */ }
private void backgroundWorkerReadScale_DoWork(object sender, DoWorkEventArgs e) { while (true) { if (testStopped) { Debug.WriteLine("RETURN; hit"); Debug.WriteLine("RETURN; hit"); Debug.WriteLine("RETURN; hit"); return; } if (openValve1) { COMMS.openValve4(); openValve1 = false; } if (closeValve1) { COMMS.closeValve4(); closeValve1 = false; } if (openValve2) { COMMS.openValve2(); openValve2 = false; } if (openValve3) { COMMS.openValve3(); openValve3 = false; } if (closeValve2) { COMMS.closeValve2(); //MessageBox.Show("Test"); closeValve2 = false; } if (closeValve3) { COMMS.closeValve3(); closeValve3 = false; } scaleReading = COMMS.ReadScaleAWS(); if (scaleReading.Length > 4) { //lastValidScaleReading = filterReading(scaleReading); lastValidScaleReading = CommonClass.filterRegex(scaleReading); backgroundWorkerReadScale.ReportProgress(0); } /* * scaleReading = COMMS.ReadScaleAWS(); * //if (scaleReading != "" && !scaleReading.Contains("M") && scaleReading.Length > 2) * if (scaleReading != "" && scaleReading.Length > 4) * { * splitReceived = scaleReading.Split(new string[] { "g" }, StringSplitOptions.None); * splitReceived = splitReceived[0].Split(new string[] { ":" }, StringSplitOptions.None); * scaleReading = splitReceived[1]; * //scaleReading = scaleReading.Substring(2, scaleReading.Length - 3); * if (scaleReading != "") * { * lastValidScaleReading = scaleReading; * } * * * backgroundWorkerReadScale.ReportProgress(0); * if ((backgroundWorkerReadScale.CancellationPending == true)) * { * Debug.WriteLine("e.Cancel ; hit"); * Debug.WriteLine("e.Cancel ; hit"); * Debug.WriteLine("e.Cancel ; hit"); * e.Cancel = true; * break; * } * } */ Thread.Sleep(150); } }
private void buttonZeroScale_Click(object sender, EventArgs e) { COMMS.zeroScale(); }
private void FormManaul_Load(object sender, EventArgs e) { testStopped = false; if (settings.upperSelected) { radioButton1.Checked = true; textBoxHeight.Text = settings.upperHeight; } else if (settings.middleSelected) { radioButton2.Checked = true; textBoxHeight.Text = settings.middleHeight; } else if (settings.lowerSelected) { radioButton3.Checked = true; textBoxHeight.Text = settings.lowerHeight; } textBoxThickness.Text = settings.sampleThickness; textBoxDiameter.Text = settings.diameter; textBoxViscosity.Text = settings.viscosity; //textBoxHeight.Text = settings.height; if (settings.checkBoxZeroScale) { checkBoxZeroScale.Checked = true; } else { checkBoxZeroScale.Checked = false; } COMMS.autoFindPort(); //COMMS.openSerial("COM3"); //MessageBox.Show(serialPort1.IsOpen.ToString()); if (COMMS.connected == false) { Close(); } //scaleReading = COMMS.ReadScaleAWSContinuous().ToString(); //reads the first weight value which will be first data point. /* * try * { * originalWeight = Convert.ToDouble(scaleReading); * } * catch (Exception) * { * Debug.WriteLine("ERROR CONVERTING ORIGINAL scaleReading to DOUBLE"); * originalWeight = 0; * }*/ currentNetWeight = 0; loadPathString(); textBox1.Text = settings.dataAcquisitionInterval.ToString(); checkBoxSaveData.Checked = settings.checkBoxSaveData; //enable this next line when ready!!!!!!!!!!!!!!!! //timerReadScale.Start(); if (backgroundWorkerReadScale.IsBusy != true) { backgroundWorkerReadScale.RunWorkerAsync(); } //chart1.Series["Series1"].Points.AddXY(String.Format("{0:#0.00}", 0), 0); chart1.Series["Series1"].BorderWidth = myBorderWidth; }
private void button8_Click(object sender, EventArgs e) { string d = COMMS.ReadScaleAWS(); labelScale.Text = "Weight = " + d + " g"; }
private void button2_Click(object sender, EventArgs e) { double d = COMMS.ReadScale(); labelScale.Text = "Weight = " + d.ToString() + " g"; }