Ejemplo n.º 1
0
 public void RunPostSimulationModels(object sender, EventArgs e)
 {
     try
     {
         Runner     runner  = new Runner(explorerPresenter.ApsimXFile, runSimulations: false, wait: false);
         RunCommand command = new RunCommand("Post-simulation tools", runner, explorerPresenter);
         command.Do();
     }
     catch (Exception err)
     {
         explorerPresenter.MainPresenter.ShowError(err);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Runs a list of simulations.
 /// </summary>
 /// <param name="sender">Sender object.</param>
 /// <param name="args">Event arguments.</param>
 private void OnRunSims(object sender, EventArgs args)
 {
     try
     {
         // Before running the simulations, disable all simulations except for those which are selected.
         model.DisabledSimNames = model.GetSimulationNames().Where(s => !view.SelectedItems.Contains(s)).ToList();
         runner.Do(presenter.CommandHistory);
     }
     catch (Exception e)
     {
         presenter.MainPresenter.ShowError(e);
     }
 }
Ejemplo n.º 3
0
 public void CheckServerCompatibility(object sender, EventArgs args)
 {
     try
     {
         SimulationChecker checker = new SimulationChecker(explorerPresenter.CurrentNode, false);
         RunCommand        command = new RunCommand("State validation", checker, explorerPresenter);
         command.Do();
     }
     catch (Exception error)
     {
         explorerPresenter.MainPresenter.ShowError(error);
     }
 }
Ejemplo n.º 4
0
    private void RunFile(MainPresenter mainPresenter)
    {
        ExplorerPresenter presenter = mainPresenter.Presenters1[0] as ExplorerPresenter;

        if (presenter == null)
        {
            throw new Exception("Unable to open wheat example.");
        }

        Clock clock = presenter.ApsimXFile.FindInScope <Clock>();

        clock.EndDate = clock.StartDate.AddDays(10);

        Runner     runner  = new Runner(presenter.ApsimXFile, runType: Runner.RunTypeEnum.MultiThreaded);
        RunCommand command = new RunCommand("Simulations", runner, presenter);

        command.Do(null);
    }
Ejemplo n.º 5
0
        /// <summary>Runs the selected simulations.</summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="args">Event arguments.</param>
        private void OnRunSims(object sender, EventArgs args)
        {
            var savedDisabledSimulationNames = experiment.DisabledSimNames;

            try
            {
                var selectedSimulations = GetSelectedSimulationNamesFromView();

                // Before running the simulations, disable all simulations except for those which are selected.
                var        runner = new Runner(experiment, simulationNamesToRun: selectedSimulations, wait: false);
                RunCommand runCmd = new RunCommand(experiment.Name, runner, explorerPresenter);
                runCmd.Do();
            }
            catch (Exception e)
            {
                explorerPresenter.MainPresenter.ShowError(e);
            }
            finally
            {
                experiment.DisabledSimNames = savedDisabledSimulationNames;
            }
        }
Ejemplo n.º 6
0
        public void OnRun(object sender, EventArgs e)
        {
            try
            {
                // If we're already running some simulations, don't do anything.
                if (command != null && command.IsRunning)
                {
                    return;
                }

                // If no explorer presenter has focus, don't do anything.
                ExplorerPresenter explorer = presenter.GetCurrentExplorerPresenter();
                if (explorer == null)
                {
                    return;
                }

                // Write .apsimx file to disk.
                if (Configuration.Settings.AutoSave)
                {
                    explorer.Save();
                }

                IModel model = FindRunnable(explorer.CurrentNode);
                if (model == null)
                {
                    throw new InvalidOperationException("Unable to find a model which may be run.");
                }

                Runner runner = new Runner(model, runType: Runner.RunTypeEnum.MultiThreaded, wait: false);
                command = new RunCommand(model.Name, runner, explorer);
                command.Do();
            }
            catch (Exception err)
            {
                presenter.ShowError(err);
            }
        }