public void OnJobAssigned(Job job) { MonitoredJobViewModel monitoredJob = new MonitoredJobViewModel(job, Plot, m_cancelTokenSource.Token, MainWindowViewModel.Instance.LogToFile); AllMonitoredJobs.Insert(0, monitoredJob); ViewModelFromModel[job] = monitoredJob; }
/// <summary> /// Initializes the experiments to be monitored through a batch file that /// contains all required data for the task. /// </summary> /// <param name="batchFileName">The batch file with experiment data</param> public bool LoadExperimentBatch(string batchFileName) { //Load unfinished experiments LoadOptions loadOptionsUnfinished = new LoadOptions() { Selection = LoadOptions.ExpUnitSelection.OnlyUnfinished, LoadVariablesInLog = false }; ExperimentBatch batchUnfinished = new ExperimentBatch(); batchUnfinished.Load(batchFileName, loadOptionsUnfinished); LoggedExperiments.Clear(); foreach (Experiment experiment in batchUnfinished.Experiments) { LoggedExperimentViewModel newExperiment = new LoggedExperimentViewModel(experiment); LoggedExperiments.Add(newExperiment); } //count unfinished experiments int numUnfinishedExperimentalUnits = batchUnfinished.CountExperimentalUnits(); //load all experimental units and count them LoadOptions loadOptionsFinished = new LoadOptions() { Selection = LoadOptions.ExpUnitSelection.OnlyFinished, LoadVariablesInLog = false }; //we use a temp variable first to get the count of finished units so that setting the value of NumFinishedExperimentalUnitsBeforeStart triggers the progress update //AFTER setting the value of NumExperimentalUnits NumFinishedExperimentalUnitsBeforeStart = ExperimentBatch.CountExperimentalUnits(batchFileName, LoadOptions.ExpUnitSelection.OnlyFinished); NumExperimentalUnits = numUnfinishedExperimentalUnits + NumFinishedExperimentalUnitsBeforeStart; NumFinishedExperimentalUnitsAfterStart = 0; //Initialize pending experiment list m_pendingExperiments.Clear(); foreach (var experiment in LoggedExperiments) { foreach (AppVersion version in experiment.AppVersions) { if (!ExistsRequiredFile(version.ExeFile)) { CaliburnUtility.ShowWarningDialog("Cannot find required file: " + version.ExeFile + ". Check the app definition file in /config/apps", "ERROR"); return(false); } foreach (string pre in version.Requirements.InputFiles) { if (!ExistsRequiredFile(pre)) { CaliburnUtility.ShowWarningDialog("Cannot find required file: " + pre + ". Check the app definition file in /config/apps", "ERROR"); return(false); } } } foreach (LoggedExperimentalUnitViewModel unit in experiment.ExperimentalUnits) { m_pendingExperiments.Add(unit.Model); } } BatchFileName = batchFileName; Plot.ClearLineSeries(); AllMonitoredJobs.Clear(); IsBatchLoaded = true; IsRunning = false; return(true); }