示例#1
0
        public int GetGreatestCurrentConnectorY(CyPhy.Connector conn)
        {
            int rVal = 0;

            // The children of the component may be things like schematic models, ports, etc.
            foreach (var child in conn.AllChildren)
            {
                foreach (MgaPart item in (child.Impl as MgaFCO).Parts)
                {
                    // Each Parts/item has info corresponding to placement on a GME aspect,
                    // where each aspect is like a separate, but overlapping canvas.
                    // Although components may be moved to different places in each aspect,
                    // we'd like to create them so they start off at the same place in
                    // each aspect.  Otherwise, it disorients the user when they switch aspects.
                    // That's why we check all aspects to get a single maximum Y, so
                    // the newly created stuff won't be overlapping in any of its aspects.

                    int    x, y;
                    string read_str;
                    item.GetGmeAttrs(out read_str, out x, out y);
                    rVal = (y > rVal) ? y : rVal;
                }
            }
            return(rVal);
        }
示例#2
0
        // Create a connector in a component
        void TestInsertIntoComponent()
        {
            SetupTest();

            RunCyPhyMLSync(
                (project, propagate, interpreter) =>
            {
                {
                    Edit msg = new Edit();
                    msg.mode.Add(Edit.EditMode.POST);
                    msg.origin.Add(origin);
                    msg.topic.Add("0");
                    msg.actions.Add(new edu.vanderbilt.isis.meta.Action()
                    {
                        actionMode = edu.vanderbilt.isis.meta.Action.ActionMode.ADD_CONNECTOR_TO_COMPONENT,
                        payload    = new Payload()
                    });
                    msg.actions[0].payload.connectors.Add(new ConnectorType()
                    {
                        DisplayName = "TestConnector",
                    });
                    msg.actions[0].payload.connectors[0].Datums.Add(new ConnectorDatumType()
                    {
                        DisplayName = "COMMON_PLANE_1_BOTTOM",
                        ID          = "COMMON_PLANE_1_BOTTOM"
                    });
                    msg.actions[0].payload.connectors[0].Datums.Add(new ConnectorDatumType()
                    {
                        DisplayName = "COMMON_PLANE_1_TOP",
                        ID          = "COMMON_PLANE_1_TOP"
                    });
                    msg.actions[0].payload.connectors[0].Datums.Add(new ConnectorDatumType()
                    {
                        DisplayName = "COMMON_AXIS",
                        ID          = "COMMON_AXIS"
                    });
                    msg.actions[0].subjectID = testAVMId;


                    propagate.EditMessageReceived(msg);
                    Application.DoEvents();
                    Thread.Sleep(1000);     // XXX don't race with propagate's send message thread
                }
                project.BeginTransactionInNewTerr();
                try
                {
                    var imported           = project.RootFolder.GetObjectByPathDisp("/@Imported_Components");
                    var damper             = imported.ChildObjects.Cast <IMgaObject>().Where(o => o.Name == "Damper_2").First();
                    var testconn           = damper.ChildObjects.Cast <MgaFCO>().Where(fco => fco.Name.Equals("TestConnector")).First();
                    CyPhyML.Connector conn = CyPhyMLClasses.Connector.Cast(testconn);
                    Xunit.Assert.Equal(conn.Children.CADDatumCollection.Count(), 3);
                }
                finally
                {
                    project.AbortTransaction();
                }
            }
                );
        }
示例#3
0
        private void VisitConnectorComposition(CyPhy.ConnectorComposition connection)
        {
            CyPhy.Connector dstconnector = connection.DstEnds.Connector;
            CyPhy.Connector srcconnector = connection.SrcEnds.Connector;
            if (dstconnector != null)
            {
                VisitConnector(dstconnector, GetRefportOrParent((MgaConnection)connection.Impl, "dst"));
            }

            if (srcconnector != null)
            {
                VisitConnector(srcconnector, GetRefportOrParent((MgaConnection)connection.Impl, "src"));
            }
        }
