public static bool SetLayoutData(object avmObj, IMgaObject cyphyObj) { if (cyphyObj is IMgaFCO) { var cyphyFCO = cyphyObj as IMgaFCO; if (cyphyFCO.ParentModel == null) { return(false); } var objWrapper = new LayoutDataWrapper(avmObj); if (objWrapper.hasLayoutData) { // Look for all aspects, and set our layout data. foreach (IMgaPart part in cyphyFCO.Parts) { part.SetGmeAttrs(null, System.Convert.ToInt32(objWrapper.xpos), System.Convert.ToInt32(objWrapper.ypos)); } return(true); } } return(false); }
private void HighlightInTree(IMgaObject item, int highlight) { if (TestMode) { return; } if (GMEConsole.gme == null) // e.g. unit tests { return; } object browser = GetBrowser(); if (browser != null) { // FIXME don't attempt if project was closed // if (item.Project.ProjectStatus try { browser.GetType().InvokeMember("HighlightItem", System.Reflection.BindingFlags.InvokeMethod, null, browser, new object[] { item, highlight }); } catch (TargetInvocationException e) { throw e.InnerException; } } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="subject"></param> /// <returns></returns> public static T CreateObject <T>(IMgaObject subject) where T : ISIS.GME.Common.Classes.Base, new() { // TODO: rename this function Contract.Requires(subject != null, "Subject cannot be null."); ISIS.GME.Common.Interfaces.Base newObject = null; //if (IsObjectCacheEnabled) //{ // if (ObjectCache.TryGetValue(subject, out newObject) == false) // { // // create new object and put it into the cache // newObject = new T() { Impl = subject as IMgaObject }; // ObjectCache.Add(subject, newObject); // } //} //else { newObject = new T() { Impl = subject as IMgaObject }; } return(newObject as T); }
public static string getPath(IMgaObject o) { MgaObject parent; GME.MGA.Meta.objtype_enum type; o.GetParent(out parent, out type); Stack <IMgaObject> stack = new Stack <IMgaObject>(); StringBuilder sb = new StringBuilder(); stack.Push(o); while (parent != null) { stack.Push(parent); parent.GetParent(out parent, out type); } foreach (var item in stack) { if (item != stack.Peek()) { sb.Append("/"); } sb.Append(item.Name); } return(sb.ToString()); }
/// <summary> /// Adds an object ID pair to the traceability map and adds the copied object to the temporary object list keeping track of /// the object to be deleted. /// </summary> /// <param name="copied">Copy of the original object</param> /// <param name="original">Original object</param> /// <param name="recursive">Adds traceability recursively, but it does not add to the temporary objects recursively.</param> protected void AddToTraceabilityAndTemporary(IMgaObject copied, IMgaObject original, bool recursive = true) { // save copied object in temporary object. this.temporaryObjects.Push(copied); this.AddToTraceability(copied, original, recursive); }
/// <summary> /// Adds an object ID pair to the traceability map. /// </summary> /// <param name="copied">Copy of the original object</param> /// <param name="original">Original object</param> /// <param name="recursive">Adds traceability recursively</param> private void AddToTraceability(IMgaObject copied, IMgaObject original, bool recursive = true) { this.traceability.AddItem(copied.ID, original.ID); if (recursive) { // recursive IEnumerable <MgaObject> copiedChildren = null; if (copied is MgaModel && original is MgaModel) { copiedChildren = (copied as MgaModel).ChildObjects.Cast <MgaObject>(); } else if (copied is MgaFolder && original is MgaFolder) { copiedChildren = (copied as MgaFolder).ChildObjects.Cast <MgaObject>(); } if (copiedChildren != null) { // container model or folder // find pair of child objects (do NOT follow references!) foreach (var copiedChild in copiedChildren) { long relID = copiedChild.RelID; // FIXME: this is NOT the correct implementation below! We only use copies. /*if (copiedChild is MgaFCO) * { * bool derived = (copiedChild as MgaFCO).IsInstance || (copiedChild as MgaFCO).ArcheType != null; * if (derived) * { * relID = relID | (RELID_BASE_MAX + 1); * } * else * { * relID = relID & ~(RELID_BASE_MAX + 1); * } * }*/ var originalChild = original.get_ChildObjectByRelID((int)relID); if (originalChild != null) { if (copied == copiedChild || original == originalChild) { // we would run into an infinite loop avoiding it here } else { this.AddToTraceability(copiedChild, originalChild, recursive); } } } } } }
public static IEnumerable<IMgaObject> getAncestorsAndSelf(IMgaFCO fco, IMgaObject stopAt = null) { yield return fco; foreach (var parent in getAncestors(fco, stopAt)) { yield return parent; } }
public void DumpWMFs(string outdir, object obj) { GME.IGMEOLEApp app; IMgaObject root; if (obj is IMgaObject) { root = obj as IMgaObject; app = (GME.IGMEOLEApp)root.Project.GetClientByName("GME.Application").OLEServer; root.Project.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED); } else { app = obj as GME.IGMEOLEApp; app.MgaProject.BeginTransactionInNewTerr(transactiontype_enum.TRANSACTION_NON_NESTED); root = app.MgaProject.RootFolder; } Dictionary <IMgaModel, string> models = new Dictionary <IMgaModel, string>(); try { Queue <IMgaObject> objects = new Queue <IMgaObject>(); objects.Enqueue(root); while (objects.Count > 0) { IMgaObject o = objects.Dequeue(); if (o.ObjType == objtype_enum.OBJTYPE_FOLDER) { foreach (var i in (o as IMgaFolder).ChildObjects) { objects.Enqueue(i as IMgaObject); } } else if (o.ObjType == objtype_enum.OBJTYPE_MODEL) { foreach (var i in (o as IMgaModel).ChildFCOs) { objects.Enqueue(i as IMgaFCO); } if ((o as IMgaModel).ChildFCOs.Count > 0) { models.Add(o as IMgaModel, o.Name + " " + o.ID); } } } } finally { root.Project.AbortTransaction(); } foreach (var ent in models) { app.ShowFCO(ent.Key as MgaFCO); app.OleIt.DumpWindowsMetaFile(Path.Combine(outdir, RemoveInvalidFilePathCharacters(ent.Value, "")) + ".wmf"); app.OleIt.Close(); } }
public static string GetLink(IMgaObject o, string linkText = null) { if (linkText == null) { linkText = getPath(o); } return("<a href=\"mga:" + o.ID + "\">" + linkText + "</a>"); }
public static bool IsLibOrLibObject(this IMgaObject o) { if (o is IMgaFolder) { return(string.IsNullOrEmpty(((IMgaFolder)o).LibraryName) == false || o.IsLibObject); } else { return(o.IsLibObject); } }
public Switcher(IMgaObject fco1Object, IMgaObject fco2Object, GMEConsole GMEConsole) { this.lib1Objects = new List <IMgaObject>() { fco1Object }; this.lib2Objects = new List <IMgaObject>() { fco2Object }; this.GMEConsole = GMEConsole; }
public static IMgaObject getTracedObjectOrSelf(this IMgaObject obj, CyPhyCOMInterfaces.IMgaTraceability traceability) { string originalID; if (traceability != null && traceability.TryGetMappedObject(obj.ID, out originalID)) { return(obj.Project.GetObjectByID(originalID)); } else { return(obj); } }
public static string GetID(this MgaTraceability t, IMgaObject obj) { String compOriginalID = null; if (t.TryGetMappedObject(obj.ID, out compOriginalID)) { } else { compOriginalID = obj.ID; } return(compOriginalID); }
private bool SafeMgaObjectCompare(IMgaObject obj1, IMgaObject obj2) { if (obj1 == obj2) { return(true); } else if (obj1 != null && obj2 != null) { return(obj1.ID == obj2.ID); } else { return(false); } }
public static HashSet <CyPhyML.Component> getCyPhyMLComponentSet(IMgaObject iMgaObject) { if (iMgaObject == null) { return(new HashSet <CyPhyML.Component>()); } string metaName = iMgaObject.MetaBase.Name; HashSet <CyPhyML.Component> cyPhyMLComponentSet = null; if (metaName == "Component") { cyPhyMLComponentSet = new HashSet <CyPhyML.Component>(); cyPhyMLComponentSet.Add(CyPhyMLClasses.Component.Cast(iMgaObject)); } else if (metaName == "ComponentRef") { CyPhyML.ComponentRef cyPhyMLComponentRef = CyPhyMLClasses.ComponentRef.Cast(iMgaObject); cyPhyMLComponentSet = new HashSet <CyPhyML.Component>(); cyPhyMLComponentSet.Add(cyPhyMLComponentRef.Referred as CyPhyML.Component); } else if (metaName == "ComponentAssembly") { cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.ComponentAssembly.Cast(iMgaObject)); } else if (metaName == "ComponentAssemblyRef") { CyPhyML.ComponentAssemblyRef cyPhyMLComponentAssemblyRef = CyPhyMLClasses.ComponentAssemblyRef.Cast(iMgaObject); cyPhyMLComponentSet = new HashSet <CyPhyML.Component>(); cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(cyPhyMLComponentAssemblyRef.Referred as CyPhyML.ComponentAssembly); } else if (metaName == "TestBench") { cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.TestBench.Cast(iMgaObject)); } else if (metaName == "RootFolder") { cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.RootFolder.GetRootFolder(iMgaObject.Project)); } else { cyPhyMLComponentSet = new HashSet <CyPhyML.Component>(); } return(cyPhyMLComponentSet); }
public static GMELightObject GetGMELightFromMgaObject(IMgaObject subject) { GMELightObject gmeLightObject = new GMELightObject(); gmeLightObject.AbsPath = subject.AbsPath; gmeLightObject.GMEId = subject.ID; // TODO: figure out how to show to the user configurations when they have no uniqie names. gmeLightObject.Name = subject.Name; // TODO: set tool tip to ParentName/ObjectName // TODO: would be nice to use a regexp or something like that gmeLightObject.ToolTip = ShortenAbsPath(subject.AbsPath); gmeLightObject.Type = subject.MetaBase.Name; return(gmeLightObject); }
private List <IMgaObject> getChildren(IMgaObject fco1Objec) { List <IMgaObject> fco1Children = new List <IMgaObject>(); if (fco1Objec == null) { return(fco1Children); } if (fco1Objec is IMgaFolder) { fco1Children.AddRange((fco1Objec as IMgaFolder).ChildFolders.Cast <IMgaObject>()); fco1Children.AddRange((fco1Objec as IMgaFolder).ChildFCOs.Cast <IMgaObject>()); } if (fco1Objec is IMgaModel) { fco1Children.AddRange((fco1Objec as IMgaModel).ChildFCOs.Cast <IMgaObject>()); } return(fco1Children); }
private static void SetLayoutData(object avmObj, IMgaObject cyphyObj) { if (cyphyObj is IMgaFCO) { var cyphyFCO = cyphyObj as IMgaFCO; var objWrapper = new LayoutDataWrapper(avmObj); // Look for layout data associated with the All aspect. // If we find that aspect, set all the values. // Otherwise, we expect that avmObj's positional values will remain unset. Boolean hasAllAspect = false; foreach (IMgaPart part in cyphyFCO.Parts) { if (part.MetaAspect.Name == "All") { hasAllAspect = true; break; } } foreach (IMgaPart part in cyphyFCO.Parts) { if (part.MetaAspect.Name == "All" || hasAllAspect == false) { String icon; int xpos = 0; int ypos = 0; part.GetGmeAttrs(out icon, out xpos, out ypos); if (xpos >= 0 && ypos >= 0) { objWrapper.xpos = System.Convert.ToUInt32(xpos); objWrapper.ypos = System.Convert.ToUInt32(ypos); } // We got what we came for. Terminate the loop. break; } } } }
void choose_Click(object sender, EventArgs e) { IMgaObject selected = GetSelectedObjects().OfType <IMgaObject>().First(); string selectedText = null; MgaGateway.PerformInTransaction(delegate { selectedText = selected.Name + " (" + selected.ID + ")"; }, abort: false); if (sender == choose1) { this.fco1.Text = selectedText; this.fco1Object = selected; } else if (sender == choose2) { this.fco2.Text = selectedText; this.fco2Object = selected; } }
public static IEnumerable<IMgaObject> getAncestors(IMgaFCO fco, IMgaObject stopAt = null) { if (fco.ParentModel != null) { IMgaModel parent = fco.ParentModel; while (parent != null && (stopAt == null || parent.ID != stopAt.ID)) { yield return parent; if (parent.ParentModel == null) { break; } parent = parent.ParentModel; } fco = parent; } IMgaFolder folder = fco.ParentFolder; while (folder != null && (stopAt == null || folder.ID != stopAt.ID)) { yield return folder; folder = folder.ParentFolder; } }
/// <summary> /// Adds an object ID pair to the traceability map. /// </summary> /// <param name="copied">Copy of the original object</param> /// <param name="original">Original object</param> /// <param name="recursive">Adds traceability recursively</param> private void AddToTraceability(IMgaObject copied, IMgaObject original, bool recursive = true) { this.traceability.AddItem(copied.ID, original.ID); if (recursive) { // recursive IEnumerable<MgaObject> copiedChildren = null; if (copied is MgaModel && original is MgaModel) { copiedChildren = (copied as MgaModel).ChildObjects.Cast<MgaObject>(); } else if (copied is MgaFolder && original is MgaFolder) { copiedChildren = (copied as MgaFolder).ChildObjects.Cast<MgaObject>(); } if (copiedChildren != null) { // container model or folder // find pair of child objects (do NOT follow references!) foreach (var copiedChild in copiedChildren) { long relID = copiedChild.RelID; // FIXME: this is NOT the correct implementation below! We only use copies. /*if (copiedChild is MgaFCO) { bool derived = (copiedChild as MgaFCO).IsInstance || (copiedChild as MgaFCO).ArcheType != null; if (derived) { relID = relID | (RELID_BASE_MAX + 1); } else { relID = relID & ~(RELID_BASE_MAX + 1); } }*/ var originalChild = original.get_ChildObjectByRelID((int)relID); if (originalChild != null) { if (copied == copiedChild || original == originalChild) { // we would run into an infinite loop avoiding it here } else { this.AddToTraceability(copiedChild, originalChild, recursive); } } } } } }
/// <summary> /// Gets the temporary folder name for a given object in GME. /// </summary> /// <param name="originalObject">Object to get the temporary folder name.</param> /// <returns>Temporary folder name</returns> protected static string GetTemporaryFolderName(IMgaObject originalObject) { return originalObject.Name + TemporaryFolderSuffix; }
/// <summary> /// Gets the temporary object name for a given object (context and configuration pair) in GME. /// </summary> /// <param name="originalObject">Object to get the temporary object name.</param> /// <param name="configuration">Configuration generated from design space.</param> /// <returns>Temporary object name</returns> protected static string GetTemporaryObjectName(IMgaObject originalObject, IMgaObject configuration) { return configuration.Name; }
private void ExecuteInTransaction(IMgaObject context, Action doWork) { if (context == null || doWork == null) { throw new ArgumentNullException(); } this.ExecuteInTransaction(context.Project, doWork); }
private void TurnOffAddons(IMgaObject context) { this.ExecuteInTransaction(context, () => { var addons = context.Project.AddOnComponents.Cast<IMgaComponentEx>().Where(x => this.addonNames.Contains(x.ComponentName)); foreach (var addon in addons) { try { addon.Enable(false); } catch (Exception ex) { // if one fails keep trying the other ones. this.Logger.WriteDebug("Turing off addon failed: {0} --> {1}", addon.ComponentName, ex.ToString()); } } }); }
public static string getPath(IMgaObject fco1Object) { return(String.Join("/", new ParentChain(fco1Object).Select(x => x.Name).Reverse().ToArray())); }
private void ExecuteInTransaction(IMgaObject context, Action doWork, bool abort = false, transactiontype_enum type = transactiontype_enum.TRANSACTION_NON_NESTED) { if (context == null || doWork == null) { throw new ArgumentNullException(); } this.ExecuteInTransaction(context.Project, doWork, abort, type); }
/// <summary> /// Gets the temporary object name for a given object (context and configuration pair) in GME. /// </summary> /// <param name="originalObject">Object to get the temporary object name.</param> /// <param name="configuration">Configuration generated from design space.</param> /// <returns>Temporary object name</returns> protected static string GetTemporaryObjectName(IMgaObject originalObject, IMgaObject configuration) { return(configuration.Name); }
private void AssertConnected(ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp, IMgaObject obj1, IMgaObject obj2) { var conns1 = comp.Children.PortCompositionCollection.Where(pc => pc.SrcEnd.ID == obj1.ID && pc.DstEnd.ID == obj2.ID); var conns2 = comp.Children.PortCompositionCollection.Where(pc => pc.SrcEnd.ID == obj2.ID && pc.DstEnd.ID == obj1.ID); Assert.Equal(1, conns1.Count() + conns2.Count()); }
/// <summary> /// Gets the temporary folder name for a given object in GME. /// </summary> /// <param name="originalObject">Object to get the temporary folder name.</param> /// <returns>Temporary folder name</returns> protected static string GetTemporaryFolderName(IMgaObject originalObject) { return(originalObject.Name + TemporaryFolderSuffix); }
public static GMELightObject GetGMELightFromMgaObject(IMgaObject subject) { GMELightObject gmeLightObject = new GMELightObject(); gmeLightObject.AbsPath = subject.AbsPath; gmeLightObject.GMEId = subject.ID; // TODO: figure out how to show to the user configurations when they have no uniqie names. //// dashboard shows last 4 digit of the guid //var guidStr = new Guid(subject.GetGuidDisp()).ToString(); //string guidPortion = guidStr.Substring(guidStr.Length - 4); //gmeLightObject.Name = string.Format("[#{0}] {1}", guidPortion , subject.Name); gmeLightObject.Name = subject.Name; // TODO: set tool tip to ParentName/ObjectName // TODO: would be nice to use a regexp or something like that gmeLightObject.ToolTip = ShortenAbsPath(subject.AbsPath); gmeLightObject.Type = subject.MetaBase.Name; return gmeLightObject; }
private static void VisitChildren(Statistics.Statistics stats, IMgaObject mgaObject, object subtree) { var tree = (Dictionary <string, object>)subtree; if (mgaObject is MgaFCO && (mgaObject as MgaFCO).ArcheType != null) { stats.Model.InheritanceTree[(new Guid(mgaObject.GetGuidDisp())).ToString("D")] = (new Guid((mgaObject as MgaFCO).ArcheType.GetGuidDisp())).ToString("D"); } else { stats.Model.InheritanceTree[(new Guid(mgaObject.GetGuidDisp())).ToString("D")] = GetGUIDFromInt(mgaObject.MetaBase.MetaRef); } if (mgaObject is MgaFCO) { var numAttr = (mgaObject as MgaFCO).Attributes.Count.ToString(); int num = 0; if (stats.Model.Attributes.TryGetValue(numAttr, out num)) { stats.Model.Attributes[numAttr] = num + 1; } else { stats.Model.Attributes[numAttr] = 1; } } if (mgaObject.ObjType == GME.MGA.Meta.objtype_enum.OBJTYPE_FOLDER || mgaObject.ObjType == GME.MGA.Meta.objtype_enum.OBJTYPE_MODEL) { MgaObjects children = mgaObject.ChildObjects; int numChildren = children.Count; int number = 0; if (stats.Model.Children.TryGetValue(numChildren.ToString(), out number)) { stats.Model.Children[numChildren.ToString()] = number + 1; } else { stats.Model.Children[numChildren.ToString()] = 1; } foreach (MgaObject child in children) { string id = new Guid(child.GetGuidDisp()).ToString("D"); tree[id] = new Dictionary <string, object>(); VisitChildren(stats, child, tree[id]); } } else { int number = 0; if (stats.Model.Children.TryGetValue("0", out number)) { stats.Model.Children["0"] = number + 1; } else { stats.Model.Children["0"] = 1; } } switch (mgaObject.ObjType) { case objtype_enum.OBJTYPE_ATOM: stats.Model.NumberOfAtoms++; break; case objtype_enum.OBJTYPE_MODEL: stats.Model.NumberOfModels++; break; case objtype_enum.OBJTYPE_FOLDER: stats.Model.NumberOfFolders++; break; case objtype_enum.OBJTYPE_CONNECTION: stats.Model.NumberOfConnections++; break; case objtype_enum.OBJTYPE_REFERENCE: stats.Model.NumberOfReferences++; break; case objtype_enum.OBJTYPE_SET: stats.Model.NumberOfSets++; break; default: // TODO: ... break; } }
private void UpdateSublibrary(IMgaObject fco1Objec, IMgaObject fco2Objec) { // fco2Object may be null if (fco1Objec is IMgaFCO) // references only refer to FCOs { IMgaFCO fco1 = (IMgaFCO)fco1Objec; IMgaFCO fco2 = fco2Objec as IMgaFCO; foreach (IMgaFCO fco in fco1.ReferencedBy) { if (fco.IsInstance) { continue; // instance references will be updated by their archetype } // Don't update references in the old library bool fcoInLib1Objects = false; foreach (IMgaObject lib1Root in this.lib1Objects) { // FIXME: Contains(this.fco1Object) doesn't work if (new ParentChain(fco).Contains(lib1Root, new MgaObjectEqualityComparor <IMgaObject>())) { fcoInLib1Objects = true; } } if (fcoInLib1Objects) { continue; } IMgaReference refe = (IMgaReference)fco; if (fco2 != null) { if (refe.UsedByConns.Count != 0) { if (refe.DerivedFrom == null) { try { MoveReferenceWithRefportConnections(fco2, refe, WriteLine); } catch (Exception e) { if (GMEConsole != null) { GMEConsole.Error.WriteLine("Could not set reference " + GetLink(refe, refe.Name)); } throw new Exception("Could not set reference " + getPath(refe) + " (" + refe.ID + ")", e); } } } else { try { bool setRef; if (refe.DerivedFrom == null) { setRef = true; } else { short compareToBase; refe.CompareToBase(out compareToBase); setRef = compareToBase != 0; } if (setRef) { // FIXME: can this fail; should we handle it somehow? refe.Referred = (GME.MGA.MgaFCO)fco2; } } catch (Exception e) { if (GMEConsole != null) { GMEConsole.Error.WriteLine("Could not set reference " + GetLink(refe, refe.Name)); } throw new Exception("Could not set reference " + getPath(refe) + " (" + refe.ID + ")", e); } } } else { WriteLine((x, y) => "Couldn't update " + x + ": " + y + " has no counterpart", refe, fco1); } } } List <IMgaObject> fco1Children = getChildren(fco1Objec); List <IMgaObject> fco2Children = getChildren(fco2Objec); Dictionary <string, ObjectPair> dict = new Dictionary <string, ObjectPair>(); foreach (IMgaObject o in fco1Children) { dict.GetValueOrDefault(o.Name + "xxx ;xxx" + o.MetaBase.Name).o1 = o; } foreach (IMgaObject o in fco2Children) { dict.GetValueOrDefault(o.Name + "xxx ;xxx" + o.MetaBase.Name).o2 = o; } foreach (KeyValuePair <string, ObjectPair> entry in dict) { if (entry.Value.o1 != null) { UpdateSublibrary(entry.Value.o1, entry.Value.o2); } } }
public static HashSet<CyPhyML.Component> getCyPhyMLComponentSet(IMgaObject iMgaObject) { if ( iMgaObject == null ) return new HashSet<CyPhyML.Component>(); string metaName = iMgaObject.MetaBase.Name; HashSet<CyPhyML.Component> cyPhyMLComponentSet = null; if (metaName == "Component") { cyPhyMLComponentSet = new HashSet<CyPhyML.Component>(); cyPhyMLComponentSet.Add(CyPhyMLClasses.Component.Cast(iMgaObject)); } else if (metaName == "ComponentRef") { CyPhyML.ComponentRef cyPhyMLComponentRef = CyPhyMLClasses.ComponentRef.Cast(iMgaObject); cyPhyMLComponentSet = new HashSet<CyPhyML.Component>(); cyPhyMLComponentSet.Add(cyPhyMLComponentRef.Referred as CyPhyML.Component); } else if (metaName == "ComponentAssembly") { cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.ComponentAssembly.Cast(iMgaObject)); } else if (metaName == "ComponentAssemblyRef") { CyPhyML.ComponentAssemblyRef cyPhyMLComponentAssemblyRef = CyPhyMLClasses.ComponentAssemblyRef.Cast(iMgaObject); cyPhyMLComponentSet = new HashSet<CyPhyML.Component>(); cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(cyPhyMLComponentAssemblyRef.Referred as CyPhyML.ComponentAssembly); } else if (metaName == "TestBench") { cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.TestBench.Cast(iMgaObject)); } else if (metaName == "RootFolder") { cyPhyMLComponentSet = CyPhy2ComponentModel.ComponentLister.getCyPhyMLComponentSet(CyPhyMLClasses.RootFolder.GetRootFolder(iMgaObject.Project)); } else { cyPhyMLComponentSet = new HashSet<CyPhyML.Component>(); } return cyPhyMLComponentSet; }
/// <summary> /// Logs debugging information about the current status of elaboration. /// </summary> /// <param name="message">Message to log.</param> /// <param name="obj">Object on which the action was performed.</param> protected void LogDebug(string message, IMgaObject obj) { this.Logger.WriteDebug("{0} - {1}: {2} [{3}]", obj.ID, message, obj.Name, obj.MetaBase.Name); }
private bool SafeMgaObjectCompare(IMgaObject obj1, IMgaObject obj2) { if (obj1 == obj2) { return true; } else if (obj1 != null && obj2 != null) { return obj1.ID == obj2.ID; } else { return false; } }
private void HighlightInTree(IMgaObject item, int highlight) { if (TestMode) { return; } if (GMEConsole.gme == null) // e.g. unit tests { return; } object browser = GetBrowser(); if (browser != null) { try { browser.GetType().InvokeMember("HighlightItem", System.Reflection.BindingFlags.InvokeMethod, null, browser, new object[] { item, highlight }); } catch (TargetInvocationException e) { throw e.InnerException; } } }
public static HashSet<Cyber.ModelicaComponent> getCyberComponentSet(IMgaObject iMgaObject) { //GME.CSharp.GMEConsole console = GME.CSharp.GMEConsole.CreateFromProject(iMgaObject.Project); //console.Info.WriteLine("getCyberComponentSet: iMgaObject Overload!"); if (iMgaObject == null) return new HashSet<Cyber.ModelicaComponent>(); string metaName = iMgaObject.MetaBase.Name; HashSet<Cyber.ModelicaComponent> CyberComponentSet = null; if (metaName == "Components") { CyberComponentSet = getCyberComponentSet(CyberClasses.Components.Cast(iMgaObject)); } else if (metaName == "LibraryFolder") { CyberComponentSet = getCyberComponentSet(CyberClasses.LibraryFolder.Cast(iMgaObject)); } else if (metaName == "SimulinkWrapper" || metaName == "SignalFlowWrapper") { //console.Info.WriteLine("getCyberComponentSet: A ModelicaComponent! "); CyberComponentSet = getCyberComponentSet(CyberClasses.ModelicaComponent.Cast(iMgaObject)); } else if (metaName == "RootFolder") { CyberComponentSet = getCyberComponentSet(CyberClasses.RootFolder.GetRootFolder(iMgaObject.Project)); } return CyberComponentSet; }
public static bool SetLayoutData(object avmObj, IMgaObject cyphyObj) { if (cyphyObj is IMgaFCO) { var cyphyFCO = cyphyObj as IMgaFCO; if (cyphyFCO.ParentModel == null) { return false; } var objWrapper = new LayoutDataWrapper(avmObj); if (objWrapper.hasLayoutData) { // Look for all aspects, and set our layout data. foreach (IMgaPart part in cyphyFCO.Parts) { part.SetGmeAttrs(null, System.Convert.ToInt32(objWrapper.xpos), System.Convert.ToInt32(objWrapper.ypos)); } return true; } } return false; }