/// <summary> /// Run the model if it is contained inside of a project. /// </summary> /// <param name="runName"></param> /// <param name="error">A message in case of error</param> /// <param name="executeNow">Should the run start executing now or wait for all other runs to finish first?</param> /// <param name="forceLocal">Execute in the local process, overriding default behaviour.</param> /// <returns>A reference to the run.</returns> public XTMFRun Run(string runName, ref string error, bool overwrite = false, bool executeNow = true, bool forceLocal = false) { // this needs to block as if a command is running lock (_SessionLock) { if (!CanRun) { error = "You can not run this model system."; return(null); } lock (_RunningLock) { XTMFRun run; if (_ModelSystemIndex >= 0) { var cloneProject = ProjectEditingSession.CreateCloneProject(ProjectEditingSession.Project); cloneProject.ModelSystemStructure[_ModelSystemIndex] = ModelSystemModel.Root.RealModelSystemStructure; cloneProject.ModelSystemDescriptions[_ModelSystemIndex] = ModelSystemModel.Description; cloneProject.LinkedParameters[_ModelSystemIndex] = ModelSystemModel.LinkedParameters.GetRealLinkedParameters(); if (((Configuration)Configuration).RemoteHost) { run = XTMFRun.CreateRemoteHost(cloneProject, _ModelSystemIndex, ModelSystemModel, _Runtime.Configuration, runName, overwrite); } else { run = Debugger.IsAttached || forceLocal || !((Configuration)Configuration).RunInSeperateProcess ? XTMFRun.CreateLocalRun(cloneProject, _ModelSystemIndex, ModelSystemModel, _Runtime.Configuration, runName, overwrite) : XTMFRun.CreateRemoteHost(cloneProject, _ModelSystemIndex, ModelSystemModel, _Runtime.Configuration, runName, overwrite); } run.ProjectSavedByRun += (theRun, newMSS) => { string e = null; ProjectEditingSession.Project.ModelSystemStructure[_ModelSystemIndex] = newMSS; ProjectEditingSession.Project.Save(ref e); Reload(); ProjectWasExternallySaved?.Invoke(this, new EventArgs()); }; } else { run = XTMFRun.CreateLocalRun(ProjectEditingSession.Project, ModelSystemModel.Root, _Runtime.Configuration, runName, overwrite); } return(run); } } }
private void TerminateRun(XTMFRun run) { lock (SessionLock) { if (_Run.Remove(run)) { lock (RunningLock) { AnyRunning = false; } } if (_Run.Count == 0) { _IsRunning = false; } } }
/// <summary> /// Run the model if it is contained inside of a project. /// </summary> /// <param name="runName"></param> /// <param name="error">A message in case of error</param> /// <returns></returns> public XTMFRun Run(string runName, ref string error) { // this needs to block as if a command is running lock (SessionLock) { if (!CanRun) { error = "You can not run this model system."; return(null); } lock (RunningLock) { if (AnyRunning) { error = "Only one run can be executing at the same time!"; return(null); } XTMFRun run; if (ModelSystemIndex >= 0) { Project cloneProject = ProjectEditingSession.CreateCloneProject(ProjectEditingSession.Project); cloneProject.ModelSystemStructure[ModelSystemIndex] = ModelSystemModel.Root.RealModelSystemStructure; cloneProject.ModelSystemDescriptions[ModelSystemIndex] = ModelSystemModel.Description; cloneProject.LinkedParameters[ModelSystemIndex] = ModelSystemModel.LinkedParameters.GetRealLinkedParameters(); run = new XTMFRun(cloneProject, ModelSystemIndex, ModelSystemModel, Runtime.Configuration, runName); } else { run = new XTMFRun(ProjectEditingSession.Project, ModelSystemModel.Root, Runtime.Configuration, runName); } this._Run.Add(run); AnyRunning = true; _IsRunning = true; run.RunComplete += () => TerminateRun(run); run.ValidationError += (e) => TerminateRun(run); run.RuntimeValidationError += (e) => TerminateRun(run); return(run); } } }
public void CancelRun(XTMFRun run) { _Runtime.RunController.CancelRun(run); }
public void ExecuteDelayedRun(XTMFRun run, DateTime delayedStartTime) { _Runtime.RunController.ExecuteDelayedRun(run, delayedStartTime); }
/// public void ExecuteRun(XTMFRun run, bool executeNow) { _Runtime.RunController.ExecuteRun(run, executeNow); }
/// <summary> /// Reorders a queued run - inserts the passed run into the new Queue index. /// </summary> /// <param name="run"></param> /// <param name="newQueueIndex"></param> public void ReorderQueuedRun(XTMFRun run, int newQueueIndex) { Runtime.RunController.ReorderQueuedRun(run, newQueueIndex); }
private void TerminateRun(XTMFRun run) { lock (SessionLock) { _Run.Remove(run); if(_Run.Count == 0) { _IsRunning = false; } } }
/// <summary> /// Run the model if it is contained inside of a project. /// </summary> /// <param name="runName"></param> /// <param name="error">A message in case of error</param> /// <returns></returns> public XTMFRun Run(string runName, ref string error) { // this needs to block as if a command is running lock (SessionLock) { if(!CanRun) { error = "You can not run this model system."; return null; } XTMFRun run; if(ModelSystemIndex >= 0) { Project cloneProject = ProjectEditingSession.CreateCloneProject(ProjectEditingSession.Project); cloneProject.ModelSystemStructure[ModelSystemIndex] = ModelSystemModel.Root.RealModelSystemStructure; cloneProject.ModelSystemDescriptions[ModelSystemIndex] = ModelSystemModel.Description; cloneProject.LinkedParameters[ModelSystemIndex] = ModelSystemModel.LinkedParameters.GetRealLinkedParameters(); run = new XTMFRun(cloneProject, ModelSystemIndex, ModelSystemModel.Root, Runtime.Configuration, runName); } else { run = new XTMFRun(ProjectEditingSession.Project, ModelSystemModel.Root, Runtime.Configuration, runName); } this._Run.Add(run); _IsRunning = true; run.RunComplete += () => TerminateRun(run); run.ValidationError += (e) => TerminateRun(run); run.RuntimeValidationError += (e) => TerminateRun(run); return run; } }