Пример #1
0
        /// <summary>
        /// Get OctoPart MPN CyPhy property value
        /// </summary>
        public string QueryCyPhyOctoPartMpnProperty(CyPhy.Component comp)
        {
            IEnumerable <CyPhy.Property> propertyCollection = comp.Children.PropertyCollection;

            CyPhy.Property property = propertyCollection.FirstOrDefault(p => p.Name.ToLower() == "octopart_mpn");
            return(property == null ? "" : property.Attributes.Value);
        }
Пример #2
0
        // META-2043 Extend CAD CAT module to create component-level Parameters for CAD Model's Parameters
        void CADModuleImportExtension(CyPhy.CADModel ProcessedCADModel)
        {
            // When the user imports a CAD Model, the current implementation creates a CyPhy CADModel object. After this point:
            int numComponentParams = 0;

            foreach (CyPhy.CADParameter parm in ProcessedCADModel.Children.CADParameterCollection)
            {
                // - For each CADParameter object, create a corresponding Property object under the parent Component.
                //   - Give the Property the same name
                CyPhy.Property newprop = CyPhyClasses.Property.Create(GetCurrentComp());
                newprop.Name = parm.Name;
                if (!String.IsNullOrWhiteSpace(parm.Attributes.Value))
                {
                    newprop.Attributes.Value = parm.Attributes.Value;
                }

                // - Create a CADParameterPortMap connection from the Property to the CADParameter
                CyPhy.CADParameterPortMap ppmap = CyPhyClasses.CADParameterPortMap.Connect(newprop, parm);
                ppmap.Name = parm.Name;

                // - Perform some layout "niceification" on the resulting objects.
                foreach (MgaPart item in (newprop.Impl as MgaFCO).Parts)
                {
                    item.SetGmeAttrs(null, PARAMETER_START_X, greatest_current_y + PARAMETER_START_Y + (numComponentParams * PARAMETER_ADJUST_Y));
                }
                numComponentParams++;
            }
        }
Пример #3
0
 public void BuildCyPhyProperty(CyPhy.Component comp,
                                string name,
                                string value,
                                CyPhyClasses.Property.AttributesClass.DataType_enum type,
                                bool is_prominent)
 {
     if (CheckPropertyDoesNotExist(comp, name))
     {
         CyPhy.Property property = ISIS.GME.Dsml.CyPhyML.Classes.Property.Create(comp);
         property.Name                   = name;
         property.Attributes.Value       = value;
         property.Attributes.DataType    = type;
         property.Attributes.IsProminent = is_prominent;
     }
 }
Пример #4
0
        // META-2043 Extend CAD CAT module to create component-level Parameters for CAD Model's Parameters
        void CADModuleImportExtension(CyPhy.CADModel ProcessedCADModel)
        {
            // When the user imports a CAD Model, the current implementation creates a CyPhy CADModel object. After this point:
            int numComponentParams = 0;

            foreach (CyPhy.CADParameter parm in ProcessedCADModel.Children.CADParameterCollection)
            {
                // - For each CADParameter object, create a corresponding Property object under the parent Component.
                //   - Give the Property the same name
                CyPhy.Property newprop = CyPhyClasses.Property.Create((CyPhy.Component)GetCurrentDesignElement());
                newprop.Name = parm.Name;
                if (!String.IsNullOrWhiteSpace(parm.Attributes.Value))
                {
                    newprop.Attributes.Value = parm.Attributes.Value;
                }

                if (String.IsNullOrWhiteSpace(parm.Attributes.Unit) == false)
                {
                    if (map == null)
                    {
                        map = new CyPhyUnitMap();
                        map._cyPhyMLRootFolder = CyPhyClasses.RootFolder.GetRootFolder(ProcessedCADModel.Impl.Project);
                        map.init(true);
                    }
                    CyPhy.unit unit;
                    if (map._unitSymbolCyPhyMLUnitMap.TryGetValue(parm.Attributes.Unit, out unit))
                    {
                        newprop.Referred.unit = unit;
                    }
                }

                // - Create a CADParameterPortMap connection from the Property to the CADParameter
                CyPhy.CADParameterPortMap ppmap = CyPhyClasses.CADParameterPortMap.Connect(newprop, parm);
                ppmap.Name = parm.Name;

                // - Perform some layout "niceification" on the resulting objects.
                foreach (MgaPart item in (newprop.Impl as MgaFCO).Parts)
                {
                    item.SetGmeAttrs(null, PARAMETER_START_X, greatest_current_y + PARAMETER_START_Y + (numComponentParams * PARAMETER_ADJUST_Y));
                }
                numComponentParams++;
            }
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PCCProperty" /> class.
 /// </summary>
 /// <param name="property">A property of a component.</param>
 public PCCProperty(CyPhy.Property property)
 {
     this.CyPhyProperty = property;
     this.DistType      = "None";
 }
Пример #6
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;
            }
        }