コード例 #1
0
        private void buttonGetModel_Click(object sender, EventArgs e)
        {
            int    n = 0;
            double coeff = 0, deltaCoeff = 0, deltaSM = 0;

            double[] masDelta;
            try
            {
                n          = (int)numericUpDownN.Value;
                coeff      = (double)numericUpDownK.Value;
                deltaCoeff = (double)numericUpDownDK.Value;
                {
                    List <double> l = new List <double> {
                    };
                    foreach (DataGridViewCell cell in dataGridViewDeltaI.Rows[0].Cells)
                    {
                        l.Add(Convert.ToDouble(cell.Value));
                    }
                    masDelta = l.ToArray();
                }
                deltaSM = (double)numericUpDownDUsm.Value;
            }
            catch
            {
                MessageBox.Show("Неверный формат входных параметров!");
                return;
            }

            DACEmulator emulator = new DACEmulator(coeff, deltaCoeff, masDelta, deltaSM);

            voltagesQuantumStep = emulator.RealStep;
            int countNumbers = (int)Math.Pow(2, n);

            modelVoltages = new double[countNumbers];
            idealVoltages = new double[countNumbers];

            dataGridViewVect.Rows.Clear();
            for (int x = 0; x < countNumbers; x++)
            {
                modelVoltages[x] = emulator.Uin(x);
                idealVoltages[x] = emulator.IdealUin(x);
                LongBits binaryCode = emulator.GetDKFromComparators(x);
                LongBits inCode     = new LongBits(x, n);
                int[]    errorInds  = emulator.GetEKPErrorFromComparators(x);

                dataGridViewVect.Rows.Add(new object[] { inCode, binaryCode, inCode.ToLong(), binaryCode.ToLong(), string.Join(", ", errorInds) });
                if (inCode != binaryCode)
                {
                    dataGridViewVect.Rows[x].DefaultCellStyle.BackColor = errorCellBackColor;
                }
            }
            modelVoltageColor = Color.DarkOrchid;
            VoltageChartService chartService = new VoltageChartService(this.mainChart, "Входное напряжение", voltagesQuantumStep);

            chartService.AddInputVoltageList("Voltages", modelVoltages, modelVoltageColor, 2);
            chartService.AddInputVoltageList("Ideal voltages", idealVoltages, idealVoltageColor, 2);
        }
コード例 #2
0
        private void buttonGetModel_Click(object sender, EventArgs e)
        {
            int    n = 0;
            double coeff = 0, deltaCoeff = 0, deltaSM = 0, deltaI = 0;

            try
            {
                n          = (int)numericUpDownN.Value;
                coeff      = (double)numericUpDownK.Value;
                deltaCoeff = (double)numericUpDownDK.Value;
                deltaI     = (double)numericUpDownDI.Value;
                deltaSM    = (double)numericUpDownDUsm.Value;
            }
            catch
            {
                MessageBox.Show("Неверный формат входных параметров!");
                return;
            }
            if (graphForm != null && graphForm.Visible)
            {
                graphForm.SelectedPoint = new Point3D((float)deltaCoeff, (float)deltaSM, (float)deltaI);
                graphForm.RefreshGraph();
            }

            DACEmulator emulator = new DACEmulator(n, coeff, deltaCoeff, deltaI, deltaSM);

            voltagesQuantumStep = emulator.RealStep;
            int countNumbers = (int)Math.Pow(2, n);

            modelVoltages = new double[countNumbers];
            idealVoltages = new double[countNumbers];

            dataGridViewVect.Rows.Clear();
            for (int x = 0; x < countNumbers; x++)
            {
                modelVoltages[x] = emulator.Uin(x);
                idealVoltages[x] = emulator.IdealUin(x);
                LongBits binaryCode = emulator.GetDKFromComparators(x);
                LongBits inCode     = new LongBits(x, n);
                int[]    errorInds  = emulator.GetEKPErrorFromComparators(x);

                dataGridViewVect.Rows.Add(new object[] { inCode, binaryCode, inCode.ToLong(), binaryCode.ToLong(), string.Join(", ", errorInds) });
                if (inCode != binaryCode)
                {
                    dataGridViewVect.Rows[x].DefaultCellStyle.BackColor = errorCellBackColor;
                }
            }
            toolStripMenuItemCopy.Visible = true;
            modelVoltageColor             = Color.DarkOrchid;
            VoltageChartService chartService = new VoltageChartService(this.mainChart, "Входное напряжение", voltagesQuantumStep);

            chartService.AddInputVoltageList("Voltages", modelVoltages, modelVoltageColor, 2);
            chartService.AddInputVoltageList("Ideal voltages", idealVoltages, idealVoltageColor, 2);
        }
コード例 #3
0
        private void buttonCritical_Click(object sender, EventArgs e)
        {
            int    n = 0, deltaIndex = 0;
            double coeff = 0, deltaCoeff = 0, deltaSM = 0;

            n     = (int)numericUpDownN.Value;
            coeff = (double)numericUpDownK.Value;
            try
            {
                deltaSM = double.Parse(labelCriticalDsm.Text);
            }
            catch
            {
                MessageBox.Show("Критические параметры отсутствуют!");
                return;
            }
            DACEmulator emulator = new DACEmulator(n, coeff, deltaCoeff, deltaIndex, deltaSM);

            voltagesQuantumStep = emulator.RealStep;
            int countNumbers = (int)Math.Pow(2, n);

            modelVoltages = new double[countNumbers];
            idealVoltages = new double[countNumbers];

            dataGridViewVect.Rows.Clear();
            for (int x = 0; x < countNumbers; x++)
            {
                modelVoltages[x] = emulator.Uin(x);
                idealVoltages[x] = emulator.IdealUin(x);
                LongBits binaryCode = emulator.GetDKFromComparators(x);
                LongBits inCode     = new LongBits(x, n);
                int[]    errorInds  = emulator.GetEKPErrorFromComparators(x);

                dataGridViewVect.Rows.Add(new object[] { inCode, binaryCode, inCode.ToLong(), binaryCode.ToLong(), string.Join(", ", errorInds) });
                if (inCode != binaryCode)
                {
                    dataGridViewVect.Rows[x].DefaultCellStyle.BackColor = errorCellBackColor;
                }
            }
            toolStripMenuItemCopy.Visible = true;
            modelVoltageColor             = Color.FromKnownColor(KnownColor.Highlight);
            VoltageChartService chartService = new VoltageChartService(this.mainChart, "Входное напряжение при критическом δсм", voltagesQuantumStep);

            chartService.AddInputVoltageList("Voltages", modelVoltages, modelVoltageColor, 2);
            chartService.AddInputVoltageList("Ideal voltages", idealVoltages, idealVoltageColor, 2);
        }