void export_component_package() { var component = this.GetCurrentComp(); this.Logger = new CyPhyGUIs.GMELogger(CurrentProj, this.GetType().Name); this.Logger.WriteDebug("Starting Component Export module..."); // check for valid component and bail if there is not one try { string checkforinvalidcomponent = Path.GetDirectoryName(component.Impl.Project.ProjectConnStr.Substring("MGA=".Length)); } catch(Exception) { this.Logger.WriteError("Error, No Current Componet"); cleanup(true); return; } #region Prompt for Output Path string startupPath = Path.GetDirectoryName(component.Impl.Project.ProjectConnStr.Substring("MGA=".Length)); // Get an output path from the user. String s_outPath; using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog() { Description = "Choose a path for the generated files.", //ShowNewFolderButton = true, SelectedPath = startupPath, }) { DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { s_outPath = fbd.SelectedPath; } else { this.Logger.WriteWarning("Component Exporter cancelled"); cleanup(false); return; } } #endregion // FIXME: this could throw an exception (but this code is currently unreachable) var pkgPath = Exp.CyPhyComponentExporterInterpreter.ExportComponentPackage(component, s_outPath); this.Logger.WriteInfo("Component package created: {0}", pkgPath); cleanup(true); }
void export_component_package() { var component = (CyPhy.Component) this.GetCurrentDesignElement(); this.Logger = new CyPhyGUIs.GMELogger(CurrentProj, this.GetType().Name); this.Logger.WriteDebug("Starting Component Export module..."); // check for valid component and bail if there is not one try { string checkforinvalidcomponent = Path.GetDirectoryName(component.Impl.Project.ProjectConnStr.Substring("MGA=".Length)); } catch (Exception) { this.Logger.WriteError("Error, No Current Component"); cleanup(true); return; } #region Prompt for Output Path string startupPath = Path.GetDirectoryName(component.Impl.Project.ProjectConnStr.Substring("MGA=".Length)); // Get an output path from the user. String s_outPath; using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog() { Description = "Choose a path for the generated files.", //ShowNewFolderButton = true, SelectedPath = startupPath, }) { DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { s_outPath = fbd.SelectedPath; } else { this.Logger.WriteWarning("Component Exporter cancelled"); cleanup(false); return; } } #endregion // FIXME: this could throw an exception (but this code is currently unreachable) var pkgPath = Exp.CyPhyComponentExporterInterpreter.ExportComponentPackage(component, s_outPath); this.Logger.WriteInfo("Component package created: {0}", pkgPath); cleanup(true); }
private string RunFolderDlg() { string currentDir = Environment.CurrentDirectory; var folderDlg = new META.FolderBrowserDialog(); folderDlg.SelectedPath = currentDir; var result = folderDlg.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { return(Path.GetFullPath(folderDlg.SelectedPath)); } return(null); }
private string RunFolderDlg() { string selectedDir = ""; string currentDir = Environment.CurrentDirectory; var folderDlg = new META.FolderBrowserDialog(); folderDlg.SelectedPath = currentDir; var result = folderDlg.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { selectedDir = Path.GetFullPath(folderDlg.SelectedPath); } return selectedDir; }
private void btnBrowsePCCCorePath_Click(object sender, EventArgs e) { string selectedPath = Directory.Exists(txtPCCCorePath.Text) ? Path.GetFullPath(txtPCCCorePath.Text) : ""; using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog() { SelectedPath = selectedPath, //ShowNewFolderButton = false, }) { var dr = fbd.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { txtPCCCorePath.Text = fbd.SelectedPath; } } }
public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode) { // Get RootFolder IMgaFolder rootFolder = project.RootFolder; #region Prompt for Output Path // Get an output path from the user. String s_outPath; using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog() { Description = "Choose a path for the generated files.", //ShowNewFolderButton = true, SelectedPath = Environment.CurrentDirectory, }) { DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { s_outPath = fbd.SelectedPath; } else { GMEConsole.Warning.WriteLine("Design Exporter cancelled"); return; } } #endregion GMEConsole.Info.WriteLine("Beginning Export..."); var testBanches = new List<CyPhy.TestBench>(); if (currentobj != null && currentobj.Meta.Name == "TestBench") { testBanches.Add(CyPhyClasses.TestBench.Cast(currentobj)); } else if (selectedobjs.Count > 0) { foreach (MgaFCO mf in selectedobjs) { if (mf.Meta.Name == "TestBench") { testBanches.Add(CyPhyClasses.TestBench.Cast(mf)); } } } else { CyPhy.RootFolder root = ISIS.GME.Common.Utils.CreateObject<CyPhyClasses.RootFolder>(project.RootFolder as MgaObject); MgaFilter filter = project.CreateFilter(); filter.Kind = "TestBench"; foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>()) { if (item.ParentFolder != null) { testBanches.Add(CyPhyClasses.TestBench.Cast(item)); } } } foreach (var tb in testBanches) { System.Windows.Forms.Application.DoEvents(); try { ExportToFile(tb, s_outPath); } catch (Exception ex) { GMEConsole.Error.WriteLine("{0}: Exception encountered ({1})", tb.Name, ex.Message); } GMEConsole.Info.WriteLine("{0}: {1}", tb.Name, s_outPath); } }
public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param) { if (!enabled) { return; } if (currentobj == null) { GMEConsole = GMEConsole.CreateFromProject(project); GMEConsole.Warning.WriteLine("Please run in the context of a TestBench"); return; } // Make sure running within the context of a testbench bool inTBContext = false; MgaGateway.PerformInTransaction(delegate { if (currentobj.Meta.Name == "TestBench") { inTBContext = true; } }); if (!inTBContext) { GMEConsole = GMEConsole.CreateFromProject(project); GMEConsole.Warning.WriteLine("Please run in the context of a TestBench"); return; } // Need to get an output path from the user. using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog()) { fbd.Description = "Choose a path for the generated files."; //fbd.ShowNewFolderButton = true; DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { OutputDirectory = fbd.SelectedPath; } else { GMEConsole = GMEConsole.CreateFromProject(project); GMEConsole.Out.WriteLine("CyPhyComplexity: Operation cancelled"); return; } } try { CallElaboratorAndMain(project, currentobj, selectedobjs, param); } finally { MgaGateway = null; project = null; currentobj = null; selectedobjs = null; GMEConsole = null; GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param) { if (!enabled) { return; } if (currentobj == null) { GMEConsole = GMEConsole.CreateFromProject(project); GMEConsole.Warning.WriteLine("Please run in the context of a TestBench"); return; } // Make sure running within the context of a testbench bool inTBContext = false; MgaGateway.PerformInTransaction(delegate { if (currentobj.Meta.Name == "TestBench") { inTBContext = true; } }); if (!inTBContext) { GMEConsole = GMEConsole.CreateFromProject(project); GMEConsole.Warning.WriteLine("Please run in the context of a TestBench"); return; } // Need to get an output path from the user. using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog()) { fbd.Description = "Choose a path for the generated files."; //fbd.ShowNewFolderButton = true; DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { OutputDirectory = fbd.SelectedPath; } else { GMEConsole = GMEConsole.CreateFromProject(project); GMEConsole.Out.WriteLine("CyPhyComplexity: Operation cancelled"); return; } } try { CallElaboratorAndMain(project, currentobj, selectedobjs, param); } finally { if (MgaGateway.territory != null) { MgaGateway.territory.Destroy(); } MgaGateway = null; project = null; currentobj = null; selectedobjs = null; GMEConsole = null; GC.Collect(); GC.WaitForPendingFinalizers(); } }
public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode) { // Get RootFolder IMgaFolder rootFolder = project.RootFolder; #region Prompt for Output Path // Get an output path from the user. String s_outPath; using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog() { Description = "Choose a path for the generated files.", //ShowNewFolderButton = true, SelectedPath = Environment.CurrentDirectory, }) { DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { s_outPath = fbd.SelectedPath; } else { GMEConsole.Warning.WriteLine("Design Exporter cancelled"); return; } } #endregion GMEConsole.Info.WriteLine("Beginning Export..."); var testBanches = new List <CyPhy.TestBench>(); if (currentobj != null && currentobj.Meta.Name == "TestBench") { testBanches.Add(CyPhyClasses.TestBench.Cast(currentobj)); } else if (selectedobjs.Count > 0) { foreach (MgaFCO mf in selectedobjs) { if (mf.Meta.Name == "TestBench") { testBanches.Add(CyPhyClasses.TestBench.Cast(mf)); } } } else { CyPhy.RootFolder root = ISIS.GME.Common.Utils.CreateObject <CyPhyClasses.RootFolder>(project.RootFolder as MgaObject); MgaFilter filter = project.CreateFilter(); filter.Kind = "TestBench"; foreach (var item in project.AllFCOs(filter).Cast <MgaFCO>()) { if (item.ParentFolder != null) { testBanches.Add(CyPhyClasses.TestBench.Cast(item)); } } } foreach (var tb in testBanches) { System.Windows.Forms.Application.DoEvents(); try { ExportToFile(tb, s_outPath); } catch (Exception ex) { GMEConsole.Error.WriteLine("{0}: Exception encountered ({1})", tb.Name, ex.Message); } GMEConsole.Info.WriteLine("{0}: {1}", tb.Name, s_outPath); } }
public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode) { // TODO: Add your interpreter code GMEConsole.Out.WriteLine("Running Design Exporter..."); #region Prompt for Output Path // Get an output path from the user. if (this.OutputDir == null) { using (META.FolderBrowserDialog fbd = new META.FolderBrowserDialog() { Description = "Choose a path for the generated files.", //ShowNewFolderButton = true, SelectedPath = Environment.CurrentDirectory, }) { DialogResult dr = fbd.ShowDialog(); if (dr == DialogResult.OK) { OutputDir = fbd.SelectedPath; } else { GMEConsole.Warning.WriteLine("Design Exporter cancelled"); return; } } } #endregion GMEConsole.Info.WriteLine("Beginning Export..."); List<CyPhy.DesignEntity> lde_allCAandDC = new List<CyPhy.DesignEntity>(); List<CyPhy.TestBenchType> ltbt_allTB = new List<CyPhy.TestBenchType>(); if (currentobj != null && currentobj.Meta.Name == "ComponentAssembly") { lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(currentobj)); } else if (currentobj != null && currentobj.Meta.Name == "DesignContainer") { lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(currentobj)); } else if (currentobj != null && IsTestBenchType(currentobj.MetaBase.Name)) //CyPhyClasses.TestBenchType.Cast(currentobj) != null) { ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(currentobj)); } else if (selectedobjs != null && selectedobjs.Count > 0) { foreach (MgaFCO mf in selectedobjs) { if (mf.Meta.Name == "ComponentAssembly") { lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(mf)); } else if (mf.Meta.Name == "DesignContainer") { lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(mf)); } else if (IsTestBenchType(mf.MetaBase.Name)) { ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(mf)); } } } else { CyPhy.RootFolder rootFolder = ISIS.GME.Common.Utils.CreateObject<CyPhyClasses.RootFolder>(project.RootFolder as MgaObject); MgaFilter filter = project.CreateFilter(); filter.Kind = "ComponentAssembly"; foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>()) { if (item.ParentFolder != null) { lde_allCAandDC.Add(CyPhyClasses.ComponentAssembly.Cast(item)); } } filter = project.CreateFilter(); filter.Kind = "DesignContainer"; foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>()) { if (item.ParentFolder != null) { lde_allCAandDC.Add(CyPhyClasses.DesignContainer.Cast(item)); } } filter = project.CreateFilter(); filter.Kind = "TestBenchType"; foreach (var item in project.AllFCOs(filter).Cast<MgaFCO>()) { if (item.ParentFolder != null) { ltbt_allTB.Add(CyPhyClasses.TestBenchType.Cast(item)); } } } foreach (CyPhy.DesignEntity de in lde_allCAandDC) { System.Windows.Forms.Application.DoEvents(); try { ExportToFile(de, OutputDir); } catch (Exception ex) { GMEConsole.Error.WriteLine("{0}: Exception encountered ({1})",de.Name,ex.Message); } GMEConsole.Info.WriteLine("{0}: {1}", de.Name, OutputDir); } foreach (CyPhy.TestBenchType tbt in ltbt_allTB) { System.Windows.Forms.Application.DoEvents(); try { ExportToFile(tbt, OutputDir); } catch (Exception ex) { GMEConsole.Error.WriteLine("{0}: Exception encountered ({1})", tbt.Name, ex.Message); } GMEConsole.Info.WriteLine("{0}: {1}", tbt.Name, OutputDir); } GMEConsole.Info.WriteLine(String.Format("{0} model(s) exported", lde_allCAandDC.Count + ltbt_allTB.Count)); GMEConsole.Info.WriteLine("Design Exporter finished"); }