private void CreateNewComponentMga(string eagleFilePath, string deviceName) { string sanitizedDevicename = deviceName; while (sanitizedDevicename[0] == '\\') { sanitizedDevicename = sanitizedDevicename.Substring(1); } foreach (char invalid in Path.GetInvalidFileNameChars()) { sanitizedDevicename = sanitizedDevicename.Replace(invalid, '_'); } // Directory.CreateDirectory(Path.Combine(startingDir, sanitizedDevicename)); //project.EnableAutoAddOns(true); // FIXME just need CyPhySignalBlocksAddOn project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED); try { project.RootFolder.Name = sanitizedDevicename; var components = (MgaFolder)project.RootFolder.ObjectByPath["/@Components|kind=Components"]; MgaMetaModel componentMeta = (MgaMetaModel)project.RootMeta.RootFolder.DefinedFCOByName["Component", false]; var component = components.CreateRootObject((MgaMetaFCO)componentMeta); component.Name = sanitizedDevicename; // Console.WriteLine("Libs " + string.Join("\n", project.RootFolder.ChildFolders.OfType<MgaFolder>().Select(x => x.LibraryName + " " + x.Name).ToArray())); var cyPhyComponent = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(component); var import = new CyPhyComponentAuthoring.Modules.EDAModelImport(); import.SetCurrentDesignElement(cyPhyComponent); import.CurrentObj = component; import.ImportSelectedEagleDevice(deviceName, eagleFilePath, cyPhyComponent); } finally { project.CommitTransaction(); } }
private static void ConvertAllSchematicsToCyPhy(string path) { var schematics = ConvertAllDevices(path); // Create MGA project on the spot. var proj = new MgaProject(); String connectionString = String.Format("MGA={0}", Path.GetTempFileName()); proj.Create(connectionString, "CyPhyML"); proj.EnableAutoAddOns(true); var mgaGateway = new MgaGateway(proj); var module = new CyPhyComponentAuthoring.Modules.EDAModelImport(); Dictionary <String, String> d_failures = new Dictionary <string, string>(); mgaGateway.PerformInTransaction(delegate { var rf = CyPhyClasses.RootFolder.GetRootFolder(proj); var cf = CyPhyClasses.Components.Create(rf); foreach (var t in schematics) { var identifier = t.Item1; var schematic = t.Item2; CyPhy.Component component = CyPhyClasses.Component.Create(cf); component.Name = identifier; module.SetCurrentDesignElement(component); module.CurrentObj = component.Impl as MgaFCO; try { var cyphySchematicModel = module.BuildCyPhyEDAModel(schematic, component); Assert.Equal(component.Children.SchematicModelCollection.Count(), 1); } catch (Exception e) { d_failures[identifier] = e.ToString(); } } }, transactiontype_enum.TRANSACTION_NON_NESTED, abort: true); proj.Save(); proj.Close(); if (d_failures.Any()) { String msg = String.Format("Failures in converting {0} component(s):" + Environment.NewLine, d_failures.Count); foreach (var kvp in d_failures) { msg += String.Format("{0}: {1}" + Environment.NewLine + Environment.NewLine, kvp.Key, kvp.Value); } Assert.True(false, msg); } }
private static void ConvertAllSchematicsToCyPhy(string path) { var schematics = ConvertAllDevices(path); // Create MGA project on the spot. var proj = new MgaProject(); String connectionString = String.Format("MGA={0}", Path.GetTempFileName()); proj.Create(connectionString, "CyPhyML"); proj.EnableAutoAddOns(true); var mgaGateway = new MgaGateway(proj); proj.CreateTerritoryWithoutSink(out mgaGateway.territory); var module = new CyPhyComponentAuthoring.Modules .EDAModelImport() { CurrentProj = proj }; Dictionary<String, String> d_failures = new Dictionary<string, string>(); mgaGateway.PerformInTransaction(delegate { var rf = CyPhyClasses.RootFolder.GetRootFolder(proj); var cf = CyPhyClasses.Components.Create(rf); foreach (var t in schematics) { var identifier = t.Item1; var schematic = t.Item2; CyPhy.Component component = CyPhyClasses.Component.Create(cf); component.Name = identifier; module.SetCurrentComp(component); try { var cyphySchematicModel = module.BuildCyPhyEDAModel(schematic, component); Assert.Equal(component.Children.SchematicModelCollection.Count(), 1); } catch (Exception e) { d_failures[identifier] = e.ToString(); } } }, transactiontype_enum.TRANSACTION_NON_NESTED, abort: true); proj.Save(); proj.Close(); if (d_failures.Any()) { String msg = String.Format("Failures in converting {0} component(s):" + Environment.NewLine, d_failures.Count); foreach (var kvp in d_failures) { msg += String.Format("{0}: {1}" + Environment.NewLine + Environment.NewLine, kvp.Key, kvp.Value); } Assert.True(false, msg); } }