Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jep/stpa with fta #21

Merged
merged 33 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
df7aa3f
causal factors for scenarios can be stated
Drakae Oct 24, 2023
b5f8757
added process for creating fault trees from stpa
Drakae Oct 24, 2023
ea55d3f
invisible node for gates with description (WIP)
Drakae Oct 24, 2023
17cc263
invisible node for gates with description
Drakae Oct 25, 2023
f587aba
adjust cut set highlighting for gates with description
Drakae Oct 25, 2023
0b308c1
stpa to fta
Drakae Oct 26, 2023
47daec8
resetting cut set option for new model
Drakae Oct 26, 2023
daabd9e
adjusted styling of description node (WIP)
Drakae Oct 26, 2023
1accdaa
adjusted layout
Drakae Oct 26, 2023
181cb46
merge outgoing edges
Drakae Oct 27, 2023
cfc9b54
junction points are drawn
Drakae Oct 27, 2023
21da3ff
label management for fta
Drakae Oct 27, 2023
9c50ec3
fixed node size for long labels
Drakae Oct 27, 2023
641eff6
adjusted fta visualization
Drakae Nov 2, 2023
185c64a
model order for fta
Drakae Nov 2, 2023
0f605de
context menu in webview
Drakae Nov 6, 2023
e3633ef
context menu: refactoring
Drakae Nov 6, 2023
465d261
context-menu: refactoring
Drakae Nov 6, 2023
3e602a3
adjjusted layout config
Drakae Nov 7, 2023
3082bb9
context menu: adjusted colors
Drakae Nov 7, 2023
e8190e5
adjusted cursor visualization
Drakae Nov 7, 2023
bd4abe8
adjusted stpa label id
Drakae Nov 7, 2023
17da973
action in context menu works
Drakae Nov 8, 2023
f4b4ac6
fixed clicking on label
Drakae Nov 8, 2023
bd53aa9
context menu works also for gates with descriptions
Drakae Nov 8, 2023
b5e4c5d
context menu: added minimal cut set action
Drakae Nov 8, 2023
df5b22c
highlighting for top of analysis is not the root (WIP)
Drakae Nov 8, 2023
250d166
fixed spofs
Drakae Nov 9, 2023
a8b5cbb
fixed highlighting for gate with desc as top of analysis
Drakae Nov 9, 2023
944bc4c
translation of scenarios for UCAs to fta
Drakae Dec 7, 2023
9e63afa
Scenarios with no causal factors are considered
Drakae Dec 21, 2023
a1b2800
added comments
Drakae Dec 21, 2023
3e15ad8
mka feedback
Drakae Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@
"title": "Create a Markdown file",
"category": "STPA PDF Creation"
},
{
"command": "pasta.stpa.ft.generation",
"title": "Generate Fault Trees",
"category": "STPA and FTA"
},
{
"command": "pasta.fta.cutSets",
"title": "Generate the cut sets",
Expand Down Expand Up @@ -237,6 +242,10 @@
"command": "pasta.stpa.md.creation",
"when": "editorLangId == 'stpa'"
},
{
"command": "pasta.stpa.ft.generation",
"when": "editorLangId == 'stpa'"
},
{
"command": "pasta.fta.cutSets",
"when": "editorLangId == 'fta'"
Expand All @@ -262,7 +271,7 @@
"group": "checks"
},
{
"submenu": "pasta.generate",
"submenu": "pasta.fta.generate",
"group": "generate"
},
{
Expand All @@ -274,6 +283,11 @@
"command": "pasta.stpa.md.creation",
"when": "editorLangId == 'stpa'",
"group": "stpa"
},
{
"command": "pasta.stpa.ft.generation",
"when": "editorLangId == 'stpa'",
"group": "stpa"
}
],
"pasta.stpa.checks": [
Expand All @@ -298,7 +312,7 @@
"group": "navigation"
}
],
"pasta.generate": [
"pasta.fta.generate": [
{
"command": "pasta.fta.cutSets",
"when": "editorLangId == 'fta'",
Expand Down Expand Up @@ -332,16 +346,6 @@
"command": "pasta.contextTable.open",
"when": "resourceExtname == '.stpa'",
"group": "navigation"
},
{
"command": "pasta.fta.cutSets",
"when": "resourceExtname == '.fta'",
"group": "navigation"
},
{
"command": "pasta.fta.minimalCutSets",
"when": "resourceExtname == '.fta'",
"group": "navigation"
}
]
},
Expand All @@ -351,7 +355,7 @@
"label": "Validation Checks"
},
{
"id": "pasta.generate",
"id": "pasta.fta.generate",
"label": "Generate cut sets"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ import {
} from "../../generated/ast";
import { namedFtaElement } from "../utils";

/* element for which the cut sets were determined */
export let topOfAnalysis: string | undefined;

/**
* Determines the minimal cut sets for the fault tree constructured by {@code allNodes}.
* @param allNodes All nodes in the fault tree.
* @returns the minimal cut sets for a fault tree.
*/
export function determineMinimalCutSets(allNodes: AstNode[]): Set<namedFtaElement>[] {
export function determineMinimalCutSets(allNodes: AstNode[], startNode?: namedFtaElement): Set<namedFtaElement>[] {
// TODO: add minimal flag (could reduce computation cost)
const allCutSets = determineCutSetsForFT(allNodes);
const allCutSets = determineCutSetsForFT(allNodes, startNode);

// Cut sets are minimal if removing one element destroys the cut set
// If cut set contains another cut set from the array, remove it since it is not minimal
Expand Down Expand Up @@ -69,18 +72,24 @@ function checkMinimalCutSet(cutSet: Set<namedFtaElement>, allCutSets: Set<namedF
/**
* Determines all cut sets of a fault tree.
* @param allNodes All nodes of the fault tree.
* @param startNode The node from which the cut sets should be determined.
* @returns the cut sets of the fault tree.
*/
export function determineCutSetsForFT(allNodes: AstNode[]): Set<namedFtaElement>[] {
export function determineCutSetsForFT(allNodes: AstNode[], startNode?: namedFtaElement): Set<namedFtaElement>[] {
/* Idea:
Start from the top event.
Get the only child of top event (will always be only one) as our starting node.
Calculate all children of the node and evaluate them.
In the evaluation we check if the child has children too and do the same recursively until
the children are components.
Depending on the type of the node process the results of the children differently. */

const startNode = getChildOfTopEvent(allNodes);

topOfAnalysis = startNode?.name;
if (!startNode) {
topOfAnalysis = (allNodes.find((node) => isTopEvent(node)) as namedFtaElement).name;
// if no start node is given, the top event is used as start node
startNode = getChildOfTopEvent(allNodes);
}
if (startNode) {
// determine the cut sets of the Fault Tree
return determineCutSetsForGate(startNode, allNodes);
Expand Down Expand Up @@ -213,9 +222,9 @@ function getChildrenOfNode(node: AstNode): namedFtaElement[] {
* @returns the child of the top event.
*/
function getChildOfTopEvent(allNodes: AstNode[]): namedFtaElement | undefined {
const topEventChildren = (allNodes.find((node) => isTopEvent(node)) as TopEvent).children;
if (topEventChildren.length !== 0) {
return topEventChildren[0].ref;
const topEventChild = (allNodes.find((node) => isTopEvent(node)) as TopEvent).child;
if (topEventChild) {
return topEventChild.ref;
}
}

Expand Down
Loading
Loading