示例#4
0
 // Connectors may be nested in the future!
 private void FindCadDatumsInConnector(CyPhy.Connector connector,
                                       List <CyPhy.CADDatum> caddatum_list,            // These datums are part of the interface
                                       List <CyPhy.CADDatum> caddatum_list_joint_refs) // These datums are references belonging to joints, not part of the interface
 {
     foreach (var datum in connector.Children.CADDatumCollection)
     {
         if (!IsLimitRef(datum))
         {
             caddatum_list.Add(datum);
         }
         else
         {
             caddatum_list_joint_refs.Add(datum);
         }
     }
 }
示例#5
0
        /// <summary>
        /// Merge two or more connectors into a single connector.
        /// </summary>
        /// <param name="currentobj">Component that holds the connectors to be merged.</param>
        /// <param name="connList">Two or more connectors which the selected pins are attempted to be matched with.</param>
        private void MergeMultipleConnectors(MgaFCO currentobj, List <CyPhy.Connector> connList)
        {
            // Get the component
            var component = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(currentobj);

            int y_offset_component = GetGreatestCurrentY(component);
            int y_offset_connector = 25;
            int x_offset           = 100;

            // Add a connector
            CyPhy.Connector new_connector = CyPhyClasses.Connector.Create(component);

            // Name it
            new_connector.Name = String.Join("_", connList.Select(a => a.Name));

            // Make sure it doesn't overlap with existing objects.
            y_offset_component = y_offset_component + 125;

            // Position the newly-created connector
            // GUI coordinates in all aspects.
            SetFCOPosition(new_connector.Impl as MgaFCO, x_offset, y_offset_component);

            foreach (CyPhy.Connector connector in connList)
            {
                foreach (MgaFCO port in (connector.Impl as MgaFCO).ChildObjects)
                {
                    // Copy fields into a cloned port or pin
                    MgaFCO cloned_port = ClonePort(new_connector.Impl as MgaModel, port);

                    // Name it
                    cloned_port.Name = port.Name;

                    // Set coordinates
                    y_offset_connector = y_offset_connector + 50;
                    SetFCOPosition(cloned_port, x_offset, y_offset_connector);

                    // Copy connections
                    CopyPinConnections(component, port, cloned_port);

                    // Delete the original port or pin
                    port.DestroyObject();
                }

                (connector.Impl as MgaFCO).DestroyObject();
            }
        }
示例#6
0
        /// <summary>
        /// Creates a connector for each selected port or pin.
        /// </summary>
        /// <param name="currentobj">Component that holds the ports/pins to be wrapped.</param>
        /// <param name="portList">List of all the selected ports/pins to be wrapped with connectors.</param>
        private void HandleNoConnectorsSelected(MgaFCO currentobj, List <MgaFCO> portList)
        {
            int popCount = 0;

            // Get the component
            var component = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(currentobj);
            int startY    = GetGreatestCurrentY(component);

            foreach (MgaFCO portOrPin in portList)
            {
                // Get the name of the selected port or pin
                string popName = portOrPin.Name;

                // Add a connector
                CyPhy.Connector newConnector = CyPhyClasses.Connector.Create(component);

                // Name it
                newConnector.Name = popName;

                // Give it X and Y coordinates
                // Figure out where to place the newly-created schematic pin based on what side
                // of the SPICE model the SPICE model pin is on.

                int pinX = 100;
                int pinY = startY + (125 * ++popCount);

                // Position the newly-created connector
                // GUI coordinates in all aspects.
                SetFCOPosition(newConnector.Impl as MgaFCO, pinX, pinY);

                // Copy fields into a cloned port or pin
                MgaFCO clonedPortOrPin = ClonePort(newConnector.Impl as MgaModel, portOrPin);

                // Name it
                clonedPortOrPin.Name = popName;

                // Set coordinates
                SetFCOPosition(clonedPortOrPin, 100, 100);

                // Copy connections
                CopyPinConnections(component, portOrPin, clonedPortOrPin);

                // Delete the original port or pin
                portOrPin.DestroyObject();
            }
        }
