Main Content

Describe System Behavior Using Sequence Diagrams

一个序列图是一个行为图,代表架构的结构元素之间的相互作用作为消息交换的顺序。

使用序列图来描述静态系统的部分相互作用。

序列图与System Composer™中的体系结构模型集成在一起。

笔记

此示例使用状态流®块。如果您没有状态流许可证,则可以打开并模拟模型,但只能进行基本更改,例如修改块参数。

Traffic Light Example for Sequence Diagrams

该交通灯示例包含序列图,以描述跨越十字路口的行人。该模型描述了以下步骤:

  1. 这traffic signal cycles from red to yellow to green.

  2. 什么时候the pedestrian crossing button is pressed, if the traffic signal is green, the traffic signal transitions from yellow to red for a limited time.

  3. 行人信号在活动时交叉。

打开包含序列图的系统作曲家模型。

模型= systemcomposer.openModel ('tlex amplem');

打开架构视图画廊以查看序列图。

OpenViews(模型)

此示例中的序列图表示架构模型中的操作场景。

1。pressDetection序列图:行人按下行人交叉按钮和信号SW上升到1。这poller生命线被激活,一个switchevent消息发生在SWitch更改交通信号的生命线以使行人越过。

2。信号序列序列图:行人按下行人交叉按钮和信号SW上升到1。经过一些中介事件,灯具生命线传输a扳机signal to theped lamp改变行人灯交通颜色的生命线红色的(停下来绿色(去),允许行人越过。

3。PedestrianCross序列图:首先trafficvalue is3, which indicates that the traffic light color is green. The traffic light loops from yellow (2) to red (1) to green (3) 然后再次。按下行人交叉按钮时控制器生命线认识到有效的pedrequest消息,交通灯从黄色变化(2) to red (1),这使行人可以越过。然后,主循环继续进行。

4。抑制序列图:抑制flag determines whether a pedestrian crossing button is set up for pedestrians to press to control the traffic lamp signal on an intersection and cross. When抑制是set to0,存在交叉按钮。什么时候抑制是set to1,不存在交叉按钮。这switcheventvalue is1,这表明行人想越过。一旦switchevent值设置为1,如果抑制0, 这控制器生命线认识到pedrequest消息以启动行人灯颜色的更改。另外,切换value is1,因此交通灯将从黄色变为红色。否则,如果抑制1, 这切换value is2,因此,交通灯将继续正常运行,而不会更改为红色,以专门允许行人越过。

Simulate Architecture Model

You can execute the model after setting these variables.

createworkspacevar(“ switchinputs”,[0 11 18],[-1 1 -1]); createWorkSpaceVar(“抑制剂”,1,0);

Related Topics