private void timer1_Tick(object sender, EventArgs e)
        {
            this.label148.Text = "Trwa pomiar...";
            Application.DoEvents();
            Thread.Sleep(0);

            Complex imp = Program.a.GetMeasurement();

            this.label148.Text = AgilentHelper.ImpedanceToString(imp, false);
            Application.DoEvents();
            Thread.Sleep(0);

            StringBuilder sb = new StringBuilder();

            sb.Append(DateTime.Now.ToLongTimeString());
            sb.Append("\t");
            sb.Append(imp.Real);
            sb.Append("\t");
            sb.Append(imp.Imaginary);
            sb.AppendLine();

            using (StreamWriter sw = File.AppendText(this.tbFileName.Text))
            {
                sw.Write(sb.ToString());
                sw.Flush();
            }
        }
        private void btnDoOneMeasurement_Click(object sender, EventArgs e)
        {
            Complex cap = Program.a.GetMeasurement();

            if (this.rbParallelCapacitance.Checked || this.rbSerialCapacitance.Checked)
            {
                this.label148.Text = AgilentHelper.CapacitanceToString(cap, false);
            }
            else if (this.rbImpedance.Checked)
            {
                this.label148.Text = AgilentHelper.ImpedanceToString(cap, false);
            }
            else
            {
                this.label148.Text = "????";
            }
        }
Esempio n. 3
0
        private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            var grid   = sender as DataGridView;
            var rowIdx = (e.RowIndex + 1).ToString();

            Complex value = (Complex)e.Value;

            if (value == Complex.Zero)
            {
                // puste kratki
                e.Value = "";
                return;
            }

            // wyświetlaj pojemność
            if (MeasurementType == MeasurementType.Capacitance_Parallel || MeasurementType == MeasurementType.Capacitance_Serial)
            {
                if (value.Real > 100)
                {
                    e.Value = "ovld";
                }
                else
                {
                    e.Value = AgilentHelper.CapacitanceToString(value, true).Replace(" ", "");
                }

                return;
            }

            if (MeasurementType == MeasurementType.Resistance_Reactance)
            {
                e.Value = AgilentHelper.ImpedanceToString(value, true).Replace(" ", "");
                return;
            }

            throw new Exception("MeasurementType");
        }
        private void btnDoOneMeasurement_Click(object sender, EventArgs e)
        {
            Complex imp = Program.a.GetMeasurement();

            this.label148.Text = AgilentHelper.ImpedanceToString(imp, false);
        }
        private void DoImpedanceMeasurement(bool show_finish_message)
        {
            DateTime tstart = DateTime.Now;

            int N     = (int)this.edtNumberOfElectrodes.Value;
            int pairs = (N * (N - 1)) / 2;
            int measurements_per_pair = (int)this.edtNumberOfMeasurementsPerPair.Value;

            this.progressBar1.Value   = 0;
            this.progressBar1.Maximum = pairs * measurements_per_pair;

            if (mg == null)
            {
                mg = new MeasurementGrid();
            }

            DataTable dt = mg.PrepareDataContainer(N, Program.a.MeasurementType);

            mg.Show();

            Program.m.SetAllChannels(ChannelState.Ground);
            Thread.Sleep(200);

            Program.a.RestartMeasurementCycle();
            int prev_channel = 1;

            for (int excitated_electrode = 1; excitated_electrode <= N; excitated_electrode++)
            {
                // ustaw elektrodę wymuszającą na wysokim wejsciu mostka
                Program.m.SetChannel(excitated_electrode, ChannelState.High);
                Thread.Sleep(300);
                Program.a.GetMeasurement();

                for (int measured_electrode = excitated_electrode + 1; measured_electrode <= N; measured_electrode++)
                {
                    // ustaw elektrode mierzona na niskim wejsciu mostka
                    Program.m.SetChannel(prev_channel, ChannelState.Ground, measured_electrode, ChannelState.Low);
                    prev_channel = measured_electrode;
                    //Program.m.SetChannel(measured_electrode, ChannelState.Low);

                    Program.a.ShowMessage(string.Format("Elektrody {0}-{1}", excitated_electrode, measured_electrode));

                    // wykonaj serię pomiaraów dla danej kombinacji elektrod
                    for (int i = 0; i < measurements_per_pair; i++)
                    {
                        Application.DoEvents();

                        if (this.socket_driver_window != null)
                        {
                            this.socket_driver_window.UpdateGUI();
                        }
                        Application.DoEvents();

                        Complex cap = Program.a.GetMeasurement();
                        Application.DoEvents();

                        dt.Rows[excitated_electrode - 1][measured_electrode - 1] = cap;

                        this.lblCurrentCapacity.Text = AgilentHelper.ImpedanceToString(cap, false);
                        this.progressBar1.Value++;
                        Application.DoEvents();
                    }

                    //                    Program.m.SetChannel(measured_electrode, ChannelState.Ground);
                    // Application.DoEvents();
                }

                Program.m.SetChannel(excitated_electrode, ChannelState.Ground);
                //Program.a.MeasureFrequency();
                //Application.DoEvents();
            }

            DateTime tstop = DateTime.Now;


            if (show_finish_message)
            {
                MessageBox.Show(
                    string.Format("Pomiar zakończony.\nWykonano {0} pomiarów dla {1} par.\nCzas pomiaru: {2:N1} sekund.", measurements_per_pair * pairs, pairs, (tstop - tstart).TotalSeconds),
                    Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }