同步序列图和架构模型
本示例演示了如何保持架构模型与相应序列图之间的一致性。协同创作工作流会根据您在序列图中进行的更改来更新架构模型。当元素不同步时,您可以使用同步工作流来检查一致性。
该软件会突出显示序列图中任何不一致的元素。在此示例中,您将学习如何通过以下方式解决突出显示的不一致之处:
将架构模型中的变更应用到序列图中
从序列图将更改推送到架构模型
打开架构模型和架构视图库。
model = systemcomposer.openModel("mRetargetElements");
openViews(model);将更改从架构模型拉到序列图
1.打开 RepairExample 序列图。在查看浏览器中,选择 RepairExample。在图中,选择 ChildComponent 生命线。

2.在架构模型中,选择 ChildComponent 组件。将光标停留在出现的省略号 (...) 上,然后选择创建组件。将新组件的名称指定为 Component。ChildComponent 组件现在是 Component 组件的子组件。

3.在架构视图库的工具条中,点击同步部分下的检查一致性。该软件将 ChildComponent 生命线突出显示,因为 ChildComponent 组件已不再位于架构模型的根级别。将鼠标悬停在黄色警告图标上即可显示提示信息。

4.要解决此不一致问题,您可以通过点击在架构中创建,在架构中创建一个新的 ChildComponent。或者,您可以选择 ChildComponent 生命线,然后点击修复序列图。在这种情况下,软件会从 mRetargetElements 架构模型中提取变更,并将 Component 组件作为生命线添加进去,从而更新 RepairExample 序列图。

将序列图中的更改推送到架构模型
1.打开 CreateInArchitecture 序列图。在查看浏览器中,选择 CreateInArchitecture。

2.DoesNotExistSrc 和 DoesNotExistDst 生命线在 mRetargetElements 架构中没有相应的组件。为了保持一致性,请选择序列图中的两条生命线和消息。然后,在工具条上,点击在架构中创建。

3.该软件通过将 CreateInArchitecture 序列图中的更改推送到 mRetargetElements 架构模型,并将 DoesNotExistSrc 和 DoesNotExistDst 组件添加到架构中

在架构模型中重新定位生命线并创建新连接
1.打开 RetargetThenCocreate 序列图。在查看浏览器中,选择 RetargetThenCocreate。

2.在序列图上选择 B 生命线。在工具条的同步部分,将架构元素设置为 C。

3.该软件将 A 和 C 生命线之间的消息突出显示出来,因为在架构模型中,A 和 C 组件之间未建立连接。将鼠标悬停在黄色警告图标上即可显示提示信息。

4.要解决此不一致问题,请点击在架构中创建。该软件通过建立一个新连接来更新 mRetargetElements 架构模型。

另请参阅
工具
函数
openViews|sim|addInteraction|getInteraction|getInteractions|open|addLifeline|addFragment|addOperand|addMessage|addDurationConstraint|addAnnotation|findLifeline|findElement|move|move|move|destroy|next|current|reset
对象
systemcomposer.arch.Model|systemcomposer.interaction.Interaction|systemcomposer.interaction.Iterator|systemcomposer.interaction.Lifeline|systemcomposer.interaction.MessageEvent|systemcomposer.interaction.FormalGate|systemcomposer.interaction.Message|systemcomposer.interaction.Fragment|systemcomposer.interaction.Operand|systemcomposer.interaction.DurationConstraint|systemcomposer.interaction.Annotation