Exemplo n.º 1
0
        private void btnEmul_Click(object sender, EventArgs e)
        {
            EmulForm ef = new EmulForm(lTech);

            if (ef.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Technology tEmul = (Technology)ef.cbTEmul.SelectedItem, tReg = (Technology)ef.cbTReg.SelectedItem;
            double     p = double.Parse(ef.tbP.Text), mult = double.Parse(ef.tbMult.Text);
            double     du = double.Parse(ef.tbDU.Text), df = double.Parse(ef.tbDF.Text);
            double     uInit = double.Parse(ef.tbUInit.Text), duInit = double.Parse(ef.tbDUInit.Text);
            double     sInit = double.Parse(ef.tbSInit.Text), dsInit = double.Parse(ef.tbDSInit.Text);
            int        iter = int.Parse(ef.tbIter.Text);
            double     R = double.Parse(ef.tbR.Text), C = double.Parse(ef.tbC.Text);

            Variable[] arrU, arrY;
            Program.Unite(tReg.lStage.ToArray(), out arrU, out arrY);
            double[] arrUMin = new double[arrU.Length], arrUMax = new double[arrU.Length],
            arrUSMin = new double[arrU.Length], arrYMin = new double[arrY.Length],
            arrYMax  = new double[arrY.Length], arrAlpha = new double[arrY.Length],
            arrYOpt  = new double[arrY.Length];
            for (int i = 0; i < ef.dgvU.Rows.Count; i++)
            {
                arrUMin[i]  = double.Parse(ef.dgvU[1, i].Value.ToString());
                arrUMax[i]  = double.Parse(ef.dgvU[2, i].Value.ToString());
                arrUSMin[i] = double.Parse(ef.dgvU[3, i].Value.ToString());
            }
            for (int i = 0; i < ef.dgvY.Rows.Count; i++)
            {
                arrYMin[i]  = double.Parse(ef.dgvY[1, i].Value.ToString());
                arrYMax[i]  = double.Parse(ef.dgvY[2, i].Value.ToString());
                arrAlpha[i] = double.Parse(ef.dgvY[3, i].Value.ToString());
                arrYOpt[i]  = double.Parse(ef.dgvY[4, i].Value.ToString());
            }
            double[][] arrC;
            string[,] matrF;
            string repMod;

            Program.Model(arrU, arrY, out arrC, out matrF, out repMod);
            string rep;

            Program.Emulate(tReg.lStage.ToArray(), tEmul.lStage.ToArray(), p,
                            arrUMin, arrUMax, arrUSMin, arrYMin, arrYMax, arrAlpha,
                            arrYOpt, mult, du, df, uInit, duInit, sInit, dsInit, iter, R, C, out arrU, out arrY, out rep);
            wb.DocumentText = rep;
        }
Exemplo n.º 2
0
        private void btnEmul_Click(object sender, EventArgs e)
        {
            //try
            {
                EmulForm ef = new EmulForm(lTech);
                if (ef.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                Technology tEmul = (Technology)ef.cbTEmul.SelectedItem, tReg = (Technology)ef.cbTReg.SelectedItem;
                string[]   arr       = ef.tbI.Text.Split(' ');
                int[]      arrIStage = new int[arr.Length];
                for (int i = 0; i < arr.Length; i++)
                {
                    arrIStage[i] = int.Parse(arr[i]);
                }
                double     mult = double.Parse(ef.tbMult.Text);
                double     du = double.Parse(ef.tbDU.Text), df = double.Parse(ef.tbDF.Text);
                double     uInit = double.Parse(ef.tbUInit.Text), duInit = double.Parse(ef.tbDUInit.Text);
                double     sInit = double.Parse(ef.tbSInit.Text), dsInit = double.Parse(ef.tbDSInit.Text);
                int        iter = int.Parse(ef.tbIter.Text);
                double     R = double.Parse(ef.tbR.Text), C = double.Parse(ef.tbC.Text);
                Variable[] arrU, arrY;
                string     uRep;
                Program.Unite(tReg.lStage.ToArray(), out arrU, out arrY, out uRep);
                double[] arrUMin = new double[arrU.Length], arrUMax = new double[arrU.Length],
                arrUSMin = new double[arrU.Length], arrYMin = new double[arrY.Length],
                arrYMax  = new double[arrY.Length], arrAlpha = new double[arrY.Length],
                arrYOpt  = new double[arrY.Length];
                for (int i = 0; i < ef.dgvU.Rows.Count; i++)
                {
                    arrUMin[i]  = double.Parse(ef.dgvU[1, i].Value.ToString());
                    arrUMax[i]  = double.Parse(ef.dgvU[2, i].Value.ToString());
                    arrUSMin[i] = double.Parse(ef.dgvU[3, i].Value.ToString());
                }
                for (int i = 0; i < ef.dgvY.Rows.Count; i++)
                {
                    arrYMin[i]  = double.Parse(ef.dgvY[1, i].Value.ToString());
                    arrYMax[i]  = double.Parse(ef.dgvY[2, i].Value.ToString());
                    arrAlpha[i] = double.Parse(ef.dgvY[3, i].Value.ToString());
                    arrYOpt[i]  = double.Parse(ef.dgvY[4, i].Value.ToString());
                }
                double[][] arrC;
                string[,] matrF;
                string repMod;
                Program.Model(arrU, arrY, out arrC, out matrF, out repMod);
                string     rep;
                Variable[] arrUEmul, arrYEmul;
                Program.Emulate(tReg.lStage.ToArray(), tEmul.lStage.ToArray(), arrIStage,
                                arrUMin, arrUMax, arrUSMin, arrYMin, arrYMax, arrAlpha,
                                arrYOpt, mult, du, df, uInit, duInit, sInit, dsInit, iter, R, C, out arrUEmul, out arrYEmul,
                                out arrU, out arrY, out rep);
                wb.DocumentText = rep;
                List <Variable> lVEmul = new List <Variable>(arrUEmul), lV = new List <Variable>(arrU);
                lVEmul.AddRange(arrYEmul);
                lV.AddRange(arrY);
                DiagForm form = new DiagForm(lVEmul.ToArray(), lV.ToArray());
                form.Show();
            }
            //catch
            {
                //MessageBox.Show("Ошибка эмуляции");
            }
        }