Skip to content

Commit

Permalink
improved handling of derived_from and derived_to.
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMarkusVoss committed Feb 22, 2025
1 parent 19d5fbc commit 044113c
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 27 deletions.
23 changes: 18 additions & 5 deletions pumla_macros_reqs.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
' in order to mix them or use them on other
' diagrams, "allowmixing" needs to be used.
!unquoted procedure _PUMLACreateReqObject($alias)
!$robjid=$alias+"_objid"
!if %not(%variable_exists($robjid))
' not sure why this is even working... addressing
' the $r object should not be possible here...
object $r.alias {
|= type | $r.type |
|= content | $r.content |
|= status | $r.status |
}
%set_variable_value($robjid, "%true()")
!endif
!endprocedure

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

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

' do not go the trace up on the first element, only down
!if %not($r.derived_from==null) && %not($cnt==0)
$r.derived_from <|-- $r.alias
!foreach $drfr in $r.derived_from
!if $drfr==$parentalias
$drfr <|-- $r.alias
!endif
!endfor
!endif

!$cnt = $cnt + 1
!if %not($r.derived_to==null)
!foreach $dtra in $r.derived_to
_PUMLARecursivePutReqsBreakdownTraceFor($dtra,$cnt)
_PUMLARecursivePutReqsBreakdownTraceFor($dtra,$cnt, $alias)
!endfor
!endif

Expand All @@ -51,7 +62,7 @@ _PUMLARecursivePutReqsBreakdownTraceFor($dtra,$cnt)
' requirement with the given alias in a
' recursive way.
!unquoted procedure PUMLAPutReqsBreakdownTraceFor($alias)
_PUMLARecursivePutReqsBreakdownTraceFor($alias,0)
_PUMLARecursivePutReqsBreakdownTraceFor($alias,0, $alias)
!endprocedure


Expand Down Expand Up @@ -105,7 +116,9 @@ _PUMLACreateReqObject($r.alias)
!foreach $r in $allreqs.reqs
_PUMLACreateReqObject($r.alias)
!if %not($r.derived_from==null)
$r.derived_from <|-- $r.alias
!foreach $drfr in $r.derived_from
$drfr <|-- $r.alias
!endfor
!endif
!endfor
!endprocedure
3 changes: 1 addition & 2 deletions src/pumla/control/reqparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ def updatePUMLAReqRepo(path, mrefilename):
if not r.get("derived_from")==None:
derived_table.append({"from": r["derived_from"], "to": r.get("alias")})
pumlareqslist.append(r)

# update the "derived to" attribute corresponding to the "derived from"
for e in derived_table:
for r in pumlareqslist:
if r.get("alias") == e.get("from"):
if r.get("alias") in e.get("from"):
der_to = r.get("derived_to")
der_to.append(e.get("to"))
r.update({"derived_to": der_to})
Expand Down
17 changes: 15 additions & 2 deletions test/examples/WeatherStation/CWeather/req.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,24 @@
- type: Requirement
alias: REQ_SW_CWeather1
status: decided
derived_from: REQ_WS1
derived_from:
- REQ_WS1
- REQ_WS4
taggedvalues:
- tag: "Level"
values: "Software"
- tag: "Variant"
values: [SysA, SysB]
content:
There shall be one central class to manage all data regarding weather.
There shall be one central class to manage all data regarding weather.

- type: Requirement
alias: REQ_SW_CWeather2
status: decided
derived_from:
- REQ_WS4
- REQ_WS1
- REQ_SW_CWeather1
taggedvalues:
content:
The Weather class shall be able to converse the data between different units.
3 changes: 3 additions & 0 deletions test/examples/WeatherStation/exampleAllReqs.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
!include reqsrepo_json.puml
!include pumla_macros.puml

left to right direction
'top to bottom direction

' put all requirement onto a diagram
' and show the trace among them.
PUMLAPutAllReqsBrief()
Expand Down
14 changes: 7 additions & 7 deletions test/examples/WeatherStation/exampleReqTrace.puml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
' "realizing" trace.
PUMLAPutReqsBreakdownTraceFor(REQ_WS1)

PUMLAPutReq(REQ_WS2)

PUMLAPutReqBrief(REQ_WS3)

' these arrows don't make sense, just to test
REQ_WS2 --> REQ_WS3
REQ_WS1 --> REQ_WS2
'PUMLAPutReq(REQ_WS2)
'
'PUMLAPutReqBrief(REQ_WS3)
'
'' these arrows don't make sense, just to test
'REQ_WS2 --> REQ_WS3
'REQ_WS1 --> REQ_WS2

@enduml
11 changes: 6 additions & 5 deletions test/examples/WeatherStation/reqs_json_diagram.puml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
@startjson
{"reqsrepopath": ".", "reqsrepofile": "./reqsrepo_json.puml", "reqs": [{"type": "Requirement", "alias": "REQ_WS1", "status": "decided", "derived_from": null, "taggedvalues": [{"tag": "Vendor", "values": ["A Inc.", "C Ltd."]},
{"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"},
{"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"},
{"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"},
{"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"},
{"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"},
{"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"},
{"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"},
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": "REQ_WS1", "taggedvalues": [{"tag": "Level", "values": "Software"},
{"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"},
{"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"}]}
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": ["REQ_WS1", "REQ_WS4"], "taggedvalues": [{"tag": "Level", "values": "Software"},
{"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"},
{"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"},
{"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"}]}
@endjson


11 changes: 6 additions & 5 deletions test/examples/WeatherStation/reqsrepo_json.puml
Original file line number Diff line number Diff line change
@@ -1,10 +1,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."]},
{"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"},
{"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"},
{"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"},
{"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"},
{"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"},
{"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"},
{"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"},
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": "REQ_WS1", "taggedvalues": [{"tag": "Level", "values": "Software"},
{"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"},
{"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"}]}
{"type": "Requirement", "alias": "REQ_SW_CWeather1", "status": "decided", "derived_from": ["REQ_WS1", "REQ_WS4"], "taggedvalues": [{"tag": "Level", "values": "Software"},
{"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"},
{"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"},
{"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"}]}

3 changes: 2 additions & 1 deletion test/examples/WeatherStation/tempSensorA/req.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- type: Requirement
alias: REQ_SensorA1
status: aligned
derived_from: REQ_WS1
derived_from:
- REQ_WS1
content:
The sensor shall be able to measure the temperature of the surrounding air in the room.

0 comments on commit 044113c

Please sign in to comment.