public void StartExperiment() { experiment.StartTime = DateTime.Now; foreach (ModuleInExperiment module in experiment.Modules) { if (module.ModuleOrder > last_module_order) { last_module_order = module.ModuleOrder; } } curr_module_order = 1; ModuleInExperiment curr_module = GetModuleInExperimentByOrder(curr_module_order); Debug.Log(curr_module); ExecuteModule(curr_module); //Итерируемся по всем модулям, и ждем закрытия предидущего, прежде чем запускать следующий }
public void ContinueExperiment() { curr_module_order++; if (curr_module_order >= last_module_order) { experimentProcessCanvasController.FinalModuleOn(); } ModuleInExperiment curr_module = GetModuleInExperimentByOrder(curr_module_order); if (curr_module == null) { experimentProcessCanvasController.SetCurrentModuleName("No Module"); experimentProcessCanvasController.SetCurrentModuleCondition("Can't find module with order " + curr_module_order); } else { ExecuteModule(curr_module); } }
private void ExecuteModule(ModuleInExperiment moduleInExperiment) { var resultsTask = namedPipeResultsGetter.GetModuleResults(moduleInExperiment.ModuleName); experimentProcessCanvasController.SetCurrentModuleName(moduleInExperiment.ModuleName); experimentProcessCanvasController.SetCurrentModuleCondition("Starting"); experimentProcessCanvasController.SetCurrentModuleOrder(curr_module_order); System.Diagnostics.Process myProcess = new System.Diagnostics.Process(); Module module = GetModuleByName(moduleInExperiment.ModuleName); myProcess.StartInfo.FileName = base_module_path + module.PathToExe + ".exe.lnk"; myProcess.StartInfo.CreateNoWindow = false; myProcess.StartInfo.UseShellExecute = true; myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; foreach (KeyValuePair <string, string> pair in moduleInExperiment.InputValues) { myProcess.StartInfo.Arguments += pair.Key + "=" + pair.Value + " "; } myProcess.StartInfo.Arguments += "first_part" + "=" + experiment.FirstParticipant.ParticipantId + " "; myProcess.StartInfo.Arguments += "second_part" + "=" + experiment.SecondParticipant.ParticipantId + " "; try { moduleInExperiment.StartTime = DateTime.Now; myProcess.Start(); experimentProcessCanvasController.SetCurrentModuleCondition("Started"); myProcess.WaitForExit(); moduleInExperiment.FinishTime = DateTime.Now; Dictionary <string, string> module_res = new Dictionary <string, string>(namedPipeResultsGetter.results); moduleInExperiment.OutputValues = module_res; experimentProcessCanvasController.SetCurrentModuleCondition("Finished"); } catch (Exception e) { experimentProcessCanvasController.SetCurrentModuleCondition("Exception while opening " + myProcess.StartInfo.FileName); Debug.Log(e); } }
private ModuleInExperiment GetModuleInExperimentByOrder(int order) { ModuleInExperiment module = experiment.Modules.Find(e => e.ModuleOrder == order); return(module); }