主题
需求图
¥Requirement Diagram
需求图提供了需求及其相互之间以及其他记录元素之间的联系的可视化。建模规范遵循 SysML v1.6 定义的规范。
¥A Requirement diagram provides a visualization for requirements and their connections, to each other and other documented elements. The modeling specs follow those defined by SysML v1.6.
渲染要求很简单。
¥Rendering requirements is straightforward.
语法
¥Syntax
需求图包含三种类型的组件:要求、要素和关系。
¥There are three types of components to a requirement diagram: requirement, element, and relationship.
用于定义每个的语法定义如下。尖括号中表示的单词(例如 <word>
)是枚举关键字,其选项在表格中详细说明。user_defined_...
用于任何需要用户输入的地方。
¥The grammar for defining each is defined below. Words denoted in angle brackets, such as <word>
, are enumerated keywords that have options elaborated in a table. user_defined_...
is use in any place where user input is expected.
关于用户文本的重要说明:所有输入都可以用引号引起来,也可以不用引号引起来。例如,Id: "here is an example"
和 Id: here is an example
都有效。但是,用户必须小心未加引号的输入。如果检测到另一个关键字,解析器将失败。
¥An important note on user text: all input can be surrounded in quotes or not. For example, both Id: "here is an example"
and Id: here is an example
are both valid. However, users must be careful with unquoted input. The parser will fail if another keyword is detected.
要求
¥Requirement
需求定义包含需求类型、名称、ID、文本、风险和验证方法。语法如下:
¥A requirement definition contains a requirement type, name, id, text, risk, and verification method. The syntax follows:
<type> user_defined_name {
id: user_defined_id
text: user_defined text
risk: <risk>
verifymethod: <method>
}
类型、风险和方法是 SysML 中定义的枚举。
¥Type, risk, and method are enumerations defined in SysML.
关键词 | 选项 |
---|---|
类型 | 需求、功能需求、接口需求、性能需求、物理需求、设计约束 |
风险 | 低中高 |
验证方法 | 分析、检验、测试、演示 |
元素
¥Element
元素定义包含元素名称、类型和文档引用。这三个都是用户定义的。元素功能旨在轻量级,但允许将需求连接到其他文档的部分。
¥An element definition contains an element name, type, and document reference. These three are all user defined. The element feature is intended to be lightweight but allow requirements to be connected to portions of other documents.
element user_defined_name {
type: user_defined_type
docref: user_defined_ref
}
Markdown 格式
¥Markdown Formatting
在可以使用用户定义文本的地方(如名称、需求文本、元素 docref 等),你可以:
¥In places where user defined text is possible (like names, requirement text, element docref, etc.), you can:
将文本括在引号中:
"example text"
¥Surround the text in quotes:
"example text"
在引号内使用 markdown 格式:
"**bold text** and *italics*"
¥Use markdown formatting inside quotes:
"**bold text** and *italics*"
示例:
¥Example:
关系
¥Relationship
关系由源节点、目标节点和关系类型组成。
¥Relationships are comprised of a source node, destination node, and relationship type.
每个都遵循以下定义格式
¥Each follows the definition format of
{name of source} - <type> -> {name of destination}
or
{name of destination} <- <type> - {name of source}
"来源名称" 和 "目的地名称" 应该是在其他地方定义的需求或元素节点的名称。
¥"name of source" and "name of destination" should be names of requirement or element nodes defined elsewhere.
关系类型可以是包含、复制、派生、满足、验证、细化或跟踪之一。
¥A relationship type can be one of contains, copies, derives, satisfies, verifies, refines, or traces.
每个关系都在图中进行了标记。
¥Each relationship is labeled in the diagram.
更大的例子
¥Larger Example
此示例使用了该图的所有功能。
¥This example uses all features of the diagram.
方向
¥Direction
可以使用 direction
语句以不同方向渲染图表。有效值为:
¥The diagram can be rendered in different directions using the direction
statement. Valid values are:
TB
- 从上到下(默认)¥
TB
- Top to Bottom (default)BT
- 从下到上¥
BT
- Bottom to TopLR
- 从左到右¥
LR
- Left to RightRL
- 从右到左¥
RL
- Right to Left
示例:
¥Example:
样式
¥Styling
需求和元素可以使用直接样式或类进行样式化。根据经验,在应用样式或类时,它接受需求或元素名称列表和类名称列表,允许一次进行多个分配(唯一的例外是简写语法 :::
,它可以分配多个类,但一次只能分配给一个需求或元素)。
¥Requirements and elements can be styled using direct styling or classes. As a rule of thumb, when applying styles or classes, it accepts a list of requirement or element names and a list of class names allowing multiple assignments at a time (The only exception is the shorthand syntax :::
which can assign multiple classes but only to one requirement or element at a time).
直接样式
¥Direct Styling
使用 style
关键字直接应用 CSS 样式:
¥Use the style
keyword to apply CSS styles directly:
类定义
¥Class Definitions
使用 classDef
定义可重复使用的样式:
¥Define reusable styles using classDef
:
默认类别
¥Default class
如果某个类名为 default,它将应用于所有节点。应在之后定义特定的样式和类以覆盖应用的默认样式。
¥If a class is named default it will be applied to all nodes. Specific styles and classes should be defined afterwards to override the applied default styling.
classDef default fill:#f9f,stroke:#333,stroke-width:4px;
应用类
¥Applying Classes
类可以以两种方式应用:
¥Classes can be applied in two ways:
使用
class
关键字:¥Using the
class
keyword:
class test_req,test_entity important
在定义期间或之后使用
:::
的简写语法:¥Using the shorthand syntax with
:::
either during the definition or afterwards:
requirement test_req:::important {
id: 1
text: class styling example
risk: low
verifymethod: test
}
element test_elem {
}
test_elem:::myClass
组合示例
¥Combined Example