/// <summary> /// Calls CyPhySoT with early bindings /// </summary> /// <param name="outputdirname">xme folder from trunk/models/DynamicsTeam</param> /// <param name="projectPath">name of mga-file</param> /// <param name="absPath">Folder-path to SoT</param> /// <returns>Boolean - True -> interpreter call was successful</returns> public static bool Run(string outputdirname, string projectPath, string absPath) { bool result = false; Assert.True(File.Exists(projectPath), "Project file does not exist."); string ProjectConnStr = "MGA=" + projectPath; MgaProject project = new MgaProject(); project.OpenEx(ProjectConnStr, "CyPhyML", null); try { var terr = project.BeginTransactionInNewTerr(); var testObj = project.ObjectByPath[absPath] as MgaFCO; project.AbortTransaction(); string OutputDir = Path.Combine(Path.GetDirectoryName(projectPath), outputdirname); if (Directory.Exists(OutputDir)) { Test.DeleteDirectory(OutputDir); } Directory.CreateDirectory(OutputDir); //dynamic interpreter = Activator.CreateInstance(CyPhyPETInterpreter); var interpreter = new CyPhySoT.CyPhySoTInterpreter(); interpreter.Initialize(project); //dynamic mainParameters = Activator.CreateInstance(MainParametersType); var mainParameters = new CyPhyGUIs.InterpreterMainParameters(); mainParameters.Project = project; mainParameters.CurrentFCO = testObj; mainParameters.SelectedFCOs = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs")); mainParameters.StartModeParam = 128; mainParameters.ConsoleMessages = false; mainParameters.ProjectDirectory = Path.GetDirectoryName(projectPath); mainParameters.OutputDirectory = OutputDir; //dynamic results = interpreter.Main(mainParameters); var results = interpreter.Main(mainParameters); Assert.True(File.Exists(ProjectConnStr.Substring("MGA=".Length))); result = results.Success; if (result == false) { Test.DeleteDirectory(OutputDir); } } finally { project.Close(true); } return(result); }
/// <summary> /// Calls CyPhySoT with early bindings /// </summary> /// <param name="outputdirname">xme folder from trunk/models/DynamicsTeam</param> /// <param name="projectPath">name of mga-file</param> /// <param name="absPath">Folder-path to SoT</param> /// <returns>Boolean - True -> interpreter call was successful</returns> public static bool Run(string outputdirname, string projectPath, string absPath) { bool result = false; Assert.True(File.Exists(projectPath), "Project file does not exist."); string ProjectConnStr = "MGA=" + projectPath; MgaProject project = new MgaProject(); project.OpenEx(ProjectConnStr, "CyPhyML", null); try { var terr = project.BeginTransactionInNewTerr(); var testObj = project.ObjectByPath[absPath] as MgaFCO; project.AbortTransaction(); string OutputDir = Path.Combine(Path.GetDirectoryName(projectPath), outputdirname); if (Directory.Exists(OutputDir)) { Test.DeleteDirectory(OutputDir); } Directory.CreateDirectory(OutputDir); //dynamic interpreter = Activator.CreateInstance(CyPhyPETInterpreter); var interpreter = new CyPhySoT.CyPhySoTInterpreter(); interpreter.Initialize(project); //dynamic mainParameters = Activator.CreateInstance(MainParametersType); var mainParameters = new CyPhyGUIs.InterpreterMainParameters(); mainParameters.Project = project; mainParameters.CurrentFCO = testObj; mainParameters.SelectedFCOs = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs")); mainParameters.StartModeParam = 128; mainParameters.ConsoleMessages = false; mainParameters.ProjectDirectory = Path.GetDirectoryName(projectPath); mainParameters.OutputDirectory = OutputDir; //dynamic results = interpreter.Main(mainParameters); var results = interpreter.Main(mainParameters); Assert.True(File.Exists(ProjectConnStr.Substring("MGA=".Length))); result = results.Success; if (result == false) { Test.DeleteDirectory(OutputDir); } } finally { project.Close(true); } return result; }
public void CyPhySoT_CurrentObjectNull() { Assert.True(File.Exists(mgaFile), "Failed to generate the mga."); string ProjectConnStr = "MGA=" + mgaFile; MgaProject project = new MgaProject(); project.OpenEx(ProjectConnStr, "CyPhyML", null); try { var interpreter = new CyPhySoT.CyPhySoTInterpreter(); interpreter.Initialize(project); Assert.DoesNotThrow(() => interpreter.InvokeEx(project, null, null, 16)); } finally { project.Close(true); } }
public void Run() { if (string.IsNullOrEmpty(this.WorkingDirectory) || Directory.Exists(this.WorkingDirectory) == false) { // nothing needs to be done. return; } // TODO: exception handling... // get manifest file string manifestFile = Path.Combine(this.WorkingDirectory, "manifest.sot.json"); if (File.Exists(manifestFile) == false) { Trace.TraceError("{0} file does not exist", manifestFile); return; } // this could fail... exception handling! sotConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<CyPhySoT.SotConfig>(File.ReadAllText(manifestFile)); // get mga filename string mgaFileName = Path.Combine(this.WorkingDirectory, sotConfig.ProjectFileName); if (File.Exists(mgaFileName) == false) { Trace.TraceError("{0} file does not exist", mgaFileName); return; } this.ProjectConnStr = "MGA=" + mgaFileName; Semaphore sem = null; if (criticalSection.TryGetValue(this.ProjectConnStr, out sem) == false) { criticalSection[this.ProjectConnStr] = new Semaphore(1, 1); } // Load GME model this.OpenProject(); if (sotConfig.MultiJobRun) { Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_READ_ONLY); try { this.TestBenches = GetMultiJobRunTestBenches(CurrentObj, Path.GetDirectoryName(sotConfig.ProjectFileName)); } finally { Project.AbortTransaction(); } } else { CyPhySoT.CyPhySoTInterpreter sotInterpreter = new CyPhySoT.CyPhySoTInterpreter(); this.TestBenches = sotInterpreter.GetTestbenchesFromModel(this.Project, (MgaModel)this.CurrentObj, Path.GetDirectoryName(this.WorkingDirectory)); Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED); try { // replace tb in TestBenches that corresponds to the MultiJobRun with the tbs from GetMultiJobRunTestBenches foreach (var tb in TestBenches.ToList<CyPhySoT.TestBench>()) { var modelProcessor = AnalysisModelProcessor.GetAnalysisModelProcessor((IMgaModel)tb.CurrentObj); if (modelProcessor is MultiJobRunProcessor) { List<CyPhySoT.TestBench> multiTbs = GetMultiJobRunTestBenches(tb.CurrentObj, tb.OutputDirectory); foreach (var upstreamTb in tb.UpstreamTestBenches) { upstreamTb.DownstreamTestBenches.Remove(tb); upstreamTb.DownstreamTestBenches.Add(multiTbs[0]); multiTbs[0].UpstreamTestBenches.Add(upstreamTb); } foreach (var downstreamTb in tb.DownstreamTestBenches) { downstreamTb.UpstreamTestBenches.Remove(tb); downstreamTb.UpstreamTestBenches.Add(multiTbs[multiTbs.Count - 1]); multiTbs[multiTbs.Count - 1].DownstreamTestBenches.Add(downstreamTb); } this.TestBenches.AddRange(multiTbs); this.TestBenches.Remove(tb); } } } finally { Project.AbortTransaction(); } } // TODO: update value flow! // Test bench/job map foreach (var testbench in this.TestBenches) { JobImpl job = new JobImpl(this.Server); this.TestBenchJobMap.Add(testbench, job); } try { // propagate the values between test benches PropagateValueFlow(); } catch (JobFailure ex) { // FIXME: add some GUI notification string failed_txt = Path.Combine(this.WorkingDirectory, "_FAILED.txt"); File.WriteAllText(failed_txt, String.Format("SoT {0} failed: {1}", this.sotName, ex.ToString())); this.CloseProject(); return; } // get all testbenches from sot that can be run without dependency foreach (var testbench in this.TestBenches.Where(x => x.UpstreamTestBenches.Count == 0)) { // call interpreters for this test bench and post it to the job manager RunTestBenchAndStart(testbench); } this.CloseProject(); }
public void Run() { if (string.IsNullOrEmpty(this.WorkingDirectory) || Directory.Exists(this.WorkingDirectory) == false) { // nothing needs to be done. return; } // TODO: exception handling... // get manifest file string manifestFile = Path.Combine(this.WorkingDirectory, "manifest.sot.json"); if (File.Exists(manifestFile) == false) { Trace.TraceError("{0} file does not exist", manifestFile); return; } // this could fail... exception handling! sotConfig = Newtonsoft.Json.JsonConvert.DeserializeObject <CyPhySoT.SotConfig>(File.ReadAllText(manifestFile)); // get mga filename string mgaFileName = Path.Combine(this.WorkingDirectory, sotConfig.ProjectFileName); if (File.Exists(mgaFileName) == false) { Trace.TraceError("{0} file does not exist", mgaFileName); return; } this.ProjectConnStr = "MGA=" + mgaFileName; Semaphore sem = null; if (criticalSection.TryGetValue(this.ProjectConnStr, out sem) == false) { criticalSection[this.ProjectConnStr] = new Semaphore(1, 1); } // Load GME model this.OpenProject(); if (sotConfig.MultiJobRun) { Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_READ_ONLY); try { this.TestBenches = GetMultiJobRunTestBenches(CurrentObj, Path.GetDirectoryName(sotConfig.ProjectFileName)); } finally { Project.AbortTransaction(); } } else { CyPhySoT.CyPhySoTInterpreter sotInterpreter = new CyPhySoT.CyPhySoTInterpreter(); this.TestBenches = sotInterpreter.GetTestbenchesFromModel(this.Project, (MgaModel)this.CurrentObj, Path.GetDirectoryName(this.WorkingDirectory)); Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED); try { // replace tb in TestBenches that corresponds to the MultiJobRun with the tbs from GetMultiJobRunTestBenches foreach (var tb in TestBenches.ToList <CyPhySoT.TestBench>()) { var modelProcessor = AnalysisModelProcessor.GetAnalysisModelProcessor((IMgaModel)tb.CurrentObj); if (modelProcessor is MultiJobRunProcessor) { List <CyPhySoT.TestBench> multiTbs = GetMultiJobRunTestBenches(tb.CurrentObj, tb.OutputDirectory); foreach (var upstreamTb in tb.UpstreamTestBenches) { upstreamTb.DownstreamTestBenches.Remove(tb); upstreamTb.DownstreamTestBenches.Add(multiTbs[0]); multiTbs[0].UpstreamTestBenches.Add(upstreamTb); } foreach (var downstreamTb in tb.DownstreamTestBenches) { downstreamTb.UpstreamTestBenches.Remove(tb); downstreamTb.UpstreamTestBenches.Add(multiTbs[multiTbs.Count - 1]); multiTbs[multiTbs.Count - 1].DownstreamTestBenches.Add(downstreamTb); } this.TestBenches.AddRange(multiTbs); this.TestBenches.Remove(tb); } } } finally { Project.AbortTransaction(); } } // TODO: update value flow! // Test bench/job map foreach (var testbench in this.TestBenches) { JobImpl job = new JobImpl(this.Server); this.TestBenchJobMap.Add(testbench, job); } try { // propagate the values between test benches PropagateValueFlow(); } catch (JobFailure ex) { // FIXME: add some GUI notification string failed_txt = Path.Combine(this.WorkingDirectory, "_FAILED.txt"); File.WriteAllText(failed_txt, String.Format("SoT {0} failed: {1}", this.sotName, ex.ToString())); this.CloseProject(); return; } // get all testbenches from sot that can be run without dependency foreach (var testbench in this.TestBenches.Where(x => x.UpstreamTestBenches.Count == 0)) { // call interpreters for this test bench and post it to the job manager RunTestBenchAndStart(testbench); } this.CloseProject(); }