Skip to content

Commit 044113c

Browse files
committed
improved handling of derived_from and derived_to.
1 parent 19d5fbc commit 044113c

File tree

8 files changed

+58
-27
lines changed

8 files changed

+58
-27
lines changed

pumla_macros_reqs.puml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@
66
' in order to mix them or use them on other
77
' diagrams, "allowmixing" needs to be used.
88
!unquoted procedure _PUMLACreateReqObject($alias)
9+
!$robjid=$alias+"_objid"
10+
!if %not(%variable_exists($robjid))
11+
' not sure why this is even working... addressing
12+
' the $r object should not be possible here...
913
object $r.alias {
1014
|= type | $r.type |
1115
|= content | $r.content |
1216
|= status | $r.status |
1317
}
18+
%set_variable_value($robjid, "%true()")
19+
!endif
1420
!endprocedure
1521

1622
' ############################################
@@ -20,7 +26,7 @@ object $r.alias {
2026
' recursive way with an iteration counter to
2127
' make sure we do not consider elements up the
2228
' trace, only down.
23-
!unquoted procedure _PUMLARecursivePutReqsBreakdownTraceFor($alias, $itcnt)
29+
!unquoted procedure _PUMLARecursivePutReqsBreakdownTraceFor($alias, $itcnt, $parentalias)
2430
!$r = null
2531
!$cnt = %intval($itcnt)
2632

@@ -30,12 +36,17 @@ _PUMLACreateReqObject($r.alias)
3036

3137
' do not go the trace up on the first element, only down
3238
!if %not($r.derived_from==null) && %not($cnt==0)
33-
$r.derived_from <|-- $r.alias
39+
!foreach $drfr in $r.derived_from
40+
!if $drfr==$parentalias
41+
$drfr <|-- $r.alias
42+
!endif
43+
!endfor
3444
!endif
45+
3546
!$cnt = $cnt + 1
3647
!if %not($r.derived_to==null)
3748
!foreach $dtra in $r.derived_to
38-
_PUMLARecursivePutReqsBreakdownTraceFor($dtra,$cnt)
49+
_PUMLARecursivePutReqsBreakdownTraceFor($dtra,$cnt, $alias)
3950
!endfor
4051
!endif
4152

@@ -51,7 +62,7 @@ _PUMLARecursivePutReqsBreakdownTraceFor($dtra,$cnt)
5162
' requirement with the given alias in a
5263
' recursive way.
5364
!unquoted procedure PUMLAPutReqsBreakdownTraceFor($alias)
54-
_PUMLARecursivePutReqsBreakdownTraceFor($alias,0)
65+
_PUMLARecursivePutReqsBreakdownTraceFor($alias,0, $alias)
5566
!endprocedure
5667

5768

@@ -105,7 +116,9 @@ _PUMLACreateReqObject($r.alias)
105116
!foreach $r in $allreqs.reqs
106117
_PUMLACreateReqObject($r.alias)
107118
!if %not($r.derived_from==null)
108-
$r.derived_from <|-- $r.alias
119+
!foreach $drfr in $r.derived_from
120+
$drfr <|-- $r.alias
121+
!endfor
109122
!endif
110123
!endfor
111124
!endprocedure

src/pumla/control/reqparse.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ def updatePUMLAReqRepo(path, mrefilename):
6666
if not r.get("derived_from")==None:
6767
derived_table.append({"from": r["derived_from"], "to": r.get("alias")})
6868
pumlareqslist.append(r)
69-
7069
# update the "derived to" attribute corresponding to the "derived from"
7170
for e in derived_table:
7271
for r in pumlareqslist:
73-
if r.get("alias") == e.get("from"):
72+
if r.get("alias") in e.get("from"):
7473
der_to = r.get("derived_to")
7574
der_to.append(e.get("to"))
7675
r.update({"derived_to": der_to})

test/examples/WeatherStation/CWeather/req.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,24 @@
22
- type: Requirement
33
alias: REQ_SW_CWeather1
44
status: decided
5-
derived_from: REQ_WS1
5+
derived_from:
6+
- REQ_WS1
7+
- REQ_WS4
68
taggedvalues:
79
- tag: "Level"
810
values: "Software"
911
- tag: "Variant"
1012
values: [SysA, SysB]
1113
content:
12-
There shall be one central class to manage all data regarding weather.
14+
There shall be one central class to manage all data regarding weather.
15+
16+
- type: Requirement
17+
alias: REQ_SW_CWeather2
18+
status: decided
19+
derived_from:
20+
- REQ_WS4
21+
- REQ_WS1
22+
- REQ_SW_CWeather1
23+
taggedvalues:
24+
content:
25+
The Weather class shall be able to converse the data between different units.

test/examples/WeatherStation/exampleAllReqs.puml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
!include reqsrepo_json.puml
33
!include pumla_macros.puml
44

5+
left to right direction
6+
'top to bottom direction
7+
58
' put all requirement onto a diagram
69
' and show the trace among them.
710
PUMLAPutAllReqsBrief()

test/examples/WeatherStation/exampleReqTrace.puml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
' "realizing" trace.
88
PUMLAPutReqsBreakdownTraceFor(REQ_WS1)
99

10-
PUMLAPutReq(REQ_WS2)
11-
12-
PUMLAPutReqBrief(REQ_WS3)
13-
14-
' these arrows don't make sense, just to test
15-
REQ_WS2 --> REQ_WS3
16-
REQ_WS1 --> REQ_WS2
10+
'PUMLAPutReq(REQ_WS2)
11+
'
12+
'PUMLAPutReqBrief(REQ_WS3)
13+
'
14+
'' these arrows don't make sense, just to test
15+
'REQ_WS2 --> REQ_WS3
16+
'REQ_WS1 --> REQ_WS2
1717

1818
@enduml
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
@startjson
22
{"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived_from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
3-
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived_to": ["REQ_SW_CWeather1", "REQ_SensorA1"], "in_file": "./req.yaml"},
3+
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived_to": ["REQ_SW_CWeather1", "REQ_SW_CWeather2", "REQ_SensorA1"], "in_file": "./req.yaml"},
44
{"type": "Requirement", "alias": "REQ_WS2", "status": "new", "derived_from": null, "content": "This is another requirement. The Weather Station housing shall be blue.", "derived_to": [], "in_file": "./req.yaml"},
55
{"type": "Requirement", "alias": "REQ_WS3", "status": "aligned", "derived_from": null, "content": "The Weather Station shall display the measured temperature so that it is conveniently readable by a human looking at it in a distance of up to 3m.", "derived_to": [], "in_file": "./req.yaml"},
6-
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived_from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived_to": [], "in_file": "./req.yaml"},
6+
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived_from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived_to": ["REQ_SW_CWeather1", "REQ_SW_CWeather2"], "in_file": "./req.yaml"},
77
{"type": "Requirement", "alias": "REQ_WS5", "status": "aligned", "derived_from": null, "content": "The unit in which the temperature is displayed shall stay as it is even after the batteries and/or the power supply has been removed.", "derived_to": [], "in_file": "./req.yaml"},
8-
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": "REQ_WS1", "taggedvalues": [{"tag": "Level", "values": "Software"},
9-
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "There shall be one central class to manage all data regarding weather.", "derived_to": [], "in_file": "./CWeather/req.yaml"},
10-
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived_from": "REQ_WS1", "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived_to": [], "in_file": "./tempSensorA/req.yaml"}]}
8+
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": ["REQ_WS1", "REQ_WS4"], "taggedvalues": [{"tag": "Level", "values": "Software"},
9+
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "There shall be one central class to manage all data regarding weather.", "derived_to": ["REQ_SW_CWeather2"], "in_file": "./CWeather/req.yaml"},
10+
{"type": "Requirement", "alias": "REQ_SW_CWeather2", "status": "decided", "derived_from": ["REQ_WS4", "REQ_WS1", "REQ_SW_CWeather1"], "taggedvalues": null, "content": "The Weather class shall be able to converse the data between different units.", "derived_to": [], "in_file": "./CWeather/req.yaml"},
11+
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived_from": ["REQ_WS1"], "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived_to": [], "in_file": "./tempSensorA/req.yaml"}]}
1112
@endjson
1213

