Skip to content

Commit

Permalink
Merge pull request #44 from kieler/jep/folding
Browse files Browse the repository at this point in the history
added folding provider to add foldings for each aspect
  • Loading branch information
Drakae authored Sep 30, 2024
2 parents dc7fc92 + f81b5d9 commit 6b265b2
Show file tree
Hide file tree
Showing 8 changed files with 714 additions and 26 deletions.
55 changes: 44 additions & 11 deletions extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,39 @@ These checks can be turned off in the context menu of the editor.

A diagram can be opened for the analysis by clicking on the icon right above the editor or by selecting `Open in Diagram` in the editor context menu. In the diagram different color styles and filtering methods are provided. Clicking on a node fades out non-connected nodes and clicking on a node while pressing the `Ctrl` key fades out nodes that belong to another aspect.

### Diagram Snippets

Defining a control structure textually can be difficult at first.
To better introduce new users to the syntax diagram snippets are provided in the `PASTA` tab on the left.
A diagram snippet shows a control structure and by clicking on it the textual representation is added to the `ControlStructure` section in the currently open file.
Custom snippets can be added by selecting the textual representation of the snippet that should be added and then selecting `Add STPA Diagram Snippet` in the context menu.
Alternatively the textual representation can be entered in the diagram snippets tab and added by clicking on the button `Add Diagram Snippet`.

### Context Table

Instead of informal UCA definitions a context table may be used. This is done by using the section `Context-Table` instead of `UCAs`. A context table can then be generated automatically and shown alongside the diagram by selecting `Show Context Tables` in the editor context menu or the corresponding icon right above the editor. Clicking on a UCA in the context table highlights the corresponding node in the diagram and its definition in the editor. In the context table view a control action can be selected in order to inspect it.

### Completion Item

Partly information is repeated in STPA e.g. when defining a scenario for a UCA, the UCA itself is written down again.
To reduce the time effort, PASTA offers completion items, which generate text automatically based on the informations already stated in other components.
The following completion items are provided:
* create system component
* create starting text for a plain text UCA
* create a template rule
* create a rule for a specific control action
* create rules for every combination of control action and type
* create controller constraints for all UCAs
* create starting text for a scenario for a UCA
* create basic scenarios for all UCAs

### Result Report

The context menu contains an option to automatically create a result report in form of a markdown file.
The file contains a section for each aspect with its defined components and a diagram showing only the relevant components for the aspect to keep the diagram small.
At the end all identified constraints are summarized and a diagram showing all components is embedded.
The markdown file can easily be exported to a PDF file.

### Safe Behavioral Model Generation

In the context menu an option to automatically generate a safe behavioral model as an SCChart is provided. For that the defined UCAs are translated to LTL formulas, which are further used to create the SCChart. This guarantees that the identified UCAs cannot occur since the LTL formulas are respected except the ones for the UCA type too early.
Expand All @@ -36,20 +65,24 @@ Furthermore, after an STPA is done, a corresponding Fault Tree can be generated

### STPA

To use the extension for an analysis, the file in which the analysis is done must have `.stpa` as its file ending. Each STPA aspect has its own section in the DSL. Components for each aspect are defined with an ID, a description, and a reference list. In order to define a new component, the prefix of the corresponding aspect must be stated, for example "L", and afterwards a string with the description. The numbering of the IDs is adjusted automatically.
To use the extension for an analysis, the file in which the analysis is done must have `.stpa` as its file ending. Each STPA aspect has its own section in the DSL. Components for each aspect are defined with an ID, a description, and a reference list. In order to define a new component, the prefix of the corresponding aspect must be stated, for example "L", and afterwards a string with the description. The numbering of the IDs is adjusted automatically. For Hazards and system-level constraints subcomponents can be defined.

In the control structure, system components can be stated, which can contain a process model, input, output, control actions, and feedback. The visualization of input and output edges is in an experimental state at the moment and will be improved in the future.
In the control structure, system components can be stated, which can contain a process model, input, output, control actions, feedback, and further system components. The visualization of input and output edges is in an experimental state at the moment and will be improved in the future.

*Minimal example of an analysis for a ferry:*
```
Losses
L1 "Loss of life or serious injury to people"
Hazards
H1 "Vessel's exposure to major damage or breakdown" [L1]
H1 "Vessel's exposure to major damage or breakdown" [L1] {
H1.1 "Vessel enters No-Go area"
}
SystemConstraints
SC1 "Vessel must not be exposed to major damage or breakdown" [H1]
SC1 "Vessel must not be exposed to major damage or breakdown" [H1] {
SC1.1 "Vessel must not enter a No Go Area" [H1.1]
}
ControlStructure
Ferry {
Expand Down Expand Up @@ -160,16 +193,16 @@ The extension provides several diagram options to adjust the diagram.
* Model Order: Order of the elements depends on the order of their textual definition
* Node Label Management: Node Labels can be wrapped, truncated, or not shown at all. The Shortening Width states how many characters are allowed in one line when truncating/wrapping

### FTA
* Show Gate Descriptions: Shows the descriptions of the gates in the diagram.
* Show Component Descriptions: Shows the descriptions of the components in the diagram.
* Highlight Cut Set: To use this first the action to generate the cut sets must be executed. Then here a cut set can be selected. The components belonging to the cut set are highlighted in red, components and gates irrelevant for the failure are faded out, and the top event is highlighted in blue. Thus, when only a subtree is analyzed, the root of this subtree is highlighted. Additionally, the option SPoFs in the dropdown menu highlights all single point of failures.

### STPA
* Color Style: The STPA aspect are colored differently to better distinguish them. With this option this can be adjusted to just use black or fewer/more colors.
* Hierarchy: If this option is selected, subcomponents are drawn inside their parents. Otherwise this connection is shown by an edge from the subcomponent to its parent.
* Group UCAs: UCAs can be grouped by their control action or their system component. Each group of UCAs has their own layer in the diagram.
* Show Labels of: This option determines of which aspects the descriptions are shown in the diagram. If "Automatic" is selected, the shown labels are determined by the cursor position. In most cases the labels of the aspect which must be referenced by the currently modified aspect are shown. When writing Hazards also the Hazard descriptions are shown.
* Filter UCA by Control Action: The UCAs can be filtered such that only UCAs for a certain control action are shown making the diagram smaller and clearer.
* Hide x: When selected the components of the specified aspect are not visualized.
* Show x: When selected the specified graph is shown, otherwise it is hidden.
* Show x: When selected the specified graph/aspect is shown, otherwise it is hidden.


### FTA
* Show Gate Descriptions: Shows the descriptions of the gates in the diagram.
* Show Component Descriptions: Shows the descriptions of the components in the diagram.
* Highlight Cut Set: To use this first the action to generate the cut sets must be executed. Then here a cut set can be selected. The components belonging to the cut set are highlighted in red, components and gates irrelevant for the failure are faded out, and the top event is highlighted in blue. Thus, when only a subtree is analyzed, the root of this subtree is highlighted. Additionally, the option SPoFs in the dropdown menu highlights all single point of failures.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import {
SafetyConstraint,
SystemConstraint,
SystemResponsibilities
} from "../generated/ast";
import { StpaServices } from "./stpa-module";
import { collectElementsWithSubComps, elementWithName, elementWithRefs } from "./utils";
} from "../../generated/ast";
import { StpaServices } from "../stpa-module";
import { collectElementsWithSubComps, elementWithName, elementWithRefs } from "../utils";

/**
* Default prefixes for the different STPA aspects.
Expand Down
Loading

0 comments on commit 6b265b2

Please sign in to comment.