示例#7
0
        private void FindMatchingSolidModelingFeatures(CyPhy.Connector a,
                                                       CyPhy.CADModel acadmodel)
        {
            // META-947: Connector instead of StructuralInterface
            // [1] Connectors can be nested so find all cad datums within a connector recursively
            // [2] Find connected datums
            //          Skip Connector without any Datum Ports

            DataRep.StructuralInterfaceConstraint sirep = new StructuralInterfaceConstraint(a,
                                                                                            this.Id,
                                                                                            this.DisplayID);
            sirep.PopulateStructuralInterface(acadmodel);

            if (sirep.DatumList.Count > 0)
            {
                StructuralInterfaceNodes[a.ID] = sirep;
            }
        }
示例#8
0
        private void VisitConnector(CyPhy.Connector connector, MgaFCO parent)
        {
            if (!visitedPorts.Contains(connector.ID + "_" + parent.ID))
            {
                visitedPorts.Add(connector.ID + "_" + parent.ID);

                bool parentIsComponent = (connector.ParentContainer is CyPhy.Component);
                bool isStart           = (connector.ID == startNodeID);

                if (!isStart && parentIsComponent)
                {
                    FoundConnectedNodes.Add(connector);
                }

                foreach (CyPhy.ConnectorComposition conn in connector.SrcConnections.ConnectorCompositionCollection)
                {
                    if (topAssembly != null && !IsParent(conn, topAssembly))
                    {
                        continue;
                    }

                    if (parent.ObjType != GME.MGA.Meta.objtype_enum.OBJTYPE_REFERENCE ||
                        GetRefportOrParent((MgaConnection)conn.Impl, "src").ID == parent.ID)
                    {
                        VisitConnector(conn.SrcEnds.Connector, parent);
                    }
                }

                foreach (CyPhy.ConnectorComposition conn in connector.DstConnections.ConnectorCompositionCollection)
                {
                    if (topAssembly != null && !IsParent(conn, topAssembly))
                    {
                        continue;
                    }

                    if (parent.ObjType != GME.MGA.Meta.objtype_enum.OBJTYPE_REFERENCE ||
                        GetRefportOrParent((MgaConnection)conn.Impl, "dst").ID == parent.ID)
                    {
                        VisitConnector(conn.DstEnds.Connector, parent);
                    }
                }
            }
        }
示例#9
0
        public void PopulateStructuralInterface(CyPhy.Connector a,
                                                CyPhy.CADModel acadmodel)
        {
            // META-947: Connector instead of StructuralInterface
            // [1] Connectors can be nested so find all cad datums within a connector recursively
            // [2] Find connected datums
            //     Skip Connector without any Datum Ports

            // Limitref datums won't be considered part of the connection
            List <CyPhy.CADDatum> CadDatum_List      = new List <CyPhy.CADDatum>();
            List <CyPhy.CADDatum> LimitRefDatum_List = new List <CyPhy.CADDatum>();

            FindCadDatumsInConnector(a, CadDatum_List, LimitRefDatum_List);

            Dictionary <string, DataRep.Datum> featuremap  = new Dictionary <string, DataRep.Datum>();
            Dictionary <string, DataRep.Datum> limitrefmap = new Dictionary <string, DataRep.Datum>();

            foreach (CyPhy.CADDatum item in CadDatum_List)
            {
                FindMatchingDatums(item, acadmodel, featuremap);
            }
            foreach (CyPhy.CADDatum item in LimitRefDatum_List)
            {
                FindMatchingDatums(item, acadmodel, limitrefmap);
            }

            this.DatumList     = featuremap;
            this.DegreeFreedom = GetDegreesOfFreedom();

            SetupJoint(CadDatum_List, LimitRefDatum_List, limitrefmap);

            SetupAdjoiningTreatment();

            foreach (var intfgeom in a.SrcConnections.InterfaceGeometryCollection.Union(a.DstConnections.InterfaceGeometryCollection))
            {
                var geom = (intfgeom.SrcEnds.GeometryTypes == null) ? intfgeom.DstEnds.GeometryTypes : intfgeom.SrcEnds.GeometryTypes;
                if (geom != null)
                {
                    Geometry.Add(CADGeometry.CreateGeometry(geom));
                }
            }
        }
