public MgaFCO RunDesignExporter(string asmName) { MgaFCO componentAssembly; proj.BeginTransactionInNewTerr(); string fileExtension = ".adp"; try { componentAssembly = (MgaFCO)proj.RootFolder.GetObjectByPathDisp("/@" + FolderName + "/@" + asmName); if (componentAssembly.Meta.Name == "DesignContainer") { fileExtension = ".adm"; } Assert.NotNull(componentAssembly); var designExporter = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter(); designExporter.Initialize(proj); var parameters = new CyPhyGUIs.InterpreterMainParameters() { CurrentFCO = componentAssembly, Project = proj, OutputDirectory = AdmPath }; designExporter.MainInTransaction(parameters, true); } finally { proj.AbortTransaction(); } Assert.True(File.Exists(Path.Combine(fixture.AdmPath, asmName + fileExtension))); return(componentAssembly); }
/// <summary> /// Calls CyPhy2Modelica using 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 test-bench</param> /// <returns>Boolean - True -> interpreter call was successful</returns> public static bool RunMain(string outputdirname, string projectPath, string absPath) { bool result = false; Assert.True(File.Exists(projectPath), "Project file does not exist."); string ProjectConnStr = "MGA=" + projectPath; //Type CyPhy2Modelica_v2Interpreter = Type.GetTypeFromProgID("MGA.Interpreter.CyPhy2Modelica_v2"); //Type MainParametersType = Type.GetTypeFromProgID("ISIS.CyPhyML.InterpreterConfiguration"); 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(CyPhy2Modelica_v2Interpreter); var interpreter = new CyPhy2Modelica_v2.CyPhy2Modelica_v2Interpreter(); 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 CyPhy2Modelica using 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 test-bench</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; //Type CyPhy2Modelica_v2Interpreter = Type.GetTypeFromProgID("MGA.Interpreter.CyPhy2Modelica_v2"); //Type MainParametersType = Type.GetTypeFromProgID("ISIS.CyPhyML.InterpreterConfiguration"); 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(CyPhy2Modelica_v2Interpreter); var interpreter = new CyPhy2Modelica_v2.CyPhy2Modelica_v2Interpreter(); 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.MainThrows(mainParameters); Assert.True(File.Exists(ProjectConnStr.Substring("MGA=".Length))); result = results.Success; if (result == false) { Test.DeleteDirectory(OutputDir); } } finally { project.Close(true); } return result; }
private bool RunInterpreterMainCADPCB( string outputdirname, string testBenchPath, CyPhy2CADPCB.CyPhy2CADPCB_Settings config = null, bool copyLayout = false) { if (Directory.Exists(outputdirname)) { Directory.Delete(outputdirname, true); } Directory.CreateDirectory(outputdirname); Assert.True(Directory.Exists(outputdirname), "Output directory wasn't created for some reason."); if (copyLayout) { File.Copy(Path.Combine(outputdirname + "_PlaceRoute", "layout.json"), Path.Combine(outputdirname, "layout.json")); } MgaFCO testObj = null; project.PerformInTransaction(delegate { testObj = project.ObjectByPath[testBenchPath] as MgaFCO; }); var interpreter = new CyPhy2CADPCB.CyPhy2CADPCBInterpreter(); interpreter.Initialize(project); var mainParameters = new CyPhyGUIs.InterpreterMainParameters() { config = (config == null) ? new CyPhy2CADPCB.CyPhy2CADPCB_Settings() { Verbose = false } : config, Project = project, CurrentFCO = testObj, SelectedFCOs = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs")), StartModeParam = 128, ConsoleMessages = false, ProjectDirectory = project.GetRootDirectoryPath(), OutputDirectory = outputdirname }; var result = interpreter.Main(mainParameters); interpreter.DisposeLogger(); return(result.Success); }
private void RunInterpreterMainSchematic( string outputdirname, string testBenchPath, CyPhy2Schematic.CyPhy2Schematic_Settings config = null) { if (Directory.Exists(outputdirname)) { Directory.Delete(outputdirname, true); } Directory.CreateDirectory(outputdirname); Assert.True(Directory.Exists(outputdirname), "Output directory wasn't created for some reason."); MgaFCO testObj = null; project.PerformInTransaction(delegate { testObj = project.ObjectByPath[testBenchPath] as MgaFCO; }); var interpreter = new CyPhy2Schematic.CyPhy2SchematicInterpreter(); interpreter.Initialize(project); var mainParameters = new CyPhyGUIs.InterpreterMainParameters() { config = (config == null) ? new CyPhy2Schematic.CyPhy2Schematic_Settings() { doPlaceRoute = "true" } : config, Project = project, CurrentFCO = testObj, SelectedFCOs = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs")), StartModeParam = 128, ConsoleMessages = false, ProjectDirectory = project.GetRootDirectoryPath(), OutputDirectory = outputdirname }; var result = interpreter.Main(mainParameters); interpreter.DisposeLogger(); Assert.True(result.Success, "Interpreter run was unsuccessful"); }
public CyPhyGUIs.IInterpreterResult RunInterpreterMainAndReturnResult(string outputdirname, string testBenchPath, CyPhy2Schematic.CyPhy2Schematic_Settings config = null) { if (Directory.Exists(outputdirname)) { foreach (string filename in Directory.GetFiles(outputdirname, "*", SearchOption.AllDirectories)) { File.Delete(Path.Combine(outputdirname, filename)); } } Directory.CreateDirectory(outputdirname); Assert.True(Directory.Exists(outputdirname), "Output directory wasn't created for some reason."); CyPhyGUIs.IInterpreterResult result = null; project.PerformInTransaction(delegate { MgaFCO testObj = null; testObj = project.ObjectByPath[testBenchPath] as MgaFCO; Assert.NotNull(testObj); var interpreter = new CyPhy2Schematic.CyPhy2SchematicInterpreter(); interpreter.Initialize(project); var mainParameters = new CyPhyGUIs.InterpreterMainParameters() { config = (config == null) ? new CyPhy2Schematic.CyPhy2Schematic_Settings() { Verbose = false } : config, Project = project, CurrentFCO = testObj, SelectedFCOs = (MgaFCOs)Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaFCOs")), StartModeParam = 128, ConsoleMessages = false, ProjectDirectory = project.GetRootDirectoryPath(), OutputDirectory = outputdirname }; result = interpreter.Main(mainParameters); interpreter.DisposeLogger(); }, abort: true); return(result); }
public static bool Run(string originalProjectDir, MgaProject project, MgaFCO testObj, bool copycomponents) { bool status = true; try { var outputdirname = GetProjectDir(project); if (copycomponents) { CopyDirectory(Path.Combine(originalProjectDir, "components"), Path.Combine(outputdirname, "components")); } var interpreter = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter(); interpreter.Initialize(project); var mainParameters = new CyPhyGUIs.InterpreterMainParameters(); var cadSettings = new CyPhy2CAD_CSharp.CyPhy2CADSettings(); cadSettings.OutputDirectory = outputdirname; cadSettings.AuxiliaryDirectory = ""; mainParameters.config = cadSettings; 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(GetProjectDir(project)); mainParameters.OutputDirectory = outputdirname; interpreter.Main(mainParameters); } catch (Exception) { status = false; } finally { project.Close(); } return(status); }
public static bool Run(string outputdirname, MgaProject project, MgaFCO testObj, bool copycomponents) { bool status = true; try { if (copycomponents) { CopyDirectory(Path.Combine(GetProjectDir(project),"components"), Path.Combine(outputdirname, "components")); } var interpreter = new CyPhy2CAD_CSharp.CyPhy2CAD_CSharpInterpreter(); interpreter.Initialize(project); var mainParameters = new CyPhyGUIs.InterpreterMainParameters(); var cadSettings = new CyPhy2CAD_CSharp.CyPhy2CADSettings(); cadSettings.OutputDirectory = outputdirname; cadSettings.AuxiliaryDirectory = ""; mainParameters.config = cadSettings; 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(GetProjectDir(project)); mainParameters.OutputDirectory = outputdirname; interpreter.Main(mainParameters); } catch (Exception) { status = false; } finally { project.Close(); } return status; }
//[Fact] public void DesignSpaceWithRefs() { var fullTestPath = Path.Combine(_exportModelDirectory, "DesignSpaceWithRefs"); var xmeFilePath = Path.Combine(fullTestPath, "DesignSpaceWithRefs.xme"); var pathExportedDesign = Path.Combine(fullTestPath, "DesignSpace.adm"); // delete design file if it already exists if (File.Exists(pathExportedDesign)) { File.Delete(pathExportedDesign); } String connectionString; GME.MGA.MgaUtils.ImportXMEForTest(xmeFilePath, out connectionString); var proj = new MgaProject(); bool ro_mode; proj.Open(connectionString, out ro_mode); proj.EnableAutoAddOns(true); try { var designExporter = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter(); designExporter.Initialize(proj); var mgaGateway = new MgaGateway(proj); MgaFCO currentFCO = null; mgaGateway.PerformInTransaction(delegate { currentFCO = proj.get_ObjectByPath("/@DesignSpaces|kind=DesignSpace|relpos=0/@DesignSpace|kind=DesignContainer|relpos=0") as MgaFCO; Assert.NotNull(currentFCO); }); var parameters = new CyPhyGUIs.InterpreterMainParameters() { CurrentFCO = currentFCO, Project = proj, OutputDirectory = fullTestPath }; var result = designExporter.Main(parameters); var design = avm.Design.LoadFromFile(pathExportedDesign); /// Add assert statements to check structure var root = design.RootContainer; Assert.NotNull(root); Assert.Equal(1, root.Container1.Count(c => c.Name == "AltContainer")); var AltContainer = root.Container1.First(c => c.Name == "AltContainer"); Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_5")); Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_6")); Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_7")); Assert.Equal(1, root.Container1.Count(c => c.Name == "DesignContainer")); var DesignContainer = root.Container1.First(c => c.Name == "DesignContainer"); Assert.Equal(1, DesignContainer.ComponentInstance.Count(ci => ci.Name == "CompA3")); Assert.Equal(1, DesignContainer.Container1.Count(c => c.Name == "Assembly1")); var Assembly1 = DesignContainer.Container1.First(c => c.Name == "Assembly1"); Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA1")); Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA2")); Assert.Equal(1, root.Container1.Count(c => c.Name == "ReusableContainer")); var ReusableContainer = root.Container1.First(c => c.Name == "ReusableContainer"); Assert.Equal(1, ReusableContainer.Container1.Count(c => c.Name == "Assembly4")); var Assembly4 = ReusableContainer.Container1.First(c => c.Name == "Assembly4"); Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA1")); Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA2")); Assert.Equal(1, ReusableContainer.ComponentInstance.Count(ci => ci.Name == "CompA4")); Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA")); Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA")); } finally { proj.Close(); } }
public static Tuple <CyPhyGUIs.InterpreterMainParameters, CyPhyGUIs.IInterpreterResult> RunReturnFull(string outputdirname, string projectPath, string absPath, CyPhyGUIs.SmartLogger logger = null, Action <MgaProject> preProcess = null) { var mainParameters = new CyPhyGUIs.InterpreterMainParameters(); CyPhyGUIs.IInterpreterResult results = null; Assert.True(File.Exists(projectPath), "Project file does not exist."); string ProjectConnStr = "MGA=" + projectPath; //Type CyPhyPETInterpreter = Type.GetTypeFromProgID("MGA.Interpreter.CyPhyPET"); //Type MainParametersType = Type.GetTypeFromProgID("ISIS.CyPhyML.InterpreterConfiguration"); MgaProject project = new MgaProject(); project.OpenEx(ProjectConnStr, "CyPhyML", null); try { if (preProcess != null) { preProcess(project); } var terr = project.BeginTransactionInNewTerr(); var testObj = project.ObjectByPath[absPath] as MgaFCO; Assert.True(testObj != null, String.Format("Could not find FCO by path '{0}'", absPath)); mainParameters.OriginalCurrentFCOName = testObj.Name; project.AbortTransaction(); string OutputDir = Path.Combine(Path.GetDirectoryName(projectPath), outputdirname); OutputDir = Path.GetFullPath(OutputDir); if (Directory.Exists(OutputDir)) { CyPhyGUIs.CyPhyDirectory.EnsureEmptyDirectory(OutputDir); } Directory.CreateDirectory(OutputDir); //dynamic interpreter = Activator.CreateInstance(CyPhyPETInterpreter); var interpreter = new CyPhyPET.CyPhyPETInterpreter(); interpreter.Initialize(project); //dynamic mainParameters = Activator.CreateInstance(MainParametersType); 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); interpreter.Logger = logger; results = interpreter.MainThrows(mainParameters); Assert.True(File.Exists(ProjectConnStr.Substring("MGA=".Length))); if (results.Success == false) { Test.DeleteDirectory(OutputDir); } } finally { project.Close(true); } return(new Tuple <CyPhyGUIs.InterpreterMainParameters, CyPhyGUIs.IInterpreterResult>(mainParameters, results)); }