Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fb7fae6
improved trigger minimzation
Drakae Jun 18, 2024
0473222
completed trigger minimization
Drakae Jun 18, 2024
5efb406
reordering of control actions
Drakae Jun 21, 2024
82bef88
Merge branch 'master' into jep/sbm
Drakae Jun 28, 2024
47fd4ac
improved trigger minimization
Drakae Jun 28, 2024
f46ea5c
all context variables are input variables
Drakae Jul 25, 2024
3ea0cf6
Merge branch 'master' into jep/sbm
Drakae Sep 3, 2024
9c397e9
enums can be in and/or output
Drakae Sep 12, 2024
e9df4c6
bugfix
Drakae Feb 19, 2025
4733a84
Merge branch 'master' into jep/sbm
Drakae Feb 19, 2025
183d012
allow direct iteration over map keys
Drakae Feb 19, 2025
324789e
fixed output declaration
Drakae Apr 3, 2025
5cc1269
Merge branch 'master' into jep/sbm
Drakae Feb 18, 2026
a08bf3f
Merge branch 'master' into jep/sbm
Drakae Feb 27, 2026
1729a59
added flag for boot up step
Drakae Feb 27, 2026
515d5aa
fixed generation for multiple controllers
Drakae Mar 25, 2026
c298105
adjusted labels and enum spelling
Drakae Jun 25, 2026
3e811d3
actions in formulas are now also capitalized
Drakae Jul 9, 2026
f0432ce
bollean variables are also declared as input
Drakae Jul 14, 2026
e11348c
dataflow synthesis (WIP)
Drakae Jul 14, 2026
1d32415
dataflow synthesis
Drakae Jul 14, 2026
589f013
corrected dataflow equation generation
Drakae Jul 14, 2026
f7c5de8
adjusted formulas for dataflow
Drakae Jul 15, 2026
96557f3
formatting
Drakae Jul 15, 2026
bb31517
added comments
Drakae Jul 15, 2026
6e45785
fixed ltl generation for dataflow
Drakae Jul 19, 2026
e9975ef
Merge branch 'master' into jep/sbm
Drakae Aug 20, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async function translateUCAsToLTLFormulas(model: Model, map: Record<string, LTLF
async function translateRuleToLTLFormulas(rule: Rule | DCARule, map: Record<string, LTLFormula[]>): Promise<void> {
const controller = rule.system.$refText;
// control action string
const controlAction = controller + "." + rule.action.$refText;
const controlAction = controller + "." + rule.action.$refText.toUpperCase();
for (const uca of rule.contexts) {
// calculate the contextVariable string
let contextVariables = await createLTLContextVariable(uca.assignedValues[0].variable, uca.assignedValues[0].value.$refText);
Expand Down
2 changes: 1 addition & 1 deletion extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import { createSTPAResultMarkdownFile } from "./report/md-export";
import { StpaResult } from "./report/utils";
import { createSBMs } from "./sbm/sbm-generation";
import { LTLFormula } from "./sbm/utils";
import { LTLFormula } from "./sbm/utils-classes";
import { StorageService } from "./storage-service";
import { createFile, createOutputChannel, setStorageOption } from "./utils";
import { InlineMarkdownDecorator } from "./decorations";
Expand Down Expand Up @@ -99,7 +99,7 @@
let decorationProvider: InlineMarkdownDecorator | undefined; //use let, so can be commented out

// To deactivate highlighting in .stpa files comment out the following two lines
decorationProvider = new InlineMarkdownDecorator();

Check warning on line 102 in extension/src/extension.ts

View workflow job for this annotation

GitHub Actions / Run eslint and test and build

'decorationProvider' is never reassigned. Use 'const' instead
context.subscriptions.push(decorationProvider);

// Set up webview panel manager for freestyle webviews
Expand Down
135 changes: 135 additions & 0 deletions extension/src/sbm/dataflow-generation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* KIELER - Kiel Integrated Environment for Layout Eclipse RichClient
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2023 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/

import { createFile } from "../utils";
import {
askForPath,
collectContextVariables,
collectControlActionVariables,
groupFormulasByActionAndType,
} from "./sbm-generation";
import { createDataflowSCChart } from "./scchart-creation";
import { Equation, LTLFormula } from "./utils-classes";

/**
* Creates an SBM as dataflow for each controller in the {@code controlActionsMap}.
* @param controlActionsMap The map containing the control actions for each controller.
* @param formulaMap The map containing the LTL formulas for each controller.
*/
export async function createDataflows(
controlActionsMap: Record<string, string[]>,
formulaMap: Record<string, LTLFormula[]>,
): Promise<void> {
for (const controller of Object.keys(controlActionsMap)) {
await createControllerDataflow(controller, controlActionsMap[controller], formulaMap[controller] ?? []);
}
}

/**
* Creates an SBM as dataflow for a single controller.
* @param controllerName The name of the controller that is modelled.
* @param controlActions The control actions of the controller.
* @param ltlFormulas The ltl formulas corresponding to the controller.
*/
export async function createControllerDataflow(
controllerName: string,
controlActions: string[],
ltlFormulas: LTLFormula[],
): Promise<void> {
// Ask the user where to save the sbm
const uriPath = await askForPath();
if (uriPath === undefined) {
// The user did not pick any file to save to.
return;
}

// collect the input variables
const contextVariables = collectContextVariables(ltlFormulas);
// collect the output variables
const outputVariables = collectControlActionVariables(controlActions);
// equations for each control action
const equations = createEquations(ltlFormulas, controlActions);

// adjust formulas since control action is not an enum value in dataflow
for (const action of controlActions) {
const upperAction = action.toUpperCase();
ltlFormulas.map(formula => {
formula.formula = formula.formula.split(`controlAction==${controllerName}.${upperAction}`).join(`${action}`);
formula.formula = formula.formula.split(`controlAction!=${controllerName}.${upperAction}`).join(`!${action}`);
});
}

// create the scchart
const scchartText = createDataflowSCChart(
controllerName,
contextVariables.variables.concat(outputVariables),
contextVariables.enums,
ltlFormulas,
equations,
);

createFile(uriPath, scchartText);
}

/**
* Creates the equations for the control actions in the dataflow model.
* @param ltlFormulas The ltl formulas belonging to the controller for which the model is created.
* @param controlActions The control actions of the controller for which the model is created.
* @returns the equations for the control actions in the dataflow model.
*/
function createEquations(ltlFormulas: LTLFormula[], controlActions: string[]): Equation[] {
const equations: Equation[] = [];
// group the formulas by control action and type
const formulaMap = groupFormulasByActionAndType(ltlFormulas);
for (const action of controlActions) {
const eq: Equation = { left: action, right: "" };

// construct subequation for provided formulas
const providedFormulas = formulaMap.providedMap.get(action) ?? [];
let providedSubEquation = "";
for (let i = 0; i < providedFormulas.length; i++) {
const formula = providedFormulas[i];
providedSubEquation += `!(${formula.contextVariables}) `;
if (i !== providedFormulas.length - 1) {
providedSubEquation += "&& ";
}
}

// construct subequation for not provided formulas
const notProvidedFormulas = formulaMap.notProvidedMap.get(action) ?? [];
let notProvidedSubEquation = "";
for (let i = 0; i < notProvidedFormulas.length; i++) {
const formula = notProvidedFormulas[i];
notProvidedSubEquation += `(${formula.contextVariables}) `;
if (i !== notProvidedFormulas.length - 1) {
notProvidedSubEquation += "|| ";
}
}

// combine the two subequations
if (providedSubEquation !== "") {
eq.right = `${providedSubEquation} && `;
}
eq.right += `(${notProvidedSubEquation})`;
// if the right side is empty, it means that there are no formulas for this control action, so we don't add an equation for it
// should normally not happen, but possibly prevents syntactic errors in the generated scchart
if (eq.right !== "") {
equations.push(eq);
}
}
return equations;
}
Loading
Loading