示例#10
0
        public OriginatingConnectorTraversal(CyPhy.Connector conn)
        {
            List <CyPhy.ConnectorComposition> visited = new List <CyPhy.ConnectorComposition>();

            CyPhy.Connector current = conn;
            CyPhy.Connector last    = conn;
            while (current != null)
            {
                List <CyPhy.ConnectorComposition> nextroute = new List <CyPhy.ConnectorComposition>();
                var connections = current.SrcConnections.ConnectorCompositionCollection.Union(conn.DstConnections.ConnectorCompositionCollection);
                foreach (var connection in connections)
                {
                    if (visited.Contains(connection))
                    {
                        continue;
                    }

                    visited.Add(connection);
                    if (connection.ParentContainer != current.ParentContainer)
                    {
                        nextroute.Add(connection);
                    }
                }
                if (nextroute.Count == 0)
                {
                    result = current;
                    return;
                }
                last    = current;
                current = nextroute.First().SrcEnds.Connector;
                if (current.Guid == last.Guid || current == null)
                {
                    current = nextroute.First().DstEnds.Connector;
                }
                nextroute.Clear();
            }
        }
 public OriginatingConnectorTraversal(CyPhy.Connector conn)
 {
     List<CyPhy.ConnectorComposition> visited = new List<CyPhy.ConnectorComposition>();
     CyPhy.Connector current = conn;
     CyPhy.Connector last = conn;
     while (current != null)
     {
         List<CyPhy.ConnectorComposition> nextroute = new List<CyPhy.ConnectorComposition>();
         var connections = current.SrcConnections.ConnectorCompositionCollection.Union(conn.DstConnections.ConnectorCompositionCollection);
         foreach (var connection in connections)
         {
             if (visited.Contains(connection)) continue;
             visited.Add(connection);
             if (connection.ParentContainer != current.ParentContainer)
             {
                 nextroute.Add(connection);
             }
         }
         if (nextroute.Count == 0)
         {
             result = current;
             return;
         }
         last = current;
         current = nextroute.First().SrcEnds.Connector;
         if (current.Guid == last.Guid || current == null)
         {
             current = nextroute.First().DstEnds.Connector;
         }
         nextroute.Clear();
     }
 }
