当前位置: 首页>>代码示例>>C#>>正文


C# ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom方法代码示例

本文整理汇总了C#中ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom方法的典型用法代码示例。如果您正苦于以下问题:C# ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom方法的具体用法?C# ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom怎么用?C# ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISIS.GME.Dsml.CyPhyML.Interfaces的用法示例。


在下文中一共展示了ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddComponent

        /// <summary>
        /// Adds the component to componentAssembly_mo as an instance.
        /// </summary>
        /// <param name="componentAssembly_mo">ComponentAssembly that contains the component.</param>
        /// <param name="parentComponentAssembly_mo">ComponentAssembly that contains componentAssembly_mo.</param>
        /// <param name="component">CyPhy Component to add.</param>
        private void AddComponent(ComponentAssembly componentAssembly_mo, ComponentAssembly parentComponentAssembly_mo, CyPhy.Component component)
        {
            var ca = componentAssembly_mo.Impl;
            var modelicaModel = this.GetModelicaModelFromComponent(component);

            // Make sure there are margins to the top- and left-border
            int canvasX = component.GenericAspect.X > ScaleFactor * ComponentIconSize ? 
                component.GenericAspect.X : ScaleFactor * ComponentIconSize;
            int canvasY = component.GenericAspect.Y > ScaleFactor * ComponentIconSize ? 
                component.GenericAspect.Y : ScaleFactor * ComponentIconSize;

            // Make sure there are margins to the bottom- and right-border
            componentAssembly_mo.CanvasXMax = canvasX + (ScaleFactor * ComponentIconSize) > componentAssembly_mo.CanvasXMax ? 
                canvasX + (ScaleFactor * ComponentIconSize) : componentAssembly_mo.CanvasXMax;
            componentAssembly_mo.CanvasYMax = canvasY + (ScaleFactor * ComponentIconSize) > componentAssembly_mo.CanvasYMax ? 
                canvasY + (ScaleFactor * ComponentIconSize) : componentAssembly_mo.CanvasYMax;

            var componentInstance_mo = new ComponentInstance(component)
            {
                InstanceOf = this.treeComponents[component.DerivedFrom().ID],
                CanvasX = canvasX,
                CanvasY = canvasY
            };

            foreach (var parameter in component.Children.ParameterCollection)
            {
                // META-3622
                if (String.IsNullOrWhiteSpace(parameter.Attributes.Dimension) || parameter.Attributes.Dimension.Trim() == "1")
                {
                    var vf = parameter.SrcConnections.ValueFlowCollection.FirstOrDefault();
                    if (vf != null && vf.ParentContainer.ID == ca.ID)
                    {
                        var parameter_mo = this.GetArgumentParameter(ca.ID, parameter, vf);
                        componentInstance_mo.Parameters.Add(parameter_mo);
                    }
                }
            }

            // META-2189 Overwrite ModelicaParameters connected to properties with formulated values in the design.
            foreach (var modelicaParameter in modelicaModel.Children.ModelicaParameterCollection)
            {
                var connection = modelicaParameter.SrcConnections.ModelicaParameterPortMapCollection.FirstOrDefault();
                if (connection != null && connection.SrcEnds.Property != null)
                {
                    double temp;
                    var value = modelicaParameter.Attributes.Value.Trim();
                    if (double.TryParse(modelicaParameter.Attributes.Value, out temp) || value == "true" || value == "false" || 
                        (value.StartsWith("\"") && value.EndsWith("\"")))
                    {
                        var parameter_mo = new UnitParameter();
                        parameter_mo.Name = modelicaParameter.Name;
                        parameter_mo.Value = new ModelicaValue(modelicaParameter.Attributes.Value.Trim());
                        componentInstance_mo.Parameters.Add(parameter_mo);
                    }
                }
            }

            componentAssembly_mo.ComponentInstances.Add(componentInstance_mo);

            string componentModelicaURI = componentAssembly_mo.Name + "." + componentInstance_mo.Name;
            var parentCA = parentComponentAssembly_mo;
            while (parentCA != null)
            {
                componentModelicaURI = parentCA.Name + "." + componentModelicaURI;
                parentCA = parentCA.ParentComponentAssembly;
            }

            this.ExtractPCCInputs(component, componentModelicaURI);


            string modelType;
            if (modelicaModel is CyPhy.CyberModel)
            {
                modelType = "ControllerModel";
            }
            else
            {
                modelType = "PlantModel";
            }

            var componentInfo = new ComponentInfo(component.Impl as GME.MGA.IMgaFCO, modelType, this.traceability);
            this.instanceURIMap.Add(string.Format("{0}.TestBenches.{1}.{2}", MainPackage, this.testBench_mo.Name, componentModelicaURI), componentInfo);
            if (this.modelURIMap.ContainsKey(componentInstance_mo.InstanceOf.FullName) == false)
            {
                this.modelURIMap.Add(componentInstance_mo.InstanceOf.FullName, componentInfo);
            }

            if (this.extendsURIMap.ContainsKey(componentInstance_mo.InstanceOf.Extends) == false)
            {
                var componentExtendInfo = new ComponentInfo(modelicaModel.Impl as GME.MGA.IMgaFCO, modelType, this.traceability);
                this.extendsURIMap.Add(componentInstance_mo.InstanceOf.Extends, componentExtendInfo);
            }

            // Iterate over all ports and look for connections FROM the port. These connections will generate equations in the 
//.........这里部分代码省略.........
开发者ID:robertowens,项目名称:meta-core,代码行数:101,代码来源:CodeGenerator.cs


注:本文中的ISIS.GME.Dsml.CyPhyML.Interfaces.DerivedFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。