private void button_agilent_autoscale_Click(object sender, EventArgs e) { GraphPane pane = ZedGraph_I_V.GraphPane; pane.XAxis.Scale.MaxAuto = true; pane.XAxis.Scale.MinAuto = true; pane.YAxis.Scale.MaxAuto = true; pane.YAxis.Scale.MinAuto = true; ZedGraph_I_V.AxisChange(); ZedGraph_I_V.Invalidate(); }
public Main() { InitializeComponent(); Serial_port_keithley.setCallback(process_keithley_output); GraphPane pane_it = this.ZedGraph_I_t.GraphPane; pane_it.XAxis.Title = new AxisLabel("t, ms", "Verdana", (float)14, Color.Black, true, false, false); pane_it.YAxis.Title = new AxisLabel("I, A", "Verdana", (float)14, Color.Black, true, false, false); pane_it.Title.Text = "Transient current I(t)"; ZedGraph_I_t.AxisChange(); ZedGraph_I_t.Invalidate(); GraphPane pane_iv = this.ZedGraph_I_V.GraphPane; pane_iv.XAxis.Title = new AxisLabel("U, V", "Verdana", (float)14, Color.Black, true, false, false); pane_iv.YAxis.Title = new AxisLabel("I, A", "Verdana", (float)14, Color.Black, true, false, false); pane_iv.Title.Text = "Volt-Ampere Characteristic I(V)"; ZedGraph_I_V.AxisChange(); ZedGraph_I_V.Invalidate(); }
private void process_agilent_output(object obj) { if (InvokeRequired) { ObjectDelegate method = new ObjectDelegate(process_agilent_output); Invoke(method, obj); return; } List <String> data = new List <String>(((String)obj.ToString()).Split(','));; int j = 0; try { System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); NumberStyles volt_style = NumberStyles.Number; double volt_start = Double.Parse(data[0], volt_style); data.RemoveAt(0); double volt_stop = Double.Parse(data[0], volt_style); data.RemoveAt(0); double volt_inc = Double.Parse(data[0], volt_style); data.RemoveAt(0); for (int i = data.Count - 1; i > 1; i -= 3) { data.RemoveAt(i); } char[] trim_char = { 'A' }; NumberStyles style = NumberStyles.AllowExponent | NumberStyles.Number; if (volt_start < volt_stop) { for (double i = volt_start; i <= volt_stop; i += volt_inc) { this.text_box_agilent_output.Text += i + "\t" + data[j] + "\r\n"; data[j] = data[j].TrimEnd(trim_char); double x = i; double y = Double.Parse(data[j], style); list_agilent.Add(x, y); data_logger.Trace("agilent: " + x.ToString() + " " + y.ToString()); this.text_box_agilent_output.SelectionStart = this.text_box_agilent_output.Text.Length; this.text_box_agilent_output.ScrollToCaret(); this.text_box_agilent_output.Refresh(); j += 2; } } else { for (double i = volt_start; i >= volt_stop; i -= volt_inc) { this.text_box_agilent_output.Text += i + "\t" + data[j] + "\r\n"; data[j] = data[j].TrimEnd(trim_char); double x = i; double y = Double.Parse(data[j], style); list_agilent.Add(x, y); data_logger.Trace("agilent: " + x.ToString() + " " + y.ToString()); this.text_box_agilent_output.SelectionStart = this.text_box_agilent_output.Text.Length; this.text_box_agilent_output.ScrollToCaret(); this.text_box_agilent_output.Refresh(); j += 2; } } GraphPane pane = ZedGraph_I_V.GraphPane; pane.AddCurve("I", list_agilent, Color.Blue, SymbolType.Default); ZedGraph_I_V.AxisChange(); ZedGraph_I_V.Invalidate(); } catch (System.Exception) { logger.Debug("Data: " + data[j]); } }