示例#12
0
        public void AddSimulinkObjectToModel(CyPhy.Component component, string blockPath, IEnumerable <string> selectedParams,
                                             IDictionary <string, string> inPorts, IDictionary <string, string> outPorts)
        {
            const int INNER_LEFT_COLUMN_X          = 50;
            const int INNER_RIGHT_COLUMN_X         = 500;
            const int INNER_VERTICAL_OFFSET        = 25;
            const int INNER_VERTICAL_PARAM_SPACING = 100;
            const int INNER_VERTICAL_PORT_SPACING  = 175;

            const int OUTER_LEFT_COLUMN_HORIZONTAL_OFFSET  = -300;
            const int OUTER_RIGHT_COLUMN_HORIZONTAL_OFFSET = 300;
            const int OUTER_VERTICAL_PARAM_SPACING         = 40;
            const int OUTER_VERTICAL_PORT_SPACING          = 100;

            int baseXPosition, baseYPosition;

            getNewModelInitialCoordinates(component, out baseXPosition, out baseYPosition);

            int nextInnerLeftYPosition  = 0;
            int nextInnerRightYPosition = 0;

            int nextOuterLeftYPosition  = baseYPosition;
            int nextOuterRightYPosition = baseYPosition;

            CyPhy.SimulinkModel newSimulinkModel = CyPhyClasses.SimulinkModel.Create(component);
            newSimulinkModel.Name = blockPath;
            newSimulinkModel.Attributes.BlockType        = blockPath;
            newSimulinkModel.Preferences.PortLabelLength = 0;
            setFCOPosition(newSimulinkModel.Impl as MgaFCO, baseXPosition, baseYPosition);


            foreach (var param in selectedParams)
            {
                CyPhy.SimulinkParameter newParam = CyPhyClasses.SimulinkParameter.Create(newSimulinkModel);
                newParam.Name = param;
                setFCOPosition(newParam.Impl as MgaFCO, INNER_LEFT_COLUMN_X, INNER_VERTICAL_OFFSET + nextInnerLeftYPosition);

                CyPhy.Property newProperty = CyPhyClasses.Property.Create(component);
                newProperty.Name = param;
                CyPhyClasses.SimulinkParameterPortMap.Connect(newProperty, newParam);
                setFCOPosition(newProperty.Impl as MgaFCO, baseXPosition + OUTER_LEFT_COLUMN_HORIZONTAL_OFFSET, nextOuterLeftYPosition);

                nextInnerLeftYPosition += INNER_VERTICAL_PARAM_SPACING;
                nextOuterLeftYPosition += OUTER_VERTICAL_PARAM_SPACING;
            }

            foreach (var inPort in inPorts)
            {
                CyPhy.SimulinkPort newPort = CyPhyClasses.SimulinkPort.Create(newSimulinkModel);

                var portName = inPort.Value;
                if (string.IsNullOrWhiteSpace(portName))
                {
                    portName = string.Format("in-{0}", inPort.Key);
                }
                newPort.Name = portName;
                newPort.Attributes.SimulinkPortDirection = CyPhyClasses.SimulinkPort.AttributesClass.SimulinkPortDirection_enum.@in;
                newPort.Attributes.SimulinkPortID        = inPort.Key.ToString();
                setFCOPosition(newPort.Impl as MgaFCO, INNER_LEFT_COLUMN_X, INNER_VERTICAL_OFFSET + nextInnerLeftYPosition);

                CyPhy.Connector newConnector = CyPhyClasses.Connector.Create(component);
                newConnector.Name = portName;
                CyPhy.SimulinkPort connectorPort = CyPhyClasses.SimulinkPort.Create(newConnector);
                connectorPort.Name = portName;
                connectorPort.Attributes.SimulinkPortDirection = CyPhyClasses.SimulinkPort.AttributesClass.SimulinkPortDirection_enum.@in;
                connectorPort.Attributes.SimulinkPortID        = inPort.Key.ToString();
                CyPhyClasses.PortComposition.Connect(connectorPort, newPort, null, null, component);
                setFCOPosition(newConnector.Impl as MgaFCO, baseXPosition + OUTER_LEFT_COLUMN_HORIZONTAL_OFFSET, nextOuterLeftYPosition);

                nextInnerLeftYPosition += INNER_VERTICAL_PORT_SPACING;
                nextOuterLeftYPosition += OUTER_VERTICAL_PORT_SPACING;
            }

            foreach (var outPort in outPorts)
            {
                CyPhy.SimulinkPort newPort = CyPhyClasses.SimulinkPort.Create(newSimulinkModel);

                var portName = outPort.Value;
                if (string.IsNullOrWhiteSpace(portName))
                {
                    portName = string.Format("out-{0}", outPort.Key);
                }
                newPort.Name = portName;
                newPort.Attributes.SimulinkPortDirection = CyPhyClasses.SimulinkPort.AttributesClass.SimulinkPortDirection_enum.@out;
                newPort.Attributes.SimulinkPortID        = outPort.Key.ToString();
                setFCOPosition(newPort.Impl as MgaFCO, INNER_RIGHT_COLUMN_X, INNER_VERTICAL_OFFSET + nextInnerRightYPosition);

                CyPhy.Connector newConnector = CyPhyClasses.Connector.Create(component);
                newConnector.Name = portName;
                CyPhy.SimulinkPort connectorPort = CyPhyClasses.SimulinkPort.Create(newConnector);
                connectorPort.Name = portName;
                connectorPort.Attributes.SimulinkPortDirection = CyPhyClasses.SimulinkPort.AttributesClass.SimulinkPortDirection_enum.@out;
                connectorPort.Attributes.SimulinkPortID        = outPort.Key.ToString();
                CyPhyClasses.PortComposition.Connect(newPort, connectorPort, null, null, component);
                setFCOPosition(newConnector.Impl as MgaFCO, baseXPosition + OUTER_RIGHT_COLUMN_HORIZONTAL_OFFSET, nextOuterRightYPosition);

                nextInnerRightYPosition += INNER_VERTICAL_PORT_SPACING;
                nextOuterRightYPosition += OUTER_VERTICAL_PORT_SPACING;
            }
        }
