private AbstractClasses.Component ParseCyPhyComponent(CyPhy.Component component) { string classification = component.Attributes.Classifications.ToString(); if (String.Compare(classification, "ara_template") == 0 || String.Compare(classification, "template.ara_module_template") == 0) { // Stock module present for component replacement. AbstractClasses.AraTemplateComponent template = new AbstractClasses.AraTemplateComponent() { name = component.Attributes.InstanceGUID, classification = classification }; ParseAraTemplateComponent(component, template); return(template); } AbstractClasses.Component rtn = new AbstractClasses.Component() { // MOT-656 Switch to using component GUID as map key. Each component guaranteed to have a GUID, no need to check. name = component.Attributes.InstanceGUID, classification = classification }; // Check for only one EDAModel IEnumerable <CyPhy.EDAModel> edas = component.Children.EDAModelCollection; if (edas.Count() > 1) { logger.WriteError("Multiple EDAModels found for component {0}. Component should " + "only have one EDAModel.", component.Name); return(null); } IEnumerable <CyPhy.CAD2EDATransform> xforms = component.Children.CAD2EDATransformCollection; if (xforms.Count() == 0) { if (edas.Count() == 0) { logger.WriteInfo("Skipping component {0}, no EDAModel or CAD2EDATransform objects found.", component.Name); } else { logger.WriteWarning("EDAModel found for component {0} with no CAD2EDATransform, will generate " + "placeholder in visualizer based on EDAModel dimensions.", component.Name); CyPhy.EDAModel edaModel = edas.First(); } } else { // At this point you know all transforms point to the same EDAModel. The language also only // allows for one transform connection per CAD model, so you know there are no duplicate // transforms. foreach (var xform in xforms) { CyPhy.CADModel cadModel = xform.SrcEnds.CADModel; AddCadModelToComponent(xform, cadModel, component, rtn); } } return(rtn); }
public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param) { if (this.enabled == false) { return; } try { // Need to call this interpreter in the same way as the MasterInterpreter will call it. // initialize main parameters var parameters = new InterpreterMainParameters() { Project = project, CurrentFCO = currentobj, SelectedFCOs = selectedobjs, StartModeParam = param }; this.mainParameters = parameters; parameters.ProjectDirectory = project.GetRootDirectoryPath(); // set up the output directory MgaGateway.PerformInTransaction(delegate { string outputDirName = project.Name; if (currentobj != null) { outputDirName = currentobj.Name; } var outputDirAbsPath = Path.GetFullPath(Path.Combine( parameters.ProjectDirectory, "results", outputDirName)); parameters.OutputDirectory = outputDirAbsPath; if (Directory.Exists(outputDirAbsPath)) { Logger.WriteWarning("Output directory {0} already exists. Unexpected behavior may result.", outputDirAbsPath); } else { Directory.CreateDirectory(outputDirAbsPath); } }); PreConfigArgs preConfigArgs = new PreConfigArgs() { ProjectDirectory = parameters.ProjectDirectory, Project = parameters.Project }; // call the preconfiguration with no parameters and get preconfig var preConfig = this.PreConfig(preConfigArgs); // get previous GUI config var settings_ = META.ComComponent.DeserializeConfiguration(parameters.ProjectDirectory, typeof(CyPhy2CADPCB_Settings), this.ComponentProgID); CyPhy2CADPCB_Settings settings = (settings_ != null) ? settings_ as CyPhy2CADPCB_Settings : new CyPhy2CADPCB_Settings(); // Set configuration based on Workflow Parameters. This will override all [WorkflowConfigItem] members. settings = InitializeSettingsFromWorkflow(settings); // get interpreter config through GUI var config = this.DoGUIConfiguration(preConfig, settings); if (config == null) { Logger.WriteWarning("Operation canceled by the user."); return; } // if config is valid save it and update it on the file system META.ComComponent.SerializeConfiguration(parameters.ProjectDirectory, config, this.ComponentProgID); // assign the new configuration to mainParameters parameters.config = config; // call the main (ICyPhyComponent) function this.Main(parameters); } catch (Exception ex) { Logger.WriteError("Interpretation failed {0}<br>{1}", ex.Message, ex.StackTrace); } finally { DisposeLogger(); MgaGateway = null; project = null; currentobj = null; selectedobjs = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); } }