예제 #1
0
        //show simulation settings for current file/definition
        private void simulationToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (cfg != null)
            {
                ModelType[]  model  = new ModelType[cfg.Exps.Length];
                SolverType[] solver = new SolverType[cfg.Exps.Length];

                for (int i = 0; i < cfg.Exps.Length; i++)
                {
                    model[i]  = cfg.Exps[i].Model;
                    solver[i] = cfg.Exps[i].Solver;
                }

                SettingsForm dlg = new SettingsForm("Simulation settings", false);
                dlg.AddProperty("Name", cfg.Name, false, true);
                dlg.AddProperty("N", cfg.N, false, true);
                dlg.AddProperty("dt", cfg.dt, false, true);
                dlg.AddArrayProperty("Initial conditions", cfg.x0, false, true, true, 0, 0);
                dlg.AddFileProperty("Parameter file name", cfg.ParamFileName, false, true);


                dlg.AddProperty("Numbe of experiments", cfg.Exps.Length, false, true);
                dlg.AddEnumArrayProperty <ModelType>("Model", model, false, true, false, 0, 0);
                dlg.AddEnumArrayProperty <SolverType>("Solver", solver, false, true, false, 0, 0);

                int        nLabel  = Math.Max(cfg.PlotMap.Length, 1);
                string[][] sLabels = new string[nLabel][];
                for (int i = 0; i < nLabel; i++)
                {
                    sLabels[i] = new string[3] {
                        "Define data for plot " + (i + 1).ToString(), "Gr.Ch", "Sim.Pr"
                    }
                }
                ;

                dlg.AddValuePairArrayProperty("Plot map", cfg.PlotMap, false, true, true, 0, "", sLabels);

                dlg.AddProperty("Get input from file", cfg.InputFromFile, false, true);
                dlg.AddArrayProperty("Input", cfg.u, false, true, true, 0, "");
                dlg.AddFileProperty("Input file name", cfg.InputFileName, false, true);
                dlg.AddArrayProperty("Plot heights (relative)", cfg.PlotHeights, false, true, false, 0, 0);
                dlg.AddProperty("Plot steps prescaling", cfg.PlotStep, false, true);
                dlg.AddProperty("Plot time step", cfg.PlotTimeStep, false, true);



                dlg.SetChangeAction(5, dlg, (x) => {
                    int n = (int)dlg.GetValue(5);
                    dlg.SetArraySize(6, n);
                    dlg.SetArraySize(7, n);
                    dlg.UpdatePanels();
                });
                dlg.SetChangeAction(9, dlg, (x) => {
                    bool b = (bool)dlg.GetValue(9);
                    dlg.ShowPanel(11, b);
                    dlg.ShowPanel(10, !b);
                    dlg.UpdatePanels();
                });

                dlg.ShowDialog();
                cfg.Name          = (string)dlg.GetValue(0);
                cfg.N             = (int)dlg.GetValue(1);
                cfg.dt            = (double)dlg.GetValue(2);
                cfg.x0            = (double[])dlg.GetValue(3);
                cfg.ParamFileName = (string)dlg.GetValue(4);

                int      nLen    = (int)dlg.GetValue(5);
                string[] sModel  = (string[])dlg.GetValue(6);
                string[] sSolver = (string[])dlg.GetValue(7);
                cfg.PlotMap = (string[][])dlg.GetValue(8);


                cfg.InputFromFile = (bool)dlg.GetValue(9);
                cfg.u             = (string[])dlg.GetValue(10);
                cfg.InputFileName = (string)dlg.GetValue(11);
                cfg.PlotHeights   = (double[])dlg.GetValue(12);
                cfg.PlotStep      = (int)dlg.GetValue(13);
                cfg.PlotTimeStep  = (double)dlg.GetValue(14);



                cfg.Exps = new ExpConfig[nLen];
                for (int i = 0; i < nLen; i++)
                {
                    cfg.Exps[i] = new ExpConfig();
                    Enum.TryParse <ModelType>(sModel[i], out cfg.Exps[i].Model);
                    Enum.TryParse <SolverType>(sSolver[i], out cfg.Exps[i].Solver);
                }
                //ClearSimulation();
                UpdateGUI();
            }
        }