示例#13
0
        private void Traverse(string srcConnectorName, Port srcPort_obj, Tonka.DesignElement parent, Tonka.Connector connector, Dictionary <string, object> visited)
        {
            // XXX this is dead code; the elaborator removes Connectors
            Logger.WriteDebug("Traverse Connector: {0}, Mapped-Pin: {1}",
                              connector.Path,
                              srcConnectorName);
            if (visited.ContainsKey(connector.ID))
            {
                Logger.WriteWarning("Traverse Connector Revisit: {0}, Mapped-Pin: {1}", connector.Path, srcConnectorName);
                return;
            }
            visited.Add(connector.ID, connector);

            // continue traversal as connector
            var remotes = connector.DstConnections.ConnectorCompositionCollection.Select(p => p.DstEnd).Union(
                connector.SrcConnections.ConnectorCompositionCollection.Select(p => p.SrcEnd));

            foreach (var remote in remotes)
            {
                if (visited.ContainsKey(remote.ID)) // already visited
                {
                    continue;
                }
                if (remote.ParentContainer is Tonka.DesignElement)
                {
                    Traverse(srcConnectorName, srcPort_obj, remote.ParentContainer as Tonka.DesignElement, remote as Tonka.Connector, visited);
                }
            }

            // continue traversal through named port
            // XXX FIXME p.Name.Equals(srcConnectorName) is a bug (why should it matter what the names are)
            var mappedPorts = connector.Children.SchematicModelPortCollection.Where(p => p.Name.Equals(srcConnectorName));

            foreach (var mappedPort in mappedPorts)
            {
                var remotePorts = mappedPort.DstConnections.PortCompositionCollection.Select(p => p.DstEnd).Union(
                    mappedPort.SrcConnections.PortCompositionCollection.Select(p => p.SrcEnd));
                foreach (var remotePort in remotePorts)
                {
                    if (visited.ContainsKey(remotePort.ID)) // already visited
                    {
                        continue;
                    }
                    if (remotePort.ParentContainer is Tonka.Connector &&
                        !visited.ContainsKey(remotePort.ParentContainer.ID))
                    // traverse connector chain, carry port name in srcConnector
                    {
                        Traverse(remotePort.Name, srcPort_obj,
                                 remotePort.ParentContainer.ParentContainer as Tonka.DesignElement,
                                 remotePort.ParentContainer as Tonka.Connector, visited);
                    }
                    else if (remotePort.ParentContainer is Tonka.DesignElement)
                    {
                        Traverse(srcPort_obj, remotePort.ParentContainer as Tonka.DesignElement, remotePort as Tonka.Port, visited);
                    }
                    else if (portHasCorrectParentType(remotePort) &&
                             CyPhyBuildVisitor.Ports.ContainsKey(remotePort.ID))
                    {
                        ConnectPorts(srcPort_obj, CyPhyBuildVisitor.Ports[remotePort.ID]);
                    }
                }
            }
        }
示例#14
0
 private CyPhy.KinematicJoint GetJoint(ISIS.GME.Dsml.CyPhyML.Interfaces.Connector conn)
 {
     return(conn.Children.KinematicJointCollection.FirstOrDefault());
 }
