主要内容

本页采用了机器翻译。点击此处可查看英文原文。

systemcomposer.profile.Style

构造型样式

自 R2026a 起

    说明

    Style 对象表示 System Composer™ 模型配置文件中的构造型样式。

    创建对象

    使用 addStereotype 函数将构造型添加到配置文件中。然后,使用一个 Style 对象修改 Stereotype 对象的 ElementStyle 属性。

    profile = systemcomposer.profile.Profile.createProfile("profileName");
    addStereotype(profile,"stereotypeName");

    属性

    全部展开

    该样式继承属性的构造型模板,指定为 systemcomposer.profile.Stereotype 对象。

    元素颜色,指定为形式为 [Red Green Blue] 的 1×3 uint32 向量。

    示例: [206 232 246]

    数据类型: uint32

    连接器线条样式,指定为字符向量或字符串。选项包括:

    • "Default"

    • "Dot"

    • "Dash"

    • "Dash Dot"

    • "Dash Dot Dot"

    此属性仅适用于连接器构造型。

    数据类型: char | string

    构造型图标名称,以字符串形式指定。选项包括:

    • "default"

    • "application"

    • "channel"

    • "controller"

    • "database"

    • "devicedriver"

    • "memory"

    • "network"

    • "plant"

    • "sensor"

    • "subsystem"

    • "transmitter"

    该属性仅对组件构造型有效。使用 AppliesTo 属性来设置构造型类型所适用的元素。

    数据类型: string

    示例

    全部折叠

    创建一个用于延迟特性的配置文件,并保存该配置文件。

    profile = systemcomposer.profile.Profile.createProfile("LatencyProfile");
    
    latencybase = profile.addStereotype("LatencyBase");
    latencybase.addProperty("latency",Type="double");
    latencybase.addProperty("dataRate",Type="double",DefaultValue="10");
    
    connLatency = profile.addStereotype("ConnectorLatency",...
    Parent="LatencyProfile.LatencyBase");
    connLatency.addProperty("secure",Type="boolean");
    connLatency.addProperty("linkDistance",Type="double");
    
    nodeLatency = profile.addStereotype("NodeLatency",...
    Parent="LatencyProfile.LatencyBase");
    nodeLatency.addProperty("resources",Type="double",DefaultValue="1");
    
    portLatency = profile.addStereotype("PortLatency",...
    Parent="LatencyProfile.LatencyBase");
    portLatency.addProperty("queueDepth",Type="double");
    portLatency.addProperty("dummy",Type="int32");
    
    profile.save

    LatencyProfile.NodeLatency 构造型指定为组件构造型。

    nodeLatency.AppliesTo = "Component";

    nodeLatency 构造型中获取 systemcomposer.profile.Style 对象。然后,为 Style 对象应用一个构造型颜色和图标。

    nodeLatency.ElementStyle.Color = [0 100 255];
    nodeLatency.ElementStyle.Icon = "application";
    profile.save

    任何带有 nodeLatency 构造型标记的组件,其样式均采用指定的颜色和图标。

    创建模型,将配置文件应用于模型,然后添加一个组件。在组件上应用构造型。然后,打开配置文件编辑器

    modelName = "archModel";
    arch = systemcomposer.createModel(modelName);
    systemcomposer.openModel(modelName);
    arch.applyProfile("LatencyProfile");
    newComponent = addComponent(arch.Architecture,"Component");
    newComponent.applyStereotype("LatencyProfile.NodeLatency");
    systemcomposer.profile.editor(profile)

    详细信息

    全部展开

    版本历史记录

    在 R2026a 中推出