/// <summary>Processes any jobs that have been added.</summary>
        /// <param name="jobManager">The job manager.</param>
        private void ProcessAddedJobs(JobManager jobManager)
        {
            JobsService.Job runningJobDescription = null;

            //If there is no YP job running, then add a new job.  Once a YP job is running don't add any more jobs (regardless of type).
            if (runningJob == null || jobManager.IsJobCompleted(runningJob))
            {
                // Remove completed jobs if nothing is running. Otherwise, completedjobs will
                // grow and grow.
                jobManager.ClearCompletedJobs();
                runningJob = null;

                using (JobsService.JobsClient jobsClient = new JobsService.JobsClient())
                {
                    runningJobDescription = jobsClient.GetNextToRun();
                }

                if (runningJobDescription != null)
                {
                    if (RunnableJobs.ProcessYPJob.IsF4PJob(runningJobDescription.Name) == true)
                        runningJob = new RunnableJobs.ProcessF4PJob(true) { JobName = runningJobDescription.Name };
                    else
                        runningJob = new RunnableJobs.ProcessYPJob(true) { JobName = runningJobDescription.Name };
                    if (runningJob != null)
                        jobManager.AddJob(runningJob);
                }
                else
                {
                    // No jobs to run so wait a bit.
                    Thread.Sleep(15 * 1000); // 15 sec.
                }
            }
        }
Exemple #2
0
        /// <summary>Constructor</summary>
        /// <param name="job">The job to run.</param>
        /// <param name="name">The name of the job</param>
        /// <param name="presenter">The explorer presenter.</param>
        public RunCommand(JobManager.IRunnable job, string name, ExplorerPresenter presenter)
        {
            this.job = job;
            this.jobName = name;
            this.explorerPresenter = presenter;

            jobManager = new JobManager();
        }
Exemple #3
0
        /// <summary>
        /// Run all simulations in the specified 'fileName' in a serial mode.
        /// i.e. don't use the multi-threaded JobManager. Useful for profiling.
        /// </summary>
        /// <param name="fileName"> the name of file to run </param>
        private static void RunSingleThreaded(string fileName)
        {
            Simulations simulations = Simulations.Read(fileName);

            // Don't use JobManager - just run the simulations.
            JobManager.IRunnable simulationsToRun = Runner.ForSimulations(simulations, simulations, false);
            JobManager           jobManager       = new JobManager();

            jobManager.AddJob(simulationsToRun);
            jobManager.Run();
        }
Exemple #4
0
        /// <summary>Constructor</summary>
        /// <param name="job">The job to run.</param>
        /// <param name="name">The name of the job</param>
        /// <param name="presenter">The explorer presenter.</param>
        /// <param name="multiProcess">Use the multi-process runner?</param>
        public RunCommand(JobManager.IRunnable job, string name, ExplorerPresenter presenter, bool multiProcess)
        {
            jobs = new List <JobManager.IRunnable>();
            this.jobs.Add(job);
            this.jobName           = name;
            this.explorerPresenter = presenter;

            if (multiProcess)
            {
                jobManager = new JobManagerMultiProcess();
            }
            else
            {
                jobManager = new JobManager();
            }
        }
Exemple #5
0
        /// <summary>
        /// User has clicked RunAPSIM
        /// </summary>
        private void OnRunApsimClick(object sender, EventArgs e)
        {
            try
            {
                Simulation           simulation = Experiment.CreateSpecificSimulation(ListView.MemoLines[ListView.CurrentPosition.Y]);
                JobManager.IRunnable job        = Runner.ForSimulations(ExplorerPresenter.ApsimXFile, simulation, false);

                Commands.RunCommand run = new Commands.RunCommand(job,
                                                                  simulation.Name,
                                                                  ExplorerPresenter,
                                                                  false);
                run.Do(null);
            }
            catch (Exception err)
            {
                ExplorerPresenter.MainPresenter.ShowMessage(err.Message, Models.DataStore.ErrorLevel.Error);
            }
        }
Exemple #6
0
        /// <summary>
        /// Perform the command
        /// </summary>
        public void Do(CommandHistory CommandHistory)
        {
            IsRunning = true;

            if (!DuplicatesFound())
            {
                stopwatch.Start();

                JobManager.IRunnable job = Runner.ForSimulations(simulations, modelClicked);

                jobManager.AddJob(job);
                jobManager.AllJobsCompleted += OnComplete;
                jobManager.Start(waitUntilFinished: false);

                showNumberRunning = true;

                timer           = new System.Timers.Timer();
                timer.Interval  = 1000;
                timer.AutoReset = true;
                timer.Elapsed  += OnTimerTick;
                timer.Start();
            }
        }