示例#15
0
        /// <summary>
        /// Intelligently adds selected ports or pins to the selected connectors.
        /// </summary>
        /// <param name="currentobj">Component that holds the ports/pins to be wrapped.</param>
        /// <param name="portList">List of all the selected ports to be moved into the connectors or wrapped.</param>
        /// <param name="connList">Two or more connectors which the selected pins are attempted to be matched with.</param>
        private void HandleMultipleConnectorsSelected(MgaFCO currentobj, List <MgaFCO> portList, List <CyPhy.Connector> connList)
        {
            // Get the component
            var component = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(currentobj);

            int y_offset_component = GetGreatestCurrentY(component);
            int x_offset           = 100;

            foreach (MgaFCO portOrPin in portList)
            {
                // Get the name of the selected port or pin
                string popName = portOrPin.Name;

                CyPhy.Connector matched_connector = null;


                foreach (var connector in connList)
                {
                    if (connector.Name == popName)
                    {
                        matched_connector = connector;
                    }
                }

                if (matched_connector == null)
                {
                    // Add a connector
                    matched_connector = CyPhyClasses.Connector.Create(component);

                    // Name it
                    matched_connector.Name = popName;

                    // Give it X and Y coordinates
                    // Figure out where to place the newly-created schematic pin based on what side
                    // of the SPICE model the SPICE model pin is on.

                    y_offset_component = y_offset_component + 125;

                    // Position the newly-created connector
                    // GUI coordinates in all aspects.
                    SetFCOPosition(matched_connector.Impl as MgaFCO, x_offset, y_offset_component);
                }

                // Find existing pin or create a new one
                MgaFCO clonedPortOrPin = null;
                if (matched_connector.AllChildren.Count() > 0)
                {
                    var matched_pin = matched_connector.Children.SchematicModelPortCollection.Where(a => a.Name == popName).FirstOrDefault();
                    if (matched_pin != null)
                    {
                        clonedPortOrPin = (matched_pin.Impl as MgaFCO);
                    }
                }

                if (clonedPortOrPin == null)
                {
                    // Copy fields into a cloned port
                    clonedPortOrPin = ClonePort(matched_connector.Impl as MgaModel, portOrPin);

                    // Name it
                    clonedPortOrPin.Name = popName;

                    int y_offset_connector = GetGreatestCurrentConnectorY(matched_connector) + 125;

                    // Set coordinates
                    SetFCOPosition(clonedPortOrPin, x_offset, y_offset_connector);
                }

                // Copy connections
                CopyPinConnections(component, portOrPin, clonedPortOrPin);

                // Delete the original port or pin
                portOrPin.DestroyObject();
            }
        }
示例#16
0
        /// <summary>
        /// Adds selected ports or pins to the selected connector.
        /// </summary>
        /// <param name="currentobj">Component that holds the ports/pins to be wrapped.</param>
        /// <param name="portList">List of all the selected ports to be moved into the selected connector.</param>
        /// <param name="conn">Connector where the selected pins are to be moved.</param>
        private void HandleOneConnectorSelected(MgaFCO currentobj, List <MgaFCO> portList, CyPhy.Connector conn)
        {
            int popCount = 0;
            int startY   = GetGreatestCurrentConnectorY(conn);

            // Get the component
            var component = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(currentobj);

            foreach (MgaFCO portOrPin in portList)
            {
                // Get the name of the selected port or pin
                string popName = portOrPin.Name;

                int pinX = 100;
                int pinY = startY + (125 * ++popCount);

                // Copy fields into a cloned port or pin
                MgaFCO clonedPortOrPin = ClonePort(conn.Impl as MgaModel, portOrPin);

                // Name it
                clonedPortOrPin.Name = popName;

                // Set coordinates
                SetFCOPosition(clonedPortOrPin, pinX, pinY);

                // Copy connections
                CopyPinConnections(component, portOrPin, clonedPortOrPin);

                // Delete the original port or pin
                portOrPin.DestroyObject();
            }
        }