private void AddReferenceCoordinateSystemForAssemblyRoot(avm.Design ad_import, CyPhy.DesignEntity cyphy_container) { foreach (var root in ad_import.DomainFeature.OfType <avm.cad.AssemblyRoot>()) { CyPhyML.ComponentRef componentRef; if (idToComponentInstanceMap.TryGetValue(root.AssemblyRootComponentInstance, out componentRef)) { MgaFCO rcs = CreateChild((ISIS.GME.Common.Interfaces.Model)componentRef.ParentContainer, typeof(CyPhyML.ReferenceCoordinateSystem)); rcs.Name = "AssemblyRoot"; CyPhyML.ReferenceCoordinateSystem componentRcs = componentRef.Referred.Component.Children.ReferenceCoordinateSystemCollection.FirstOrDefault(); if (componentRcs == null) { componentRcs = CyPhyClasses.ReferenceCoordinateSystem.Create(componentRef.Referred.Component); } ((MgaModel)componentRef.ParentContainer.Impl).CreateSimpleConnDisp(((MgaMetaModel)componentRef.ParentContainer.Impl.MetaBase).RoleByName[typeof(CyPhyML.RefCoordSystem2RefCoordSystem).Name], rcs, (MgaFCO)componentRcs.Impl, null, (MgaFCO)componentRef.Impl); while (rcs.ParentModel.ID != cyphy_container.ID) { var oldrcs = rcs; rcs = CreateChild(rcs.ParentModel.ParentModel, typeof(CyPhyML.ReferenceCoordinateSystem)); rcs.Name = "AssemblyRoot"; ((MgaModel)rcs.ParentModel).CreateSimplerConnDisp(((MgaMetaModel)rcs.ParentModel.Meta).RoleByName[typeof(CyPhyML.RefCoordSystem2RefCoordSystem).Name], rcs, oldrcs); } } } }
public ReferenceCoordinateSystemTraversal(CyPhy.ReferenceCoordinateSystem port) { visitedIDs = new List <string>(); referenceCoordComponents = new List <string>(); VisitReferenceCoordinateSystem(port); }
private void VisitReferenceCoordinateSystem(CyPhy.ReferenceCoordinateSystem port) { if (!visitedIDs.Contains(port.ID)) { visitedIDs.Add(port.ID); if (port.ParentContainer.Kind == "Component") { referenceCoordComponents.Add(port.ParentContainer.ID); } foreach (var item in port.DstConnections.RefCoordSystem2RefCoordSystemCollection) { VisitReferenceCoordinateSystem(item.DstEnds.ReferenceCoordinateSystem); } foreach (var item in port.SrcConnections.RefCoordSystem2RefCoordSystemCollection) { VisitReferenceCoordinateSystem(item.SrcEnds.ReferenceCoordinateSystem); } } }
public void CoordinateSystem() { String testName = GetCurrentMethod(); fixture.proj.PerformInTransaction(delegate { var comp = fixture.proj.GetComponentsByName("CoordinateSystem") .First(); // Export then Import the component CyPhy.Components importedcomponents; CyPhy.Component newcomp = ExportThenImport(comp, out importedcomponents, testName); try { CyPhy.ReferenceCoordinateSystem sysInComponent = null; CyPhy.ReferenceCoordinateSystem sysInConnector = null; foreach (CyPhy.PortComposition portcomp in newcomp.Children.PortCompositionCollection) { CyPhy.ReferenceCoordinateSystem sys = null; if (portcomp.SrcEnds.ReferenceCoordinateSystem != null && portcomp.SrcEnds.ReferenceCoordinateSystem.ParentContainer.Kind == typeof(CyPhy.CADModel).Name) { sys = portcomp.DstEnds.ReferenceCoordinateSystem; } else if (portcomp.DstEnds.ReferenceCoordinateSystem != null) { sys = portcomp.SrcEnds.ReferenceCoordinateSystem; } else { continue; } if (sys.ParentContainer == newcomp) { if (sysInComponent != null) { Assert.False(true, "Found two PortCompositions connected to a ReferenceCoordinateSystem in the component. Only expected one"); } sysInComponent = sys; } else if (sys.ParentContainer.Kind == typeof(CyPhy.Connector).Name) { if (sysInConnector != null) { Assert.False(true, "Found two PortCompositions connected to a ReferenceCoordinateSystem in the component's Connector. Only expected one"); } sysInConnector = sys; } } // TODO // Assert.True(sysInComponent != null, "Did not find a connection from CADModel ReferenceCoordinateSystem to a ReferenceCoordinateSystem in the Component"); // Assert.True(sysInConnector != null, "Did not find a connection from CADModel ReferenceCoordinateSystem to a ReferenceCoordinateSystem in the Component's Connector"); } finally { // cleanup newcomp.Delete(); importedcomponents.Delete(); } }); }