1314

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
!$allreqs = {"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived_from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
2-
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived_to": ["REQ_SW_CWeather1", "REQ_SensorA1"], "in_file": "./req.yaml"},
2+
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "This is a requirement towards my Weather Station. The Weather Station shall be able to measure the temperature.", "derived_to": ["REQ_SW_CWeather1", "REQ_SW_CWeather2", "REQ_SensorA1"], "in_file": "./req.yaml"},
33
{"type": "Requirement", "alias": "REQ_WS2", "status": "new", "derived_from": null, "content": "This is another requirement. The Weather Station housing shall be blue.", "derived_to": [], "in_file": "./req.yaml"},
44
{"type": "Requirement", "alias": "REQ_WS3", "status": "aligned", "derived_from": null, "content": "The Weather Station shall display the measured temperature so that it is conveniently readable by a human looking at it in a distance of up to 3m.", "derived_to": [], "in_file": "./req.yaml"},
5-
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived_from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived_to": [], "in_file": "./req.yaml"},
5+
{"type": "Requirement", "alias": "REQ_WS4", "status": "aligned", "derived_from": null, "content": "It shall be possible to switch the unit of the displayed temperature between degree Celsius and Fahrenheit.", "derived_to": ["REQ_SW_CWeather1", "REQ_SW_CWeather2"], "in_file": "./req.yaml"},
66
{"type": "Requirement", "alias": "REQ_WS5", "status": "aligned", "derived_from": null, "content": "The unit in which the temperature is displayed shall stay as it is even after the batteries and/or the power supply has been removed.", "derived_to": [], "in_file": "./req.yaml"},
7-
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": "REQ_WS1", "taggedvalues": [{"tag": "Level", "values": "Software"},
8-
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "There shall be one central class to manage all data regarding weather.", "derived_to": [], "in_file": "./CWeather/req.yaml"},
9-
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived_from": "REQ_WS1", "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived_to": [], "in_file": "./tempSensorA/req.yaml"}]}
7+
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": ["REQ_WS1", "REQ_WS4"], "taggedvalues": [{"tag": "Level", "values": "Software"},
8+
{"tag": "Variant", "values": ["SysA", "SysB"]}], "content": "There shall be one central class to manage all data regarding weather.", "derived_to": ["REQ_SW_CWeather2"], "in_file": "./CWeather/req.yaml"},
9+
{"type": "Requirement", "alias": "REQ_SW_CWeather2", "status": "decided", "derived_from": ["REQ_WS4", "REQ_WS1", "REQ_SW_CWeather1"], "taggedvalues": null, "content": "The Weather class shall be able to converse the data between different units.", "derived_to": [], "in_file": "./CWeather/req.yaml"},
10+
{"type": "Requirement", "alias": "REQ_SensorA1", "status": "aligned", "derived_from": ["REQ_WS1"], "content": "The sensor shall be able to measure the temperature of the surrounding air in the room.", "derived_to": [], "in_file": "./tempSensorA/req.yaml"}]}
1011

test/examples/WeatherStation/tempSensorA/req.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- type: Requirement
44
alias: REQ_SensorA1
55
status: aligned
6-
derived_from: REQ_WS1
6+
derived_from:
7+
- REQ_WS1
78
content:
89
The sensor shall be able to measure the temperature of the surrounding air in the room.

0 commit comments

Comments
 (0)