Add elements for AbstractOperationalSituation and OperationalSituation

Signed-off-by: Dan Yeaw <dan@yeaw.me>
This commit is contained in:
Dan Yeaw 2021-05-16 13:52:36 -04:00
parent 74392c3643
commit f7e3232de9
No known key found for this signature in database
GPG Key ID: 42239C515C9B9841
6 changed files with 160 additions and 9 deletions

View File

@ -20,11 +20,13 @@ situation {
</StyleSheet>
<Package id="c403507e-b5ad-11eb-b5c7-18cf5efc6bb9">
<name>
<val>New model</val>
<val>STPA Example Model</val>
</name>
<ownedDiagram>
<reflist>
<ref refid="c4035380-b5ad-11eb-b5c7-18cf5efc6bb9"/>
<ref refid="7e97e97e-b5e3-11eb-a24a-18cf5efc6bb9"/>
<ref refid="f9f0d900-b5e8-11eb-a24a-18cf5efc6bb9"/>
</reflist>
</ownedDiagram>
<ownedType>
@ -98,7 +100,7 @@ situation {
<canvas>
<item id="e23d2902-b5ad-11eb-b5c7-18cf5efc6bb9" type="CommentItem">
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 328.0, -80.37109375)</val>
<val>(1.0, 0.0, 0.0, 1.0, 328.0, -96.37109375)</val>
</matrix>
<width>
<val>164.0</val>
@ -1216,4 +1218,22 @@ Figure 2.9</val>
</reflist>
</presentation>
</Comment>
<Diagram id="7e97e97e-b5e3-11eb-a24a-18cf5efc6bb9">
<name>
<val>Mapping of losses and hazards</val>
</name>
<package>
<ref refid="c403507e-b5ad-11eb-b5c7-18cf5efc6bb9"/>
</package>
<canvas/>
</Diagram>
<Diagram id="f9f0d900-b5e8-11eb-a24a-18cf5efc6bb9">
<name>
<val>Operational situations of the system</val>
</name>
<package>
<ref refid="c403507e-b5ad-11eb-b5c7-18cf5efc6bb9"/>
</package>
<canvas/>
</Diagram>
</gaphor>

View File

@ -52,7 +52,7 @@ class AbstractFailureMode(DysfunctionalEvent):
pass
class OperationalCondition:
class OperationalCondition(Situation):
pass

View File

@ -1 +1,2 @@
from gaphor.RAAML.stpa.operationalsituation import OperationalSituationItem
from gaphor.RAAML.stpa.situation import SituationItem

View File

@ -0,0 +1,56 @@
"""Operational Situation item definition."""
from gaphas.geometry import Rectangle
from gaphor.core.modeling import DrawContext
from gaphor.diagram.presentation import (
Classified,
ElementPresentation,
from_package_str,
)
from gaphor.diagram.shapes import Box, Text, draw_border
from gaphor.diagram.support import represents
from gaphor.diagram.text import FontStyle, FontWeight
from gaphor.i18n import gettext
from gaphor.RAAML import raaml
from gaphor.UML.modelfactory import stereotypes_str
@represents(raaml.OperationalSituation)
@represents(raaml.AbstractOperationalSituation)
class OperationalSituationItem(ElementPresentation, Classified):
def __init__(self, diagram, id=None):
super().__init__(diagram, id)
self.watch("subject[NamedElement].name").watch(
"subject[NamedElement].namespace.name"
)
def update_shapes(self, event=None):
self.shape = Box(
Box(
Text(
text=lambda: stereotypes_str(
self.subject, [gettext("OperationalSituation")]
),
),
Text(
text=lambda: self.subject.name or "",
width=lambda: self.width - 4,
style={
"font-weight": FontWeight.BOLD,
"font-style": FontStyle.NORMAL,
},
),
Text(
text=lambda: from_package_str(self),
style={"font-size": "x-small"},
),
style={"padding": (12, 4, 12, 4)},
),
draw=draw_operational_situation,
)
def draw_operational_situation(box, context: DrawContext, bounding_box: Rectangle):
draw_border(box, context, bounding_box)

View File

@ -22,6 +22,11 @@ def hazard_config(new_item):
new_item.subject.name = "Hazard"
def abstract_operational_situation_config(new_item):
default_namespace(new_item)
new_item.subject.name = "AbstractOperationalSituation"
stpa = ToolSection(
"STPA",
(
@ -87,14 +92,22 @@ stpa = ToolSection(
gettext("Abstract Operational Situation"),
"gaphor-abstract-operational-situation-symbolic",
"",
new_item_factory(uml_items.ClassItem),
new_item_factory(
diagramitems.OperationalSituationItem,
raaml.AbstractOperationalSituation,
config_func=abstract_operational_situation_config,
),
),
ToolDef(
"operational-situation",
gettext("Operational Situation"),
"gaphor-operational-situation-symbolic",
"",
new_item_factory(uml_items.ClassItem),
new_item_factory(
diagramitems.OperationalSituationItem,
raaml.OperationalSituation,
config_func=namespace_config,
),
),
ToolDef(
"unsafe-control-action",

View File

@ -306,6 +306,7 @@
<ref refid="9973b790-b026-11eb-a838-18cf5efc6bb9"/>
<ref refid="7666633c-b027-11eb-a838-18cf5efc6bb9"/>
<ref refid="37970e18-b5a9-11eb-9e03-18cf5efc6bb9"/>
<ref refid="eac4a00c-b66e-11eb-aa87-18cf5efc6bb9"/>
</reflist>
</presentation>
</Stereotype>
@ -19303,6 +19304,8 @@ Figure 9.149</val>
<ref refid="d65d44cc-b027-11eb-a838-18cf5efc6bb9"/>
<ref refid="d65e23d8-b027-11eb-a838-18cf5efc6bb9"/>
<ref refid="d65edc9c-b027-11eb-a838-18cf5efc6bb9"/>
<ref refid="eac4a00c-b66e-11eb-aa87-18cf5efc6bb9"/>
<ref refid="eede7e2e-b66e-11eb-aa87-18cf5efc6bb9"/>
</reflist>
</ownedPresentation>
<package>
@ -19323,7 +19326,7 @@ Figure 9.149</val>
<ref refid="5d8ff6b9-2b10-11ea-99a7-7d79dbbd423e"/>
</subject>
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 143.36480712890625, 124.76823425292969)</val>
<val>(1.0, 0.0, 0.0, 1.0, 145.36480712890625, 234.7682342529297)</val>
</matrix>
<points>
<val>[(0.0, 0.0), (0.0, 79.08749389648438), (1.20098876953125, 79.08749389648438)]</val>
@ -19337,7 +19340,7 @@ Figure 9.149</val>
</item>
<item id="d65c03d2-b027-11eb-a838-18cf5efc6bb9" type="ClassItem">
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 121.73211669921875, 50.76823425292969)</val>
<val>(1.0, 0.0, 0.0, 1.0, 123.73211669921875, 160.7682342529297)</val>
</matrix>
<width>
<val>169.0</val>
@ -19360,7 +19363,7 @@ Figure 9.149</val>
</item>
<item id="d65d44cc-b027-11eb-a838-18cf5efc6bb9" type="ClassItem">
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 100.92181396484375, 203.85572814941406)</val>
<val>(1.0, 0.0, 0.0, 1.0, 102.92181396484375, 313.85572814941406)</val>
</matrix>
<width>
<val>229.0</val>
@ -19418,7 +19421,7 @@ Figure 9.149</val>
<ref refid="662f6cba-2b10-11ea-99a7-7d79dbbd423e"/>
</tail_subject>
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 266.86578369140625, 124.76823425292969)</val>
<val>(1.0, 0.0, 0.0, 1.0, 268.86578369140625, 234.7682342529297)</val>
</matrix>
<points>
<val>[(-2.281821877540409, 0.0), (-1.080322265625, 79.08749389648438)]</val>
@ -19427,6 +19430,46 @@ Figure 9.149</val>
<ref refid="d65d44cc-b027-11eb-a838-18cf5efc6bb9"/>
</tail-connection>
</item>
<item id="eac4a00c-b66e-11eb-aa87-18cf5efc6bb9" type="ClassItem">
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 158.23211669921875, 28.999999999999886)</val>
</matrix>
<width>
<val>100.0</val>
</width>
<height>
<val>71.0</val>
</height>
<diagram>
<ref refid="9c8993ea-b027-11eb-a838-18cf5efc6bb9"/>
</diagram>
<subject>
<ref refid="dde0bab8-235f-11ea-ab0b-c72c0738acd2"/>
</subject>
</item>
<item id="eede7e2e-b66e-11eb-aa87-18cf5efc6bb9" type="GeneralizationItem">
<diagram>
<ref refid="9c8993ea-b027-11eb-a838-18cf5efc6bb9"/>
</diagram>
<horizontal>
<val>0</val>
</horizontal>
<subject>
<ref refid="ef5a542c-b66e-11eb-aa87-18cf5efc6bb9"/>
</subject>
<matrix>
<val>(1.0, 0.0, 0.0, 1.0, 209.0, 60.999999999999886)</val>
</matrix>
<points>
<val>[(0.15378632642293155, 39.0), (-0.8856699201795806, 99.7682342529298)]</val>
</points>
<head-connection>
<ref refid="eac4a00c-b66e-11eb-aa87-18cf5efc6bb9"/>
</head-connection>
<tail-connection>
<ref refid="d65c03d2-b027-11eb-a838-18cf5efc6bb9"/>
</tail-connection>
</item>
</canvas>
</Diagram>
<Generalization id="5d8ff6b9-2b10-11ea-99a7-7d79dbbd423e">
@ -19448,6 +19491,11 @@ Figure 9.149</val>
<ref refid="ded32dce-b027-11eb-a838-18cf5efc6bb9"/>
</reflist>
</appliedStereotype>
<generalization>
<reflist>
<ref refid="ef5a542c-b66e-11eb-aa87-18cf5efc6bb9"/>
</reflist>
</generalization>
<name>
<val>OperationalCondition</val>
</name>
@ -22444,4 +22492,17 @@ Figure x (No Figure)</val>
<ref refid="dde0bab8-235f-11ea-ab0b-c72c0738acd2"/>
</specific>
</Generalization>
<Generalization id="ef5a542c-b66e-11eb-aa87-18cf5efc6bb9">
<general>
<ref refid="dde0bab8-235f-11ea-ab0b-c72c0738acd2"/>
</general>
<presentation>
<reflist>
<ref refid="eede7e2e-b66e-11eb-aa87-18cf5efc6bb9"/>
</reflist>
</presentation>
<specific>
<ref refid="1131b50e-2b10-11ea-99a7-7d79dbbd423e"/>
</specific>
</Generalization>
</gaphor>