public override void Expand(CyPhy.ComponentAssembly configuration) { this.Configuration = configuration; if (this.OriginalSystemUnderTest == null) { // don't need to do anything } else if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID) { this.expandedTestBenchSuite = this.testBenchSuite; } else { // create temp folder for test bench suite CyPhy.TestBenchSuiteFolder testing = CyPhyClasses.TestBenchSuiteFolder.Cast(this.testBenchSuite.ParentContainer.Impl); var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.testBenchSuite.Impl); CyPhy.TestBenchSuiteFolder tempFolder = testing.Children.TestBenchSuiteFolderCollection.FirstOrDefault(x => x.Name == tempFolderName); if (tempFolder == null) { tempFolder = CyPhyClasses.TestBenchSuiteFolder.Create(testing); tempFolder.Name = tempFolderName; this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false); } // copy test bench suite var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.testBenchSuite.Impl as MgaFCO); // fix name tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.testBenchSuite.Impl, configuration.Impl); this.AddToTraceabilityAndTemporary(tempCopy, this.testBenchSuite.Impl); // set expanded property to the expanded element this.expandedTestBenchSuite = CyPhyClasses.TestBenchSuite.Cast(tempCopy); } // expand all test benches foreach (var testBenchRef in this.expandedTestBenchSuite.Children.TestBenchRefCollection) { var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType); testBenchTypeExpander.Expand(configuration); // switch references var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter(); // TODO: handle failures for this switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference); this.InnerExpanders.Push(testBenchTypeExpander); } }
public TestBenchSuiteProcessor(CyPhy.TestBenchSuite testBenchSuite) { this.testBenchSuite = testBenchSuite; this.OriginalSystemUnderTest = testBenchSuite .Children .TestBenchRefCollection .FirstOrDefault() .Referred .TestBenchType .Children .TopLevelSystemUnderTestCollection .FirstOrDefault(); }
public override void Expand(CyPhy.ComponentAssembly configuration) { this.Configuration = configuration; if (this.OriginalSystemUnderTest.Referred.DesignEntity.ID == configuration.ID) { this.expandedTestBenchSuite = this.testBenchSuite; } else { // create temp folder for test bench suite CyPhy.TestBenchSuiteFolder testing = CyPhyClasses.TestBenchSuiteFolder.Cast(this.testBenchSuite.ParentContainer.Impl); var tempFolderName = AnalysisModelProcessor.GetTemporaryFolderName(this.testBenchSuite.Impl); CyPhy.TestBenchSuiteFolder tempFolder = testing.Children.TestBenchSuiteFolderCollection.FirstOrDefault(x => x.Name == tempFolderName); if (tempFolder == null) { tempFolder = CyPhyClasses.TestBenchSuiteFolder.Create(testing); tempFolder.Name = tempFolderName; this.AddToTraceabilityAndTemporary(tempFolder.Impl, testing.Impl, recursive: false); } // copy test bench suite var tempCopy = (tempFolder.Impl as MgaFolder).CopyFCODisp(this.testBenchSuite.Impl as MgaFCO); // fix name tempCopy.Name = AnalysisModelProcessor.GetTemporaryObjectName(this.testBenchSuite.Impl, configuration.Impl); this.AddToTraceabilityAndTemporary(tempCopy, this.testBenchSuite.Impl); // set expanded property to the expanded element this.expandedTestBenchSuite = CyPhyClasses.TestBenchSuite.Cast(tempCopy); } // expand all test benches foreach (var testBenchRef in this.expandedTestBenchSuite.Children.TestBenchRefCollection) { var testBenchTypeExpander = new TestBenchTypeProcessor(testBenchRef.Referred.TestBenchType); testBenchTypeExpander.Expand(configuration); // switch references var switcher = new ReferenceSwitcher.ReferenceSwitcherInterpreter(); // TODO: handle failures for this switcher.SwitchReference(testBenchTypeExpander.expandedTestBenchType.Impl as MgaFCO, testBenchRef.Impl as IMgaReference); this.InnerExpanders.Push(testBenchTypeExpander); } }
public IInterpreterResult Main(IInterpreterMainParameters parameters) { this.runtime.Clear(); this.mainParameters = (InterpreterMainParameters)parameters; this.result.Success = true; var configSuccess = this.mainParameters != null; this.paramInvoked = this.mainParameters.StartModeParam; this.ProjectFilename = this.mainParameters.Project.ProjectConnStr.Substring("MGA=".Length); this.OutputBaseDir = this.mainParameters.OutputDirectory; sotConfig.OriginalProjectFileName = this.ProjectFilename; bool disposeLogger = false; if (this.Logger == null) { this.Logger = new CyPhyGUIs.GMELogger(this.mainParameters.Project, this.ComponentName); this.Logger.WriteInfo("Running CyPhySoT"); System.Windows.Forms.Application.DoEvents(); disposeLogger = true; } if (this.mainParameters.VerboseConsole) { this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Debug; } else { this.Logger.GMEConsoleLoggingLevel = SmartLogger.MessageType_enum.Info; } CyPhy.TestBenchSuite tbs = CyPhyClasses.TestBenchSuite.Cast(parameters.CurrentFCO); // MgaGateway.PerformInTransaction(delegate // { // foreach (var testBenchRef in tbs.Children.TestBenchRefCollection) // { // if (testBenchRef.Referred == null) // { // continue; // } // var testBench = testBenchRef.Referred.TestBenchType; // if (testBench != null && // testBench.Impl.MetaBase.Name != (typeof(CyPhy.TestBench)).Name) // { // this.Logger.WriteError(string.Format(@"Test benches must currently // be of type TestBench in a CyPhySoT. Please see {0}.", // testBenchRef.ToHyperLink())); // this.result.Success = false; // object automation; // if (this.componentParameters != null && // this.componentParameters.TryGetValue("automation", out automation)) // { // if ((string)automation == "true") // { // throw new NotSupportedException(@"Error: only test benches of // type TestBench are currently supported in a CyPhySoT!"); // } // } // } // } // }); if (this.result.Success == false) { return(this.result); } var asyncResult = this.Logger.LoggingVersionInfo.BeginInvoke(parameters.Project, null, null); var header = this.Logger.LoggingVersionInfo.EndInvoke(asyncResult); this.Logger.WriteDebug(header); this.UpdateSuccess("Configuration", configSuccess); this.result.Labels = ""; //this.result.LogFileDirectory = Path.Combine(this.mainParameters.ProjectDirectory, "log"); //this.LogFileFilename = this.ComponentName + "." + System.Diagnostics.Process.GetCurrentProcess().Id + ".log"; //META.Logger.AddFileListener(this.LogFilePath, this.ComponentName, parameters.Project); try { MgaGateway.PerformInTransaction(delegate { this.WorkInMainTransaction(); }, abort: true); this.WorkOutsideOfMainTransaction(); this.PrintRuntimeStatistics(); if (this.result.Success) { this.Logger.WriteInfo("CyPhySoT finished successfully."); this.Logger.WriteInfo("Generated files are here: <a href=\"file:///{0}\" target=\"_blank\">{0}</a>", this.mainParameters.OutputDirectory); this.Logger.WriteDebug("[SUCCESS: {0}]", this.result.Success); } else { this.Logger.WriteError("CyPhySoT failed! See error messages above."); } } finally { if (this.Logger != null && disposeLogger) { this.Logger.Dispose(); this.Logger = null; } MgaGateway = null; //GMEConsole = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } //META.Logger.RemoveFileListener(this.ComponentName); return(this.result); }
public TestBenchSuiteChecker(CyPhy.TestBenchSuite testBenchSuite) { this.testBenchSuite = testBenchSuite; }
public TestBenchSuiteChecker(CyPhy.TestBenchSuite testBenchSuite) { this.testBenchSuite = testBenchSuite; }