主要内容

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

systemcomposer.interaction.FormalGate

交互中的形式化门

自 R2024a 起

    说明

    FormalGate 对象表示序列图门上的消息事件。在架构模型中,一个门对应一个根架构。

    交互边界上的消息末端允许消息进出交互。形式化门表示为交互作用序列图左边界上的一条缝隙。门包含在交互片段中。

    创建对象

    通过相应 systemcomposer.interaction.Interaction 对象的 RootFragment 属性访问 FormalGate 对象。遍历根片段,检查片段中的 FormalGatesystemcomposer.interaction.MessageEvent 对象。

    属性

    全部展开

    形式化门的名称,指定为字符串。

    数据类型: string

    父消息,指定为 systemcomposer.interaction.Message 对象。

    门是否代表消息开始,指定为 1 (true) 或 0 (false)。

    数据类型: logical

    父操作数,指定为 systemcomposer.interaction.Operand 对象。

    形式化门代表的端口,指定为 systemcomposer.arch.ArchitecturePort 对象。

    唯一外部标识符,指定为字符向量。外部 ID 在元素的整个生命周期以及所有保留 UUID 的操作中都会被保留。

    数据类型: char

    统一唯一标识符,指定为字符向量

    示例: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'

    数据类型: char

    对象函数

    destroy移除模型元素

    示例

    全部折叠

    您可以使用只读 API 工作流浏览 System Composer™ 中的序列图,并显示每个元素的相关信息。

    打开交通灯示例

    打开交通灯示例架构模型,以便直观地检查序列图并确认程序输出。

    model = systemcomposer.openModel("TLExample");

    要查看与模型关联的序列图,请在 System Composer 工具条上导航至建模 > 序列图

    The press detection sequence diagram in the views gallery of the top model.

    以编程方式浏览序列图

    收集由 interactions 表示的序列图,其中包含模型中元素的特定交互。

    interactions = model.getInteractions;

    对于第一个交互,提取序列图的名称。

    disp("The first sequence diagram is called " + interactions(1).Name + ".")
    The first sequence diagram is called PressDetection.
    

    在该序列图中,显示每条生命线以及生命线所代表的组件。

    for i = 1:length(interactions(1).Lifelines)
        disp("The " + interactions(1).Lifelines(i).Name + ...
        " lifeline represents the " + ...
        interactions(1).Lifelines(i).RelatedElements.Name + ...
        " component.")
    end
    The source lifeline represents the source component.
    The poller lifeline represents the poller component.
    The switch lifeline represents the switch component.
    

    显示根片段中一条消息的内容。

    disp("The sequence diagram message starting at the " + ...
        interactions(1).RootFragment.Operands.Fragments(1).Name + ...
        " message end is of type " + ...
        string(interactions(1).RootFragment.Operands.Fragments(1).Message.Type) + ...
        " and the message label is " + ...
        interactions(1).RootFragment.Operands.Fragments(1).Message.Condition + ".")
    The sequence diagram message starting at the switchout message end is of type Signal and the message label is rising(sw-1).
    

    使用迭代器实用工具逐步浏览序列图

    使用 Inhibit 实用工具逐步浏览 Iterator 序列图。

    interaction = model.getInteraction('Inhibit');
    interaction.open

    Inhibit sequence diagram from the top model.

    显示交互中的注解。

    disp(interaction.Annotations.Content)
    When inhibit is true, it means pedestrian crossing is not controlled by a walk signal on this intersection.
    

    在提取序列图的属性之前,使用迭代器浏览序列图的所有元素。

    iterator = systemcomposer.interaction.Iterator(interaction.RootFragment);
    next = iterator.next;
    while ~isempty(next)
        disp(class(next))
        next = iterator.next;
    end
    systemcomposer.interaction.RootFragment
    systemcomposer.interaction.Operand
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.AltFragment
    systemcomposer.interaction.Operand
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.Operand
    systemcomposer.interaction.MessageEvent
    systemcomposer.interaction.MessageEvent
    

    详细信息

    全部展开

    版本历史记录

    在 R2024a 中推出