@bptlab/openbpt-modeler-typed-pn-variants 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/assets/icons/pn-fire-transition.svg +6 -0
- package/assets/icons/pn-inhibitor-arc.svg +30 -0
- package/assets/icons/pn-place.svg +62 -0
- package/assets/icons/pn-transition.svg +46 -0
- package/assets/icons/pn-unfire-transition.svg +6 -0
- package/assets/icons/reset.svg +1 -0
- package/assets/icons/toggle-off.svg +1 -0
- package/assets/icons/toggle-on.svg +1 -0
- package/assets/simulation.css +265 -0
- package/assets/tpn-js.css +101 -0
- package/dist/lib/BaseViewer.js +181 -0
- package/dist/lib/BaseViewer.js.map +1 -0
- package/dist/lib/CustomModeler.js +100 -0
- package/dist/lib/CustomModeler.js.map +1 -0
- package/dist/lib/NavigatedViewer.js +14 -0
- package/dist/lib/NavigatedViewer.js.map +1 -0
- package/dist/lib/Viewer.js +53 -0
- package/dist/lib/Viewer.js.map +1 -0
- package/dist/lib/auto-place/CustomAutoPlace.js +10 -0
- package/dist/lib/auto-place/CustomAutoPlace.js.map +1 -0
- package/dist/lib/auto-place/CustomAutoPlaceUtil.js +51 -0
- package/dist/lib/auto-place/CustomAutoPlaceUtil.js.map +1 -0
- package/dist/lib/auto-place/index.js +9 -0
- package/dist/lib/auto-place/index.js.map +1 -0
- package/dist/lib/common/copy-paste/CommonCopyPaste.js +58 -0
- package/dist/lib/common/copy-paste/CommonCopyPaste.js.map +1 -0
- package/dist/lib/common/copy-paste/ModdleCopy.js +168 -0
- package/dist/lib/common/copy-paste/ModdleCopy.js.map +1 -0
- package/dist/lib/common/copy-paste/index.js +10 -0
- package/dist/lib/common/copy-paste/index.js.map +1 -0
- package/dist/lib/common/editor-actions/EditorActions.js +110 -0
- package/dist/lib/common/editor-actions/EditorActions.js.map +1 -0
- package/dist/lib/common/editor-actions/index.js +7 -0
- package/dist/lib/common/editor-actions/index.js.map +1 -0
- package/dist/lib/common/keyboard/KeyboardBindings.js +101 -0
- package/dist/lib/common/keyboard/KeyboardBindings.js.map +1 -0
- package/dist/lib/common/keyboard/index.js +8 -0
- package/dist/lib/common/keyboard/index.js.map +1 -0
- package/dist/lib/common/search/CommonSearchProvider.js +72 -0
- package/dist/lib/common/search/CommonSearchProvider.js.map +1 -0
- package/dist/lib/common/search/index.js +9 -0
- package/dist/lib/common/search/index.js.map +1 -0
- package/dist/lib/core/index.js +6 -0
- package/dist/lib/core/index.js.map +1 -0
- package/dist/lib/declarations-panel/Util.js +32 -0
- package/dist/lib/declarations-panel/Util.js.map +1 -0
- package/dist/lib/declarations-panel/cmd/IdentifierCommitHandler.js +34 -0
- package/dist/lib/declarations-panel/cmd/IdentifierCommitHandler.js.map +1 -0
- package/dist/lib/declarations-panel/cmd/MultiCommandHandler.js +24 -0
- package/dist/lib/declarations-panel/cmd/MultiCommandHandler.js.map +1 -0
- package/dist/lib/declarations-panel/cmd/index.js +19 -0
- package/dist/lib/declarations-panel/cmd/index.js.map +1 -0
- package/dist/lib/declarations-panel/context/DeclarationsPanelContext.js +10 -0
- package/dist/lib/declarations-panel/context/DeclarationsPanelContext.js.map +1 -0
- package/dist/lib/declarations-panel/context/index.js +2 -0
- package/dist/lib/declarations-panel/context/index.js.map +1 -0
- package/dist/lib/declarations-panel/hooks/index.js +2 -0
- package/dist/lib/declarations-panel/hooks/index.js.map +1 -0
- package/dist/lib/declarations-panel/hooks/useService.js +7 -0
- package/dist/lib/declarations-panel/hooks/useService.js.map +1 -0
- package/dist/lib/declarations-panel/provider/DeclarationsProvider.js +107 -0
- package/dist/lib/declarations-panel/provider/DeclarationsProvider.js.map +1 -0
- package/dist/lib/declarations-panel/provider/IdentifierService.js +107 -0
- package/dist/lib/declarations-panel/provider/IdentifierService.js.map +1 -0
- package/dist/lib/declarations-panel/provider/SimulationModeService.js +14 -0
- package/dist/lib/declarations-panel/provider/SimulationModeService.js.map +1 -0
- package/dist/lib/declarations-panel/provider/index.js +14 -0
- package/dist/lib/declarations-panel/provider/index.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/ArcProps.js +123 -0
- package/dist/lib/declarations-panel/provider/properties/ArcProps.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/IdProps.js +47 -0
- package/dist/lib/declarations-panel/provider/properties/IdProps.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/ModelDeclarations.js +193 -0
- package/dist/lib/declarations-panel/provider/properties/ModelDeclarations.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/NameProps.js +43 -0
- package/dist/lib/declarations-panel/provider/properties/NameProps.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/PlaceProps.js +135 -0
- package/dist/lib/declarations-panel/provider/properties/PlaceProps.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/ReferenceSelect.js +21 -0
- package/dist/lib/declarations-panel/provider/properties/ReferenceSelect.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/TokenProps.js +116 -0
- package/dist/lib/declarations-panel/provider/properties/TokenProps.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/Util.js +112 -0
- package/dist/lib/declarations-panel/provider/properties/Util.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/VariableArcProps.js +107 -0
- package/dist/lib/declarations-panel/provider/properties/VariableArcProps.js.map +1 -0
- package/dist/lib/declarations-panel/provider/properties/index.js +8 -0
- package/dist/lib/declarations-panel/provider/properties/index.js.map +1 -0
- package/dist/lib/declarations-panel/render/DeclarationsPanel.js +197 -0
- package/dist/lib/declarations-panel/render/DeclarationsPanel.js.map +1 -0
- package/dist/lib/declarations-panel/render/DeclarationsPanelRenderer.js +154 -0
- package/dist/lib/declarations-panel/render/DeclarationsPanelRenderer.js.map +1 -0
- package/dist/lib/declarations-panel/render/PanelHeaderProvider.js +55 -0
- package/dist/lib/declarations-panel/render/PanelHeaderProvider.js.map +1 -0
- package/dist/lib/declarations-panel/render/PanelPlaceholderProvider.js +17 -0
- package/dist/lib/declarations-panel/render/PanelPlaceholderProvider.js.map +1 -0
- package/dist/lib/declarations-panel/render/index.js +9 -0
- package/dist/lib/declarations-panel/render/index.js.map +1 -0
- package/dist/lib/draw/CustomRenderer.js +361 -0
- package/dist/lib/draw/CustomRenderer.js.map +1 -0
- package/dist/lib/draw/TextRenderer.js +52 -0
- package/dist/lib/draw/TextRenderer.js.map +1 -0
- package/dist/lib/draw/index.js +8 -0
- package/dist/lib/draw/index.js.map +1 -0
- package/dist/lib/import/CustomImporter.js +177 -0
- package/dist/lib/import/CustomImporter.js.map +1 -0
- package/dist/lib/import/CustomTreeWalker.js +178 -0
- package/dist/lib/import/CustomTreeWalker.js.map +1 -0
- package/dist/lib/import/Importer.js +47 -0
- package/dist/lib/import/Importer.js.map +1 -0
- package/dist/lib/import/index.js +7 -0
- package/dist/lib/import/index.js.map +1 -0
- package/dist/lib/moddle/CustomModdle.js +86 -0
- package/dist/lib/moddle/CustomModdle.js.map +1 -0
- package/dist/lib/moddle/index.js +15 -0
- package/dist/lib/moddle/index.js.map +1 -0
- package/dist/lib/moddle/resources/dc.json +99 -0
- package/dist/lib/moddle/resources/diagramSchema.js +210 -0
- package/dist/lib/moddle/resources/diagramSchema.js.map +1 -0
- package/dist/lib/moddle/resources/modelSchema.js +254 -0
- package/dist/lib/moddle/resources/modelSchema.js.map +1 -0
- package/dist/lib/modeling/CustomElementFactory.js +66 -0
- package/dist/lib/modeling/CustomElementFactory.js.map +1 -0
- package/dist/lib/modeling/CustomLabelEditing.js +177 -0
- package/dist/lib/modeling/CustomLabelEditing.js.map +1 -0
- package/dist/lib/modeling/CustomModeling.js +40 -0
- package/dist/lib/modeling/CustomModeling.js.map +1 -0
- package/dist/lib/modeling/CustomUpdater.js +291 -0
- package/dist/lib/modeling/CustomUpdater.js.map +1 -0
- package/dist/lib/modeling/CustomVerification.js +111 -0
- package/dist/lib/modeling/CustomVerification.js.map +1 -0
- package/dist/lib/modeling/ElementFactory.js +56 -0
- package/dist/lib/modeling/ElementFactory.js.map +1 -0
- package/dist/lib/modeling/LabelUtil.js +151 -0
- package/dist/lib/modeling/LabelUtil.js.map +1 -0
- package/dist/lib/modeling/UpdateLabelHandler.js +86 -0
- package/dist/lib/modeling/UpdateLabelHandler.js.map +1 -0
- package/dist/lib/modeling/UpdateModdlePropertiesHandler.js +88 -0
- package/dist/lib/modeling/UpdateModdlePropertiesHandler.js.map +1 -0
- package/dist/lib/modeling/UpdatePropertiesHandler.js +136 -0
- package/dist/lib/modeling/UpdatePropertiesHandler.js.map +1 -0
- package/dist/lib/modeling/behavior/AdaptiveLabelPositioningBehavior.js +169 -0
- package/dist/lib/modeling/behavior/AdaptiveLabelPositioningBehavior.js.map +1 -0
- package/dist/lib/modeling/behavior/LabelBehavior.js +255 -0
- package/dist/lib/modeling/behavior/LabelBehavior.js.map +1 -0
- package/dist/lib/modeling/behavior/index.js +8 -0
- package/dist/lib/modeling/behavior/index.js.map +1 -0
- package/dist/lib/modeling/behavior/util/GeometricUtil.js +99 -0
- package/dist/lib/modeling/behavior/util/GeometricUtil.js.map +1 -0
- package/dist/lib/modeling/behavior/util/LabelLayoutUtil.js +178 -0
- package/dist/lib/modeling/behavior/util/LabelLayoutUtil.js.map +1 -0
- package/dist/lib/modeling/behavior/util/LineAttachmentUtil.js +175 -0
- package/dist/lib/modeling/behavior/util/LineAttachmentUtil.js.map +1 -0
- package/dist/lib/modeling/index.js +36 -0
- package/dist/lib/modeling/index.js.map +1 -0
- package/dist/lib/palette/CustomContextPadProvider.js +182 -0
- package/dist/lib/palette/CustomContextPadProvider.js.map +1 -0
- package/dist/lib/palette/CustomPaletteProvider.js +93 -0
- package/dist/lib/palette/CustomPaletteProvider.js.map +1 -0
- package/dist/lib/palette/TokenModals.js +105 -0
- package/dist/lib/palette/TokenModals.js.map +1 -0
- package/dist/lib/palette/index.js +28 -0
- package/dist/lib/palette/index.js.map +1 -0
- package/dist/lib/replace/ReplaceMenuProvider.js +84 -0
- package/dist/lib/replace/ReplaceMenuProvider.js.map +1 -0
- package/dist/lib/replace/index.js +9 -0
- package/dist/lib/replace/index.js.map +1 -0
- package/dist/lib/rules/CustomRuleProvider.js +107 -0
- package/dist/lib/rules/CustomRuleProvider.js.map +1 -0
- package/dist/lib/rules/index.js +8 -0
- package/dist/lib/rules/index.js.map +1 -0
- package/dist/lib/simulation/EventHelper.js +6 -0
- package/dist/lib/simulation/EventHelper.js.map +1 -0
- package/dist/lib/simulation/Utils.js +8 -0
- package/dist/lib/simulation/Utils.js.map +1 -0
- package/dist/lib/simulation/binding-utils/arcPlaceInfoLogic.js +157 -0
- package/dist/lib/simulation/binding-utils/arcPlaceInfoLogic.js.map +1 -0
- package/dist/lib/simulation/binding-utils/bindingUtils.js +64 -0
- package/dist/lib/simulation/binding-utils/bindingUtils.js.map +1 -0
- package/dist/lib/simulation/binding-utils/earlyReturnLogic.js +107 -0
- package/dist/lib/simulation/binding-utils/earlyReturnLogic.js.map +1 -0
- package/dist/lib/simulation/binding-utils/exactSynchro.js +102 -0
- package/dist/lib/simulation/binding-utils/exactSynchro.js.map +1 -0
- package/dist/lib/simulation/binding-utils/helpers.js +141 -0
- package/dist/lib/simulation/binding-utils/helpers.js.map +1 -0
- package/dist/lib/simulation/binding-utils/inhibitorLogic.js +166 -0
- package/dist/lib/simulation/binding-utils/inhibitorLogic.js.map +1 -0
- package/dist/lib/simulation/binding-utils/linkingLogic.js +384 -0
- package/dist/lib/simulation/binding-utils/linkingLogic.js.map +1 -0
- package/dist/lib/simulation/context-pads/ContextPads.js +141 -0
- package/dist/lib/simulation/context-pads/ContextPads.js.map +1 -0
- package/dist/lib/simulation/context-pads/FireTransitionHandler.js +481 -0
- package/dist/lib/simulation/context-pads/FireTransitionHandler.js.map +1 -0
- package/dist/lib/simulation/context-pads/FireTransitionUtils.js +169 -0
- package/dist/lib/simulation/context-pads/FireTransitionUtils.js.map +1 -0
- package/dist/lib/simulation/context-pads/FormJsAdapter.js +99 -0
- package/dist/lib/simulation/context-pads/FormJsAdapter.js.map +1 -0
- package/dist/lib/simulation/context-pads/index.js +8 -0
- package/dist/lib/simulation/context-pads/index.js.map +1 -0
- package/dist/lib/simulation/palette/Palette.js +36 -0
- package/dist/lib/simulation/palette/Palette.js.map +1 -0
- package/dist/lib/simulation/palette/index.js +6 -0
- package/dist/lib/simulation/palette/index.js.map +1 -0
- package/dist/lib/simulation/reset-simulation/ResetSimulation.js +36 -0
- package/dist/lib/simulation/reset-simulation/ResetSimulation.js.map +1 -0
- package/dist/lib/simulation/reset-simulation/index.js +6 -0
- package/dist/lib/simulation/reset-simulation/index.js.map +1 -0
- package/dist/lib/simulation/simulation-history/SimulationHistory.js +158 -0
- package/dist/lib/simulation/simulation-history/SimulationHistory.js.map +1 -0
- package/dist/lib/simulation/simulation-history/index.js +6 -0
- package/dist/lib/simulation/simulation-history/index.js.map +1 -0
- package/dist/lib/simulation/simulator/Simulator.js +131 -0
- package/dist/lib/simulation/simulator/Simulator.js.map +1 -0
- package/dist/lib/simulation/simulator/index.js +6 -0
- package/dist/lib/simulation/simulator/index.js.map +1 -0
- package/dist/lib/simulation/toggle-simulation-mode/DisableModeling.js +85 -0
- package/dist/lib/simulation/toggle-simulation-mode/DisableModeling.js.map +1 -0
- package/dist/lib/simulation/toggle-simulation-mode/ToggleSimulationMode.js +65 -0
- package/dist/lib/simulation/toggle-simulation-mode/ToggleSimulationMode.js.map +1 -0
- package/dist/lib/simulation/toggle-simulation-mode/index.js +8 -0
- package/dist/lib/simulation/toggle-simulation-mode/index.js.map +1 -0
- package/dist/lib/util/EventBusEvents.js +70 -0
- package/dist/lib/util/EventBusEvents.js.map +1 -0
- package/dist/lib/util/FileUtil.js +35 -0
- package/dist/lib/util/FileUtil.js.map +1 -0
- package/dist/lib/util/HtmlUtil.js +67 -0
- package/dist/lib/util/HtmlUtil.js.map +1 -0
- package/dist/lib/util/Util.js +60 -0
- package/dist/lib/util/Util.js.map +1 -0
- package/dist/lib/util/constants.js +6 -0
- package/dist/lib/util/constants.js.map +1 -0
- package/dist/lib/util/emptyDiagram.js +12 -0
- package/dist/lib/util/emptyDiagram.js.map +1 -0
- package/dist/lib/util/generated-icons.js +12 -0
- package/dist/lib/util/generated-icons.js.map +1 -0
- package/dist/scripts/build-icons.js +30 -0
- package/dist/scripts/build-icons.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.js +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { getLinkPartFromDataClassKey } from "./helpers";
|
|
2
|
+
import { groupTokensByNonVariableDataclasses } from "./linkingLogic";
|
|
3
|
+
export function checkExactSynchroConstraints(exactSynchingArcPlaceInfoDict, validInputBindings) {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
let synchedInputBindings = [];
|
|
6
|
+
let tokenDictPerArc = [];
|
|
7
|
+
const exactSynchroArcPlaceInfos = Object.entries(exactSynchingArcPlaceInfoDict);
|
|
8
|
+
if (exactSynchroArcPlaceInfos.length === 0) {
|
|
9
|
+
return validInputBindings;
|
|
10
|
+
}
|
|
11
|
+
for (const [arcId, arcPlaceInfo] of exactSynchroArcPlaceInfos) {
|
|
12
|
+
const groupedTokens = groupTokensByNonVariableDataclasses(Object.keys(arcPlaceInfo.dataClassInfoDict).map((dataClassKey) => getLinkPartFromDataClassKey(dataClassKey)), arcPlaceInfo.tokens);
|
|
13
|
+
tokenDictPerArc.push({
|
|
14
|
+
arcId,
|
|
15
|
+
groupedTokens,
|
|
16
|
+
dataClassInfoDict: arcPlaceInfo.dataClassInfoDict,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// For each input Binding ...
|
|
20
|
+
for (const inputBinding of validInputBindings) {
|
|
21
|
+
let currentSynchedBinding = [];
|
|
22
|
+
// ... check all exact synchro arcs ...
|
|
23
|
+
for (const tokenDict of tokenDictPerArc) {
|
|
24
|
+
let countAny = 0;
|
|
25
|
+
let countAll = 0;
|
|
26
|
+
for (const arcBinding of Object.values(tokenDict.groupedTokens)) {
|
|
27
|
+
for (const dataClassKey of Object.keys(arcBinding)) {
|
|
28
|
+
const tokenValues = arcBinding[dataClassKey];
|
|
29
|
+
const bindingValues = (_a = inputBinding[dataClassKey]) !== null && _a !== void 0 ? _a : [];
|
|
30
|
+
countAny += tokenValues.some((tokenValue) => bindingValues.includes(tokenValue))
|
|
31
|
+
? 1
|
|
32
|
+
: 0;
|
|
33
|
+
countAll += tokenValues.every((tokenValue) => bindingValues.includes(tokenValue))
|
|
34
|
+
? 1
|
|
35
|
+
: 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (countAny === 0 || (countAny > 0 && countAny !== countAll)) {
|
|
39
|
+
// Not or partially included, exclude binding
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
for (const [dataClassKey, tokenValues] of Object.entries(inputBinding)) {
|
|
43
|
+
if (dataClassKey.endsWith(":false")) {
|
|
44
|
+
currentSynchedBinding.push({
|
|
45
|
+
DataClassKey: dataClassKey,
|
|
46
|
+
isExactSync: false,
|
|
47
|
+
values: tokenValues,
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const syncedValues = ((_b = tokenDict.dataClassInfoDict[dataClassKey]) !== null && _b !== void 0 ? _b : []).filter((value) => tokenValues.includes(value));
|
|
52
|
+
const unsynchedValues = tokenValues.filter((value) => !syncedValues.includes(value));
|
|
53
|
+
if (syncedValues.length > 0) {
|
|
54
|
+
currentSynchedBinding.push({
|
|
55
|
+
DataClassKey: dataClassKey,
|
|
56
|
+
isExactSync: true,
|
|
57
|
+
values: syncedValues,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (unsynchedValues.length > 0) {
|
|
61
|
+
currentSynchedBinding.push({
|
|
62
|
+
DataClassKey: dataClassKey,
|
|
63
|
+
isExactSync: false,
|
|
64
|
+
values: unsynchedValues,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// ... and merge the results.
|
|
70
|
+
let synchedBindings = {};
|
|
71
|
+
const groupedByKey = {};
|
|
72
|
+
for (const entry of currentSynchedBinding) {
|
|
73
|
+
if (!groupedByKey[entry.DataClassKey]) {
|
|
74
|
+
groupedByKey[entry.DataClassKey] = [];
|
|
75
|
+
}
|
|
76
|
+
groupedByKey[entry.DataClassKey].push(entry);
|
|
77
|
+
}
|
|
78
|
+
for (const [dataClassKey, entries] of Object.entries(groupedByKey)) {
|
|
79
|
+
const exactSyncEntries = entries.filter((e) => e.isExactSync);
|
|
80
|
+
const nonExactSyncEntries = entries.filter((e) => !e.isExactSync);
|
|
81
|
+
if (exactSyncEntries.length > 0) {
|
|
82
|
+
// Pick the one with the largest values array
|
|
83
|
+
const maxEntry = exactSyncEntries.reduce((prev, curr) => curr.values.length > prev.values.length ? curr : prev);
|
|
84
|
+
if (maxEntry.values.length > 0) {
|
|
85
|
+
synchedBindings[dataClassKey + ":exact"] = maxEntry.values;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (nonExactSyncEntries.length > 0) {
|
|
89
|
+
// Pick the one with the smallest values array
|
|
90
|
+
const minEntry = nonExactSyncEntries.reduce((prev, curr) => curr.values.length < prev.values.length ? curr : prev);
|
|
91
|
+
if (minEntry.values.length > 0) {
|
|
92
|
+
synchedBindings[dataClassKey + ":subset"] = minEntry.values;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (Object.keys(synchedBindings).length > 0) {
|
|
97
|
+
synchedInputBindings.push({ ...synchedBindings });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return synchedInputBindings;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=exactSynchro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exactSynchro.js","sourceRoot":"","sources":["../../../../lib/simulation/binding-utils/exactSynchro.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,W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AgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CACtD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CACtD,CAAC;gBACF,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/B,eAAe,CAAC,YAAY,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;gBAC7D,CAAC;YACH,CAAC;YACD,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnC,8CAA8C;gBAC9C,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CACzD,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CACtD,CAAC;gBACF,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/B,eAAe,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;gBAC9D,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5C,oBAAoB,CAAC,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two Token objects for equality.
|
|
3
|
+
*
|
|
4
|
+
* A Token is defined as a record where each key is a dataClassKey and the value is a token value.
|
|
5
|
+
* The function checks if both tokens have the same set of keys and that each corresponding value is equal.
|
|
6
|
+
*
|
|
7
|
+
* @param tokenA - The first Token object to compare.
|
|
8
|
+
* @param tokenB - The second Token object to compare.
|
|
9
|
+
* @returns `true` if both tokens have identical keys and values; otherwise, `false`.
|
|
10
|
+
*/
|
|
11
|
+
export function tokensEqual(tokenA, tokenB) {
|
|
12
|
+
// Assuming the new Token implementation is: type Token = Record<string, string>
|
|
13
|
+
// where the key is a dataClassKey and the value is the token value.
|
|
14
|
+
const tokenAKeys = Object.keys(tokenA);
|
|
15
|
+
const tokenBKeys = Object.keys(tokenB);
|
|
16
|
+
return tokenAKeys.length !== tokenBKeys.length
|
|
17
|
+
? false
|
|
18
|
+
: tokenAKeys.every((key) => tokenB.hasOwnProperty(key) && tokenA[key] === tokenB[key]);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Determines whether two tokens overlap based on a set of specified data class keys.
|
|
22
|
+
*
|
|
23
|
+
* This function checks if, for every key in `dataClassKeys`, both `tokenA` and `tokenB` have the key,
|
|
24
|
+
* and the values for that key are strictly equal in both tokens. If any key is missing or the values differ,
|
|
25
|
+
* the function returns `false`. Otherwise, it returns `true`.
|
|
26
|
+
*
|
|
27
|
+
* @param tokenA - The first token object to compare.
|
|
28
|
+
* @param tokenB - The second token object to compare.
|
|
29
|
+
* @param dataClassKeys - An array of string keys to check for overlap between the two tokens.
|
|
30
|
+
* @returns `true` if all specified keys exist in both tokens and their values are equal; otherwise, `false`.
|
|
31
|
+
*/
|
|
32
|
+
export function tokensOverlap(tokenA, tokenB, dataClassKeys) {
|
|
33
|
+
for (const key of dataClassKeys) {
|
|
34
|
+
if (!(key in tokenA) || !(key in tokenB) || tokenA[key] !== tokenB[key]) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Generates a unique key for a data class based on its identifier, alias, and variable status.
|
|
42
|
+
*
|
|
43
|
+
* @param id - The unique identifier for the data class.
|
|
44
|
+
* @param alias - The alias or alternative name for the data class.
|
|
45
|
+
* @param isVariable - Indicates whether the data class represents a variable.
|
|
46
|
+
* @returns A string key in the format `${id}:${alias}:${isVariable}`.
|
|
47
|
+
*/
|
|
48
|
+
export function getDataClassKey(id, alias, isVariable) {
|
|
49
|
+
return `${id}:${alias}:${isVariable}`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Extracts the base data class identifier without variable flag.
|
|
53
|
+
* @param dataClassKey - Full key like "DataClass_2:I:false" or "DataClass_2:I:true"
|
|
54
|
+
* @returns Base key like "DataClass_2:I"
|
|
55
|
+
*/
|
|
56
|
+
export function getBaseDataClassKey(dataClassKey) {
|
|
57
|
+
// Remove the last part (":true" or ":false")
|
|
58
|
+
const parts = dataClassKey.split(":");
|
|
59
|
+
if (parts.length >= 2) {
|
|
60
|
+
return parts.slice(0, -1).join(":");
|
|
61
|
+
}
|
|
62
|
+
return dataClassKey;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generates a unique string key representing a combination of data classes.
|
|
66
|
+
*
|
|
67
|
+
* The key is constructed by iterating over the entries of the provided `dataClassInfoDict`,
|
|
68
|
+
* sorting them by their keys, and concatenating each entry's `dataClassId`, `alias`, and
|
|
69
|
+
* `isVariable` property, separated by colons. Each entry is delimited by a double colon (`::`).
|
|
70
|
+
* The trailing delimiter is removed from the final key.
|
|
71
|
+
*
|
|
72
|
+
* @param dataClassInfoDict - An object mapping data class IDs to their corresponding `DataClassInfo`.
|
|
73
|
+
* @returns A string key uniquely identifying the combination of data classes and their properties.
|
|
74
|
+
*/
|
|
75
|
+
export function createDataClassCombinationKeyFromDict(dataClassInfoDict) {
|
|
76
|
+
let key = "";
|
|
77
|
+
for (const dataClassKey of Object.keys(dataClassInfoDict).sort()) {
|
|
78
|
+
key += dataClassKey + "::";
|
|
79
|
+
}
|
|
80
|
+
return key.endsWith("::") ? key.slice(0, -2) : key;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Generates a unique string key representing a combination of data classes.
|
|
84
|
+
*
|
|
85
|
+
* The key is constructed by iterating over the entries of the provided `dataClassInfoDict`,
|
|
86
|
+
* sorting them by their keys, and concatenating each entry's `dataClassId`, `alias`, and
|
|
87
|
+
* `isVariable` property, separated by colons. Each entry is delimited by a double colon (`::`).
|
|
88
|
+
* The trailing delimiter is removed from the final key.
|
|
89
|
+
*
|
|
90
|
+
* @param dataClassInfoDict - An object mapping data class IDs to their corresponding `DataClassInfo`.
|
|
91
|
+
* @returns A string key uniquely identifying the combination of data classes and their properties.
|
|
92
|
+
*/
|
|
93
|
+
export function createDataClassCombinationKeyFromLink(link) {
|
|
94
|
+
let key = "";
|
|
95
|
+
for (const linkElement of [...link].sort((a, b) => a.id.localeCompare(b.id))) {
|
|
96
|
+
key +=
|
|
97
|
+
getDataClassKey(linkElement.id, linkElement.alias, linkElement.isVariable) + "::";
|
|
98
|
+
}
|
|
99
|
+
return key.endsWith("::") ? key.slice(0, -2) : key;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Extracts a `DataClass` object from a string key.
|
|
103
|
+
*
|
|
104
|
+
* The key is expected to be a colon-separated string in the format `"id:alias:isVariableStr"`.
|
|
105
|
+
* Only the `id` and `alias` parts are used to construct the returned object.
|
|
106
|
+
*
|
|
107
|
+
* @param dataClassKey - The colon-separated string representing the data class.
|
|
108
|
+
* @returns An object containing the `id` and `alias` extracted from the key.
|
|
109
|
+
*/
|
|
110
|
+
export function getDataClassFromKey(dataClassKey) {
|
|
111
|
+
const [id, alias] = dataClassKey.split(":");
|
|
112
|
+
return { id, alias };
|
|
113
|
+
}
|
|
114
|
+
export function getLinkPartFromDataClassKey(dataClassKey) {
|
|
115
|
+
const [id, alias, isVariableStr] = dataClassKey.split(":");
|
|
116
|
+
return { id: id, alias: alias, isVariable: isVariableStr === "true" };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Returns the set of all incoming dataClassKeys excluding inhibitor arcs.
|
|
120
|
+
*
|
|
121
|
+
* @param arcPlaceInfoDict - A dictionary mapping arc-place identifiers to their corresponding information, including tokens and inhibitor status.
|
|
122
|
+
* @returns A complete set of dataClassKeys.
|
|
123
|
+
*/
|
|
124
|
+
export function getAllDataClassKeysFromArcs(arcPlaceInfoDict) {
|
|
125
|
+
return new Set(Object.values(arcPlaceInfoDict).flatMap((arcPlaceInfo) => Object.keys(arcPlaceInfo.dataClassInfoDict)));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Flattens a binding from { dataClassKey: [values] } to [{ dataClassKey: value }]
|
|
129
|
+
* @param {BindingPerDataClass} binding - Binding with array values per data class
|
|
130
|
+
* @returns {Array} Array of single key-value objects for execution
|
|
131
|
+
*/
|
|
132
|
+
export function flattenBinding(binding) {
|
|
133
|
+
const flattened = [];
|
|
134
|
+
for (const [dataClassKey, values] of Object.entries(binding)) {
|
|
135
|
+
values.forEach((value) => {
|
|
136
|
+
flattened.push({ [dataClassKey]: value });
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return flattened;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../lib/simulation/binding-utils/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CAAC,MAAa,EAAE,MAAa;IACtD,gFAAgF;IAChF,oEAAoE;IAEpE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEvC,OAAO,UAAU,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM;QAC5C,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,UAAU,CAAC,KAAK,CACd,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,GAA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AAkC;IAElC,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE,CACvD,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAC5C,CACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,OAA4B;IAE5B,MAAM,SAAS,GAAyC,EAAE,CAAC;IAC3D,KAAK,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACvB,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { has } from "min-dash";
|
|
2
|
+
import { getAllDataClassKeysFromArcs, getBaseDataClassKey } from "./helpers";
|
|
3
|
+
/**
|
|
4
|
+
* Filters and returns only the non-inhibitor arcs from the provided arc-place information dictionary.
|
|
5
|
+
*
|
|
6
|
+
* @param arcPlaceInfoDict - A dictionary mapping arc-place identifiers to their corresponding information, including tokens and inhibitor status.
|
|
7
|
+
* @returns A new dictionary containing only the entries where `isInhibitorArc` is `false`.
|
|
8
|
+
*/
|
|
9
|
+
export function getNonInhibitorArcs(arcPlaceInfoDict) {
|
|
10
|
+
return Object.fromEntries(Object.entries(arcPlaceInfoDict).filter(([_, arcPlaceInfo]) => !arcPlaceInfo.isInhibitorArc));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Filters and returns only the inhibitor arcs from the provided arc-place information dictionary.
|
|
14
|
+
*
|
|
15
|
+
* @param arcPlaceInfoDict - A dictionary mapping arc-place identifiers to their corresponding information, including tokens and inhibitor status.
|
|
16
|
+
* @returns A new dictionary containing only the entries where `isInhibitorArc` is `true`.
|
|
17
|
+
*/
|
|
18
|
+
function getInhibitorArcs(arcPlaceInfoDict) {
|
|
19
|
+
return Object.fromEntries(Object.entries(arcPlaceInfoDict).filter(([_, arcPlaceInfo]) => arcPlaceInfo.isInhibitorArc));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if an inhibitor arc ...
|
|
23
|
+
* 1. has tokens
|
|
24
|
+
* 2. is not linking
|
|
25
|
+
* 3. only has data classes that exist in the incoming arcs
|
|
26
|
+
*
|
|
27
|
+
* @param arcPlaceInfo - The arc-place information to check.
|
|
28
|
+
* @param incomingDataClassKeys - Set of all data class keys from incoming arcs (excluding inhibitor arcs).
|
|
29
|
+
* @returns `true` if all data classes from the arc exist in incoming arcs; otherwise, `false`.
|
|
30
|
+
*/
|
|
31
|
+
function isRelevant(arcPlaceInfo, incomingDataClassKeys) {
|
|
32
|
+
if (Object.keys(arcPlaceInfo.dataClassInfoDict).length === 0) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const incomingBaseDataClassKeys = new Set(Array.from(incomingDataClassKeys).map(getBaseDataClassKey));
|
|
36
|
+
return Object.keys(arcPlaceInfo.dataClassInfoDict).every((dataClassKey) => {
|
|
37
|
+
const baseKey = getBaseDataClassKey(dataClassKey);
|
|
38
|
+
return incomingBaseDataClassKeys.has(baseKey);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generates an array of `BindingPerDataClass` objects representing inhibitor tokens
|
|
43
|
+
* from the provided inhibitor arcs information.
|
|
44
|
+
*
|
|
45
|
+
* For each token in each arc, creates a binding object where each key is the base data class key
|
|
46
|
+
* (obtained via `getBaseDataClassKey`) suffixed with `:true` and `:false`, both mapped to the token's value in an array.
|
|
47
|
+
* Each binding is then added to the result array.
|
|
48
|
+
*
|
|
49
|
+
* @param relevantInhibitorArcs - A dictionary mapping arc identifiers to their corresponding place information,
|
|
50
|
+
* which includes tokens to be processed as inhibitor tokens.
|
|
51
|
+
* @returns An array of `BindingPerDataClass` objects, each representing the inhibitor token bindings
|
|
52
|
+
* for the given arcs.
|
|
53
|
+
*/
|
|
54
|
+
function getInhibitorTokens(relevantInhibitorArcs) {
|
|
55
|
+
const inhibitorTokens = [];
|
|
56
|
+
for (const arcPlaceInfo of Object.values(relevantInhibitorArcs)) {
|
|
57
|
+
for (const token of arcPlaceInfo.tokens) {
|
|
58
|
+
const binding = {};
|
|
59
|
+
for (const [dataClassKey, value] of Object.entries(token)) {
|
|
60
|
+
binding[getBaseDataClassKey(dataClassKey)] = [value];
|
|
61
|
+
}
|
|
62
|
+
inhibitorTokens.push(binding);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return inhibitorTokens;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Filters bindings by removing or modifying them based on inhibitor tokens.
|
|
69
|
+
*
|
|
70
|
+
* For each inhibitor token, this function:
|
|
71
|
+
* 1. Checks if all inhibitor token values exist in a binding's data
|
|
72
|
+
* 2. If they match, removes the inhibitor token values from that binding
|
|
73
|
+
* 3. Removes the entire binding if any key becomes empty after filtering
|
|
74
|
+
* 4. Keeps bindings that don't match the inhibitor token criteria
|
|
75
|
+
*
|
|
76
|
+
* @param bindings - The array of bindings to filter
|
|
77
|
+
* @param inhibitorTokens - The array of inhibitor tokens used to filter the bindings
|
|
78
|
+
* @returns A new array of filtered bindings with inhibitor token values removed
|
|
79
|
+
*/
|
|
80
|
+
function getFilteredBindings(bindings, inhibitorTokens) {
|
|
81
|
+
let filteredBindings = [...bindings];
|
|
82
|
+
let processedInhibitorToken = {};
|
|
83
|
+
for (const inhibitorToken of inhibitorTokens) {
|
|
84
|
+
let newBindings = [];
|
|
85
|
+
for (const binding of filteredBindings) {
|
|
86
|
+
let allMatch = true;
|
|
87
|
+
for (const key of Object.keys(inhibitorToken)) {
|
|
88
|
+
const bindingValues = (binding[key + ":false"] || []).concat(binding[key + ":true"] || []);
|
|
89
|
+
if (!inhibitorToken[key].every((v) => bindingValues.includes(v))) {
|
|
90
|
+
allMatch = false;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!allMatch) {
|
|
95
|
+
newBindings.push(binding);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
for (const key of Object.keys(inhibitorToken)) {
|
|
99
|
+
if (!has(processedInhibitorToken, key)) {
|
|
100
|
+
processedInhibitorToken[key] = [];
|
|
101
|
+
}
|
|
102
|
+
if (processedInhibitorToken[key].includes(inhibitorToken[key][0])) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
let inhibitoredBinding = { ...binding };
|
|
106
|
+
let hasEmpty = false;
|
|
107
|
+
for (const isVariable of [true, false]) {
|
|
108
|
+
if (inhibitoredBinding[key + `:${isVariable}`]) {
|
|
109
|
+
inhibitoredBinding[key + `:${isVariable}`] = inhibitoredBinding[key + `:${isVariable}`].filter((v) => !inhibitorToken[key].includes(v));
|
|
110
|
+
}
|
|
111
|
+
if (inhibitoredBinding[key + `:${isVariable}`] &&
|
|
112
|
+
inhibitoredBinding[key + `:${isVariable}`].length === 0) {
|
|
113
|
+
hasEmpty = true;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!hasEmpty) {
|
|
118
|
+
newBindings.push(inhibitoredBinding);
|
|
119
|
+
}
|
|
120
|
+
processedInhibitorToken[key].push(...inhibitorToken[key]);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
filteredBindings = newBindings;
|
|
124
|
+
}
|
|
125
|
+
return filteredBindings;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Filters bindings by removing those that contain inhibitor arc tokens.
|
|
129
|
+
*
|
|
130
|
+
* @param bindings - The bindings to filter, organized by data class
|
|
131
|
+
* @param arcPlaceInfoDict - Dictionary containing information about all arcs and places
|
|
132
|
+
* @returns A new array of bindings with entries removed if they contain any inhibitor arc tokens
|
|
133
|
+
*
|
|
134
|
+
* @description
|
|
135
|
+
* This function performs the following steps:
|
|
136
|
+
* 1. Identifies all inhibitor arcs from the arc place info dictionary
|
|
137
|
+
* 2. Collects all incoming data class keys from non-inhibitor arcs
|
|
138
|
+
* 3. Filters inhibitor arcs to only those that are relevant (have tokens and matching data classes)
|
|
139
|
+
* 4. Returns the original bindings early if no relevant inhibitor arcs exist
|
|
140
|
+
* 5. Extracts inhibitor tokens from the relevant inhibitor arcs
|
|
141
|
+
* 6. Removes bindings that contain any of the inhibitor tokens
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* Inhibitor arcs are special arcs in Petri nets that prevent a transition from firing if tokens
|
|
145
|
+
* are present in the associated places. This function filters out bindings that would violate
|
|
146
|
+
* such inhibition conditions.
|
|
147
|
+
*/
|
|
148
|
+
export function filterBindingsByInhibitors(bindings, arcPlaceInfoDict) {
|
|
149
|
+
const inhibitorArcs = getInhibitorArcs(arcPlaceInfoDict);
|
|
150
|
+
// Get all incoming data classes (excluding inhibitor arcs)
|
|
151
|
+
const incomingDataClassKeys = getAllDataClassKeysFromArcs(getNonInhibitorArcs(arcPlaceInfoDict));
|
|
152
|
+
// Filter inhibitor arcs to only those relevant
|
|
153
|
+
// (having tokens and data classes in incoming arcs)
|
|
154
|
+
const relevantInhibitorArcs = Object.fromEntries(Object.entries(inhibitorArcs).filter(([_, arcPlaceInfo]) => isRelevant(arcPlaceInfo, incomingDataClassKeys)));
|
|
155
|
+
// Early return: if no relevant inhibitor arcs exist, return original bindings
|
|
156
|
+
if (Object.keys(relevantInhibitorArcs).length === 0) {
|
|
157
|
+
return bindings;
|
|
158
|
+
}
|
|
159
|
+
// Get inhibitor tokens as bindings
|
|
160
|
+
const inhibitorTokens = getInhibitorTokens(relevantInhibitorArcs);
|
|
161
|
+
// Filter out tokenvalues that are part of inhibitor tokens
|
|
162
|
+
// If any array becomes empty, the binding is removed
|
|
163
|
+
const filteredBindings = getFilteredBindings(bindings, inhibitorTokens);
|
|
164
|
+
return filteredBindings;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=inhibitorLogic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inhibitorLogic.js","sourceRoot":"","sources":["../../../../lib/simulation/binding-utils/inhibitorLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,gBAAkC;IAElC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,MAAM,CACrC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,cAAc,CACpD,CACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CACvB,gBAAkC;IAElC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,MAAM,CACrC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,cAAc,CACnD,CACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,UAAU,CACjB,YAA0B,EAC1B,qBAAkC;IAElC,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,yBAAyB,GAAG,IAAI,GAAG,CACvC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAC3D,CAAC;IAEF,OAAO,MAAM,CAAC,IAAI,CA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