Spaces:
Running
Running
chore: phase 6.3 architecture and LFS media tracking
Browse files- .gitattributes +2 -0
- ARCHITECTURE.md +14 -3
- js/app.js +918 -144
- js/i18n.js +105 -3
- js/renderers/mermaid-adapter.js +147 -12
- js/renderers/vis-adapter.js +165 -10
- js/scenarios/scenario-vanishing-crack.js +280 -0
- js/smim/bfo.js +209 -40
- js/smim/iso15926.js +372 -90
- js/smim/naive.js +238 -0
- js/smrm/actions.js +96 -66
- js/smrm/definitions.js +30 -0
- js/sms/lpg-generator.js +28 -13
- js/sms/rdf-generator.js +133 -44
- js/sms/sms-graph-generator.js +172 -0
- js/state.js +46 -9
- js/urmsm/bom-view.js +44 -4
- js/urmsm/smrm-view.js +106 -0
- narratives/Ontologies_-_Disappearing_Crack.mp3 +3 -0
- narratives/Ontologies_-_Disappearing_Crack.srt +149 -0
- styles/Twemoji-16.0.1.ttf +3 -0
- styles/main.css +336 -2
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*.ttf filter=lfs diff=lfs merge=lfs -text
|
ARCHITECTURE.md
CHANGED
|
@@ -16,15 +16,26 @@ This is a **Buildless Vue 3** application using native ES6 modules.
|
|
| 16 |
|
| 17 |
### The Pipeline Modules
|
| 18 |
* `/js/smrm/` (System Model Reference Model) - **Domain Logic & Actions.**
|
|
|
|
| 19 |
* `actions.js`: Validates user input and pushes strict Event objects to `state.js`. Never touches the UI.
|
| 20 |
* `/js/smim/` (Information Elements & Rules) - **Ontology Adapters.**
|
| 21 |
-
* `bfo.js`, `iso15926.js`: Pure functions. They take the Event Log and Current Time, and return a standardised `SemanticGraph` object `{ nodes: [], edges: [] }`.
|
| 22 |
* `/js/sms/` (Data in Tool) - **Storage Generators.**
|
|
|
|
| 23 |
* `lpg-generator.js`, `rdf-generator.js`: Generate database-specific table views and queries (Cypher, SPARQL/Turtle) from the `SemanticGraph`.
|
| 24 |
* `/js/urmsm/` (Dimension & Aspect) - **User Viewpoints.**
|
| 25 |
-
* `bom-view.js`: Generates the engineering Bill of Materials tree abstracting away database/ontology mechanics.
|
|
|
|
|
|
|
|
|
|
| 26 |
* `/js/renderers/` - **Visualisation.**
|
| 27 |
-
* `vis-adapter.js`, `mermaid-adapter.js`: Pure painters. They take the `SemanticGraph` and map node/edge types to colours, shapes, and physics.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
## 3. The Data Contract: Semantic Graph Object
|
| 30 |
All `smim/` adapters must return an object in this format to decouple ontologies from renderers:
|
|
|
|
| 16 |
|
| 17 |
### The Pipeline Modules
|
| 18 |
* `/js/smrm/` (System Model Reference Model) - **Domain Logic & Actions.**
|
| 19 |
+
* `definitions.js`: Standard manufacturing domain vocabulary (Entity Classes, Relationship Types).
|
| 20 |
* `actions.js`: Validates user input and pushes strict Event objects to `state.js`. Never touches the UI.
|
| 21 |
* `/js/smim/` (Information Elements & Rules) - **Ontology Adapters.**
|
| 22 |
+
* `bfo.js`, `iso15926.js`, `naive.js`: Pure functions. They take the Event Log and Current Time, and return a standardised `SemanticGraph` object `{ nodes: [], edges: [] }`. `naive.js` acts as an unconstrained property graph adapter without 3D/4D formalisms.
|
| 23 |
* `/js/sms/` (Data in Tool) - **Storage Generators.**
|
| 24 |
+
* `sms-graph-generator.js`: Transforms the canonical `SemanticGraph` (SMIM) into a physical storage graph (SMS), implementing W3C Reification for RDF and `TRANSITION_TO` state chains for LPG.
|
| 25 |
* `lpg-generator.js`, `rdf-generator.js`: Generate database-specific table views and queries (Cypher, SPARQL/Turtle) from the `SemanticGraph`.
|
| 26 |
* `/js/urmsm/` (Dimension & Aspect) - **User Viewpoints.**
|
| 27 |
+
* `bom-view.js`: Generates the engineering Bill of Materials tree abstracting away database/ontology mechanics with strict Parent -> Slot -> Child traversal.
|
| 28 |
+
* `smrm-view.js`: Transforms the canonical SMIM Semantic Graph into the SMRM Engineer View by mathematically collapsing contextual Slot nodes into direct transitive Parent -> Child relationships while preserving edge properties/defects.
|
| 29 |
+
* `/js/scenarios/` - **Interactive Scenarios & Narratives.**
|
| 30 |
+
* `scenario-vanishing-crack.js`: Defines temporal subtitles and chronological Event Sourcing timeline actions for the "Vanishing Crack" narrative demonstration across `NAIVE_NODE`, `NAIVE_EDGE`, and `ISO15926`.
|
| 31 |
* `/js/renderers/` - **Visualisation.**
|
| 32 |
+
* `vis-adapter.js`, `mermaid-adapter.js`: Pure painters. They take the `SemanticGraph` and map node/edge types to colours, shapes, and physics. `mermaid-adapter.js` serialises relationship properties directly onto edge labels.
|
| 33 |
+
|
| 34 |
+
## 3. The Perspectives Architecture (IEC 63339)
|
| 35 |
+
The application provides three distinct viewpoints:
|
| 36 |
+
1. **SMRM Perspective (`state.perspective = 'SMRM'`):** Engineering viewpoint. Contextual Slots are collapsed via `smrm-view.js`, presenting a direct part-to-part hierarchy with defects transferred to transitive edges.
|
| 37 |
+
2. **SMIM Perspective (`state.perspective = 'SMIM'`):** Canonical ontology layer. Preserves full ontological topology (Parent -> Slot -> Child, BFO MaterialEntity/Quality, ISO 15926 4D Extent/State).
|
| 38 |
+
3. **SMS Perspective (`state.perspective = 'SMS'`):** Physical database storage layer (LPG states and `TRANSITION_TO` edges, W3C RDF statement reification and literals).
|
| 39 |
|
| 40 |
## 3. The Data Contract: Semantic Graph Object
|
| 41 |
All `smim/` adapters must return an object in this format to decouple ontologies from renderers:
|
js/app.js
CHANGED
|
@@ -6,17 +6,31 @@
|
|
| 6 |
* passes data between the Event Log, Domain Actions, Ontologies, and Renderers.
|
| 7 |
*/
|
| 8 |
|
| 9 |
-
import { createApp, computed, watch, onMounted, ref, reactive } from 'vue';
|
| 10 |
-
import { state, advanceTime } from './state.js';
|
| 11 |
import { i18n } from './i18n.js';
|
| 12 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
import * as bfoAdapter from './smim/bfo.js';
|
| 14 |
import * as isoAdapter from './smim/iso15926.js';
|
|
|
|
| 15 |
import { initVisNetwork, updateVisNetwork } from './renderers/vis-adapter.js';
|
| 16 |
import { updateMermaidNetwork } from './renderers/mermaid-adapter.js';
|
| 17 |
import { generateBomTree } from './urmsm/bom-view.js';
|
|
|
|
| 18 |
import { generateLpgStorage, generateLpgQuery } from './sms/lpg-generator.js';
|
| 19 |
import { generateRdfStorage, generateRdfQuery } from './sms/rdf-generator.js';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
/**
|
| 22 |
* RECURSIVE BOM TREE NODE COMPONENT
|
|
@@ -54,14 +68,73 @@ const App = {
|
|
| 54 |
// 1. Local UI Settings (Isolated from domain state)
|
| 55 |
const settings = reactive({
|
| 56 |
language: 'sv', // Available options: 'sv', 'en', 'ru'
|
| 57 |
-
ontology: '
|
| 58 |
storage: 'LPG', // SMS Storage Paradigm: 'LPG' or 'RDF'
|
| 59 |
-
engine: 'vis'
|
|
|
|
| 60 |
});
|
| 61 |
|
| 62 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
const visContainer = ref(null);
|
| 64 |
const mermaidContainer = ref(null);
|
|
|
|
| 65 |
|
| 66 |
// Form inputs
|
| 67 |
const partNameInput = ref('');
|
|
@@ -69,48 +142,195 @@ const App = {
|
|
| 69 |
const selectedEdgeToRemove = ref('');
|
| 70 |
const showHistory = ref(true);
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
// Layout State (Flex percentages for resizers)
|
| 73 |
const layout = reactive({ leftWidth: 66, bomHeight: 25, storageHeight: 40 });
|
| 74 |
|
| 75 |
// Active dictionary based on local settings
|
| 76 |
const t = computed(() => i18n[settings.language]);
|
| 77 |
|
| 78 |
-
/
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
});
|
| 85 |
|
| 86 |
const activeNodes = computed(() => {
|
| 87 |
-
|
| 88 |
-
activeEdges.value.forEach(e => {
|
| 89 |
-
if (e.from) nodes.add(e.from);
|
| 90 |
-
if (e.to) nodes.add(e.to);
|
| 91 |
-
});
|
| 92 |
-
return Array.from(nodes);
|
| 93 |
});
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
}
|
| 109 |
});
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
});
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
/**
|
| 115 |
* Central Event Dispatcher
|
| 116 |
* ------------------------
|
|
@@ -119,57 +339,30 @@ const App = {
|
|
| 119 |
*
|
| 120 |
* @param {Object} event - The domain event object to dispatch.
|
| 121 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
function dispatch(event) {
|
| 123 |
if (!event) return;
|
| 124 |
-
|
| 125 |
-
if (event.type === 'EDGE_REMOVED' || event.type === 'REMOVE_EDGE') {
|
| 126 |
-
const targetEdge = state.eventLog.find(e => e.id === event.edgeId);
|
| 127 |
-
if (!targetEdge) {
|
| 128 |
-
console.error(`[Dispatcher] Cannot sever relation. Edge ${event.edgeId} not found.`);
|
| 129 |
-
return;
|
| 130 |
-
}
|
| 131 |
-
if (targetEdge.valid_to !== null) {
|
| 132 |
-
console.warn(`[Dispatcher] Relation ${event.edgeId} is already closed.`);
|
| 133 |
-
return;
|
| 134 |
-
}
|
| 135 |
-
targetEdge.valid_to = event.valid_to ?? state.currentTime;
|
| 136 |
-
return;
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
// Relationship creation event
|
| 140 |
-
if (!event.id) {
|
| 141 |
-
event.id = `e${state.edgeSequence++}`;
|
| 142 |
-
} else {
|
| 143 |
-
const match = String(event.id).match(/^e(\d+)$/);
|
| 144 |
-
if (match) {
|
| 145 |
-
const num = parseInt(match[1], 10);
|
| 146 |
-
if (num >= state.edgeSequence) {
|
| 147 |
-
state.edgeSequence = num + 1;
|
| 148 |
-
}
|
| 149 |
-
}
|
| 150 |
-
}
|
| 151 |
-
|
| 152 |
-
const edgeExists = state.eventLog.some(e =>
|
| 153 |
-
e.from === event.from &&
|
| 154 |
-
e.to === event.to &&
|
| 155 |
-
e.valid_to === null
|
| 156 |
-
);
|
| 157 |
-
if (edgeExists) {
|
| 158 |
-
console.warn(`[Dispatcher] Active edge already exists between ${event.from} and ${event.to}`);
|
| 159 |
-
return;
|
| 160 |
-
}
|
| 161 |
-
|
| 162 |
state.eventLog.push(event);
|
| 163 |
}
|
| 164 |
|
| 165 |
// The core transformation pipeline: Event Log -> Ontology -> Semantic Graph
|
| 166 |
const semanticGraph = computed(() => {
|
| 167 |
-
const eventsToProcess =
|
| 168 |
|
| 169 |
if (settings.ontology === 'BFO') {
|
| 170 |
return bfoAdapter.generateSemanticGraph(eventsToProcess, baseNodes.value, state.currentTime);
|
| 171 |
-
} else {
|
| 172 |
return isoAdapter.generateSemanticGraph(eventsToProcess, baseNodes.value, state.currentTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
}
|
| 174 |
});
|
| 175 |
|
|
@@ -208,59 +401,370 @@ const App = {
|
|
| 208 |
}
|
| 209 |
});
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
// Watch for graph or engine changes to trigger re-renders
|
| 212 |
-
watch([
|
| 213 |
renderGraph();
|
| 214 |
}, { deep: true });
|
| 215 |
|
| 216 |
function renderGraph() {
|
|
|
|
|
|
|
| 217 |
if (settings.engine === 'vis') {
|
| 218 |
-
const isComplex = settings.ontology === 'ISO15926';
|
| 219 |
-
updateVisNetwork(
|
| 220 |
} else if (mermaidContainer.value) {
|
| 221 |
-
updateMermaidNetwork(
|
| 222 |
}
|
| 223 |
}
|
| 224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
// Lifecycle hooks
|
| 226 |
onMounted(() => {
|
| 227 |
-
if (visContainer.value) {
|
| 228 |
-
initVisNetwork(visContainer.value);
|
| 229 |
-
}
|
| 230 |
-
|
| 231 |
// Inject initial seed data via pure factories and central dispatcher
|
| 232 |
-
dispatch(
|
| 233 |
-
dispatch(
|
| 234 |
-
dispatch(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
|
| 236 |
-
|
|
|
|
|
|
|
|
|
|
| 237 |
});
|
| 238 |
|
| 239 |
// UI Event Handlers
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
);
|
| 248 |
if (event) {
|
| 249 |
dispatch(event);
|
| 250 |
-
|
| 251 |
}
|
| 252 |
}
|
| 253 |
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
}
|
| 265 |
}
|
| 266 |
|
|
@@ -307,19 +811,121 @@ const App = {
|
|
| 307 |
document.body.classList.add('no-select');
|
| 308 |
}
|
| 309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
return {
|
| 311 |
state, settings, t, layout, advanceTime, dispatch,
|
| 312 |
-
|
| 313 |
-
|
|
|
|
|
|
|
| 314 |
activeNodes, activeEdges,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 315 |
bomTree, lpgRecords, rdfTtl, formatProperties, queryCode,
|
| 316 |
visContainer, mermaidContainer,
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
};
|
| 319 |
},
|
| 320 |
|
| 321 |
template: `
|
| 322 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
<!-- Tier 1: Architecture Settings -->
|
| 324 |
<div class="deck-row deck-row-top">
|
| 325 |
<div class="section-label">
|
|
@@ -327,8 +933,10 @@ const App = {
|
|
| 327 |
<span>{{ t.ontoTitle }}</span>
|
| 328 |
</div>
|
| 329 |
<div class="btn-group">
|
| 330 |
-
<button :class="{ active: settings.ontology === 'BFO' }" @click="settings.ontology = 'BFO'">BFO (3D)</button>
|
| 331 |
-
<button :class="{ active: settings.ontology === 'ISO15926' }" @click="settings.ontology = 'ISO15926'">ISO 15926 (4D)</button>
|
|
|
|
|
|
|
| 332 |
</div>
|
| 333 |
|
| 334 |
<div class="divider"></div>
|
|
@@ -338,67 +946,151 @@ const App = {
|
|
| 338 |
<span>{{ t.graphTitle }}</span>
|
| 339 |
</div>
|
| 340 |
<div class="btn-group">
|
| 341 |
-
<button :class="{ active: settings.storage === 'LPG' }" @click="settings.storage = 'LPG'">LPG</button>
|
| 342 |
-
<button :class="{ active: settings.storage === 'RDF' }" @click="settings.storage = 'RDF'">RDF (W3C)</button>
|
| 343 |
</div>
|
| 344 |
|
| 345 |
<div class="divider"></div>
|
| 346 |
|
| 347 |
<div class="section-label">🎨 <span>{{ t.engineTitle }}</span></div>
|
| 348 |
<div class="btn-group">
|
| 349 |
-
<button :class="{ active: settings.engine === 'vis' }" @click="settings.engine = 'vis'">🌐 Vis.js</button>
|
| 350 |
-
<button :class="{ active: settings.engine === 'mermaid' }" @click="settings.engine = 'mermaid'">📊 Mermaid</button>
|
| 351 |
</div>
|
| 352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
<div style="margin-left: auto;" class="btn-group flag-group">
|
| 354 |
-
<button :class="{ active: settings.language === 'sv' }" @click="settings.language = 'sv'" title="Svenska">🇸🇪</button>
|
| 355 |
-
<button :class="{ active: settings.language === 'en' }" @click="settings.language = 'en'" title="British English">🇬🇧</button>
|
| 356 |
-
<button :class="{ active: settings.language === 'ru' }" @click="settings.language = 'ru'" title="Русский">🇷🇺</button>
|
| 357 |
</div>
|
| 358 |
</div>
|
| 359 |
|
| 360 |
-
<!--
|
| 361 |
-
<
|
| 362 |
-
<
|
| 363 |
-
<
|
|
|
|
|
|
|
| 364 |
|
| 365 |
-
|
| 366 |
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
<
|
| 370 |
-
|
| 371 |
|
| 372 |
-
|
| 373 |
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
<
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
<select v-model="selectedEdgeToRemove">
|
| 384 |
-
<option v-for="edge in activeEdges" :key="edge.id" :value="edge.id">
|
| 385 |
-
{{ edge.from }} → {{ edge.to }}
|
| 386 |
-
</option>
|
| 387 |
-
</select>
|
| 388 |
-
<button class="danger" @click="handleRemove">{{ t.removeBtn }}</button>
|
| 389 |
|
| 390 |
-
|
| 391 |
|
| 392 |
-
|
| 393 |
-
<
|
| 394 |
-
|
| 395 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
</div>
|
| 397 |
|
| 398 |
<div class="main-container">
|
| 399 |
<div id="canvas-container" :style="{ flex: \`0 0 \${layout.leftWidth}%\` }">
|
| 400 |
<div ref="visContainer" v-show="settings.engine === 'vis'" style="width: 100%; height: 100%; position: absolute;"></div>
|
| 401 |
<div ref="mermaidContainer" v-show="settings.engine === 'mermaid'" id="mermaid-container"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
</div>
|
| 403 |
|
| 404 |
<!-- Horizontal Resizer -->
|
|
@@ -474,6 +1166,88 @@ const App = {
|
|
| 474 |
</div>
|
| 475 |
</div>
|
| 476 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
`
|
| 478 |
};
|
| 479 |
|
|
|
|
| 6 |
* passes data between the Event Log, Domain Actions, Ontologies, and Renderers.
|
| 7 |
*/
|
| 8 |
|
| 9 |
+
import { createApp, computed, watch, onMounted, ref, reactive, nextTick } from 'vue';
|
| 10 |
+
import { state, advanceTime, loadState } from './state.js';
|
| 11 |
import { i18n } from './i18n.js';
|
| 12 |
+
import {
|
| 13 |
+
createRegisterPartEvent,
|
| 14 |
+
createAssembleEvent,
|
| 15 |
+
createReportDefectEvent,
|
| 16 |
+
createDismantleEvent
|
| 17 |
+
} from './smrm/actions.js';
|
| 18 |
+
import { ENTITY_CLASSES, RELATION_TYPES } from './smrm/definitions.js';
|
| 19 |
import * as bfoAdapter from './smim/bfo.js';
|
| 20 |
import * as isoAdapter from './smim/iso15926.js';
|
| 21 |
+
import * as naiveAdapter from './smim/naive.js';
|
| 22 |
import { initVisNetwork, updateVisNetwork } from './renderers/vis-adapter.js';
|
| 23 |
import { updateMermaidNetwork } from './renderers/mermaid-adapter.js';
|
| 24 |
import { generateBomTree } from './urmsm/bom-view.js';
|
| 25 |
+
import { reduceGraphForSMRM } from './urmsm/smrm-view.js';
|
| 26 |
import { generateLpgStorage, generateLpgQuery } from './sms/lpg-generator.js';
|
| 27 |
import { generateRdfStorage, generateRdfQuery } from './sms/rdf-generator.js';
|
| 28 |
+
import { generatePhysicalGraph } from './sms/sms-graph-generator.js';
|
| 29 |
+
import {
|
| 30 |
+
vanishingCrackScenario,
|
| 31 |
+
onTimeUpdate as dispatchScenarioTimeline,
|
| 32 |
+
resetTimeline
|
| 33 |
+
} from './scenarios/scenario-vanishing-crack.js';
|
| 34 |
|
| 35 |
/**
|
| 36 |
* RECURSIVE BOM TREE NODE COMPONENT
|
|
|
|
| 68 |
// 1. Local UI Settings (Isolated from domain state)
|
| 69 |
const settings = reactive({
|
| 70 |
language: 'sv', // Available options: 'sv', 'en', 'ru'
|
| 71 |
+
ontology: 'NAIVE_NODE', // SMIM Top-Level Ontology: 'BFO' | 'ISO15926' | 'NAIVE_NODE' | 'NAIVE_EDGE'
|
| 72 |
storage: 'LPG', // SMS Storage Paradigm: 'LPG' or 'RDF'
|
| 73 |
+
engine: 'vis', // Renderer: 'vis' (Vis.js) or 'mermaid'
|
| 74 |
+
perspective: 'SMRM' // Perspective: 'SMRM' | 'SMIM' | 'SMS'
|
| 75 |
});
|
| 76 |
|
| 77 |
+
// User Role State ('UNI_ENGINEER')
|
| 78 |
+
const userRole = ref('UNI_ENGINEER');
|
| 79 |
+
watch(userRole, (newRole) => {
|
| 80 |
+
state.userRole = newRole;
|
| 81 |
+
});
|
| 82 |
+
watch(() => state.userRole, (newRole) => {
|
| 83 |
+
if (newRole && userRole.value !== newRole) {
|
| 84 |
+
userRole.value = newRole;
|
| 85 |
+
}
|
| 86 |
+
});
|
| 87 |
+
|
| 88 |
+
// Synchronise reactive ontology between settings and domain state
|
| 89 |
+
watch(() => state.ontology, (newOnto) => {
|
| 90 |
+
if (newOnto === 'ISO_15926_4D' || newOnto === 'ISO15926') {
|
| 91 |
+
settings.ontology = 'ISO15926';
|
| 92 |
+
} else if (newOnto === 'NAIVE_NODE') {
|
| 93 |
+
settings.ontology = 'NAIVE_NODE';
|
| 94 |
+
} else if (newOnto === 'NAIVE_EDGE') {
|
| 95 |
+
settings.ontology = 'NAIVE_EDGE';
|
| 96 |
+
} else if (newOnto === 'NAIVE') {
|
| 97 |
+
settings.ontology = 'NAIVE_NODE';
|
| 98 |
+
} else if (newOnto === 'BFO') {
|
| 99 |
+
settings.ontology = 'BFO';
|
| 100 |
+
}
|
| 101 |
+
}, { immediate: true });
|
| 102 |
+
watch(() => settings.ontology, (newOnto) => {
|
| 103 |
+
if (state.ontology !== newOnto) {
|
| 104 |
+
state.ontology = newOnto;
|
| 105 |
+
}
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
// Synchronise perspective between settings and domain state
|
| 109 |
+
watch(() => state.perspective, (newPersp) => {
|
| 110 |
+
if (newPersp && settings.perspective !== newPersp) {
|
| 111 |
+
settings.perspective = newPersp;
|
| 112 |
+
}
|
| 113 |
+
}, { immediate: true });
|
| 114 |
+
watch(() => settings.perspective, (newPersp) => {
|
| 115 |
+
if (state.perspective !== newPersp) {
|
| 116 |
+
state.perspective = newPersp;
|
| 117 |
+
}
|
| 118 |
+
});
|
| 119 |
+
|
| 120 |
+
// Synchronise engine between settings and domain state
|
| 121 |
+
watch(() => state.graphEngine, (newEngine) => {
|
| 122 |
+
const lower = (newEngine || 'VIS').toLowerCase();
|
| 123 |
+
if (settings.engine !== lower) {
|
| 124 |
+
settings.engine = lower;
|
| 125 |
+
}
|
| 126 |
+
}, { immediate: true });
|
| 127 |
+
watch(() => settings.engine, (newEngine) => {
|
| 128 |
+
const upper = (newEngine || 'vis').toUpperCase();
|
| 129 |
+
if (state.graphEngine !== upper) {
|
| 130 |
+
state.graphEngine = upper;
|
| 131 |
+
}
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
// DOM References for renderers & file operations
|
| 135 |
const visContainer = ref(null);
|
| 136 |
const mermaidContainer = ref(null);
|
| 137 |
+
const fileInput = ref(null);
|
| 138 |
|
| 139 |
// Form inputs
|
| 140 |
const partNameInput = ref('');
|
|
|
|
| 142 |
const selectedEdgeToRemove = ref('');
|
| 143 |
const showHistory = ref(true);
|
| 144 |
|
| 145 |
+
// New Sandbox & Domain Extension Form inputs
|
| 146 |
+
const selectedNodeClass = ref(ENTITY_CLASSES[0]);
|
| 147 |
+
const newNodeIdInput = ref('');
|
| 148 |
+
const selectedRelSource = ref('System_A');
|
| 149 |
+
const selectedRelType = ref(RELATION_TYPES[0]);
|
| 150 |
+
const selectedRelTarget = ref('');
|
| 151 |
+
const propTargetType = ref('NODE');
|
| 152 |
+
const propTargetId = ref('');
|
| 153 |
+
const propKeyInput = ref('');
|
| 154 |
+
const propValInput = ref('');
|
| 155 |
+
|
| 156 |
+
// Universal Engineer Business UI inputs
|
| 157 |
+
const bizRegType = ref('Vehicle');
|
| 158 |
+
const bizRegId = ref('');
|
| 159 |
+
const bizInstSource = ref('');
|
| 160 |
+
const bizInstTarget = ref('');
|
| 161 |
+
const bizDefTarget = ref('');
|
| 162 |
+
const bizDefType = ref('');
|
| 163 |
+
const bizDefVal = ref('');
|
| 164 |
+
const bizRevDefect = ref('');
|
| 165 |
+
const bizDismPart = ref('');
|
| 166 |
+
const bizStorePart = ref('');
|
| 167 |
+
const bizStoreTarget = ref('');
|
| 168 |
+
|
| 169 |
+
// Scenario Player State
|
| 170 |
+
const scenarioAudio = ref(null);
|
| 171 |
+
const isPlaying = ref(false);
|
| 172 |
+
const audioCurrentTime = ref(0);
|
| 173 |
+
const audioDuration = ref(0);
|
| 174 |
+
const showSubtitles = ref(true);
|
| 175 |
+
const currentSubtitleText = ref('');
|
| 176 |
+
const executedTimelineActions = ref(new Set());
|
| 177 |
+
|
| 178 |
// Layout State (Flex percentages for resizers)
|
| 179 |
const layout = reactive({ leftWidth: 66, bomHeight: 25, storageHeight: 40 });
|
| 180 |
|
| 181 |
// Active dictionary based on local settings
|
| 182 |
const t = computed(() => i18n[settings.language]);
|
| 183 |
|
| 184 |
+
/**
|
| 185 |
+
* Resolves the domain entity class of a node by inspecting ID conventions.
|
| 186 |
+
*
|
| 187 |
+
* @param {string} nodeId - Identifier of the node.
|
| 188 |
+
* @returns {string} Domain entity class ('Vehicle' | 'Slot' | 'Part' | 'Defect' | 'Warehouse').
|
| 189 |
+
*/
|
| 190 |
+
function getNodeEntityClass(nodeId) {
|
| 191 |
+
if (!nodeId) return 'Part';
|
| 192 |
+
if (/^veh/i.test(nodeId) || /^sys/i.test(nodeId)) return 'Vehicle';
|
| 193 |
+
if (/^slot/i.test(nodeId)) return 'Slot';
|
| 194 |
+
if (/^ware|^wh/i.test(nodeId)) return 'Warehouse';
|
| 195 |
+
if (/^def/i.test(nodeId)) return 'Defect';
|
| 196 |
+
return 'Part';
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
// Dynamic entity projection: Reconstruct base entities from pure business events in eventLog
|
| 200 |
+
const baseNodes = computed(() => {
|
| 201 |
+
const nodeMap = new Map();
|
| 202 |
+
|
| 203 |
+
state.eventLog.forEach(event => {
|
| 204 |
+
if (event.valid_from !== undefined && event.valid_from > state.currentTime) return;
|
| 205 |
+
|
| 206 |
+
if (event.type === 'REGISTER_PART' && event.partId) {
|
| 207 |
+
nodeMap.set(event.partId, {
|
| 208 |
+
id: event.partId,
|
| 209 |
+
label: event.partId,
|
| 210 |
+
type: getNodeEntityClass(event.partId),
|
| 211 |
+
entityClass: getNodeEntityClass(event.partId)
|
| 212 |
+
});
|
| 213 |
+
} else if (event.type === 'ASSEMBLE') {
|
| 214 |
+
if (event.parentId && !nodeMap.has(event.parentId)) {
|
| 215 |
+
nodeMap.set(event.parentId, {
|
| 216 |
+
id: event.parentId,
|
| 217 |
+
label: event.parentId,
|
| 218 |
+
type: getNodeEntityClass(event.parentId),
|
| 219 |
+
entityClass: getNodeEntityClass(event.parentId)
|
| 220 |
+
});
|
| 221 |
+
}
|
| 222 |
+
if (event.childId && !nodeMap.has(event.childId)) {
|
| 223 |
+
nodeMap.set(event.childId, {
|
| 224 |
+
id: event.childId,
|
| 225 |
+
label: event.childId,
|
| 226 |
+
type: getNodeEntityClass(event.childId),
|
| 227 |
+
entityClass: getNodeEntityClass(event.childId)
|
| 228 |
+
});
|
| 229 |
+
}
|
| 230 |
+
}
|
| 231 |
+
});
|
| 232 |
+
|
| 233 |
+
return Array.from(nodeMap.values());
|
| 234 |
+
});
|
| 235 |
+
|
| 236 |
+
const availableNodes = computed(() => {
|
| 237 |
+
return baseNodes.value.map(n => n.id);
|
| 238 |
});
|
| 239 |
|
| 240 |
const activeNodes = computed(() => {
|
| 241 |
+
return availableNodes.value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
});
|
| 243 |
|
| 244 |
+
const activeEdges = computed(() => {
|
| 245 |
+
return naiveAdapter.generateSemanticGraph(
|
| 246 |
+
state.eventLog,
|
| 247 |
+
baseNodes.value,
|
| 248 |
+
state.currentTime
|
| 249 |
+
).edges.filter(e => e.properties?.isCurrent !== false);
|
| 250 |
+
});
|
| 251 |
|
| 252 |
+
const activeVehicles = computed(() => availableNodes.value.filter(id => getNodeEntityClass(id) === 'Vehicle'));
|
| 253 |
+
const activeSlots = computed(() => availableNodes.value.filter(id => getNodeEntityClass(id) === 'Slot'));
|
| 254 |
+
const activeParts = computed(() => availableNodes.value.filter(id => !id.startsWith('Slot_')));
|
| 255 |
+
const activeWarehouses = computed(() => availableNodes.value.filter(id => getNodeEntityClass(id) === 'Warehouse'));
|
| 256 |
+
|
| 257 |
+
const bizInstallSources = computed(() => {
|
| 258 |
+
return availableNodes.value.filter(id => !id.startsWith('Slot_'));
|
| 259 |
+
});
|
| 260 |
+
|
| 261 |
+
const bizInstallTargets = computed(() => {
|
| 262 |
+
return availableNodes.value.filter(id => !id.startsWith('Slot_'));
|
| 263 |
+
});
|
| 264 |
+
|
| 265 |
+
const installedComponents = computed(() => {
|
| 266 |
+
const comps = new Set();
|
| 267 |
+
activeEdges.value.forEach(e => {
|
| 268 |
+
if (e.label === 'mounted_in' || e.label === 'stored_at') {
|
| 269 |
+
comps.add(e.childId || e.from);
|
| 270 |
}
|
| 271 |
});
|
| 272 |
+
return Array.from(comps).filter(id => !id.startsWith('Slot_'));
|
| 273 |
+
});
|
| 274 |
|
| 275 |
+
const activeDefectsList = computed(() => {
|
| 276 |
+
return state.eventLog
|
| 277 |
+
.map((e, index) => ({ event: e, logIndex: index }))
|
| 278 |
+
.filter(({ event: e }) => e.type === 'REPORT_DEFECT' && (e.valid_to === null || e.valid_to > state.currentTime) && (e.valid_from === undefined || e.valid_from <= state.currentTime))
|
| 279 |
+
.map(({ event: e, logIndex }) => {
|
| 280 |
+
const id = e.id || `def_${logIndex}_${e.targetId}_${e.defectName}`;
|
| 281 |
+
return {
|
| 282 |
+
id,
|
| 283 |
+
logIndex,
|
| 284 |
+
targetId: e.targetId,
|
| 285 |
+
defectName: e.defectName,
|
| 286 |
+
defectValue: e.defectValue,
|
| 287 |
+
label: `${e.targetId} • ${e.defectName}=${e.defectValue}`
|
| 288 |
+
};
|
| 289 |
+
});
|
| 290 |
});
|
| 291 |
|
| 292 |
+
watch(bizInstallSources, (sources) => {
|
| 293 |
+
if (!sources.includes(bizInstSource.value)) {
|
| 294 |
+
bizInstSource.value = sources[0] || '';
|
| 295 |
+
}
|
| 296 |
+
}, { immediate: true });
|
| 297 |
+
|
| 298 |
+
watch(bizInstallTargets, (targets) => {
|
| 299 |
+
if (!targets.includes(bizInstTarget.value)) {
|
| 300 |
+
bizInstTarget.value = targets[0] || '';
|
| 301 |
+
}
|
| 302 |
+
}, { immediate: true });
|
| 303 |
+
|
| 304 |
+
watch(activeParts, (parts) => {
|
| 305 |
+
if (!parts.includes(bizStorePart.value)) {
|
| 306 |
+
bizStorePart.value = parts[0] || '';
|
| 307 |
+
}
|
| 308 |
+
}, { immediate: true });
|
| 309 |
+
|
| 310 |
+
watch(activeWarehouses, (warehouses) => {
|
| 311 |
+
if (!warehouses.includes(bizStoreTarget.value)) {
|
| 312 |
+
bizStoreTarget.value = warehouses[0] || '';
|
| 313 |
+
}
|
| 314 |
+
}, { immediate: true });
|
| 315 |
+
|
| 316 |
+
watch(installedComponents, (comps) => {
|
| 317 |
+
if (!comps.includes(bizDismPart.value)) {
|
| 318 |
+
bizDismPart.value = comps[0] || '';
|
| 319 |
+
}
|
| 320 |
+
}, { immediate: true });
|
| 321 |
+
|
| 322 |
+
watch(activeDefectsList, (defects) => {
|
| 323 |
+
if (!defects.some(d => d.id === bizRevDefect.value)) {
|
| 324 |
+
bizRevDefect.value = defects[0]?.id || '';
|
| 325 |
+
}
|
| 326 |
+
}, { immediate: true });
|
| 327 |
+
|
| 328 |
+
watch(availableNodes, (nodes) => {
|
| 329 |
+
if (!nodes.includes(bizDefTarget.value)) {
|
| 330 |
+
bizDefTarget.value = nodes[0] || '';
|
| 331 |
+
}
|
| 332 |
+
}, { immediate: true });
|
| 333 |
+
|
| 334 |
/**
|
| 335 |
* Central Event Dispatcher
|
| 336 |
* ------------------------
|
|
|
|
| 339 |
*
|
| 340 |
* @param {Object} event - The domain event object to dispatch.
|
| 341 |
*/
|
| 342 |
+
/**
|
| 343 |
+
* Central Event Dispatcher (Pure Event Sourcing)
|
| 344 |
+
* ------------------------------------------------
|
| 345 |
+
* Directly appends immutable business facts to the event log.
|
| 346 |
+
*
|
| 347 |
+
* @param {Object} event - The domain event object to dispatch.
|
| 348 |
+
*/
|
| 349 |
function dispatch(event) {
|
| 350 |
if (!event) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
state.eventLog.push(event);
|
| 352 |
}
|
| 353 |
|
| 354 |
// The core transformation pipeline: Event Log -> Ontology -> Semantic Graph
|
| 355 |
const semanticGraph = computed(() => {
|
| 356 |
+
const eventsToProcess = state.eventLog;
|
| 357 |
|
| 358 |
if (settings.ontology === 'BFO') {
|
| 359 |
return bfoAdapter.generateSemanticGraph(eventsToProcess, baseNodes.value, state.currentTime);
|
| 360 |
+
} else if (settings.ontology === 'ISO15926') {
|
| 361 |
return isoAdapter.generateSemanticGraph(eventsToProcess, baseNodes.value, state.currentTime);
|
| 362 |
+
} else {
|
| 363 |
+
return naiveAdapter.generateSemanticGraph(eventsToProcess, baseNodes.value, state.currentTime, {
|
| 364 |
+
ontology: settings.ontology
|
| 365 |
+
});
|
| 366 |
}
|
| 367 |
});
|
| 368 |
|
|
|
|
| 401 |
}
|
| 402 |
});
|
| 403 |
|
| 404 |
+
// Physical projection (SMS) vs Engineer View (SMRM) vs Canonical Logical (SMIM) graph routing
|
| 405 |
+
const activeGraph = computed(() => {
|
| 406 |
+
if (settings.perspective === 'SMS') {
|
| 407 |
+
return generatePhysicalGraph(semanticGraph.value, settings.storage);
|
| 408 |
+
}
|
| 409 |
+
if (settings.perspective === 'SMRM') {
|
| 410 |
+
return reduceGraphForSMRM(semanticGraph.value);
|
| 411 |
+
}
|
| 412 |
+
return semanticGraph.value;
|
| 413 |
+
});
|
| 414 |
+
|
| 415 |
+
// Reactive Graph Caption
|
| 416 |
+
const graphCaption = computed(() => {
|
| 417 |
+
let ontoText = 'BFO (3D)';
|
| 418 |
+
if (settings.ontology === 'ISO15926') ontoText = 'ISO 15926 (4D)';
|
| 419 |
+
if (settings.ontology === 'NAIVE_NODE') ontoText = t.value.ontoNaiveNode || 'Naive Graph (Node)';
|
| 420 |
+
if (settings.ontology === 'NAIVE_EDGE') ontoText = t.value.ontoNaiveEdge || 'Naive Graph (Edge)';
|
| 421 |
+
const storageText = settings.storage;
|
| 422 |
+
let viewText = t.value.viewLogicalCaption;
|
| 423 |
+
if (settings.perspective === 'SMRM') viewText = t.value.viewSmrmCaption;
|
| 424 |
+
if (settings.perspective === 'SMS') viewText = t.value.viewPhysicalCaption;
|
| 425 |
+
return `${ontoText} | ${storageText} | ${viewText}`;
|
| 426 |
+
});
|
| 427 |
+
|
| 428 |
+
// Contextual Dynamic Legend
|
| 429 |
+
const graphLegendItems = computed(() => {
|
| 430 |
+
const nodes = [];
|
| 431 |
+
const edges = [];
|
| 432 |
+
const dict = t.value.legend;
|
| 433 |
+
|
| 434 |
+
if (settings.ontology === 'NAIVE_NODE' || settings.ontology === 'NAIVE_EDGE' || settings.ontology === 'NAIVE') {
|
| 435 |
+
nodes.push({ id: 'naiveVehicle', label: dict.naiveVehicle, swatch: 'swatch-box-vehicle' });
|
| 436 |
+
nodes.push({ id: 'naiveSlot', label: dict.naiveSlot, swatch: 'swatch-box-slot' });
|
| 437 |
+
nodes.push({ id: 'naivePart', label: dict.naivePart, swatch: 'swatch-box-part' });
|
| 438 |
+
nodes.push({ id: 'naiveDefect', label: dict.naiveDefect, swatch: 'swatch-diamond-defect' });
|
| 439 |
+
nodes.push({ id: 'naiveWarehouse', label: dict.naiveWarehouse, swatch: 'swatch-box-warehouse' });
|
| 440 |
+
|
| 441 |
+
edges.push({ id: 'relHasSlot', label: dict.relHasSlot, swatch: 'swatch-line-slot' });
|
| 442 |
+
edges.push({ id: 'relMountedIn', label: dict.relMountedIn, swatch: 'swatch-line-mount' });
|
| 443 |
+
edges.push({ id: 'relStoredAt', label: dict.relStoredAt, swatch: 'swatch-line-store' });
|
| 444 |
+
edges.push({ id: 'relHasDefect', label: dict.relHasDefect, swatch: 'swatch-line-defect' });
|
| 445 |
+
} else if (settings.ontology === 'BFO') {
|
| 446 |
+
nodes.push({ id: 'bfoSys', label: dict.bfoSys, swatch: 'swatch-box-sys' });
|
| 447 |
+
nodes.push({ id: 'bfoElem', label: dict.bfoElem, swatch: 'swatch-box-elem' });
|
| 448 |
+
nodes.push({ id: 'bfoQuality', label: dict.bfoQuality, swatch: 'swatch-diamond' });
|
| 449 |
+
|
| 450 |
+
if (settings.perspective === 'SMS' && settings.storage === 'RDF') {
|
| 451 |
+
nodes.push({ id: 'rdfStmt', label: dict.rdfStmt, swatch: 'swatch-diamond' });
|
| 452 |
+
nodes.push({ id: 'rdfLit', label: dict.rdfLit, swatch: 'swatch-literal' });
|
| 453 |
+
edges.push({ id: 'rdfPred', label: dict.rdfPred, swatch: 'swatch-line-past' });
|
| 454 |
+
} else {
|
| 455 |
+
edges.push({ id: 'bfoActive', label: dict.bfoActiveEdge, swatch: 'swatch-line-active' });
|
| 456 |
+
edges.push({ id: 'bfoInheres', label: dict.bfoInheres, swatch: 'swatch-line-transition' });
|
| 457 |
+
if (showHistory.value) {
|
| 458 |
+
edges.push({ id: 'bfoPast', label: dict.bfoPastEdge, swatch: 'swatch-line-past' });
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
} else {
|
| 462 |
+
// ISO 15926 (4D)
|
| 463 |
+
nodes.push({ id: 'iso4d', label: dict.iso4d, swatch: 'swatch-box-4d' });
|
| 464 |
+
nodes.push({ id: 'isoState', label: dict.isoState, swatch: 'swatch-box-state' });
|
| 465 |
+
nodes.push({ id: 'isoDefect', label: dict.isoDefect, swatch: 'swatch-diamond-defect' });
|
| 466 |
+
edges.push({ id: 'isoPart', label: dict.isoPartRel, swatch: 'swatch-line-active' });
|
| 467 |
+
edges.push({ id: 'isoSlice', label: dict.isoSliceRel, swatch: 'swatch-line-past' });
|
| 468 |
+
edges.push({ id: 'isoDefectRel', label: dict.isoDefectRel, swatch: 'swatch-line-defect' });
|
| 469 |
+
|
| 470 |
+
if (settings.perspective === 'SMS' && settings.storage === 'LPG') {
|
| 471 |
+
edges.push({ id: 'isoTrans', label: dict.isoTransitionRel, swatch: 'swatch-line-transition' });
|
| 472 |
+
}
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
return { nodes, edges };
|
| 476 |
+
});
|
| 477 |
+
|
| 478 |
// Watch for graph or engine changes to trigger re-renders
|
| 479 |
+
watch([activeGraph, () => settings.engine], () => {
|
| 480 |
renderGraph();
|
| 481 |
}, { deep: true });
|
| 482 |
|
| 483 |
function renderGraph() {
|
| 484 |
+
if (state.currentView === 'MENU') return;
|
| 485 |
+
const graphToRender = activeGraph.value;
|
| 486 |
if (settings.engine === 'vis') {
|
| 487 |
+
const isComplex = settings.ontology === 'ISO15926' || settings.perspective === 'SMS';
|
| 488 |
+
updateVisNetwork(graphToRender, isComplex);
|
| 489 |
} else if (mermaidContainer.value) {
|
| 490 |
+
updateMermaidNetwork(graphToRender, mermaidContainer.value);
|
| 491 |
}
|
| 492 |
}
|
| 493 |
|
| 494 |
+
// Watch for view changes to initialise the canvas when entering the sandbox workspace
|
| 495 |
+
watch(() => state.currentView, async (newView) => {
|
| 496 |
+
if (newView !== 'SCENARIO') {
|
| 497 |
+
stopAudio();
|
| 498 |
+
}
|
| 499 |
+
if (newView === 'SCENARIO') {
|
| 500 |
+
userRole.value = 'UNI_ENGINEER';
|
| 501 |
+
state.eventLog.length = 0;
|
| 502 |
+
resetTimeline(0);
|
| 503 |
+
state.currentTime = 0;
|
| 504 |
+
state.ontology = 'NAIVE_NODE';
|
| 505 |
+
state.perspective = 'SMRM';
|
| 506 |
+
state.graphEngine = 'MERMAID';
|
| 507 |
+
}
|
| 508 |
+
if (newView !== 'MENU') {
|
| 509 |
+
await nextTick();
|
| 510 |
+
if (visContainer.value) {
|
| 511 |
+
initVisNetwork(visContainer.value);
|
| 512 |
+
}
|
| 513 |
+
renderGraph();
|
| 514 |
+
}
|
| 515 |
+
});
|
| 516 |
+
|
| 517 |
// Lifecycle hooks
|
| 518 |
onMounted(() => {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
// Inject initial seed data via pure factories and central dispatcher
|
| 520 |
+
dispatch(createRegisterPartEvent('System_A', state.currentTime));
|
| 521 |
+
dispatch(createRegisterPartEvent('SubAssembly_1', state.currentTime));
|
| 522 |
+
dispatch(createAssembleEvent('System_A', 'SubAssembly_1', 'has_part', state.currentTime));
|
| 523 |
+
dispatch(createRegisterPartEvent('Part_A', state.currentTime));
|
| 524 |
+
dispatch(createAssembleEvent('System_A', 'Part_A', 'has_part', state.currentTime));
|
| 525 |
+
dispatch(createRegisterPartEvent('Sensor_X', state.currentTime));
|
| 526 |
+
dispatch(createAssembleEvent('SubAssembly_1', 'Sensor_X', 'has_part', state.currentTime));
|
| 527 |
|
| 528 |
+
if (state.currentView !== 'MENU' && visContainer.value) {
|
| 529 |
+
initVisNetwork(visContainer.value);
|
| 530 |
+
renderGraph();
|
| 531 |
+
}
|
| 532 |
});
|
| 533 |
|
| 534 |
// UI Event Handlers
|
| 535 |
+
/**
|
| 536 |
+
* Resets the application state, stops audio playback, and returns to the main menu.
|
| 537 |
+
*/
|
| 538 |
+
function goHome() {
|
| 539 |
+
stopAudio();
|
| 540 |
+
state.currentView = 'MENU';
|
| 541 |
+
state.eventLog.splice(0, state.eventLog.length);
|
| 542 |
+
state.currentTime = 0;
|
| 543 |
+
state.edgeSequence = 1;
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
/**
|
| 547 |
+
* Starts audio playback.
|
| 548 |
+
*/
|
| 549 |
+
function playAudio() {
|
| 550 |
+
if (scenarioAudio.value) {
|
| 551 |
+
scenarioAudio.value.play().catch(err => {
|
| 552 |
+
console.warn('Audio playback was prevented or failed:', err);
|
| 553 |
+
});
|
| 554 |
+
}
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
/**
|
| 558 |
+
* Pauses audio playback.
|
| 559 |
+
*/
|
| 560 |
+
function pauseAudio() {
|
| 561 |
+
if (scenarioAudio.value) {
|
| 562 |
+
scenarioAudio.value.pause();
|
| 563 |
+
}
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
/**
|
| 567 |
+
* Toggles audio playback between play and pause states.
|
| 568 |
+
*/
|
| 569 |
+
function togglePlayAudio() {
|
| 570 |
+
if (isPlaying.value) {
|
| 571 |
+
pauseAudio();
|
| 572 |
+
} else {
|
| 573 |
+
playAudio();
|
| 574 |
+
}
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
/**
|
| 578 |
+
* Stops audio playback, resets the timeline to zero, and clears the Event Sourcing log.
|
| 579 |
+
*/
|
| 580 |
+
function stopAudio() {
|
| 581 |
+
if (scenarioAudio.value) {
|
| 582 |
+
scenarioAudio.value.pause();
|
| 583 |
+
scenarioAudio.value.currentTime = 0;
|
| 584 |
+
}
|
| 585 |
+
isPlaying.value = false;
|
| 586 |
+
audioCurrentTime.value = 0;
|
| 587 |
+
currentSubtitleText.value = '';
|
| 588 |
+
|
| 589 |
+
// Reset Event Sourcing state
|
| 590 |
+
state.eventLog.length = 0;
|
| 591 |
+
resetTimeline(0);
|
| 592 |
+
state.ontology = 'NAIVE_NODE';
|
| 593 |
+
state.perspective = 'SMRM';
|
| 594 |
+
state.graphEngine = 'MERMAID';
|
| 595 |
+
nextTick(() => {
|
| 596 |
+
renderGraph();
|
| 597 |
+
});
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
/**
|
| 601 |
+
* Synchronises reactive audio time, subtitles, and timeline graph events with HTML5 audio playback.
|
| 602 |
+
*/
|
| 603 |
+
function onTimeUpdate() {
|
| 604 |
+
if (scenarioAudio.value) {
|
| 605 |
+
audioCurrentTime.value = scenarioAudio.value.currentTime;
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
const currentTime = audioCurrentTime.value;
|
| 609 |
+
|
| 610 |
+
// Subtitle synchronisation
|
| 611 |
+
const activeSubtitle = vanishingCrackScenario.subtitles.find(
|
| 612 |
+
sub => currentTime >= sub.start && currentTime <= sub.end
|
| 613 |
+
);
|
| 614 |
+
currentSubtitleText.value = activeSubtitle ? activeSubtitle.text : '';
|
| 615 |
+
|
| 616 |
+
// Scenario timeline dispatcher
|
| 617 |
+
dispatchScenarioTimeline(currentTime, state, renderGraph);
|
| 618 |
+
}
|
| 619 |
+
|
| 620 |
+
/**
|
| 621 |
+
* Initialises audio duration when metadata is loaded.
|
| 622 |
+
*/
|
| 623 |
+
function onLoadedMetadata() {
|
| 624 |
+
if (scenarioAudio.value) {
|
| 625 |
+
audioDuration.value = scenarioAudio.value.duration || 0;
|
| 626 |
+
}
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
/**
|
| 630 |
+
* Handles completion of audio playback.
|
| 631 |
+
* Crucial: On audio end, do NOT rewind or reset the state. Let the graph remain on screen!
|
| 632 |
+
*/
|
| 633 |
+
function onAudioEnded() {
|
| 634 |
+
isPlaying.value = false;
|
| 635 |
+
currentSubtitleText.value = '';
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
/**
|
| 639 |
+
* Seeks to a specific position in the audio timeline based on range input,
|
| 640 |
+
* resetting and re-evaluating the Event Sourcing state up to the new timestamp.
|
| 641 |
+
*
|
| 642 |
+
* @param {Event} event - The range slider input event.
|
| 643 |
+
*/
|
| 644 |
+
function onSeek(event) {
|
| 645 |
+
const targetTime = parseFloat(event.target.value);
|
| 646 |
+
if (scenarioAudio.value) {
|
| 647 |
+
scenarioAudio.value.currentTime = targetTime;
|
| 648 |
+
}
|
| 649 |
+
audioCurrentTime.value = targetTime;
|
| 650 |
+
|
| 651 |
+
// Reset Event Sourcing state for replay
|
| 652 |
+
state.eventLog.length = 0;
|
| 653 |
+
resetTimeline(0);
|
| 654 |
+
state.ontology = 'NAIVE_NODE';
|
| 655 |
+
state.perspective = 'SMRM';
|
| 656 |
+
state.graphEngine = 'MERMAID';
|
| 657 |
+
|
| 658 |
+
// Fast-forward timeline events and update subtitles to targetTime
|
| 659 |
+
onTimeUpdate();
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
/**
|
| 663 |
+
* Formats seconds into a human-readable mm:ss format.
|
| 664 |
+
*
|
| 665 |
+
* @param {number} seconds - Time duration in seconds.
|
| 666 |
+
* @returns {string} Formatted time string.
|
| 667 |
+
*/
|
| 668 |
+
function formatTime(seconds) {
|
| 669 |
+
if (!seconds || isNaN(seconds) || seconds < 0) return '00:00';
|
| 670 |
+
const mins = Math.floor(seconds / 60);
|
| 671 |
+
const secs = Math.floor(seconds % 60);
|
| 672 |
+
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
/**
|
| 676 |
+
* Universal Engineer Action 1: Register Asset
|
| 677 |
+
*/
|
| 678 |
+
function handleBizRegister() {
|
| 679 |
+
if (!bizRegId.value) return;
|
| 680 |
+
const event = createRegisterPartEvent(
|
| 681 |
+
bizRegId.value,
|
| 682 |
+
state.currentTime
|
| 683 |
);
|
| 684 |
if (event) {
|
| 685 |
dispatch(event);
|
| 686 |
+
bizRegId.value = '';
|
| 687 |
}
|
| 688 |
}
|
| 689 |
|
| 690 |
+
/**
|
| 691 |
+
* Universal Engineer Action 2: Install / Assemble
|
| 692 |
+
*/
|
| 693 |
+
function handleBizInstall() {
|
| 694 |
+
if (!bizInstSource.value || !bizInstTarget.value) return;
|
| 695 |
+
const childId = bizInstSource.value;
|
| 696 |
+
const parentId = bizInstTarget.value;
|
| 697 |
+
if (childId === parentId) return;
|
| 698 |
+
|
| 699 |
+
const event = createAssembleEvent(
|
| 700 |
+
parentId,
|
| 701 |
+
childId,
|
| 702 |
+
'mounted_in',
|
| 703 |
+
state.currentTime
|
| 704 |
+
);
|
| 705 |
+
if (event) {
|
| 706 |
+
dispatch(event);
|
| 707 |
+
}
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
/**
|
| 711 |
+
* Universal Engineer Action 3: Report Defect
|
| 712 |
+
*/
|
| 713 |
+
function handleBizReportDefect() {
|
| 714 |
+
if (!bizDefTarget.value || !bizDefType.value) return;
|
| 715 |
+
const event = createReportDefectEvent(
|
| 716 |
+
bizDefTarget.value,
|
| 717 |
+
bizDefType.value,
|
| 718 |
+
bizDefVal.value || 'present',
|
| 719 |
+
state.currentTime
|
| 720 |
+
);
|
| 721 |
+
if (event) {
|
| 722 |
+
dispatch(event);
|
| 723 |
+
bizDefType.value = '';
|
| 724 |
+
bizDefVal.value = '';
|
| 725 |
+
}
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
/**
|
| 729 |
+
* Universal Engineer Action 4: Revoke Defect
|
| 730 |
+
*/
|
| 731 |
+
function handleBizRevokeDefect() {
|
| 732 |
+
if (!bizRevDefect.value) return;
|
| 733 |
+
const item = activeDefectsList.value.find(d => d.id === bizRevDefect.value);
|
| 734 |
+
if (item && item.logIndex !== undefined) {
|
| 735 |
+
state.eventLog.splice(item.logIndex, 1);
|
| 736 |
+
bizRevDefect.value = '';
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
/**
|
| 741 |
+
* Universal Engineer Action 5: Dismantle
|
| 742 |
+
*/
|
| 743 |
+
function handleBizDismantle() {
|
| 744 |
+
if (!bizDismPart.value) return;
|
| 745 |
+
const event = createDismantleEvent(
|
| 746 |
+
bizDismPart.value,
|
| 747 |
+
state.currentTime
|
| 748 |
+
);
|
| 749 |
+
if (event) {
|
| 750 |
+
dispatch(event);
|
| 751 |
+
bizDismPart.value = '';
|
| 752 |
+
}
|
| 753 |
+
}
|
| 754 |
+
|
| 755 |
+
/**
|
| 756 |
+
* Universal Engineer Action 6: Move to Storage
|
| 757 |
+
*/
|
| 758 |
+
function handleBizStore() {
|
| 759 |
+
if (!bizStorePart.value || !bizStoreTarget.value) return;
|
| 760 |
+
const event = createAssembleEvent(
|
| 761 |
+
bizStoreTarget.value,
|
| 762 |
+
bizStorePart.value,
|
| 763 |
+
'stored_at',
|
| 764 |
+
state.currentTime
|
| 765 |
+
);
|
| 766 |
+
if (event) {
|
| 767 |
+
dispatch(event);
|
| 768 |
}
|
| 769 |
}
|
| 770 |
|
|
|
|
| 811 |
document.body.classList.add('no-select');
|
| 812 |
}
|
| 813 |
|
| 814 |
+
/**
|
| 815 |
+
* Serialises and exports the current Event Sourcing state to a JSON file.
|
| 816 |
+
*/
|
| 817 |
+
function saveJson() {
|
| 818 |
+
const exportData = {
|
| 819 |
+
version: '1.0',
|
| 820 |
+
savedAt: new Date().toISOString(),
|
| 821 |
+
userRole: userRole.value,
|
| 822 |
+
currentTime: state.currentTime,
|
| 823 |
+
edgeSequence: state.edgeSequence,
|
| 824 |
+
eventLog: JSON.parse(JSON.stringify(state.eventLog))
|
| 825 |
+
};
|
| 826 |
+
const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
|
| 827 |
+
const url = URL.createObjectURL(blob);
|
| 828 |
+
const a = document.createElement('a');
|
| 829 |
+
a.href = url;
|
| 830 |
+
a.download = `workbench-state-t${state.currentTime}.json`;
|
| 831 |
+
document.body.appendChild(a);
|
| 832 |
+
a.click();
|
| 833 |
+
document.body.removeChild(a);
|
| 834 |
+
URL.revokeObjectURL(url);
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
/**
|
| 838 |
+
* Opens the native file dialogue for loading a saved state JSON file.
|
| 839 |
+
*/
|
| 840 |
+
function triggerLoadJson() {
|
| 841 |
+
if (fileInput.value) {
|
| 842 |
+
fileInput.value.value = '';
|
| 843 |
+
fileInput.value.click();
|
| 844 |
+
}
|
| 845 |
+
}
|
| 846 |
+
|
| 847 |
+
/**
|
| 848 |
+
* Reads, deserialises, and restores the application domain state from a JSON file.
|
| 849 |
+
*
|
| 850 |
+
* @param {Event} e - HTML input change event.
|
| 851 |
+
*/
|
| 852 |
+
function onFileLoaded(e) {
|
| 853 |
+
const file = e.target.files?.[0];
|
| 854 |
+
if (!file) return;
|
| 855 |
+
|
| 856 |
+
const reader = new FileReader();
|
| 857 |
+
reader.onload = (event) => {
|
| 858 |
+
try {
|
| 859 |
+
const parsed = JSON.parse(event.target.result);
|
| 860 |
+
if (Array.isArray(parsed)) {
|
| 861 |
+
loadState({ eventLog: parsed });
|
| 862 |
+
} else if (parsed && typeof parsed === 'object') {
|
| 863 |
+
loadState(parsed);
|
| 864 |
+
if (parsed.userRole && (parsed.userRole === 'DB_ADMIN' || parsed.userRole === 'UNI_ENGINEER')) {
|
| 865 |
+
userRole.value = parsed.userRole;
|
| 866 |
+
}
|
| 867 |
+
}
|
| 868 |
+
nextTick(() => {
|
| 869 |
+
renderGraph();
|
| 870 |
+
});
|
| 871 |
+
} catch (err) {
|
| 872 |
+
console.error('Failed to parse state JSON:', err);
|
| 873 |
+
alert('Invalid JSON file format.');
|
| 874 |
+
}
|
| 875 |
+
};
|
| 876 |
+
reader.readAsText(file);
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
return {
|
| 880 |
state, settings, t, layout, advanceTime, dispatch,
|
| 881 |
+
userRole, fileInput, saveJson, triggerLoadJson, onFileLoaded,
|
| 882 |
+
entityClasses: ENTITY_CLASSES,
|
| 883 |
+
relationTypes: RELATION_TYPES,
|
| 884 |
+
availableNodes, goHome, showHistory,
|
| 885 |
activeNodes, activeEdges,
|
| 886 |
+
activeVehicles, activeSlots, activeParts, activeWarehouses,
|
| 887 |
+
bizRegType, bizRegId, handleBizRegister,
|
| 888 |
+
bizInstSource, bizInstTarget, handleBizInstall, bizInstallSources, bizInstallTargets,
|
| 889 |
+
bizDefTarget, bizDefType, bizDefVal, handleBizReportDefect,
|
| 890 |
+
bizRevDefect, handleBizRevokeDefect, activeDefectsList,
|
| 891 |
+
bizDismPart, handleBizDismantle, installedComponents,
|
| 892 |
+
bizStorePart, bizStoreTarget, handleBizStore,
|
| 893 |
bomTree, lpgRecords, rdfTtl, formatProperties, queryCode,
|
| 894 |
visContainer, mermaidContainer,
|
| 895 |
+
graphCaption, graphLegendItems,
|
| 896 |
+
startResizeH, startResizeV,
|
| 897 |
+
scenarioAudio, isPlaying, audioCurrentTime, audioDuration,
|
| 898 |
+
showSubtitles, currentSubtitleText, executedTimelineActions,
|
| 899 |
+
playAudio, pauseAudio, togglePlayAudio, stopAudio,
|
| 900 |
+
onTimeUpdate, onLoadedMetadata, onAudioEnded, onSeek, formatTime
|
| 901 |
};
|
| 902 |
},
|
| 903 |
|
| 904 |
template: `
|
| 905 |
+
<!-- Main Menu (Landing View) -->
|
| 906 |
+
<div v-if="state.currentView === 'MENU'" class="landing-view">
|
| 907 |
+
<div class="menu-card">
|
| 908 |
+
<div class="menu-badge">IEC 63339 Workbench</div>
|
| 909 |
+
<h1 class="menu-title">Knowledge Architecture Workbench</h1>
|
| 910 |
+
<p class="menu-subtitle">Top-Level Ontologies (SMIM), Storage Paradigms (SMS) & Event Sourcing</p>
|
| 911 |
+
|
| 912 |
+
<div class="menu-actions">
|
| 913 |
+
<button class="menu-btn menu-btn-primary" @click="state.currentView = 'SANDBOX'">
|
| 914 |
+
<span class="btn-main-text">Sandbox Mode</span>
|
| 915 |
+
<span class="btn-sub-text">Interactive exploration of 3D/4D ontologies & temporal graph models</span>
|
| 916 |
+
</button>
|
| 917 |
+
|
| 918 |
+
<button class="menu-btn menu-btn-scenario" @click="state.currentView = 'SCENARIO'">
|
| 919 |
+
<span class="btn-main-text">Scenario: The Vanishing Crack</span>
|
| 920 |
+
<span class="btn-sub-text">Guided demonstration of temporal defect tracing across lifecycle states</span>
|
| 921 |
+
</button>
|
| 922 |
+
</div>
|
| 923 |
+
</div>
|
| 924 |
+
</div>
|
| 925 |
+
|
| 926 |
+
<!-- Main Sandbox Workspace -->
|
| 927 |
+
<div v-if="state.currentView !== 'MENU'" class="sandbox-workspace">
|
| 928 |
+
<div class="control-deck">
|
| 929 |
<!-- Tier 1: Architecture Settings -->
|
| 930 |
<div class="deck-row deck-row-top">
|
| 931 |
<div class="section-label">
|
|
|
|
| 933 |
<span>{{ t.ontoTitle }}</span>
|
| 934 |
</div>
|
| 935 |
<div class="btn-group">
|
| 936 |
+
<button id="ctrl-onto-bfo" :class="{ active: settings.ontology === 'BFO' }" @click="settings.ontology = 'BFO'">BFO (3D)</button>
|
| 937 |
+
<button id="ctrl-onto-iso" :class="{ active: settings.ontology === 'ISO15926' }" @click="settings.ontology = 'ISO15926'">ISO 15926 (4D)</button>
|
| 938 |
+
<button id="ctrl-onto-naive-node" :class="{ active: settings.ontology === 'NAIVE_NODE' }" @click="settings.ontology = 'NAIVE_NODE'">{{ t.ontoNaiveNode }}</button>
|
| 939 |
+
<button id="ctrl-onto-naive-edge" :class="{ active: settings.ontology === 'NAIVE_EDGE' }" @click="settings.ontology = 'NAIVE_EDGE'">{{ t.ontoNaiveEdge }}</button>
|
| 940 |
</div>
|
| 941 |
|
| 942 |
<div class="divider"></div>
|
|
|
|
| 946 |
<span>{{ t.graphTitle }}</span>
|
| 947 |
</div>
|
| 948 |
<div class="btn-group">
|
| 949 |
+
<button id="ctrl-storage-lpg" :class="{ active: settings.storage === 'LPG' }" @click="settings.storage = 'LPG'">LPG</button>
|
| 950 |
+
<button id="ctrl-storage-rdf" :class="{ active: settings.storage === 'RDF' }" @click="settings.storage = 'RDF'">RDF (W3C)</button>
|
| 951 |
</div>
|
| 952 |
|
| 953 |
<div class="divider"></div>
|
| 954 |
|
| 955 |
<div class="section-label">🎨 <span>{{ t.engineTitle }}</span></div>
|
| 956 |
<div class="btn-group">
|
| 957 |
+
<button id="ctrl-engine-vis" :class="{ active: settings.engine === 'vis' }" @click="settings.engine = 'vis'">🌐 Vis.js</button>
|
| 958 |
+
<button id="ctrl-engine-mermaid" :class="{ active: settings.engine === 'mermaid' }" @click="settings.engine = 'mermaid'">📊 Mermaid</button>
|
| 959 |
</div>
|
| 960 |
|
| 961 |
+
<div class="divider"></div>
|
| 962 |
+
|
| 963 |
+
<div class="section-label">👁️ <span>{{ t.viewTitle }}</span></div>
|
| 964 |
+
<div class="btn-group">
|
| 965 |
+
<button id="ctrl-view-smrm" :class="{ active: settings.perspective === 'SMRM' }" @click="settings.perspective = 'SMRM'">{{ t.viewSmrm }}</button>
|
| 966 |
+
<button id="ctrl-view-logical" :class="{ active: settings.perspective === 'SMIM' }" @click="settings.perspective = 'SMIM'">{{ t.viewLogical }}</button>
|
| 967 |
+
<button id="ctrl-view-physical" :class="{ active: settings.perspective === 'SMS' }" @click="settings.perspective = 'SMS'">{{ t.viewPhysical }}</button>
|
| 968 |
+
</div>
|
| 969 |
+
|
| 970 |
+
<div class="divider"></div>
|
| 971 |
+
|
| 972 |
+
<!-- JSON State Operations -->
|
| 973 |
+
<button id="ctrl-save-json" class="secondary" @click="saveJson" :title="t.saveBtn">{{ t.saveBtn }}</button>
|
| 974 |
+
<button id="ctrl-load-json" class="secondary" @click="triggerLoadJson" :title="t.loadBtn">{{ t.loadBtn }}</button>
|
| 975 |
+
<input ref="fileInput" type="file" accept=".json" style="display: none;" @change="onFileLoaded" />
|
| 976 |
+
|
| 977 |
<div style="margin-left: auto;" class="btn-group flag-group">
|
| 978 |
+
<button id="ctrl-lang-sv" :class="{ active: settings.language === 'sv' }" @click="settings.language = 'sv'" title="Svenska">🇸🇪</button>
|
| 979 |
+
<button id="ctrl-lang-en" :class="{ active: settings.language === 'en' }" @click="settings.language = 'en'" title="British English">🇬🇧</button>
|
| 980 |
+
<button id="ctrl-lang-ru" :class="{ active: settings.language === 'ru' }" @click="settings.language = 'ru'" title="Русский">🇷🇺</button>
|
| 981 |
</div>
|
| 982 |
</div>
|
| 983 |
|
| 984 |
+
<!-- Universal Engineer Workspace -->
|
| 985 |
+
<template v-if="userRole === 'UNI_ENGINEER'">
|
| 986 |
+
<!-- Row 1: Time, Register, Install, Dismantle -->
|
| 987 |
+
<div class="deck-row">
|
| 988 |
+
<span id="biz-time-badge" class="badge">T = {{ state.currentTime }}</span>
|
| 989 |
+
<button id="biz-step-btn" @click="advanceTime">{{ t.stepBtn }}</button>
|
| 990 |
|
| 991 |
+
<div class="divider"></div>
|
| 992 |
|
| 993 |
+
<!-- Action 1: Register Part -->
|
| 994 |
+
<label style="font-size: 11px; font-weight: 700; color: #0284c7;">1. Register Part:</label>
|
| 995 |
+
<input id="biz-reg-id" type="text" v-model="bizRegId" placeholder="Part ID" style="width: 110px;">
|
| 996 |
+
<button id="biz-reg-btn" class="secondary" @click="handleBizRegister">Register</button>
|
| 997 |
|
| 998 |
+
<div class="divider"></div>
|
| 999 |
|
| 1000 |
+
<!-- Action 2: Install / Assemble -->
|
| 1001 |
+
<label style="font-size: 11px; font-weight: 700; color: #0284c7;">2. Install:</label>
|
| 1002 |
+
<select id="biz-inst-source" v-model="bizInstSource">
|
| 1003 |
+
<option v-for="node in bizInstallSources" :key="'src_' + node" :value="node">{{ node }}</option>
|
| 1004 |
+
</select>
|
| 1005 |
+
<select id="biz-inst-target" v-model="bizInstTarget">
|
| 1006 |
+
<option v-for="node in bizInstallTargets" :key="'tgt_' + node" :value="node">{{ node }}</option>
|
| 1007 |
+
</select>
|
| 1008 |
+
<button id="biz-inst-btn" class="secondary" @click="handleBizInstall">Install</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1009 |
|
| 1010 |
+
<div class="divider"></div>
|
| 1011 |
|
| 1012 |
+
<!-- Action 5: Dismantle -->
|
| 1013 |
+
<label style="font-size: 11px; font-weight: 700; color: #0284c7;">5. Dismantle:</label>
|
| 1014 |
+
<select id="biz-dism-part" v-model="bizDismPart">
|
| 1015 |
+
<option v-for="comp in installedComponents" :key="'comp_' + comp" :value="comp">{{ comp }}</option>
|
| 1016 |
+
</select>
|
| 1017 |
+
<button id="biz-dism-btn" class="danger" @click="handleBizDismantle">Dismantle</button>
|
| 1018 |
+
</div>
|
| 1019 |
+
|
| 1020 |
+
<!-- Row 2: Defect, Revoke, Storage, History -->
|
| 1021 |
+
<div class="deck-row" style="border-top: 1px solid #f1f5f9; background: #fafafa;">
|
| 1022 |
+
<!-- Action 3: Report Defect -->
|
| 1023 |
+
<label style="font-size: 11px; font-weight: 700; color: #0284c7;">3. Defect:</label>
|
| 1024 |
+
|
| 1025 |
+
<select id="biz-def-target" v-model="bizDefTarget">
|
| 1026 |
+
<option v-for="node in availableNodes" :key="'dn_' + node" :value="node">{{ node }}</option>
|
| 1027 |
+
</select>
|
| 1028 |
+
<input id="biz-def-type" type="text" v-model="bizDefType" placeholder="Type (e.g. crack)" style="width: 110px;">
|
| 1029 |
+
<input id="biz-def-val" type="text" v-model="bizDefVal" placeholder="Value (e.g. 2mm)" style="width: 80px;">
|
| 1030 |
+
<button id="biz-def-btn" class="secondary" @click="handleBizReportDefect">Report Defect</button>
|
| 1031 |
+
|
| 1032 |
+
<div class="divider"></div>
|
| 1033 |
+
|
| 1034 |
+
<!-- Action 4: Revoke Defect -->
|
| 1035 |
+
<label style="font-size: 11px; font-weight: 700; color: #0284c7;">4. Revoke:</label>
|
| 1036 |
+
<select id="biz-rev-defect" v-model="bizRevDefect">
|
| 1037 |
+
<option v-for="d in activeDefectsList" :key="d.id" :value="d.id">{{ d.label }}</option>
|
| 1038 |
+
</select>
|
| 1039 |
+
<button id="biz-rev-btn" class="danger" @click="handleBizRevokeDefect">Revoke</button>
|
| 1040 |
+
|
| 1041 |
+
<div class="divider"></div>
|
| 1042 |
+
|
| 1043 |
+
<!-- Action 6: Move to Storage -->
|
| 1044 |
+
<label style="font-size: 11px; font-weight: 700; color: #0284c7;">6. Storage:</label>
|
| 1045 |
+
<select id="biz-store-part" v-model="bizStorePart">
|
| 1046 |
+
<option v-for="part in activeParts" :key="'sp_' + part" :value="part">{{ part }}</option>
|
| 1047 |
+
</select>
|
| 1048 |
+
<select id="biz-store-target" v-model="bizStoreTarget">
|
| 1049 |
+
<option v-for="wh in activeWarehouses" :key="'sw_' + wh" :value="wh">{{ wh }}</option>
|
| 1050 |
+
</select>
|
| 1051 |
+
<button id="biz-store-btn" class="secondary" @click="handleBizStore">Store</button>
|
| 1052 |
+
|
| 1053 |
+
<div class="divider"></div>
|
| 1054 |
+
|
| 1055 |
+
<!-- History Checkbox -->
|
| 1056 |
+
<label style="font-size: 11px; display: flex; align-items: center; gap: 4px;">
|
| 1057 |
+
<input type="checkbox" v-model="showHistory"> {{ t.history }}
|
| 1058 |
+
</label>
|
| 1059 |
+
</div>
|
| 1060 |
+
</template>
|
| 1061 |
</div>
|
| 1062 |
|
| 1063 |
<div class="main-container">
|
| 1064 |
<div id="canvas-container" :style="{ flex: \`0 0 \${layout.leftWidth}%\` }">
|
| 1065 |
<div ref="visContainer" v-show="settings.engine === 'vis'" style="width: 100%; height: 100%; position: absolute;"></div>
|
| 1066 |
<div ref="mermaidContainer" v-show="settings.engine === 'mermaid'" id="mermaid-container"></div>
|
| 1067 |
+
|
| 1068 |
+
<!-- Dynamic Graph Caption Overlay -->
|
| 1069 |
+
<div class="graph-caption">
|
| 1070 |
+
<span>📌</span>
|
| 1071 |
+
<span>{{ graphCaption }}</span>
|
| 1072 |
+
</div>
|
| 1073 |
+
|
| 1074 |
+
<!-- Contextual Dynamic Legend Overlay -->
|
| 1075 |
+
<div class="graph-legend">
|
| 1076 |
+
<div class="legend-title">
|
| 1077 |
+
<span>{{ t.legend.title }}</span>
|
| 1078 |
+
</div>
|
| 1079 |
+
<div v-if="graphLegendItems.nodes.length > 0" class="legend-section">
|
| 1080 |
+
<div class="legend-section-title">{{ t.legend.nodes }}</div>
|
| 1081 |
+
<div v-for="item in graphLegendItems.nodes" :key="item.id" class="legend-item">
|
| 1082 |
+
<div :class="item.swatch"></div>
|
| 1083 |
+
<span>{{ item.label }}</span>
|
| 1084 |
+
</div>
|
| 1085 |
+
</div>
|
| 1086 |
+
<div v-if="graphLegendItems.edges.length > 0" class="legend-section">
|
| 1087 |
+
<div class="legend-section-title">{{ t.legend.edges }}</div>
|
| 1088 |
+
<div v-for="item in graphLegendItems.edges" :key="item.id" class="legend-item">
|
| 1089 |
+
<div :class="item.swatch"></div>
|
| 1090 |
+
<span>{{ item.label }}</span>
|
| 1091 |
+
</div>
|
| 1092 |
+
</div>
|
| 1093 |
+
</div>
|
| 1094 |
</div>
|
| 1095 |
|
| 1096 |
<!-- Horizontal Resizer -->
|
|
|
|
| 1166 |
</div>
|
| 1167 |
</div>
|
| 1168 |
</div>
|
| 1169 |
+
|
| 1170 |
+
<!-- Hidden Scenario Audio Element -->
|
| 1171 |
+
<audio
|
| 1172 |
+
ref="scenarioAudio"
|
| 1173 |
+
src="./narratives/Ontologies_-_Disappearing_Crack.mp3"
|
| 1174 |
+
preload="metadata"
|
| 1175 |
+
@timeupdate="onTimeUpdate"
|
| 1176 |
+
@loadedmetadata="onLoadedMetadata"
|
| 1177 |
+
@play="isPlaying = true"
|
| 1178 |
+
@pause="isPlaying = false"
|
| 1179 |
+
@ended="onAudioEnded"
|
| 1180 |
+
></audio>
|
| 1181 |
+
|
| 1182 |
+
<!-- Subtitles Overlay (Scenario Mode) -->
|
| 1183 |
+
<div
|
| 1184 |
+
v-if="state.currentView === 'SCENARIO' && showSubtitles"
|
| 1185 |
+
class="scenario-subtitles"
|
| 1186 |
+
>
|
| 1187 |
+
{{ currentSubtitleText }}
|
| 1188 |
+
</div>
|
| 1189 |
+
|
| 1190 |
+
<!-- Floating Scenario Player Panel -->
|
| 1191 |
+
<div
|
| 1192 |
+
v-if="state.currentView === 'SCENARIO'"
|
| 1193 |
+
class="scenario-player-panel"
|
| 1194 |
+
>
|
| 1195 |
+
<button
|
| 1196 |
+
class="player-btn"
|
| 1197 |
+
@click="togglePlayAudio"
|
| 1198 |
+
:title="isPlaying ? 'Pause' : 'Play'"
|
| 1199 |
+
:aria-label="isPlaying ? 'Pause' : 'Play'"
|
| 1200 |
+
>
|
| 1201 |
+
<span v-if="isPlaying">⏸</span>
|
| 1202 |
+
<span v-else>▶</span>
|
| 1203 |
+
</button>
|
| 1204 |
+
|
| 1205 |
+
<button
|
| 1206 |
+
class="player-btn"
|
| 1207 |
+
@click="stopAudio"
|
| 1208 |
+
title="Stop"
|
| 1209 |
+
aria-label="Stop"
|
| 1210 |
+
>
|
| 1211 |
+
<span>⏹</span>
|
| 1212 |
+
</button>
|
| 1213 |
+
|
| 1214 |
+
<input
|
| 1215 |
+
type="range"
|
| 1216 |
+
class="player-progress"
|
| 1217 |
+
min="0"
|
| 1218 |
+
:max="audioDuration || 100"
|
| 1219 |
+
step="0.1"
|
| 1220 |
+
:value="audioCurrentTime"
|
| 1221 |
+
@input="onSeek"
|
| 1222 |
+
aria-label="Audio Timeline"
|
| 1223 |
+
/>
|
| 1224 |
+
|
| 1225 |
+
<span class="player-time">{{ formatTime(audioCurrentTime) }} / {{ formatTime(audioDuration) }}</span>
|
| 1226 |
+
|
| 1227 |
+
<button
|
| 1228 |
+
class="player-btn player-btn-cc"
|
| 1229 |
+
:class="{ active: showSubtitles }"
|
| 1230 |
+
@click="showSubtitles = !showSubtitles"
|
| 1231 |
+
title="Toggle Subtitles"
|
| 1232 |
+
aria-label="Toggle Subtitles"
|
| 1233 |
+
>
|
| 1234 |
+
CC
|
| 1235 |
+
</button>
|
| 1236 |
+
</div>
|
| 1237 |
+
|
| 1238 |
+
<!-- Floating Home Button -->
|
| 1239 |
+
<button
|
| 1240 |
+
v-if="state.currentView !== 'MENU'"
|
| 1241 |
+
class="floating-home-btn"
|
| 1242 |
+
@click="goHome"
|
| 1243 |
+
title="Return to Main Menu (Resets Sandbox)"
|
| 1244 |
+
aria-label="Return to Main Menu"
|
| 1245 |
+
>
|
| 1246 |
+
<svg viewBox="0 0 24 24" width="22" height="22" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
| 1247 |
+
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
|
| 1248 |
+
<polyline points="9 22 9 12 15 12 15 22"></polyline>
|
| 1249 |
+
</svg>
|
| 1250 |
+
</button>
|
| 1251 |
`
|
| 1252 |
};
|
| 1253 |
|
js/i18n.js
CHANGED
|
@@ -9,6 +9,13 @@ export const i18n = {
|
|
| 9 |
ontoTitle: "Ontologi:",
|
| 10 |
graphTitle: "Datamodell:",
|
| 11 |
engineTitle: "Grafmotor:",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
stepBtn: "Lås steg (T+1)",
|
| 13 |
parent: "Överordnad:",
|
| 14 |
partPlaceholder: "Komponentnamn",
|
|
@@ -27,6 +34,20 @@ export const i18n = {
|
|
| 27 |
loadBtn: "📂 Ladda JSON",
|
| 28 |
queryTitle: "Databasfråga",
|
| 29 |
queryDesc: "Visa aktuell struktur (T = T_nu)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
tooltips: {
|
| 31 |
urmsm: "<b>URMSM (Dimension & Aspect)</b><br/>Definierar intressentens perspektiv (ISO 42010 Viewpoint). Användaren ser bara BOM-strukturen vid tidpunkten T, oavsett underliggande IT-lager.",
|
| 32 |
smrm: "<b>SMRM (Concept Repository)</b><br/>Domänontologi och gemensam begreppsbank (System, Component, Physical/Functional Object). Här låst till standardiserad produktnedbrytning.",
|
|
@@ -41,20 +62,40 @@ export const i18n = {
|
|
| 41 |
bfoElem: "Continuant / Komponent (:Element)",
|
| 42 |
bfoActiveEdge: "Aktiv relation [giltig till nu]",
|
| 43 |
bfoPastEdge: "Historisk relation (avslutad)",
|
|
|
|
|
|
|
| 44 |
iso4d: "4D-individ (Spatio-Temporal Extent)",
|
| 45 |
isoState: "Temporal del / Tillstånd (State)",
|
| 46 |
isoPartRel: "Tidlös komposition (hasPart)",
|
| 47 |
isoSliceRel: "temporalPartOf (del av 4D-individ)",
|
| 48 |
isoTransitionRel: "TRANSITION_TO (tillståndskedja i LPG)",
|
|
|
|
|
|
|
| 49 |
rdfStmt: "Reifiering (_:statement)",
|
| 50 |
rdfLit: "Literal (tidsstämpel xsd:int)",
|
| 51 |
-
rdfPred: "RDF-predikat"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
}
|
| 53 |
},
|
| 54 |
en: {
|
| 55 |
ontoTitle: "Ontology:",
|
| 56 |
graphTitle: "Data Model:",
|
| 57 |
engineTitle: "Renderer:",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
stepBtn: "Commit step (T+1)",
|
| 59 |
parent: "Parent:",
|
| 60 |
partPlaceholder: "Component name",
|
|
@@ -73,6 +114,20 @@ export const i18n = {
|
|
| 73 |
loadBtn: "📂 Load JSON",
|
| 74 |
queryTitle: "Database Query",
|
| 75 |
queryDesc: "Show current structure (T = T_now)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
tooltips: {
|
| 77 |
urmsm: "<b>URMSM (Dimension & Aspect)</b><br/>Captures the stakeholder concern and viewpoint (ISO 42010). The engineer always sees a unified BOM snapshot at time T, decoupled from graph mechanics.",
|
| 78 |
smrm: "<b>SMRM (Concept Repository)</b><br/>Domain Ontology: the shared engineering lexicon (System, System Element, Physical/Functional Object). Fixed here to physical decomposition.",
|
|
@@ -87,20 +142,40 @@ export const i18n = {
|
|
| 87 |
bfoElem: "Continuant / Component (:Element)",
|
| 88 |
bfoActiveEdge: "Active relation [valid to now]",
|
| 89 |
bfoPastEdge: "Historical relation (closed)",
|
|
|
|
|
|
|
| 90 |
iso4d: "4D Individual (Spatio-Temporal Extent)",
|
| 91 |
isoState: "Temporal Part / State",
|
| 92 |
isoPartRel: "Tenseless Composition (hasPart)",
|
| 93 |
isoSliceRel: "temporalPartOf (Extent link)",
|
| 94 |
isoTransitionRel: "TRANSITION_TO (State Chain in LPG)",
|
|
|
|
|
|
|
| 95 |
rdfStmt: "Reification Node (_:statement)",
|
| 96 |
rdfLit: "Literal (xsd:int timestamp)",
|
| 97 |
-
rdfPred: "RDF Predicate"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
| 99 |
},
|
| 100 |
ru: {
|
| 101 |
ontoTitle: "Онтология:",
|
| 102 |
graphTitle: "Модель данных:",
|
| 103 |
engineTitle: "Движок:",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
stepBtn: "Зафиксировать шаг (T+1)",
|
| 105 |
parent: "Родитель:",
|
| 106 |
partPlaceholder: "Имя компонента",
|
|
@@ -119,6 +194,20 @@ export const i18n = {
|
|
| 119 |
loadBtn: "📂 Загрузить JSON",
|
| 120 |
queryTitle: "Запрос к БД",
|
| 121 |
queryDesc: "Показать текущую структуру (T = T_now)",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
tooltips: {
|
| 123 |
urmsm: "<b>URMSM (Dimension & Aspect)</b><br/>Уровень точки зрения пользователя (ISO 42010). Инженер всегда видит чистый срез BOM на момент времени T, абстрагированный от структуры базы данных.",
|
| 124 |
smrm: "<b>SMRM (Concept Repository)</b><br/>Онтология предметной области (Domain Ontology). Общий словарь понятий проекта (System, Component, Physical Object). Зафиксирована на базовой декомпозиции.",
|
|
@@ -133,14 +222,27 @@ export const i18n = {
|
|
| 133 |
bfoElem: "Континуант / Компонент (:Element)",
|
| 134 |
bfoActiveEdge: "Активная связь [действует сейчас]",
|
| 135 |
bfoPastEdge: "Архивная связь (закрыта)",
|
|
|
|
|
|
|
| 136 |
iso4d: "4D-индивид (Пространственно-временной объем)",
|
| 137 |
isoState: "Темпоральный срез / Состояние",
|
| 138 |
isoPartRel: "Вневременной состав (hasPart)",
|
| 139 |
isoSliceRel: "temporalPartOf (связь с 4D-целым)",
|
| 140 |
isoTransitionRel: "TRANSITION_TO (цепочка состояний в LPG)",
|
|
|
|
|
|
|
| 141 |
rdfStmt: "Узел реификации (_:statement)",
|
| 142 |
rdfLit: "Литерал (метка времени xsd:int)",
|
| 143 |
-
rdfPred: "RDF-предикат"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
}
|
| 145 |
}
|
| 146 |
};
|
|
|
|
| 9 |
ontoTitle: "Ontologi:",
|
| 10 |
graphTitle: "Datamodell:",
|
| 11 |
engineTitle: "Grafmotor:",
|
| 12 |
+
viewTitle: "Perspektiv:",
|
| 13 |
+
viewSmrm: "Ingenjör (SMRM)",
|
| 14 |
+
viewLogical: "Logisk (SMIM)",
|
| 15 |
+
viewPhysical: "Fysisk (SMS)",
|
| 16 |
+
viewSmrmCaption: "Ingenjörsperspektiv (SMRM)",
|
| 17 |
+
viewLogicalCaption: "Logiskt perspektiv (SMIM)",
|
| 18 |
+
viewPhysicalCaption: "Fysiskt perspektiv (SMS)",
|
| 19 |
stepBtn: "Lås steg (T+1)",
|
| 20 |
parent: "Överordnad:",
|
| 21 |
partPlaceholder: "Komponentnamn",
|
|
|
|
| 34 |
loadBtn: "📂 Ladda JSON",
|
| 35 |
queryTitle: "Databasfråga",
|
| 36 |
queryDesc: "Visa aktuell struktur (T = T_nu)",
|
| 37 |
+
ontoNaive: "Naiv Graf",
|
| 38 |
+
ontoNaiveNode: "Naiv Graf (Node)",
|
| 39 |
+
ontoNaiveEdge: "Naiv Graf (Edge)",
|
| 40 |
+
nodeClass: "Klass:",
|
| 41 |
+
nodeIdPlaceholder: "Nod-ID",
|
| 42 |
+
addNodeBtn: "+ Nod",
|
| 43 |
+
relTypeLabel: "Relation:",
|
| 44 |
+
addRelBtn: "+ Relation",
|
| 45 |
+
propTarget: "Mål:",
|
| 46 |
+
propKeyPlaceholder: "Nyckel (t.ex. crack)",
|
| 47 |
+
propValPlaceholder: "Värde (t.ex. 2mm)",
|
| 48 |
+
addPropBtn: "+ Egenskap",
|
| 49 |
+
targetNode: "Nod",
|
| 50 |
+
targetEdge: "Relation",
|
| 51 |
tooltips: {
|
| 52 |
urmsm: "<b>URMSM (Dimension & Aspect)</b><br/>Definierar intressentens perspektiv (ISO 42010 Viewpoint). Användaren ser bara BOM-strukturen vid tidpunkten T, oavsett underliggande IT-lager.",
|
| 53 |
smrm: "<b>SMRM (Concept Repository)</b><br/>Domänontologi och gemensam begreppsbank (System, Component, Physical/Functional Object). Här låst till standardiserad produktnedbrytning.",
|
|
|
|
| 62 |
bfoElem: "Continuant / Komponent (:Element)",
|
| 63 |
bfoActiveEdge: "Aktiv relation [giltig till nu]",
|
| 64 |
bfoPastEdge: "Historisk relation (avslutad)",
|
| 65 |
+
bfoQuality: "Kvalitet / Egenskap (:Quality)",
|
| 66 |
+
bfoInheres: "inheres_in (egenskap i bärare)",
|
| 67 |
iso4d: "4D-individ (Spatio-Temporal Extent)",
|
| 68 |
isoState: "Temporal del / Tillstånd (State)",
|
| 69 |
isoPartRel: "Tidlös komposition (hasPart)",
|
| 70 |
isoSliceRel: "temporalPartOf (del av 4D-individ)",
|
| 71 |
isoTransitionRel: "TRANSITION_TO (tillståndskedja i LPG)",
|
| 72 |
+
isoDefect: "Defekt (Tillståndsklassificering)",
|
| 73 |
+
isoDefectRel: "has_defect (tillståndsklassificering)",
|
| 74 |
rdfStmt: "Reifiering (_:statement)",
|
| 75 |
rdfLit: "Literal (tidsstämpel xsd:int)",
|
| 76 |
+
rdfPred: "RDF-predikat",
|
| 77 |
+
naiveVehicle: "Fordon (:Vehicle)",
|
| 78 |
+
naiveSlot: "Plats (:Slot)",
|
| 79 |
+
naivePart: "Komponent (:Part)",
|
| 80 |
+
naiveDefect: "Defekt (:Defect)",
|
| 81 |
+
naiveWarehouse: "Lager (:Warehouse)",
|
| 82 |
+
relHasSlot: "has_slot (fordonsslot)",
|
| 83 |
+
relMountedIn: "mounted_in (monterad i)",
|
| 84 |
+
relStoredAt: "stored_at (lagrad på)",
|
| 85 |
+
relHasDefect: "has_defect (identifierad defekt)"
|
| 86 |
}
|
| 87 |
},
|
| 88 |
en: {
|
| 89 |
ontoTitle: "Ontology:",
|
| 90 |
graphTitle: "Data Model:",
|
| 91 |
engineTitle: "Renderer:",
|
| 92 |
+
viewTitle: "Perspective:",
|
| 93 |
+
viewSmrm: "Engineer (SMRM)",
|
| 94 |
+
viewLogical: "Logical (SMIM)",
|
| 95 |
+
viewPhysical: "Physical (SMS)",
|
| 96 |
+
viewSmrmCaption: "Engineer Perspective (SMRM)",
|
| 97 |
+
viewLogicalCaption: "Logical Perspective (SMIM)",
|
| 98 |
+
viewPhysicalCaption: "Physical Perspective (SMS)",
|
| 99 |
stepBtn: "Commit step (T+1)",
|
| 100 |
parent: "Parent:",
|
| 101 |
partPlaceholder: "Component name",
|
|
|
|
| 114 |
loadBtn: "📂 Load JSON",
|
| 115 |
queryTitle: "Database Query",
|
| 116 |
queryDesc: "Show current structure (T = T_now)",
|
| 117 |
+
ontoNaive: "Naive Graph",
|
| 118 |
+
ontoNaiveNode: "Naive Graph (Node)",
|
| 119 |
+
ontoNaiveEdge: "Naive Graph (Edge)",
|
| 120 |
+
nodeClass: "Class:",
|
| 121 |
+
nodeIdPlaceholder: "Node ID",
|
| 122 |
+
addNodeBtn: "+ Node",
|
| 123 |
+
relTypeLabel: "Relation:",
|
| 124 |
+
addRelBtn: "+ Relation",
|
| 125 |
+
propTarget: "Target:",
|
| 126 |
+
propKeyPlaceholder: "Key (e.g. crack)",
|
| 127 |
+
propValPlaceholder: "Value (e.g. 2mm)",
|
| 128 |
+
addPropBtn: "+ Property",
|
| 129 |
+
targetNode: "Node",
|
| 130 |
+
targetEdge: "Relation",
|
| 131 |
tooltips: {
|
| 132 |
urmsm: "<b>URMSM (Dimension & Aspect)</b><br/>Captures the stakeholder concern and viewpoint (ISO 42010). The engineer always sees a unified BOM snapshot at time T, decoupled from graph mechanics.",
|
| 133 |
smrm: "<b>SMRM (Concept Repository)</b><br/>Domain Ontology: the shared engineering lexicon (System, System Element, Physical/Functional Object). Fixed here to physical decomposition.",
|
|
|
|
| 142 |
bfoElem: "Continuant / Component (:Element)",
|
| 143 |
bfoActiveEdge: "Active relation [valid to now]",
|
| 144 |
bfoPastEdge: "Historical relation (closed)",
|
| 145 |
+
bfoQuality: "Dependent Continuant (:Quality)",
|
| 146 |
+
bfoInheres: "inheres_in (Quality inherence)",
|
| 147 |
iso4d: "4D Individual (Spatio-Temporal Extent)",
|
| 148 |
isoState: "Temporal Part / State",
|
| 149 |
isoPartRel: "Tenseless Composition (hasPart)",
|
| 150 |
isoSliceRel: "temporalPartOf (Extent link)",
|
| 151 |
isoTransitionRel: "TRANSITION_TO (State Chain in LPG)",
|
| 152 |
+
isoDefect: "Defect (State Classification)",
|
| 153 |
+
isoDefectRel: "has_defect (State Classification)",
|
| 154 |
rdfStmt: "Reification Node (_:statement)",
|
| 155 |
rdfLit: "Literal (xsd:int timestamp)",
|
| 156 |
+
rdfPred: "RDF Predicate",
|
| 157 |
+
naiveVehicle: "Vehicle (:Vehicle)",
|
| 158 |
+
naiveSlot: "Slot (:Slot)",
|
| 159 |
+
naivePart: "Part (:Part)",
|
| 160 |
+
naiveDefect: "Defect (:Defect)",
|
| 161 |
+
naiveWarehouse: "Warehouse (:Warehouse)",
|
| 162 |
+
relHasSlot: "has_slot (Vehicle Slot)",
|
| 163 |
+
relMountedIn: "mounted_in (Installed in Slot)",
|
| 164 |
+
relStoredAt: "stored_at (Stored in Warehouse)",
|
| 165 |
+
relHasDefect: "has_defect (Identified Defect)"
|
| 166 |
}
|
| 167 |
},
|
| 168 |
ru: {
|
| 169 |
ontoTitle: "Онтология:",
|
| 170 |
graphTitle: "Модель данных:",
|
| 171 |
engineTitle: "Движок:",
|
| 172 |
+
viewTitle: "Ракурс:",
|
| 173 |
+
viewSmrm: "Инженер (SMRM)",
|
| 174 |
+
viewLogical: "Логический (SMIM)",
|
| 175 |
+
viewPhysical: "Физический (SMS)",
|
| 176 |
+
viewSmrmCaption: "Инженерный ракурс (SMRM)",
|
| 177 |
+
viewLogicalCaption: "Логический ракурс (SMIM)",
|
| 178 |
+
viewPhysicalCaption: "Физический ракурс (SMS)",
|
| 179 |
stepBtn: "Зафиксировать шаг (T+1)",
|
| 180 |
parent: "Родитель:",
|
| 181 |
partPlaceholder: "Имя компонента",
|
|
|
|
| 194 |
loadBtn: "📂 Загрузить JSON",
|
| 195 |
queryTitle: "Запрос к БД",
|
| 196 |
queryDesc: "Показать текущую структуру (T = T_now)",
|
| 197 |
+
ontoNaive: "Наивный граф",
|
| 198 |
+
ontoNaiveNode: "Наивный граф (Узел)",
|
| 199 |
+
ontoNaiveEdge: "Наивный граф (Ребро)",
|
| 200 |
+
nodeClass: "Класс:",
|
| 201 |
+
nodeIdPlaceholder: "ID узла",
|
| 202 |
+
addNodeBtn: "+ Узел",
|
| 203 |
+
relTypeLabel: "Связь:",
|
| 204 |
+
addRelBtn: "+ Связь",
|
| 205 |
+
propTarget: "Цель:",
|
| 206 |
+
propKeyPlaceholder: "Ключ (напр. crack)",
|
| 207 |
+
propValPlaceholder: "Значение (напр. 2mm)",
|
| 208 |
+
addPropBtn: "+ Свойство",
|
| 209 |
+
targetNode: "Узел",
|
| 210 |
+
targetEdge: "Связь",
|
| 211 |
tooltips: {
|
| 212 |
urmsm: "<b>URMSM (Dimension & Aspect)</b><br/>Уровень точки зрения пользователя (ISO 42010). Инженер всегда видит чистый срез BOM на момент времени T, абстрагированный от структуры базы данных.",
|
| 213 |
smrm: "<b>SMRM (Concept Repository)</b><br/>Онтология предметной области (Domain Ontology). Общий словарь понятий проекта (System, Component, Physical Object). Зафиксирована на базовой декомпозиции.",
|
|
|
|
| 222 |
bfoElem: "Континуант / Компонент (:Element)",
|
| 223 |
bfoActiveEdge: "Активная связь [действует сейчас]",
|
| 224 |
bfoPastEdge: "Архивная связь (закрыта)",
|
| 225 |
+
bfoQuality: "Зависимый континуант (:Quality)",
|
| 226 |
+
bfoInheres: "inheres_in (присущ носителю)",
|
| 227 |
iso4d: "4D-индивид (Пространственно-временной объем)",
|
| 228 |
isoState: "Темпоральный срез / Состояние",
|
| 229 |
isoPartRel: "Вневременной состав (hasPart)",
|
| 230 |
isoSliceRel: "temporalPartOf (связь с 4D-целым)",
|
| 231 |
isoTransitionRel: "TRANSITION_TO (цепочка состояний в LPG)",
|
| 232 |
+
isoDefect: "Дефект (Классификация среза)",
|
| 233 |
+
isoDefectRel: "has_defect (классификация среза)",
|
| 234 |
rdfStmt: "Узел реификации (_:statement)",
|
| 235 |
rdfLit: "Литерал (метка времени xsd:int)",
|
| 236 |
+
rdfPred: "RDF-предикат",
|
| 237 |
+
naiveVehicle: "Транспорт (:Vehicle)",
|
| 238 |
+
naiveSlot: "Слот (:Slot)",
|
| 239 |
+
naivePart: "Деталь (:Part)",
|
| 240 |
+
naiveDefect: "Дефект (:Defect)",
|
| 241 |
+
naiveWarehouse: "Склад (:Warehouse)",
|
| 242 |
+
relHasSlot: "has_slot (слот транспорта)",
|
| 243 |
+
relMountedIn: "mounted_in (установлен в)",
|
| 244 |
+
relStoredAt: "stored_at (хранится на складе)",
|
| 245 |
+
relHasDefect: "has_defect (выявлен дефект)"
|
| 246 |
}
|
| 247 |
}
|
| 248 |
};
|
js/renderers/mermaid-adapter.js
CHANGED
|
@@ -79,50 +79,185 @@ function buildMermaidDefinition(semanticGraph) {
|
|
| 79 |
def += ' classDef default fill:#f8fafc,stroke:#cbd5e1,color:#334155,stroke-width:1px\n';
|
| 80 |
def += ' classDef bfoSys fill:#0284c7,stroke:#0369a1,color:#ffffff,stroke-width:2px\n';
|
| 81 |
def += ' classDef bfoElem fill:#64748b,stroke:#475569,color:#ffffff,stroke-width:1px\n';
|
|
|
|
|
|
|
|
|
|
| 82 |
def += ' classDef iso4d fill:#4f46e5,stroke:#3730a3,color:#ffffff,stroke-width:2px\n';
|
| 83 |
-
def += ' classDef isoState fill:#0d9488,stroke:#0f766e,color:#ffffff,stroke-width:1px\n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
// 2. Add Nodes
|
| 86 |
-
semanticGraph.nodes.forEach(node => {
|
| 87 |
const safeId = sanitizeId(node.id);
|
| 88 |
const styleClass = getNodeClass(node);
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
});
|
| 93 |
|
| 94 |
def += '\n';
|
| 95 |
|
| 96 |
-
//
|
| 97 |
-
|
|
|
|
| 98 |
const safeFrom = sanitizeId(edge.from);
|
| 99 |
const safeTo = sanitizeId(edge.to);
|
| 100 |
const isCurrent = edge.properties?.isCurrent !== false;
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
// Escape quotes in the label
|
| 106 |
-
const safeEdgeLabel =
|
|
|
|
|
|
|
| 107 |
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
});
|
| 110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
return def;
|
| 112 |
}
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
/**
|
| 115 |
* Maps ontological node types to Mermaid CSS classes.
|
| 116 |
*/
|
| 117 |
function getNodeClass(node) {
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
case 'MaterialEntity':
|
| 120 |
return node.properties?.entityType === 'system' ? 'bfoSys' : 'bfoElem';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
case 'ActualIndividual':
|
| 122 |
return 'iso4d';
|
| 123 |
case 'State':
|
| 124 |
return 'isoState';
|
| 125 |
default:
|
|
|
|
|
|
|
| 126 |
return 'default';
|
| 127 |
}
|
| 128 |
}
|
|
|
|
| 79 |
def += ' classDef default fill:#f8fafc,stroke:#cbd5e1,color:#334155,stroke-width:1px\n';
|
| 80 |
def += ' classDef bfoSys fill:#0284c7,stroke:#0369a1,color:#ffffff,stroke-width:2px\n';
|
| 81 |
def += ' classDef bfoElem fill:#64748b,stroke:#475569,color:#ffffff,stroke-width:1px\n';
|
| 82 |
+
def += ' classDef bfoQuality fill:#f59e0b,stroke:#d97706,color:#000000,stroke-width:2px\n';
|
| 83 |
+
def += ' classDef rdfStmt fill:#f59e0b,stroke:#d97706,color:#000000,stroke-width:1px\n';
|
| 84 |
+
def += ' classDef rdfLit fill:#f1f5f9,stroke:#cbd5e1,color:#334155,stroke-dasharray:3 3\n';
|
| 85 |
def += ' classDef iso4d fill:#4f46e5,stroke:#3730a3,color:#ffffff,stroke-width:2px\n';
|
| 86 |
+
def += ' classDef isoState fill:#0d9488,stroke:#0f766e,color:#ffffff,stroke-width:1px\n';
|
| 87 |
+
def += ' classDef naiveVehicle fill:#0284c7,stroke:#0369a1,color:#ffffff,stroke-width:2px\n';
|
| 88 |
+
def += ' classDef naiveSlot fill:#64748b,stroke:#475569,color:#ffffff,stroke-width:1px\n';
|
| 89 |
+
def += ' classDef naivePart fill:#10b981,stroke:#059669,color:#ffffff,stroke-width:2px\n';
|
| 90 |
+
def += ' classDef naiveDefect fill:#ef4444,stroke:#dc2626,color:#ffffff,stroke-width:2px\n';
|
| 91 |
+
def += ' classDef naiveWarehouse fill:#f97316,stroke:#ea580c,color:#ffffff,stroke-width:2px\n\n';
|
| 92 |
|
| 93 |
+
// 2. Add Nodes directly from the Semantic Graph (pure renderer)
|
| 94 |
+
(semanticGraph.nodes || []).forEach(node => {
|
| 95 |
const safeId = sanitizeId(node.id);
|
| 96 |
const styleClass = getNodeClass(node);
|
| 97 |
+
let labelText = node.label || '';
|
| 98 |
+
if (node.properties) {
|
| 99 |
+
const customProps = Object.entries(node.properties).filter(
|
| 100 |
+
([k]) => !['isCurrent', 'originalId', 'entityType', 'validFrom', 'validTo', 'ownerId'].includes(k)
|
| 101 |
+
);
|
| 102 |
+
if (customProps.length > 0) {
|
| 103 |
+
const propStr = customProps.map(([k, v]) => `${k}: ${v}`).join(', ');
|
| 104 |
+
labelText = `${labelText} {${propStr}}`;
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
const safeLabel = labelText
|
| 108 |
+
.replace(/\n/g, '<br/>')
|
| 109 |
+
.replace(/"/g, '"');
|
| 110 |
+
|
| 111 |
+
let shapeOpen = '["';
|
| 112 |
+
let shapeClose = '"]';
|
| 113 |
|
| 114 |
+
const entityType = node.type || node.properties?.entityClass;
|
| 115 |
+
if (entityType === 'TemporalPartMembership' || entityType === 'RelationalQuality' || entityType === 'Defect' || /^def/i.test(node.id)) {
|
| 116 |
+
shapeOpen = '{{"'; // Rhombus / diamond shape
|
| 117 |
+
shapeClose = '"}}';
|
| 118 |
+
} else if (entityType === 'Literal' || entityType === 'Quality' || entityType === 'DependentContinuant' || /^qual/i.test(node.id)) {
|
| 119 |
+
shapeOpen = '(["'; // Oval / capsule shape for Quality and Literals
|
| 120 |
+
shapeClose = '"])';
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
def += ` ${safeId}${shapeOpen}<b>${safeLabel}</b><br/><i>${entityType || 'Node'}</i>${shapeClose}:::${styleClass}\n`;
|
| 124 |
});
|
| 125 |
|
| 126 |
def += '\n';
|
| 127 |
|
| 128 |
+
// 4. Add Edges and collect explicit linkStyle declarations
|
| 129 |
+
const linkStyles = [];
|
| 130 |
+
(semanticGraph.edges || []).forEach((edge, idx) => {
|
| 131 |
const safeFrom = sanitizeId(edge.from);
|
| 132 |
const safeTo = sanitizeId(edge.to);
|
| 133 |
const isCurrent = edge.properties?.isCurrent !== false;
|
| 134 |
|
| 135 |
+
let linkArrow = '-->';
|
| 136 |
+
if (edge.type === 'transition') {
|
| 137 |
+
linkArrow = '==>'; // Thick arrow for LPG state transitions
|
| 138 |
+
} else if (!isCurrent || edge.type === 'classification' || edge.type === 'reification' || edge.type === 'predicate') {
|
| 139 |
+
linkArrow = '-.->'; // Dashed line for inactive, classification, or reification links
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// Format edge label and append custom properties (e.g. defect observations) if present
|
| 143 |
+
let rawLabel = edge.label || '';
|
| 144 |
+
if (edge.properties) {
|
| 145 |
+
const customEdgeProps = Object.entries(edge.properties).filter(
|
| 146 |
+
([k]) => !['isCurrent', 'validFrom', 'validTo', 'originalId', 'ownerId', 'entityType', 'childId', 'parentId'].includes(k)
|
| 147 |
+
);
|
| 148 |
+
if (customEdgeProps.length > 0) {
|
| 149 |
+
const propStr = customEdgeProps.map(([k, v]) => `${k}: ${v}`).join(', ');
|
| 150 |
+
rawLabel = `${rawLabel}\\n{${propStr}}`;
|
| 151 |
+
}
|
| 152 |
+
}
|
| 153 |
|
| 154 |
// Escape quotes in the label
|
| 155 |
+
const safeEdgeLabel = rawLabel.replace(/"/g, "'");
|
| 156 |
+
|
| 157 |
+
def += ` ${safeFrom} ${linkArrow}|"${safeEdgeLabel}"| ${safeTo}\n`;
|
| 158 |
|
| 159 |
+
// Calculate edge colour and line styling to match the legend
|
| 160 |
+
const style = getMermaidEdgeStyle(edge);
|
| 161 |
+
let styleDecl = `stroke:${style.stroke},stroke-width:${style.width}px`;
|
| 162 |
+
if (style.dash) {
|
| 163 |
+
styleDecl += `,stroke-dasharray:${style.dash}`;
|
| 164 |
+
}
|
| 165 |
+
linkStyles.push(` linkStyle ${idx} ${styleDecl};`);
|
| 166 |
});
|
| 167 |
|
| 168 |
+
if (linkStyles.length > 0) {
|
| 169 |
+
def += '\n' + linkStyles.join('\n') + '\n';
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
return def;
|
| 173 |
}
|
| 174 |
|
| 175 |
+
/**
|
| 176 |
+
* Determines the stroke colour, width, and dash style for a Mermaid edge.
|
| 177 |
+
* Perfectly synchronises canvas edge rendering with the UI legend colours.
|
| 178 |
+
*
|
| 179 |
+
* @param {Object} edge - Canonical semantic edge.
|
| 180 |
+
* @returns {{ stroke: string, width: number, dash?: string }} Styling descriptor.
|
| 181 |
+
*/
|
| 182 |
+
function getMermaidEdgeStyle(edge) {
|
| 183 |
+
const isCurrent = edge.properties?.isCurrent !== false;
|
| 184 |
+
|
| 185 |
+
if (!isCurrent) {
|
| 186 |
+
return { stroke: '#94a3b8', width: 1, dash: '4 4' };
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
const rel = (edge.type || '').toLowerCase();
|
| 190 |
+
const label = (edge.label || '').toLowerCase();
|
| 191 |
+
|
| 192 |
+
if (rel === 'has_defect' || label === 'has_defect' || label === 'defect') {
|
| 193 |
+
return { stroke: '#ef4444', width: 2 }; // Red
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
if (rel === 'inherence' || label === 'inheres_in' || label === 'bearer_of') {
|
| 197 |
+
return { stroke: '#f59e0b', width: 2 }; // Amber
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
if (rel === 'has_slot' || label === 'has_slot') {
|
| 201 |
+
return { stroke: '#0284c7', width: 2 }; // Blue
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
if (rel === 'mounted_in' || label === 'mounted_in') {
|
| 205 |
+
return { stroke: '#10b981', width: 2 }; // Green
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
if (rel === 'stored_at' || label === 'stored_at') {
|
| 209 |
+
return { stroke: '#f97316', width: 2 }; // Orange
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
if (rel === 'composition' || rel === 'has_part' || label === 'has_part' || label === 'haspart' || label === 'partof') {
|
| 213 |
+
return { stroke: '#10b981', width: 2 }; // Emerald green
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
if (rel === 'transition') {
|
| 217 |
+
return { stroke: '#f59e0b', width: 2 }; // Amber
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
if (rel === 'classification' || rel === 'reification' || rel === 'predicate' || label === 'temporalpartof') {
|
| 221 |
+
return { stroke: '#94a3b8', width: 1, dash: '3 3' };
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
return { stroke: '#94a3b8', width: 1 };
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
/**
|
| 228 |
* Maps ontological node types to Mermaid CSS classes.
|
| 229 |
*/
|
| 230 |
function getNodeClass(node) {
|
| 231 |
+
const entityType = node.type || node.properties?.entityClass || node.properties?.entityType;
|
| 232 |
+
|
| 233 |
+
switch (entityType) {
|
| 234 |
+
case 'Vehicle':
|
| 235 |
+
return 'naiveVehicle';
|
| 236 |
+
case 'Slot':
|
| 237 |
+
return 'naiveSlot';
|
| 238 |
+
case 'Part':
|
| 239 |
+
return 'naivePart';
|
| 240 |
+
case 'Defect':
|
| 241 |
+
return 'naiveDefect';
|
| 242 |
+
case 'Warehouse':
|
| 243 |
+
return 'naiveWarehouse';
|
| 244 |
case 'MaterialEntity':
|
| 245 |
return node.properties?.entityType === 'system' ? 'bfoSys' : 'bfoElem';
|
| 246 |
+
case 'Quality':
|
| 247 |
+
case 'DependentContinuant':
|
| 248 |
+
return 'bfoQuality';
|
| 249 |
+
case 'RelationalQuality':
|
| 250 |
+
case 'TemporalPartMembership':
|
| 251 |
+
return 'rdfStmt';
|
| 252 |
+
case 'Literal':
|
| 253 |
+
return 'rdfLit';
|
| 254 |
case 'ActualIndividual':
|
| 255 |
return 'iso4d';
|
| 256 |
case 'State':
|
| 257 |
return 'isoState';
|
| 258 |
default:
|
| 259 |
+
if (/^def/i.test(node.id)) return 'naiveDefect';
|
| 260 |
+
if (/^qual/i.test(node.id)) return 'bfoQuality';
|
| 261 |
return 'default';
|
| 262 |
}
|
| 263 |
}
|
js/renderers/vis-adapter.js
CHANGED
|
@@ -17,6 +17,10 @@ const visEdges = new vis.DataSet();
|
|
| 17 |
* @param {HTMLElement} container - The DOM element to host the canvas.
|
| 18 |
*/
|
| 19 |
export function initVisNetwork(container) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
const data = { nodes: visNodes, edges: visEdges };
|
| 21 |
network = new vis.Network(container, data, getBaseOptions(false));
|
| 22 |
}
|
|
@@ -40,19 +44,39 @@ export function updateVisNetwork(semanticGraph, isComplex = false) {
|
|
| 40 |
visNodes.clear();
|
| 41 |
visEdges.clear();
|
| 42 |
|
| 43 |
-
// 1. Map and style Nodes
|
| 44 |
-
const styledNodes = semanticGraph.nodes.map(node => {
|
| 45 |
const style = getNodeStyle(node);
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
id: node.id,
|
| 48 |
-
label:
|
| 49 |
shape: style.shape,
|
| 50 |
color: style.color,
|
| 51 |
font: style.font,
|
| 52 |
-
size: style.size,
|
| 53 |
-
margin: 10,
|
| 54 |
borderWidth: 1.5
|
| 55 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
});
|
| 57 |
visNodes.add(styledNodes);
|
| 58 |
|
|
@@ -77,11 +101,23 @@ export function updateVisNetwork(semanticGraph, isComplex = false) {
|
|
| 77 |
|
| 78 |
const style = getEdgeStyle(edge);
|
| 79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
styledEdges.push({
|
| 81 |
id: edge.id,
|
| 82 |
from: edge.from,
|
| 83 |
to: edge.to,
|
| 84 |
-
label:
|
| 85 |
color: style.color,
|
| 86 |
dashes: style.dashes,
|
| 87 |
width: style.width,
|
|
@@ -102,7 +138,46 @@ export function updateVisNetwork(semanticGraph, isComplex = false) {
|
|
| 102 |
* @returns {Object} Vis.js node styling object.
|
| 103 |
*/
|
| 104 |
function getNodeStyle(node) {
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
// BFO 3D Continuants
|
| 107 |
case 'MaterialEntity': {
|
| 108 |
const isSystem = node.properties?.entityType === 'system';
|
|
@@ -113,6 +188,34 @@ function getNodeStyle(node) {
|
|
| 113 |
};
|
| 114 |
}
|
| 115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
// ISO 15926 4D Perdurants
|
| 117 |
case 'ActualIndividual':
|
| 118 |
return {
|
|
@@ -128,8 +231,15 @@ function getNodeStyle(node) {
|
|
| 128 |
font: { color: '#ffffff' }
|
| 129 |
};
|
| 130 |
|
| 131 |
-
default:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
return { shape: 'box', color: '#94a3b8', font: { color: '#ffffff' } };
|
|
|
|
| 133 |
}
|
| 134 |
}
|
| 135 |
|
|
@@ -143,16 +253,61 @@ function getEdgeStyle(edge) {
|
|
| 143 |
const isCurrent = edge.properties?.isCurrent !== false;
|
| 144 |
|
| 145 |
switch (edge.type) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
case 'composition':
|
|
|
|
| 147 |
return {
|
| 148 |
color: isCurrent ? { color: '#10b981' } : { color: '#cbd5e1' }, // Emerald active, Slate past
|
| 149 |
dashes: !isCurrent,
|
| 150 |
width: isCurrent ? 2 : 1
|
| 151 |
};
|
| 152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
case 'classification':
|
|
|
|
|
|
|
| 154 |
return {
|
| 155 |
-
color: { color: '#94a3b8' }, // Subtle slate for structural 4D
|
| 156 |
dashes: !isCurrent,
|
| 157 |
width: 1
|
| 158 |
};
|
|
|
|
| 17 |
* @param {HTMLElement} container - The DOM element to host the canvas.
|
| 18 |
*/
|
| 19 |
export function initVisNetwork(container) {
|
| 20 |
+
if (network) {
|
| 21 |
+
network.destroy();
|
| 22 |
+
network = null;
|
| 23 |
+
}
|
| 24 |
const data = { nodes: visNodes, edges: visEdges };
|
| 25 |
network = new vis.Network(container, data, getBaseOptions(false));
|
| 26 |
}
|
|
|
|
| 44 |
visNodes.clear();
|
| 45 |
visEdges.clear();
|
| 46 |
|
| 47 |
+
// 1. Map and style Nodes directly from the Semantic Graph (pure renderer)
|
| 48 |
+
const styledNodes = (semanticGraph.nodes || []).map(node => {
|
| 49 |
const style = getNodeStyle(node);
|
| 50 |
+
|
| 51 |
+
// Display custom properties directly on the node label if present
|
| 52 |
+
let displayLabel = node.label || node.id;
|
| 53 |
+
if (node.properties) {
|
| 54 |
+
const customProps = Object.entries(node.properties).filter(
|
| 55 |
+
([k]) => !['isCurrent', 'originalId', 'entityType', 'validFrom', 'validTo', 'ownerId'].includes(k)
|
| 56 |
+
);
|
| 57 |
+
if (customProps.length > 0) {
|
| 58 |
+
const propStr = customProps.map(([k, v]) => `${k}: ${v}`).join(', ');
|
| 59 |
+
displayLabel = `${displayLabel}\n{${propStr}}`;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
const styledNode = {
|
| 64 |
id: node.id,
|
| 65 |
+
label: displayLabel,
|
| 66 |
shape: style.shape,
|
| 67 |
color: style.color,
|
| 68 |
font: style.font,
|
|
|
|
|
|
|
| 69 |
borderWidth: 1.5
|
| 70 |
};
|
| 71 |
+
|
| 72 |
+
if (style.size !== undefined) {
|
| 73 |
+
styledNode.size = style.size;
|
| 74 |
+
}
|
| 75 |
+
if (style.shape === 'box' || style.shape === 'ellipse') {
|
| 76 |
+
styledNode.margin = 10;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
return styledNode;
|
| 80 |
});
|
| 81 |
visNodes.add(styledNodes);
|
| 82 |
|
|
|
|
| 101 |
|
| 102 |
const style = getEdgeStyle(edge);
|
| 103 |
|
| 104 |
+
// Display custom properties directly on the edge label if present
|
| 105 |
+
let displayEdgeLabel = edge.label;
|
| 106 |
+
if (edge.properties) {
|
| 107 |
+
const customEdgeProps = Object.entries(edge.properties).filter(
|
| 108 |
+
([k]) => !['isCurrent', 'validFrom', 'validTo'].includes(k)
|
| 109 |
+
);
|
| 110 |
+
if (customEdgeProps.length > 0) {
|
| 111 |
+
const propStr = customEdgeProps.map(([k, v]) => `${k}: ${v}`).join(', ');
|
| 112 |
+
displayEdgeLabel = `${displayEdgeLabel} {${propStr}}`;
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
styledEdges.push({
|
| 117 |
id: edge.id,
|
| 118 |
from: edge.from,
|
| 119 |
to: edge.to,
|
| 120 |
+
label: displayEdgeLabel,
|
| 121 |
color: style.color,
|
| 122 |
dashes: style.dashes,
|
| 123 |
width: style.width,
|
|
|
|
| 138 |
* @returns {Object} Vis.js node styling object.
|
| 139 |
*/
|
| 140 |
function getNodeStyle(node) {
|
| 141 |
+
const entityType = node.type || node.properties?.entityClass || node.properties?.entityType;
|
| 142 |
+
|
| 143 |
+
switch (entityType) {
|
| 144 |
+
// Specific Manufacturing Domain Classes (Naive Mode)
|
| 145 |
+
case 'Vehicle':
|
| 146 |
+
return {
|
| 147 |
+
shape: 'box',
|
| 148 |
+
color: '#0284c7', // Blue
|
| 149 |
+
font: { color: '#ffffff', bold: true }
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
case 'Slot':
|
| 153 |
+
return {
|
| 154 |
+
shape: 'box',
|
| 155 |
+
color: '#64748b', // Grey
|
| 156 |
+
font: { color: '#ffffff' }
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
case 'Part':
|
| 160 |
+
return {
|
| 161 |
+
shape: 'box',
|
| 162 |
+
color: '#10b981', // Green
|
| 163 |
+
font: { color: '#ffffff', bold: true }
|
| 164 |
+
};
|
| 165 |
+
|
| 166 |
+
case 'Defect':
|
| 167 |
+
return {
|
| 168 |
+
shape: 'diamond',
|
| 169 |
+
size: 25,
|
| 170 |
+
color: '#ef4444', // Red
|
| 171 |
+
font: { color: '#ffffff', bold: true }
|
| 172 |
+
};
|
| 173 |
+
|
| 174 |
+
case 'Warehouse':
|
| 175 |
+
return {
|
| 176 |
+
shape: 'box',
|
| 177 |
+
color: '#f97316', // Orange
|
| 178 |
+
font: { color: '#ffffff', bold: true }
|
| 179 |
+
};
|
| 180 |
+
|
| 181 |
// BFO 3D Continuants
|
| 182 |
case 'MaterialEntity': {
|
| 183 |
const isSystem = node.properties?.entityType === 'system';
|
|
|
|
| 188 |
};
|
| 189 |
}
|
| 190 |
|
| 191 |
+
case 'Quality':
|
| 192 |
+
case 'DependentContinuant':
|
| 193 |
+
return {
|
| 194 |
+
shape: 'diamond',
|
| 195 |
+
size: 25,
|
| 196 |
+
color: '#f59e0b', // Amber / orange for Dependent Continuant
|
| 197 |
+
font: { color: '#000000', bold: true }
|
| 198 |
+
};
|
| 199 |
+
|
| 200 |
+
// W3C RDF Reification and Literals (SMS physical layer)
|
| 201 |
+
case 'RelationalQuality':
|
| 202 |
+
case 'TemporalPartMembership': {
|
| 203 |
+
const isStmtActive = node.properties?.isCurrent !== false;
|
| 204 |
+
return {
|
| 205 |
+
shape: 'diamond',
|
| 206 |
+
size: 15,
|
| 207 |
+
color: isStmtActive ? '#f59e0b' : '#e2e8f0', // Amber if active, light grey if past
|
| 208 |
+
font: { size: 10, color: isStmtActive ? '#000000' : '#64748b', bold: true }
|
| 209 |
+
};
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
case 'Literal':
|
| 213 |
+
return {
|
| 214 |
+
shape: 'ellipse', // Oval shape
|
| 215 |
+
color: '#f8fafc',
|
| 216 |
+
font: { size: 8, color: '#334155' }
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
// ISO 15926 4D Perdurants
|
| 220 |
case 'ActualIndividual':
|
| 221 |
return {
|
|
|
|
| 231 |
font: { color: '#ffffff' }
|
| 232 |
};
|
| 233 |
|
| 234 |
+
default: {
|
| 235 |
+
if (/^def/i.test(node.id)) {
|
| 236 |
+
return { shape: 'diamond', color: '#ef4444', font: { color: '#ffffff', bold: true } };
|
| 237 |
+
}
|
| 238 |
+
if (/^qual/i.test(node.id)) {
|
| 239 |
+
return { shape: 'diamond', color: '#f59e0b', font: { color: '#000000', bold: true } };
|
| 240 |
+
}
|
| 241 |
return { shape: 'box', color: '#94a3b8', font: { color: '#ffffff' } };
|
| 242 |
+
}
|
| 243 |
}
|
| 244 |
}
|
| 245 |
|
|
|
|
| 253 |
const isCurrent = edge.properties?.isCurrent !== false;
|
| 254 |
|
| 255 |
switch (edge.type) {
|
| 256 |
+
case 'has_slot':
|
| 257 |
+
return {
|
| 258 |
+
color: isCurrent ? { color: '#0284c7' } : { color: '#cbd5e1' }, // Blue
|
| 259 |
+
dashes: !isCurrent,
|
| 260 |
+
width: isCurrent ? 2 : 1
|
| 261 |
+
};
|
| 262 |
+
|
| 263 |
+
case 'mounted_in':
|
| 264 |
+
return {
|
| 265 |
+
color: isCurrent ? { color: '#10b981' } : { color: '#cbd5e1' }, // Green
|
| 266 |
+
dashes: !isCurrent,
|
| 267 |
+
width: isCurrent ? 2 : 1
|
| 268 |
+
};
|
| 269 |
+
|
| 270 |
+
case 'stored_at':
|
| 271 |
+
return {
|
| 272 |
+
color: isCurrent ? { color: '#f97316' } : { color: '#cbd5e1' }, // Orange
|
| 273 |
+
dashes: !isCurrent,
|
| 274 |
+
width: isCurrent ? 2 : 1
|
| 275 |
+
};
|
| 276 |
+
|
| 277 |
+
case 'has_defect':
|
| 278 |
+
return {
|
| 279 |
+
color: isCurrent ? { color: '#ef4444' } : { color: '#cbd5e1' }, // Red
|
| 280 |
+
dashes: !isCurrent,
|
| 281 |
+
width: 2
|
| 282 |
+
};
|
| 283 |
+
|
| 284 |
+
case 'inherence':
|
| 285 |
+
return {
|
| 286 |
+
color: isCurrent ? { color: '#f59e0b' } : { color: '#cbd5e1' }, // Amber for inheres_in
|
| 287 |
+
dashes: !isCurrent,
|
| 288 |
+
width: 2
|
| 289 |
+
};
|
| 290 |
+
|
| 291 |
case 'composition':
|
| 292 |
+
case 'has_part':
|
| 293 |
return {
|
| 294 |
color: isCurrent ? { color: '#10b981' } : { color: '#cbd5e1' }, // Emerald active, Slate past
|
| 295 |
dashes: !isCurrent,
|
| 296 |
width: isCurrent ? 2 : 1
|
| 297 |
};
|
| 298 |
|
| 299 |
+
case 'transition':
|
| 300 |
+
return {
|
| 301 |
+
color: { color: '#f59e0b' }, // Amber for LPG state transitions
|
| 302 |
+
dashes: false,
|
| 303 |
+
width: 2
|
| 304 |
+
};
|
| 305 |
+
|
| 306 |
case 'classification':
|
| 307 |
+
case 'reification':
|
| 308 |
+
case 'predicate':
|
| 309 |
return {
|
| 310 |
+
color: { color: '#94a3b8' }, // Subtle slate for structural 4D or RDF links
|
| 311 |
dashes: !isCurrent,
|
| 312 |
width: 1
|
| 313 |
};
|
js/scenarios/scenario-vanishing-crack.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* SCENARIO: THE VANISHING CRACK
|
| 3 |
+
* -----------------------------
|
| 4 |
+
* Contains narrative subtitle data and the chronological action timeline
|
| 5 |
+
* synchronised with audio playback.
|
| 6 |
+
*
|
| 7 |
+
* Timestamps are represented in seconds (float).
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
import {
|
| 11 |
+
createRegisterPartEvent,
|
| 12 |
+
createAssembleEvent,
|
| 13 |
+
createReportDefectEvent,
|
| 14 |
+
createDismantleEvent
|
| 15 |
+
} from '../smrm/actions.js';
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Highlights specified UI elements by IDs with a temporary glowing effect.
|
| 19 |
+
* Simulates a Phantom User interacting with the workbench controls.
|
| 20 |
+
*
|
| 21 |
+
* @param {string[]} elementIds - Array of DOM element IDs to highlight.
|
| 22 |
+
* @param {number} [duration=1200] - Duration of the highlight effect in milliseconds.
|
| 23 |
+
*/
|
| 24 |
+
export function highlightUI(elementIds, duration = 1200) {
|
| 25 |
+
if (typeof document === 'undefined' || !Array.isArray(elementIds)) return;
|
| 26 |
+
elementIds.forEach(id => {
|
| 27 |
+
const el = document.getElementById(id);
|
| 28 |
+
if (el) {
|
| 29 |
+
el.classList.add('scenario-highlight');
|
| 30 |
+
setTimeout(() => {
|
| 31 |
+
el.classList.remove('scenario-highlight');
|
| 32 |
+
}, duration);
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
const subtitles = [
|
| 38 |
+
{ start: 0.14, end: 1.84, text: "Welcome to the Data Sandbox." },
|
| 39 |
+
{ start: 2.46, end: 7.50, text: "Currently, the system is operating in naive graph mode. We have no strict" },
|
| 40 |
+
{ start: 7.50, end: 10.62, text: "ontological rules, just nodes and relationships." },
|
| 41 |
+
{ start: 11.26, end: 13.78, text: "Let's model a typical manufacturing scenario." },
|
| 42 |
+
{ start: 15.50, end: 16.38, text: "We have a vehicle." },
|
| 43 |
+
{ start: 17.02, end: 22.02, text: "Within it, there is a suspension slot where part M01 is installed." },
|
| 44 |
+
{ start: 22.64, end: 23.84, text: "Everything is straightforward." },
|
| 45 |
+
{ start: 24.44, end: 27.06, text: "But what happens when a real-world problem occurs?" },
|
| 46 |
+
{ start: 28.62, end: 33.72, text: "During an inspection, a two-millimeter crack is discovered on part M01." },
|
| 47 |
+
{ start: 34.64, end: 37.06, text: "How do we store this fact in a naive graph?" },
|
| 48 |
+
{ start: 38.74, end: 40.44, text: "The developer faces a dilemma." },
|
| 49 |
+
{ start: 41.12, end: 45.72, text: "If we add the property crack two millimeters directly to the part node," },
|
| 50 |
+
{ start: 46.26, end: 50.32, text: "then when we try to query the car's condition a year ago, the system will" },
|
| 51 |
+
{ start: 50.32, end: 55.68, text: "answer that the part was already broken because the node exists outside of time." },
|
| 52 |
+
{ start: 55.68, end: 56.74, text: "It has been overwritten." },
|
| 53 |
+
{ start: 58.58, end: 63.08, text: "The obvious workaround is to attach the defect information to the temporal edge," },
|
| 54 |
+
{ start: 63.66, end: 64.40, text: "mounted_in." },
|
| 55 |
+
{ start: 66.02, end: 71.26, text: "Excellent. The crack is anchored in time. The inspector is satisfied, and the" },
|
| 56 |
+
{ start: 71.26, end: 73.08, text: "database has saved the information." },
|
| 57 |
+
{ start: 74.74, end: 76.26, text: "But then comes the next day." },
|
| 58 |
+
{ start: 77.00, end: 80.76, text: "The part is removed from the vehicle and sent to the warehouse for repair." },
|
| 59 |
+
{ start: 82.46, end: 87.68, text: "The mounting edge is closed and archived. The part is now linked to the warehouse." },
|
| 60 |
+
{ start: 88.46, end: 90.02, text: "Now, let's ask the system," },
|
| 61 |
+
{ start: 90.76, end: 93.60, text: "how many defective parts are currently in the warehouse?" },
|
| 62 |
+
{ start: 95.08, end: 96.14, text: "The system answers" },
|
| 63 |
+
{ start: 96.78, end: 97.20, text: "zero." },
|
| 64 |
+
{ start: 97.86, end: 102.02, text: "The crack has disappeared from the vehicle, but in the warehouse, the part is" },
|
| 65 |
+
{ start: 102.02, end: 106.96, text: "registered as completely flawless. The defect attribute remains buried in the" },
|
| 66 |
+
{ start: 106.96, end: 108.20, text: "archived mounting edge." },
|
| 67 |
+
{ start: 108.84, end: 112.92, text: "Our naive approach has just destroyed critical data about a fault." },
|
| 68 |
+
{ start: 114.50, end: 119.42, text: "This is exactly where the naive approach collapses and an industrial ontology is" },
|
| 69 |
+
{ start: 119.42, end: 124.68, text: "required. We are now switching the system to ISO 15926 mode." },
|
| 70 |
+
{ start: 126.06, end: 131.42, text: "Under this standard, a part is not a static node, but a four-dimensional object" },
|
| 71 |
+
{ start: 131.42, end: 133.08, text: "with temporal life stages." },
|
| 72 |
+
{ start: 133.76, end: 138.78, text: "A defect is an independent entity that classifies the condition of a specific" },
|
| 73 |
+
{ start: 138.78, end: 140.30, text: "temporal stage of the part." },
|
| 74 |
+
{ start: 141.06, end: 146.48, text: "Now, when moved to the warehouse, the part takes its state history with it. Data is" },
|
| 75 |
+
{ start: 146.48, end: 147.42, text: "no longer lost." }
|
| 76 |
+
];
|
| 77 |
+
|
| 78 |
+
export const vanishingCrackScenario = {
|
| 79 |
+
subtitles,
|
| 80 |
+
timeline: [
|
| 81 |
+
// 1. t = 1.0: Initialize Naive Node mode, SMRM perspective, and Mermaid engine
|
| 82 |
+
{
|
| 83 |
+
id: 'step_1_0_init_naive',
|
| 84 |
+
time: 1.0,
|
| 85 |
+
executed: false,
|
| 86 |
+
action(state, renderGraph) {
|
| 87 |
+
state.ontology = 'NAIVE_NODE';
|
| 88 |
+
state.perspective = 'SMRM';
|
| 89 |
+
state.graphEngine = 'MERMAID';
|
| 90 |
+
}
|
| 91 |
+
},
|
| 92 |
+
|
| 93 |
+
// 2. t = 15.5: highlight UI. Action: createRegisterPartEvent('System_A', time)
|
| 94 |
+
{
|
| 95 |
+
id: 'step_15_5_reg_vehicle',
|
| 96 |
+
time: 15.5,
|
| 97 |
+
executed: false,
|
| 98 |
+
action(state, renderGraph) {
|
| 99 |
+
highlightUI(['biz-reg-id', 'biz-reg-btn']);
|
| 100 |
+
state.currentTime = 15.5;
|
| 101 |
+
const event = createRegisterPartEvent('System_A', state.currentTime);
|
| 102 |
+
if (event) {
|
| 103 |
+
state.eventLog.push(event);
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
|
| 108 |
+
// 3. t = 18.0: Audio mentions slot: Simply register Part_M01 and assemble System_A and Part_M01
|
| 109 |
+
// The smart adapters implicitly generate the contextual slot!
|
| 110 |
+
{
|
| 111 |
+
id: 'step_18_0_reg_part_install',
|
| 112 |
+
time: 18.0,
|
| 113 |
+
executed: false,
|
| 114 |
+
action(state, renderGraph) {
|
| 115 |
+
highlightUI(['biz-reg-id', 'biz-inst-btn']);
|
| 116 |
+
state.currentTime = 18.0;
|
| 117 |
+
const regEvent = createRegisterPartEvent('Part_M01', state.currentTime);
|
| 118 |
+
if (regEvent) {
|
| 119 |
+
state.eventLog.push(regEvent);
|
| 120 |
+
}
|
| 121 |
+
const asmEvent = createAssembleEvent('System_A', 'Part_M01', 'mounted_in', state.currentTime);
|
| 122 |
+
if (asmEvent) {
|
| 123 |
+
state.eventLog.push(asmEvent);
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
},
|
| 127 |
+
|
| 128 |
+
// 4. t = 43.0: highlight UI. Action: createReportDefectEvent('Part_M01', 'crack', '2mm', time) -> Adapter will attach to NODE
|
| 129 |
+
{
|
| 130 |
+
id: 'step_43_0_attach_crack_node',
|
| 131 |
+
time: 43.0,
|
| 132 |
+
executed: false,
|
| 133 |
+
action(state, renderGraph) {
|
| 134 |
+
highlightUI(['biz-def-target', 'biz-def-btn']);
|
| 135 |
+
state.currentTime = 43.0;
|
| 136 |
+
const event = createReportDefectEvent('Part_M01', 'crack', '2mm', state.currentTime);
|
| 137 |
+
if (event) {
|
| 138 |
+
state.eventLog.push(event);
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
},
|
| 142 |
+
|
| 143 |
+
// 5. t = 56.5: Revoke the defect
|
| 144 |
+
{
|
| 145 |
+
id: 'step_56_5_revoke_crack_node',
|
| 146 |
+
time: 56.5,
|
| 147 |
+
executed: false,
|
| 148 |
+
action(state, renderGraph) {
|
| 149 |
+
highlightUI(['biz-rev-defect', 'biz-rev-btn']);
|
| 150 |
+
state.currentTime = 56.5;
|
| 151 |
+
const idx = state.eventLog.findIndex(e => e.type === 'REPORT_DEFECT' && e.targetId === 'Part_M01');
|
| 152 |
+
if (idx !== -1) {
|
| 153 |
+
state.eventLog.splice(idx, 1);
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
},
|
| 157 |
+
|
| 158 |
+
// 6. t = 58.5: Switch state.ontology = 'NAIVE_EDGE' and highlight top header button
|
| 159 |
+
{
|
| 160 |
+
id: 'step_58_5_switch_strategy_edge',
|
| 161 |
+
time: 58.5,
|
| 162 |
+
executed: false,
|
| 163 |
+
action(state, renderGraph) {
|
| 164 |
+
highlightUI(['ctrl-onto-naive-edge']);
|
| 165 |
+
state.ontology = 'NAIVE_EDGE';
|
| 166 |
+
}
|
| 167 |
+
},
|
| 168 |
+
|
| 169 |
+
// 7. t = 61.0: highlight UI. Action: createReportDefectEvent('Part_M01', 'crack', '2mm', time) -> Adapter attaches to EDGE
|
| 170 |
+
{
|
| 171 |
+
id: 'step_61_0_attach_crack_edge',
|
| 172 |
+
time: 61.0,
|
| 173 |
+
executed: false,
|
| 174 |
+
action(state, renderGraph) {
|
| 175 |
+
highlightUI(['biz-def-target', 'biz-def-btn']);
|
| 176 |
+
state.currentTime = 61.0;
|
| 177 |
+
const event = createReportDefectEvent('Part_M01', 'crack', '2mm', state.currentTime);
|
| 178 |
+
if (event) {
|
| 179 |
+
state.eventLog.push(event);
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
},
|
| 183 |
+
|
| 184 |
+
// 8. t = 78.0: highlight UI. Action: createDismantleEvent('Part_M01', time)
|
| 185 |
+
{
|
| 186 |
+
id: 'step_78_0_dismantle_part',
|
| 187 |
+
time: 78.0,
|
| 188 |
+
executed: false,
|
| 189 |
+
action(state, renderGraph) {
|
| 190 |
+
highlightUI(['biz-dism-part', 'biz-dism-btn']);
|
| 191 |
+
state.currentTime = 78.0;
|
| 192 |
+
const event = createDismantleEvent('Part_M01', state.currentTime);
|
| 193 |
+
if (event) {
|
| 194 |
+
state.eventLog.push(event);
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
},
|
| 198 |
+
|
| 199 |
+
// 9. t = 82.0: highlight UI. Action: createRegisterPartEvent('Warehouse_1', time)
|
| 200 |
+
{
|
| 201 |
+
id: 'step_82_0_reg_warehouse',
|
| 202 |
+
time: 82.0,
|
| 203 |
+
executed: false,
|
| 204 |
+
action(state, renderGraph) {
|
| 205 |
+
highlightUI(['biz-reg-id', 'biz-reg-btn']);
|
| 206 |
+
state.currentTime = 82.0;
|
| 207 |
+
const event = createRegisterPartEvent('Warehouse_1', state.currentTime);
|
| 208 |
+
if (event) {
|
| 209 |
+
state.eventLog.push(event);
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
},
|
| 213 |
+
|
| 214 |
+
// 10. t = 84.0: highlight UI. Action: createAssembleEvent('Warehouse_1', 'Part_M01', 'stored_at', time)
|
| 215 |
+
{
|
| 216 |
+
id: 'step_84_0_store_part',
|
| 217 |
+
time: 84.0,
|
| 218 |
+
executed: false,
|
| 219 |
+
action(state, renderGraph) {
|
| 220 |
+
highlightUI(['biz-store-part', 'biz-store-target', 'biz-store-btn']);
|
| 221 |
+
state.currentTime = 84.0;
|
| 222 |
+
const event = createAssembleEvent('Warehouse_1', 'Part_M01', 'stored_at', state.currentTime);
|
| 223 |
+
if (event) {
|
| 224 |
+
state.eventLog.push(event);
|
| 225 |
+
}
|
| 226 |
+
}
|
| 227 |
+
},
|
| 228 |
+
|
| 229 |
+
// 11. t = 122.0: highlight UI (ontology switch). Action: state.ontology = 'ISO15926'
|
| 230 |
+
{
|
| 231 |
+
id: 'step_122_0_switch_iso',
|
| 232 |
+
time: 122.0,
|
| 233 |
+
executed: false,
|
| 234 |
+
action(state, renderGraph) {
|
| 235 |
+
highlightUI(['ctrl-onto-iso']);
|
| 236 |
+
state.ontology = 'ISO15926';
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
]
|
| 240 |
+
};
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* Dispatches pending timeline actions based on current playback time.
|
| 244 |
+
* Resolves float chunking using `>= step.time && !step.executed`.
|
| 245 |
+
*
|
| 246 |
+
* @param {number} currentTime - Current audio playback time in seconds.
|
| 247 |
+
* @param {Object} state - The reactive domain state.
|
| 248 |
+
* @param {Function} [renderGraph] - Function to trigger canvas redraw.
|
| 249 |
+
*/
|
| 250 |
+
export function onTimeUpdate(currentTime, state, renderGraph) {
|
| 251 |
+
if (!Array.isArray(vanishingCrackScenario.timeline)) return;
|
| 252 |
+
|
| 253 |
+
vanishingCrackScenario.timeline.forEach(step => {
|
| 254 |
+
if (currentTime >= step.time && !step.executed) {
|
| 255 |
+
console.log('Executing step:', step.time);
|
| 256 |
+
step.executed = true;
|
| 257 |
+
const fn = step.action || step.execute;
|
| 258 |
+
if (typeof fn === 'function') {
|
| 259 |
+
fn(state, renderGraph);
|
| 260 |
+
}
|
| 261 |
+
if (typeof renderGraph === 'function') {
|
| 262 |
+
renderGraph();
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
});
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
/**
|
| 269 |
+
* Resets execution flags on timeline steps when seeking, stopping, or rewinding.
|
| 270 |
+
*
|
| 271 |
+
* @param {number} [targetTime=0] - Audio target time. Steps with step.time >= targetTime are reset to unexecuted.
|
| 272 |
+
*/
|
| 273 |
+
export function resetTimeline(targetTime = 0) {
|
| 274 |
+
if (!Array.isArray(vanishingCrackScenario.timeline)) return;
|
| 275 |
+
vanishingCrackScenario.timeline.forEach(step => {
|
| 276 |
+
if (step.time >= targetTime) {
|
| 277 |
+
step.executed = false;
|
| 278 |
+
}
|
| 279 |
+
});
|
| 280 |
+
}
|
js/smim/bfo.js
CHANGED
|
@@ -1,58 +1,227 @@
|
|
| 1 |
/**
|
| 2 |
* BFO ONTOLOGY ADAPTER (3D Continuant)
|
| 3 |
* ------------------------------------
|
| 4 |
-
* Maps
|
| 5 |
-
* Entities are 'MaterialEntities' that endure through time.
|
| 6 |
-
* Relations are Continuant compositions ('has_part') carrying temporal properties.
|
| 7 |
*
|
| 8 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
*
|
| 10 |
-
* @param {Array} eventLog - The projection of temporal events.
|
| 11 |
-
* @param {Array} baseNodes - The projection of base continuant entities.
|
| 12 |
* @param {number|null} [currentTime=null] - Global time to evaluate current validity.
|
| 13 |
* @returns {{ nodes: Array, edges: Array }} The canonical Semantic Graph.
|
| 14 |
*/
|
| 15 |
|
| 16 |
-
export function generateSemanticGraph(eventLog, baseNodes, currentTime = null) {
|
| 17 |
-
const
|
| 18 |
const edges = [];
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
});
|
| 32 |
|
| 33 |
-
// 2.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
});
|
| 56 |
|
| 57 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
}
|
|
|
|
| 1 |
/**
|
| 2 |
* BFO ONTOLOGY ADAPTER (3D Continuant)
|
| 3 |
* ------------------------------------
|
| 4 |
+
* Maps Domain Business Events into a canonical 3D BFO Semantic Graph.
|
|
|
|
|
|
|
| 5 |
*
|
| 6 |
+
* Ontological Axioms:
|
| 7 |
+
* - Entities (Vehicle, Part, Warehouse) are Independent Continuants ('MaterialEntity')
|
| 8 |
+
* that endure wholly through time without temporal parts or states.
|
| 9 |
+
* - Defect observations are Specifically Dependent Continuants ('Quality')
|
| 10 |
+
* that exist only by inhering in an independent continuant via the 'inheres_in' relation.
|
| 11 |
+
* - Relationships between continuants (mounted_in, stored_at, etc.) hold directly
|
| 12 |
+
* between the continuants at a given time, carrying temporal validity intervals.
|
| 13 |
+
* - Both the Quality node and the 'inheres_in' edge record validFrom: timestamp.
|
| 14 |
+
* - NEVER generates 'State' or 'Temporal Part' nodes.
|
| 15 |
*
|
| 16 |
+
* @param {Array} eventLog - The projection of temporal business events.
|
| 17 |
+
* @param {Array} [baseNodes=[]] - The projection of base continuant entities.
|
| 18 |
* @param {number|null} [currentTime=null] - Global time to evaluate current validity.
|
| 19 |
* @returns {{ nodes: Array, edges: Array }} The canonical Semantic Graph.
|
| 20 |
*/
|
| 21 |
|
| 22 |
+
export function generateSemanticGraph(eventLog = [], baseNodes = [], currentTime = null) {
|
| 23 |
+
const nodeMap = new Map();
|
| 24 |
const edges = [];
|
| 25 |
|
| 26 |
+
function ensureContinuantNode(partId, overrideClass = null) {
|
| 27 |
+
if (!nodeMap.has(partId)) {
|
| 28 |
+
nodeMap.set(partId, {
|
| 29 |
+
id: partId,
|
| 30 |
+
label: partId,
|
| 31 |
+
type: 'MaterialEntity',
|
| 32 |
+
properties: {
|
| 33 |
+
originalId: partId,
|
| 34 |
+
entityClass: overrideClass || inferContinuantClass(partId)
|
| 35 |
+
}
|
| 36 |
+
});
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// 1. Initialise base continuant entities (if provided)
|
| 41 |
+
(baseNodes || []).forEach(bn => {
|
| 42 |
+
ensureContinuantNode(bn.id);
|
| 43 |
});
|
| 44 |
|
| 45 |
+
// 2. Filter and sort business events by timestamp
|
| 46 |
+
const eventsToProcess = (eventLog || [])
|
| 47 |
+
.filter(event => currentTime === null || currentTime === undefined || event.valid_from <= currentTime)
|
| 48 |
+
.slice()
|
| 49 |
+
.sort((a, b) => (a.valid_from || 0) - (b.valid_from || 0));
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
// 3. Process business events in temporal order
|
| 53 |
+
eventsToProcess.forEach(event => {
|
| 54 |
+
switch (event.type) {
|
| 55 |
+
case 'REGISTER_PART': {
|
| 56 |
+
ensureContinuantNode(event.partId);
|
| 57 |
+
break;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
case 'ASSEMBLE': {
|
| 61 |
+
const { parentId, childId } = event;
|
| 62 |
+
const relType = event.relationType || 'mounted_in';
|
| 63 |
+
const timestamp = event.valid_from;
|
| 64 |
+
|
| 65 |
+
ensureContinuantNode(parentId);
|
| 66 |
+
ensureContinuantNode(childId);
|
| 67 |
+
|
| 68 |
+
if (relType === 'stored_at') {
|
| 69 |
+
const edgeId = event.id ? `edge_${event.id}` : `edge_${childId}_${parentId}_${timestamp}`;
|
| 70 |
+
edges.push({
|
| 71 |
+
id: edgeId,
|
| 72 |
+
from: childId,
|
| 73 |
+
to: parentId,
|
| 74 |
+
label: 'stored_at',
|
| 75 |
+
type: 'composition',
|
| 76 |
+
childId,
|
| 77 |
+
parentId,
|
| 78 |
+
properties: {
|
| 79 |
+
validFrom: timestamp,
|
| 80 |
+
validTo: null,
|
| 81 |
+
isCurrent: true
|
| 82 |
+
}
|
| 83 |
+
});
|
| 84 |
+
break;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
// Implicit contextual Slot generation: Slot_${parentId}_${childId}
|
| 88 |
+
const slotId = `Slot_${parentId}_${childId}`;
|
| 89 |
+
ensureContinuantNode(slotId, 'Slot');
|
| 90 |
+
|
| 91 |
+
// Link 1: Parent -> Slot (has_slot)
|
| 92 |
+
const slotEdgeId = `edge_slot_${parentId}_${slotId}_${timestamp}`;
|
| 93 |
+
edges.push({
|
| 94 |
+
id: slotEdgeId,
|
| 95 |
+
from: parentId,
|
| 96 |
+
to: slotId,
|
| 97 |
+
label: 'has_slot',
|
| 98 |
+
type: 'has_slot',
|
| 99 |
+
childId: slotId,
|
| 100 |
+
parentId: parentId,
|
| 101 |
+
properties: {
|
| 102 |
+
validFrom: timestamp,
|
| 103 |
+
validTo: null,
|
| 104 |
+
isCurrent: true
|
| 105 |
+
}
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
// Link 2: Child -> Slot (mounted_in)
|
| 109 |
+
const mountEdgeId = event.id ? `edge_${event.id}` : `edge_${childId}_${slotId}_${timestamp}`;
|
| 110 |
+
edges.push({
|
| 111 |
+
id: mountEdgeId,
|
| 112 |
+
from: childId,
|
| 113 |
+
to: slotId,
|
| 114 |
+
label: 'mounted_in',
|
| 115 |
+
type: 'composition',
|
| 116 |
+
childId: childId,
|
| 117 |
+
parentId: slotId,
|
| 118 |
+
properties: {
|
| 119 |
+
validFrom: timestamp,
|
| 120 |
+
validTo: null,
|
| 121 |
+
isCurrent: true
|
| 122 |
+
}
|
| 123 |
+
});
|
| 124 |
+
break;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
case 'DISMANTLE': {
|
| 128 |
+
const { childId } = event;
|
| 129 |
+
const dismantleTime = event.valid_from;
|
| 130 |
+
|
| 131 |
+
// Locate active assembly relationship for the child component
|
| 132 |
+
const activeEdge = edges.find(
|
| 133 |
+
e => (e.childId === childId || e.from === childId) &&
|
| 134 |
+
(e.label === 'mounted_in' || e.label === 'stored_at') &&
|
| 135 |
+
e.properties.validTo === null
|
| 136 |
+
);
|
| 137 |
+
if (activeEdge) {
|
| 138 |
+
activeEdge.properties.validTo = dismantleTime;
|
| 139 |
+
activeEdge.properties.isCurrent = (currentTime !== null && currentTime !== undefined)
|
| 140 |
+
? dismantleTime > currentTime
|
| 141 |
+
: false;
|
| 142 |
+
} else {
|
| 143 |
+
console.warn(`[SMIM BFO] No active assembly relationship found to dismantle child part: ${childId}`);
|
| 144 |
+
}
|
| 145 |
+
break;
|
| 146 |
+
}
|
| 147 |
|
| 148 |
+
case 'REPORT_DEFECT': {
|
| 149 |
+
const { targetId, defectName, defectValue } = event;
|
| 150 |
+
const timestamp = event.valid_from;
|
| 151 |
+
|
| 152 |
+
ensureContinuantNode(targetId);
|
| 153 |
+
|
| 154 |
+
const qualityId = `qual_${targetId}_${defectName}`;
|
| 155 |
+
const qualityLabel = `${capitalize(defectName)}: ${defectValue}`;
|
| 156 |
+
|
| 157 |
+
// Specifically Dependent Continuant (Quality) node recording validFrom
|
| 158 |
+
nodeMap.set(qualityId, {
|
| 159 |
+
id: qualityId,
|
| 160 |
+
label: qualityLabel,
|
| 161 |
+
type: 'Quality',
|
| 162 |
+
properties: {
|
| 163 |
+
originalId: qualityId,
|
| 164 |
+
qualityType: defectName,
|
| 165 |
+
value: defectValue,
|
| 166 |
+
bearerId: targetId,
|
| 167 |
+
entityClass: 'Quality',
|
| 168 |
+
validFrom: timestamp
|
| 169 |
+
}
|
| 170 |
+
});
|
| 171 |
+
|
| 172 |
+
// Canonical BFO relation: Quality inheres_in Independent Continuant (with validFrom)
|
| 173 |
+
const edgeId = `inh_${targetId}_${defectName}_${timestamp}`;
|
| 174 |
+
edges.push({
|
| 175 |
+
id: edgeId,
|
| 176 |
+
from: qualityId,
|
| 177 |
+
to: targetId,
|
| 178 |
+
label: 'inheres_in',
|
| 179 |
+
type: 'inherence',
|
| 180 |
+
properties: {
|
| 181 |
+
validFrom: timestamp,
|
| 182 |
+
validTo: null,
|
| 183 |
+
isCurrent: true
|
| 184 |
+
}
|
| 185 |
+
});
|
| 186 |
+
break;
|
| 187 |
}
|
| 188 |
+
|
| 189 |
+
default:
|
| 190 |
+
break;
|
| 191 |
+
}
|
| 192 |
+
});
|
| 193 |
+
|
| 194 |
+
// 4. Synchronise final temporal currentness flags
|
| 195 |
+
edges.forEach(edge => {
|
| 196 |
+
edge.properties.isCurrent = edge.properties.validTo === null ||
|
| 197 |
+
(currentTime !== null && currentTime !== undefined ? edge.properties.validTo > currentTime : false);
|
| 198 |
});
|
| 199 |
|
| 200 |
+
return {
|
| 201 |
+
nodes: Array.from(nodeMap.values()),
|
| 202 |
+
edges
|
| 203 |
+
};
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/**
|
| 207 |
+
* Fallback helper to infer continuant entity class.
|
| 208 |
+
*
|
| 209 |
+
* @param {string} id - Continuant identifier.
|
| 210 |
+
* @returns {string} Inferred entity class name.
|
| 211 |
+
*/
|
| 212 |
+
function inferContinuantClass(id) {
|
| 213 |
+
if (/^veh/i.test(id)) return 'Vehicle';
|
| 214 |
+
if (/^slot/i.test(id)) return 'Slot';
|
| 215 |
+
if (/^ware|^wh/i.test(id)) return 'Warehouse';
|
| 216 |
+
return 'Part';
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
/**
|
| 220 |
+
* Capitalises the first letter of a string.
|
| 221 |
+
* @param {string} str
|
| 222 |
+
* @returns {string}
|
| 223 |
+
*/
|
| 224 |
+
function capitalize(str) {
|
| 225 |
+
if (!str) return '';
|
| 226 |
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
| 227 |
}
|
js/smim/iso15926.js
CHANGED
|
@@ -1,111 +1,393 @@
|
|
| 1 |
/**
|
| 2 |
* ISO 15926 ONTOLOGY ADAPTER (4D Perdurant)
|
| 3 |
* -----------------------------------------
|
| 4 |
-
* Maps
|
| 5 |
-
* Entities are treated as 'ActualIndividuals' (4D extents).
|
| 6 |
-
* Relationships do not connect extents directly; instead, they connect
|
| 7 |
-
* specific 'States' (temporal parts) of those entities via canonical 'hasPart'
|
| 8 |
-
* composition, with states linked to their 4D extents via 'temporalPartOf'.
|
| 9 |
*
|
| 10 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
*
|
| 12 |
-
* @param {Array} eventLog - The projection of temporal events.
|
| 13 |
-
* @param {Array} baseNodes - The projection of base entities.
|
| 14 |
* @param {number|null} [currentTime=null] - Global time to evaluate current validity.
|
| 15 |
* @returns {{ nodes: Array, edges: Array }} The canonical Semantic Graph.
|
| 16 |
*/
|
| 17 |
|
| 18 |
-
export function generateSemanticGraph(eventLog, baseNodes, currentTime = null) {
|
| 19 |
-
const
|
| 20 |
const edges = [];
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
properties: {
|
| 29 |
-
originalId: n.id,
|
| 30 |
-
entityType: n.type
|
| 31 |
-
}
|
| 32 |
-
});
|
| 33 |
-
});
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
if (
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
nodes.push({
|
| 61 |
-
id: childStateId,
|
| 62 |
-
label: `${event.to}_State`,
|
| 63 |
-
type: 'State',
|
| 64 |
-
properties: {
|
| 65 |
-
ownerId: event.to,
|
| 66 |
-
validFrom: event.valid_from,
|
| 67 |
-
validTo: event.valid_to,
|
| 68 |
-
isCurrent
|
| 69 |
}
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
}
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
});
|
| 109 |
|
| 110 |
-
return {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
}
|
|
|
|
| 1 |
/**
|
| 2 |
* ISO 15926 ONTOLOGY ADAPTER (4D Perdurant)
|
| 3 |
* -----------------------------------------
|
| 4 |
+
* Maps Domain Business Events into a canonical 4D ISO 15926 Semantic Graph.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
*
|
| 6 |
+
* Ontological Axioms:
|
| 7 |
+
* - Physical entities (Vehicle, Part, Warehouse) are 4D individuals ('ActualIndividual')
|
| 8 |
+
* with spatio-temporal extents across their entire lifetime.
|
| 9 |
+
* - Relationships (mounted_in, stored_at, etc.) do not connect 4D extents directly;
|
| 10 |
+
* they connect temporal slices ('State') of those entities during specific validity periods.
|
| 11 |
+
* - Each 'State' is linked to its whole 4D extent via the 'temporalPartOf' relation.
|
| 12 |
+
* - A 'Defect' is an independent condition/classification entity that classifies a specific
|
| 13 |
+
* temporal part ('State') of an entity during a specific time slice, NOT the root 4D individual.
|
| 14 |
*
|
| 15 |
+
* @param {Array} eventLog - The projection of temporal business events.
|
| 16 |
+
* @param {Array} [baseNodes=[]] - The projection of base entities.
|
| 17 |
* @param {number|null} [currentTime=null] - Global time to evaluate current validity.
|
| 18 |
* @returns {{ nodes: Array, edges: Array }} The canonical Semantic Graph.
|
| 19 |
*/
|
| 20 |
|
| 21 |
+
export function generateSemanticGraph(eventLog = [], baseNodes = [], currentTime = null) {
|
| 22 |
+
const nodeMap = new Map();
|
| 23 |
const edges = [];
|
| 24 |
+
const stateNodesByOwner = new Map();
|
| 25 |
|
| 26 |
+
function registerStateNode(ownerId, stateNode) {
|
| 27 |
+
if (!stateNodesByOwner.has(ownerId)) {
|
| 28 |
+
stateNodesByOwner.set(ownerId, []);
|
| 29 |
+
}
|
| 30 |
+
stateNodesByOwner.get(ownerId).push(stateNode);
|
| 31 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
function ensureExtentNode(partId, overrideClass = null) {
|
| 34 |
+
const extentId = `4d_${partId}`;
|
| 35 |
+
if (!nodeMap.has(extentId)) {
|
| 36 |
+
nodeMap.set(extentId, {
|
| 37 |
+
id: extentId,
|
| 38 |
+
label: `${partId}_4D`,
|
| 39 |
+
type: 'ActualIndividual',
|
| 40 |
+
properties: {
|
| 41 |
+
originalId: partId,
|
| 42 |
+
entityClass: overrideClass || inferEntityType(partId)
|
| 43 |
+
}
|
| 44 |
+
});
|
| 45 |
}
|
| 46 |
+
return extentId;
|
| 47 |
+
}
|
| 48 |
|
| 49 |
+
// 1. Initialise base 4D extent nodes (if provided)
|
| 50 |
+
(baseNodes || []).forEach(bn => {
|
| 51 |
+
ensureExtentNode(bn.id);
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
// 2. Filter and sort business events by timestamp
|
| 55 |
+
const eventsToProcess = (eventLog || [])
|
| 56 |
+
.filter(event => currentTime === null || currentTime === undefined || event.valid_from <= currentTime)
|
| 57 |
+
.slice()
|
| 58 |
+
.sort((a, b) => (a.valid_from || 0) - (b.valid_from || 0));
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
// 3. Process business events in temporal order
|
| 62 |
+
eventsToProcess.forEach(event => {
|
| 63 |
+
switch (event.type) {
|
| 64 |
+
case 'REGISTER_PART': {
|
| 65 |
+
ensureExtentNode(event.partId);
|
| 66 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
}
|
| 68 |
+
|
| 69 |
+
case 'ASSEMBLE': {
|
| 70 |
+
const { parentId, childId } = event;
|
| 71 |
+
const relType = event.relationType || 'mounted_in';
|
| 72 |
+
const timestamp = event.valid_from;
|
| 73 |
+
|
| 74 |
+
const parentExtentId = ensureExtentNode(parentId);
|
| 75 |
+
const childExtentId = ensureExtentNode(childId);
|
| 76 |
+
|
| 77 |
+
if (relType === 'stored_at') {
|
| 78 |
+
const parentStateId = `st_${parentId}_${event.id || `${childId}_${timestamp}`}`;
|
| 79 |
+
const childStateId = `st_${childId}_${event.id || `${parentId}_${timestamp}`}`;
|
| 80 |
+
|
| 81 |
+
const parentState = {
|
| 82 |
+
id: parentStateId,
|
| 83 |
+
label: `${parentId}_State`,
|
| 84 |
+
type: 'State',
|
| 85 |
+
properties: { ownerId: parentId, validFrom: timestamp, validTo: null, isCurrent: true }
|
| 86 |
+
};
|
| 87 |
+
nodeMap.set(parentStateId, parentState);
|
| 88 |
+
registerStateNode(parentId, parentState);
|
| 89 |
+
|
| 90 |
+
const childState = {
|
| 91 |
+
id: childStateId,
|
| 92 |
+
label: `${childId}_State`,
|
| 93 |
+
type: 'State',
|
| 94 |
+
properties: { ownerId: childId, validFrom: timestamp, validTo: null, isCurrent: true }
|
| 95 |
+
};
|
| 96 |
+
nodeMap.set(childStateId, childState);
|
| 97 |
+
registerStateNode(childId, childState);
|
| 98 |
+
|
| 99 |
+
edges.push({
|
| 100 |
+
id: `tpo_${parentStateId}`,
|
| 101 |
+
from: parentStateId,
|
| 102 |
+
to: parentExtentId,
|
| 103 |
+
label: 'temporalPartOf',
|
| 104 |
+
type: 'classification',
|
| 105 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
edges.push({
|
| 109 |
+
id: `tpo_${childStateId}`,
|
| 110 |
+
from: childStateId,
|
| 111 |
+
to: childExtentId,
|
| 112 |
+
label: 'temporalPartOf',
|
| 113 |
+
type: 'classification',
|
| 114 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 115 |
+
});
|
| 116 |
+
|
| 117 |
+
const storageEdgeId = event.id ? `rel_${event.id}` : `rel_${childId}_${parentId}_${timestamp}`;
|
| 118 |
+
edges.push({
|
| 119 |
+
id: storageEdgeId,
|
| 120 |
+
from: childStateId,
|
| 121 |
+
to: parentStateId,
|
| 122 |
+
label: 'stored_at',
|
| 123 |
+
type: 'composition',
|
| 124 |
+
childId,
|
| 125 |
+
parentId,
|
| 126 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 127 |
+
});
|
| 128 |
+
break;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// Implicit contextual Slot generation: Slot_${parentId}_${childId}
|
| 132 |
+
const slotId = `Slot_${parentId}_${childId}`;
|
| 133 |
+
const slotExtentId = ensureExtentNode(slotId, 'Slot');
|
| 134 |
+
|
| 135 |
+
const parentStateId = `st_${parentId}_${event.id || `${slotId}_${timestamp}`}`;
|
| 136 |
+
const slotStateId = `st_${slotId}_${event.id || `${childId}_${timestamp}`}`;
|
| 137 |
+
const childStateId = `st_${childId}_${event.id || `${slotId}_${timestamp}`}`;
|
| 138 |
+
|
| 139 |
+
const parentState = {
|
| 140 |
+
id: parentStateId,
|
| 141 |
+
label: `${parentId}_State`,
|
| 142 |
+
type: 'State',
|
| 143 |
+
properties: {
|
| 144 |
+
ownerId: parentId,
|
| 145 |
+
validFrom: timestamp,
|
| 146 |
+
validTo: null,
|
| 147 |
+
isCurrent: true
|
| 148 |
+
}
|
| 149 |
+
};
|
| 150 |
+
nodeMap.set(parentStateId, parentState);
|
| 151 |
+
registerStateNode(parentId, parentState);
|
| 152 |
+
|
| 153 |
+
const slotState = {
|
| 154 |
+
id: slotStateId,
|
| 155 |
+
label: `${slotId}_State`,
|
| 156 |
+
type: 'State',
|
| 157 |
+
properties: {
|
| 158 |
+
ownerId: slotId,
|
| 159 |
+
validFrom: timestamp,
|
| 160 |
+
validTo: null,
|
| 161 |
+
isCurrent: true
|
| 162 |
+
}
|
| 163 |
+
};
|
| 164 |
+
nodeMap.set(slotStateId, slotState);
|
| 165 |
+
registerStateNode(slotId, slotState);
|
| 166 |
+
|
| 167 |
+
const childState = {
|
| 168 |
+
id: childStateId,
|
| 169 |
+
label: `${childId}_State`,
|
| 170 |
+
type: 'State',
|
| 171 |
+
properties: {
|
| 172 |
+
ownerId: childId,
|
| 173 |
+
validFrom: timestamp,
|
| 174 |
+
validTo: null,
|
| 175 |
+
isCurrent: true
|
| 176 |
+
}
|
| 177 |
+
};
|
| 178 |
+
nodeMap.set(childStateId, childState);
|
| 179 |
+
registerStateNode(childId, childState);
|
| 180 |
+
|
| 181 |
+
// Link temporal states to their 4D extents
|
| 182 |
+
edges.push({
|
| 183 |
+
id: `tpo_${parentStateId}`,
|
| 184 |
+
from: parentStateId,
|
| 185 |
+
to: parentExtentId,
|
| 186 |
+
label: 'temporalPartOf',
|
| 187 |
+
type: 'classification',
|
| 188 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
edges.push({
|
| 192 |
+
id: `tpo_${slotStateId}`,
|
| 193 |
+
from: slotStateId,
|
| 194 |
+
to: slotExtentId,
|
| 195 |
+
label: 'temporalPartOf',
|
| 196 |
+
type: 'classification',
|
| 197 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 198 |
+
});
|
| 199 |
+
|
| 200 |
+
edges.push({
|
| 201 |
+
id: `tpo_${childStateId}`,
|
| 202 |
+
from: childStateId,
|
| 203 |
+
to: childExtentId,
|
| 204 |
+
label: 'temporalPartOf',
|
| 205 |
+
type: 'classification',
|
| 206 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 207 |
+
});
|
| 208 |
+
|
| 209 |
+
// Link 1: Parent State -> Slot State (has_slot)
|
| 210 |
+
const slotEdgeId = `rel_slot_${parentId}_${slotId}_${timestamp}`;
|
| 211 |
+
edges.push({
|
| 212 |
+
id: slotEdgeId,
|
| 213 |
+
from: parentStateId,
|
| 214 |
+
to: slotStateId,
|
| 215 |
+
label: 'has_slot',
|
| 216 |
+
type: 'has_slot',
|
| 217 |
+
childId: slotId,
|
| 218 |
+
parentId: parentId,
|
| 219 |
+
childStateId: slotStateId,
|
| 220 |
+
parentStateId: parentStateId,
|
| 221 |
+
properties: {
|
| 222 |
+
validFrom: timestamp,
|
| 223 |
+
validTo: null,
|
| 224 |
+
isCurrent: true
|
| 225 |
+
}
|
| 226 |
+
});
|
| 227 |
+
|
| 228 |
+
// Link 2: Child State -> Slot State (mounted_in)
|
| 229 |
+
const assemblyEdgeId = event.id ? `rel_${event.id}` : `rel_${childId}_${slotId}_${timestamp}`;
|
| 230 |
+
edges.push({
|
| 231 |
+
id: assemblyEdgeId,
|
| 232 |
+
from: childStateId,
|
| 233 |
+
to: slotStateId,
|
| 234 |
+
label: 'mounted_in',
|
| 235 |
+
type: 'composition',
|
| 236 |
+
childId,
|
| 237 |
+
parentId: slotId,
|
| 238 |
+
childStateId,
|
| 239 |
+
parentStateId: slotStateId,
|
| 240 |
+
properties: {
|
| 241 |
+
validFrom: timestamp,
|
| 242 |
+
validTo: null,
|
| 243 |
+
isCurrent: true
|
| 244 |
+
}
|
| 245 |
+
});
|
| 246 |
+
break;
|
| 247 |
}
|
| 248 |
+
|
| 249 |
+
case 'DISMANTLE': {
|
| 250 |
+
const { childId } = event;
|
| 251 |
+
const dismantleTime = event.valid_from;
|
| 252 |
+
|
| 253 |
+
// Find active assembly or storage edge for this child
|
| 254 |
+
const activeAssembly = edges.find(
|
| 255 |
+
e => (e.childId === childId || e.from.startsWith(`st_${childId}_`)) &&
|
| 256 |
+
(e.label === 'mounted_in' || e.label === 'stored_at') &&
|
| 257 |
+
e.properties.validTo === null
|
| 258 |
+
);
|
| 259 |
+
if (activeAssembly) {
|
| 260 |
+
activeAssembly.properties.validTo = dismantleTime;
|
| 261 |
+
activeAssembly.properties.isCurrent = (currentTime !== null && currentTime !== undefined)
|
| 262 |
+
? dismantleTime > currentTime
|
| 263 |
+
: false;
|
| 264 |
+
|
| 265 |
+
// Close the child state slice
|
| 266 |
+
const childState = nodeMap.get(activeAssembly.childStateId);
|
| 267 |
+
if (childState) {
|
| 268 |
+
childState.properties.validTo = dismantleTime;
|
| 269 |
+
childState.properties.isCurrent = activeAssembly.properties.isCurrent;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
// Close the child's temporalPartOf link
|
| 273 |
+
const tpoChild = edges.find(e => e.id === `tpo_${activeAssembly.childStateId}`);
|
| 274 |
+
if (tpoChild) {
|
| 275 |
+
tpoChild.properties.validTo = dismantleTime;
|
| 276 |
+
tpoChild.properties.isCurrent = activeAssembly.properties.isCurrent;
|
| 277 |
+
}
|
| 278 |
+
} else {
|
| 279 |
+
console.warn(`[SMIM ISO15926] No active assembly found to dismantle child part: ${childId}`);
|
| 280 |
+
}
|
| 281 |
+
break;
|
| 282 |
}
|
| 283 |
+
|
| 284 |
+
case 'REPORT_DEFECT': {
|
| 285 |
+
const { targetId, defectName, defectValue } = event;
|
| 286 |
+
const timestamp = event.valid_from;
|
| 287 |
+
|
| 288 |
+
const targetExtentId = ensureExtentNode(targetId);
|
| 289 |
+
|
| 290 |
+
// Find current active State of the target part
|
| 291 |
+
const existingStates = stateNodesByOwner.get(targetId) || [];
|
| 292 |
+
let targetState = existingStates.find(st => st.properties?.isCurrent && st.properties?.validTo === null) ||
|
| 293 |
+
existingStates[existingStates.length - 1];
|
| 294 |
+
|
| 295 |
+
if (!targetState) {
|
| 296 |
+
const newStateId = `st_${targetId}_def_${event.id || `${defectName}_${timestamp}`}`;
|
| 297 |
+
targetState = {
|
| 298 |
+
id: newStateId,
|
| 299 |
+
label: `${targetId}_State`,
|
| 300 |
+
type: 'State',
|
| 301 |
+
properties: {
|
| 302 |
+
ownerId: targetId,
|
| 303 |
+
validFrom: timestamp,
|
| 304 |
+
validTo: null,
|
| 305 |
+
isCurrent: true
|
| 306 |
+
}
|
| 307 |
+
};
|
| 308 |
+
nodeMap.set(newStateId, targetState);
|
| 309 |
+
registerStateNode(targetId, targetState);
|
| 310 |
+
|
| 311 |
+
edges.push({
|
| 312 |
+
id: `tpo_${newStateId}`,
|
| 313 |
+
from: newStateId,
|
| 314 |
+
to: targetExtentId,
|
| 315 |
+
label: 'temporalPartOf',
|
| 316 |
+
type: 'classification',
|
| 317 |
+
properties: { validFrom: timestamp, validTo: null, isCurrent: true }
|
| 318 |
+
});
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
const defectNodeId = `def_${targetId}_${defectName}`;
|
| 322 |
+
const defectLabel = `Defect: ${capitalize(defectName)} (${defectValue})`;
|
| 323 |
+
|
| 324 |
+
nodeMap.set(defectNodeId, {
|
| 325 |
+
id: defectNodeId,
|
| 326 |
+
label: defectLabel,
|
| 327 |
+
type: 'Defect',
|
| 328 |
+
properties: {
|
| 329 |
+
originalId: defectNodeId,
|
| 330 |
+
defectType: defectName,
|
| 331 |
+
value: defectValue,
|
| 332 |
+
targetId,
|
| 333 |
+
entityClass: 'Defect',
|
| 334 |
+
validFrom: timestamp
|
| 335 |
+
}
|
| 336 |
+
});
|
| 337 |
+
|
| 338 |
+
const defectEdgeId = `def_class_${targetId}_${defectName}_${timestamp}`;
|
| 339 |
+
edges.push({
|
| 340 |
+
id: defectEdgeId,
|
| 341 |
+
from: targetState.id,
|
| 342 |
+
to: defectNodeId,
|
| 343 |
+
label: 'has_defect',
|
| 344 |
+
type: 'classification',
|
| 345 |
+
properties: {
|
| 346 |
+
validFrom: timestamp,
|
| 347 |
+
validTo: null,
|
| 348 |
+
isCurrent: targetState.properties.isCurrent
|
| 349 |
+
}
|
| 350 |
+
});
|
| 351 |
+
break;
|
| 352 |
}
|
| 353 |
+
|
| 354 |
+
default:
|
| 355 |
+
break;
|
| 356 |
+
}
|
| 357 |
+
});
|
| 358 |
+
|
| 359 |
+
// 4. Synchronise final temporal currentness flags
|
| 360 |
+
edges.forEach(edge => {
|
| 361 |
+
edge.properties.isCurrent = edge.properties.validTo === null ||
|
| 362 |
+
(currentTime !== null && currentTime !== undefined ? edge.properties.validTo > currentTime : false);
|
| 363 |
});
|
| 364 |
|
| 365 |
+
return {
|
| 366 |
+
nodes: Array.from(nodeMap.values()),
|
| 367 |
+
edges
|
| 368 |
+
};
|
| 369 |
+
}
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
* Fallback helper to infer entity type from common identifier naming conventions.
|
| 373 |
+
*
|
| 374 |
+
* @param {string} id - Node identifier.
|
| 375 |
+
* @returns {string} Inferred entity class name.
|
| 376 |
+
*/
|
| 377 |
+
function inferEntityType(id) {
|
| 378 |
+
if (/^veh/i.test(id)) return 'Vehicle';
|
| 379 |
+
if (/^slot/i.test(id)) return 'Slot';
|
| 380 |
+
if (/^def/i.test(id)) return 'Defect';
|
| 381 |
+
if (/^ware|^wh/i.test(id)) return 'Warehouse';
|
| 382 |
+
return 'Part';
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
/**
|
| 386 |
+
* Capitalises the first letter of a string.
|
| 387 |
+
* @param {string} str
|
| 388 |
+
* @returns {string}
|
| 389 |
+
*/
|
| 390 |
+
function capitalize(str) {
|
| 391 |
+
if (!str) return '';
|
| 392 |
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
| 393 |
}
|
js/smim/naive.js
CHANGED
|
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* NAIVE GRAPH ADAPTER (Direct Property Graph)
|
| 3 |
+
* --------------------------------------------
|
| 4 |
+
* Maps Domain Business Events into a direct, unconstrained Property Graph without
|
| 5 |
+
* enforcing 3D Continuant (BFO) or 4D Perdurant (ISO 15926) semantic rules.
|
| 6 |
+
*
|
| 7 |
+
* In this mode:
|
| 8 |
+
* - Entities (Vehicle, Part, Warehouse, etc.) are direct nodes.
|
| 9 |
+
* - Assembly events create direct relationships (e.g. 'mounted_in', 'stored_at')
|
| 10 |
+
* directed from child component to parent entity.
|
| 11 |
+
* - Dismantling events locate the active assembly relationship and close its temporal validity.
|
| 12 |
+
* - Defect reports are attached directly to Node properties (if naiveDefectTarget === 'NODE')
|
| 13 |
+
* or to the active assembly Edge properties (if naiveDefectTarget === 'EDGE').
|
| 14 |
+
*
|
| 15 |
+
* Decoupled from database storage (SMS) and UI concerns, strictly adhering
|
| 16 |
+
* to the SemanticGraph data contract ({ nodes: [], edges: [] }).
|
| 17 |
+
*
|
| 18 |
+
* @param {Array} eventLog - The projection of temporal business events.
|
| 19 |
+
* @param {Array} [baseNodes=[]] - The projection of base entities.
|
| 20 |
+
* @param {number|null} [currentTime=null] - Global time to evaluate current validity.
|
| 21 |
+
* @param {Object} [options={}] - Optional configuration overrides.
|
| 22 |
+
* @returns {{ nodes: Array, edges: Array }} The canonical Semantic Graph.
|
| 23 |
+
*/
|
| 24 |
+
|
| 25 |
+
import { state } from '../state.js';
|
| 26 |
+
|
| 27 |
+
export function generateSemanticGraph(eventLog = [], baseNodes = [], currentTime = null, options = {}) {
|
| 28 |
+
const nodeMap = new Map();
|
| 29 |
+
const edges = [];
|
| 30 |
+
|
| 31 |
+
const ontologyMode = options.ontology || state?.ontology || 'NAIVE_NODE';
|
| 32 |
+
const defectTargetMode = ontologyMode === 'NAIVE_EDGE' ? 'EDGE' : (options.naiveDefectTarget || state?.naiveDefectTarget || 'NODE');
|
| 33 |
+
|
| 34 |
+
// 1. Initialise base nodes from projection (if provided)
|
| 35 |
+
(baseNodes || []).forEach(bn => {
|
| 36 |
+
nodeMap.set(bn.id, {
|
| 37 |
+
id: bn.id,
|
| 38 |
+
label: bn.label || bn.id,
|
| 39 |
+
type: bn.entityClass || bn.type || inferEntityType(bn.id),
|
| 40 |
+
properties: { ...(bn.properties || {}) }
|
| 41 |
+
});
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
// 2. Filter and sort business events by timestamp
|
| 45 |
+
const eventsToProcess = (eventLog || [])
|
| 46 |
+
.filter(event => currentTime === null || currentTime === undefined || event.valid_from <= currentTime)
|
| 47 |
+
.slice()
|
| 48 |
+
.sort((a, b) => (a.valid_from || 0) - (b.valid_from || 0));
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
// 3. Process business events in temporal order
|
| 52 |
+
eventsToProcess.forEach(event => {
|
| 53 |
+
switch (event.type) {
|
| 54 |
+
case 'REGISTER_PART': {
|
| 55 |
+
const partId = event.partId;
|
| 56 |
+
if (!nodeMap.has(partId)) {
|
| 57 |
+
nodeMap.set(partId, {
|
| 58 |
+
id: partId,
|
| 59 |
+
label: partId,
|
| 60 |
+
type: inferEntityType(partId),
|
| 61 |
+
properties: {}
|
| 62 |
+
});
|
| 63 |
+
}
|
| 64 |
+
break;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
case 'ASSEMBLE': {
|
| 68 |
+
const { parentId, childId } = event;
|
| 69 |
+
const relType = event.relationType || 'mounted_in';
|
| 70 |
+
|
| 71 |
+
// Ensure both parent and child nodes exist in the node map
|
| 72 |
+
if (!nodeMap.has(parentId)) {
|
| 73 |
+
nodeMap.set(parentId, {
|
| 74 |
+
id: parentId,
|
| 75 |
+
label: parentId,
|
| 76 |
+
type: inferEntityType(parentId),
|
| 77 |
+
properties: {}
|
| 78 |
+
});
|
| 79 |
+
}
|
| 80 |
+
if (!nodeMap.has(childId)) {
|
| 81 |
+
nodeMap.set(childId, {
|
| 82 |
+
id: childId,
|
| 83 |
+
label: childId,
|
| 84 |
+
type: inferEntityType(childId),
|
| 85 |
+
properties: {}
|
| 86 |
+
});
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// Warehouse storage links child directly to warehouse
|
| 90 |
+
if (relType === 'stored_at') {
|
| 91 |
+
const edgeId = event.id ? `edge_${event.id}` : `edge_${childId}_${parentId}_${event.valid_from}`;
|
| 92 |
+
edges.push({
|
| 93 |
+
id: edgeId,
|
| 94 |
+
from: childId,
|
| 95 |
+
to: parentId,
|
| 96 |
+
label: 'stored_at',
|
| 97 |
+
type: 'stored_at',
|
| 98 |
+
childId,
|
| 99 |
+
parentId,
|
| 100 |
+
properties: {
|
| 101 |
+
validFrom: event.valid_from,
|
| 102 |
+
validTo: null,
|
| 103 |
+
isCurrent: true
|
| 104 |
+
}
|
| 105 |
+
});
|
| 106 |
+
break;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
// Implicit contextual Slot generation: Slot_${parentId}_${childId}
|
| 110 |
+
const slotId = `Slot_${parentId}_${childId}`;
|
| 111 |
+
if (!nodeMap.has(slotId)) {
|
| 112 |
+
nodeMap.set(slotId, {
|
| 113 |
+
id: slotId,
|
| 114 |
+
label: slotId,
|
| 115 |
+
type: 'Slot',
|
| 116 |
+
properties: { entityClass: 'Slot' }
|
| 117 |
+
});
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// Link 1: Parent -> Slot (has_slot)
|
| 121 |
+
const slotEdgeId = `edge_slot_${parentId}_${slotId}_${event.valid_from}`;
|
| 122 |
+
edges.push({
|
| 123 |
+
id: slotEdgeId,
|
| 124 |
+
from: parentId,
|
| 125 |
+
to: slotId,
|
| 126 |
+
label: 'has_slot',
|
| 127 |
+
type: 'has_slot',
|
| 128 |
+
childId: slotId,
|
| 129 |
+
parentId: parentId,
|
| 130 |
+
properties: {
|
| 131 |
+
validFrom: event.valid_from,
|
| 132 |
+
validTo: null,
|
| 133 |
+
isCurrent: true
|
| 134 |
+
}
|
| 135 |
+
});
|
| 136 |
+
|
| 137 |
+
// Link 2: Child -> Slot (mounted_in)
|
| 138 |
+
const mountEdgeId = event.id ? `edge_${event.id}` : `edge_${childId}_${slotId}_${event.valid_from}`;
|
| 139 |
+
edges.push({
|
| 140 |
+
id: mountEdgeId,
|
| 141 |
+
from: childId,
|
| 142 |
+
to: slotId,
|
| 143 |
+
label: 'mounted_in',
|
| 144 |
+
type: 'mounted_in',
|
| 145 |
+
childId,
|
| 146 |
+
parentId: slotId,
|
| 147 |
+
properties: {
|
| 148 |
+
validFrom: event.valid_from,
|
| 149 |
+
validTo: null,
|
| 150 |
+
isCurrent: true
|
| 151 |
+
}
|
| 152 |
+
});
|
| 153 |
+
break;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
case 'DISMANTLE': {
|
| 157 |
+
const { childId } = event;
|
| 158 |
+
const dismantleTime = event.valid_from;
|
| 159 |
+
|
| 160 |
+
// Locate active assembly/storage edge for the child component
|
| 161 |
+
const activeEdge = edges.find(
|
| 162 |
+
e => (e.childId === childId || e.from === childId) &&
|
| 163 |
+
(e.label === 'mounted_in' || e.label === 'stored_at') &&
|
| 164 |
+
e.properties.validTo === null
|
| 165 |
+
);
|
| 166 |
+
if (activeEdge) {
|
| 167 |
+
activeEdge.properties.validTo = dismantleTime;
|
| 168 |
+
activeEdge.properties.isCurrent = (currentTime !== null && currentTime !== undefined)
|
| 169 |
+
? dismantleTime > currentTime
|
| 170 |
+
: false;
|
| 171 |
+
} else {
|
| 172 |
+
console.warn(`[SMIM Naive] No active assembly edge found to dismantle child part: ${childId}`);
|
| 173 |
+
}
|
| 174 |
+
break;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
case 'REPORT_DEFECT': {
|
| 178 |
+
const { targetId, defectName, defectValue } = event;
|
| 179 |
+
|
| 180 |
+
if (defectTargetMode === 'NODE') {
|
| 181 |
+
let targetNode = nodeMap.get(targetId);
|
| 182 |
+
if (!targetNode) {
|
| 183 |
+
targetNode = {
|
| 184 |
+
id: targetId,
|
| 185 |
+
label: targetId,
|
| 186 |
+
type: inferEntityType(targetId),
|
| 187 |
+
properties: {}
|
| 188 |
+
};
|
| 189 |
+
nodeMap.set(targetId, targetNode);
|
| 190 |
+
}
|
| 191 |
+
targetNode.properties[defectName] = defectValue;
|
| 192 |
+
} else if (defectTargetMode === 'EDGE') {
|
| 193 |
+
// Find the active assembly edge where targetId is the mounted component
|
| 194 |
+
const activeEdge = edges.find(
|
| 195 |
+
e => (e.childId === targetId || e.from === targetId) &&
|
| 196 |
+
(e.label === 'mounted_in' || e.type === 'mounted_in') &&
|
| 197 |
+
(e.properties.validTo === null || e.properties.validTo >= event.valid_from)
|
| 198 |
+
);
|
| 199 |
+
if (activeEdge) {
|
| 200 |
+
activeEdge.properties[defectName] = defectValue;
|
| 201 |
+
} else {
|
| 202 |
+
console.warn(`[SMIM Naive] No active edge found for defect report on part: ${targetId}`);
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
break;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
default:
|
| 209 |
+
break;
|
| 210 |
+
}
|
| 211 |
+
});
|
| 212 |
+
|
| 213 |
+
// 4. Synchronise final temporal currentness flags
|
| 214 |
+
edges.forEach(edge => {
|
| 215 |
+
edge.properties.isCurrent = edge.properties.validTo === null ||
|
| 216 |
+
(currentTime !== null && currentTime !== undefined ? edge.properties.validTo > currentTime : false);
|
| 217 |
+
});
|
| 218 |
+
|
| 219 |
+
return {
|
| 220 |
+
nodes: Array.from(nodeMap.values()),
|
| 221 |
+
edges
|
| 222 |
+
};
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/**
|
| 226 |
+
* Fallback helper to infer entity type from common identifier naming conventions.
|
| 227 |
+
*
|
| 228 |
+
* @param {string} id - Node identifier.
|
| 229 |
+
* @returns {string} Inferred entity class name.
|
| 230 |
+
*/
|
| 231 |
+
function inferEntityType(id) {
|
| 232 |
+
if (/^veh/i.test(id)) return 'Vehicle';
|
| 233 |
+
if (/^slot/i.test(id)) return 'Slot';
|
| 234 |
+
if (/^def/i.test(id)) return 'Defect';
|
| 235 |
+
if (/^ware|^wh/i.test(id)) return 'Warehouse';
|
| 236 |
+
return 'Part';
|
| 237 |
+
}
|
| 238 |
+
|
js/smrm/actions.js
CHANGED
|
@@ -1,98 +1,128 @@
|
|
| 1 |
/**
|
| 2 |
* DOMAIN ACTION FACTORIES (SMRM Layer)
|
| 3 |
* ------------------------------------
|
| 4 |
-
* This module contains pure factory functions responsible for
|
| 5 |
-
* business
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
*
|
| 7 |
* Strict Architectural Rule:
|
| 8 |
* Functions here MUST NOT import the singleton state or directly mutate data.
|
| 9 |
* All functions are pure factories returning event descriptors to be dispatched.
|
| 10 |
*/
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
/**
|
| 13 |
-
* Creates
|
| 14 |
* Pure factory function - does not mutate any external state.
|
| 15 |
*
|
| 16 |
-
* @param {string} parentId - The unique identifier of the parent
|
| 17 |
-
* @param {string}
|
| 18 |
-
* @param {
|
| 19 |
-
* @param {number
|
| 20 |
-
* @
|
| 21 |
-
* @returns {Object|null} The created relationship event object, or null if validation fails.
|
| 22 |
*/
|
| 23 |
-
export function
|
| 24 |
-
if (!parentId || !
|
| 25 |
-
|
| 26 |
const trimmedParent = String(parentId).trim();
|
| 27 |
-
const
|
| 28 |
-
|
| 29 |
-
// Rule 1:
|
| 30 |
-
if (!trimmedParent || !
|
| 31 |
return null;
|
| 32 |
}
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
e.from === trimmedParent &&
|
| 38 |
-
e.to === trimmedPart &&
|
| 39 |
-
e.valid_to === null
|
| 40 |
-
);
|
| 41 |
-
|
| 42 |
-
if (edgeExists) {
|
| 43 |
-
console.warn(`[SMRM] Active edge already exists between ${trimmedParent} and ${trimmedPart}`);
|
| 44 |
-
return null;
|
| 45 |
-
}
|
| 46 |
-
}
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
return {
|
| 53 |
-
id:
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
| 58 |
};
|
| 59 |
}
|
| 60 |
|
| 61 |
/**
|
| 62 |
-
* Creates
|
| 63 |
* Pure factory function - does not mutate any external state.
|
| 64 |
*
|
| 65 |
-
* @param {string}
|
| 66 |
-
* @param {number} [
|
| 67 |
-
* @
|
| 68 |
-
* @returns {Object|null} The relationship closure descriptor, or null if validation fails.
|
| 69 |
*/
|
| 70 |
-
export function
|
| 71 |
-
if (!
|
| 72 |
-
|
| 73 |
-
const
|
| 74 |
-
|
| 75 |
-
// Rule: Validate that the edge exists and is currently active
|
| 76 |
-
if (Array.isArray(existingEvents) && existingEvents.length > 0) {
|
| 77 |
-
const edge = existingEvents.find(e => e.id === strEdgeId);
|
| 78 |
-
if (!edge) {
|
| 79 |
-
console.error(`[SMRM] Cannot sever relation. Edge ${strEdgeId} not found.`);
|
| 80 |
-
return null;
|
| 81 |
-
}
|
| 82 |
-
if (edge.valid_to !== null) {
|
| 83 |
-
console.warn(`[SMRM] Relation ${strEdgeId} is already closed.`);
|
| 84 |
-
return null;
|
| 85 |
-
}
|
| 86 |
-
}
|
| 87 |
|
| 88 |
return {
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 92 |
};
|
| 93 |
}
|
| 94 |
|
| 95 |
-
// Aliases for terminology consistency and backwards compatibility
|
| 96 |
-
export const createCloseEdgeEvent = createRemoveEdgeEvent;
|
| 97 |
-
export const addPart = createAddPartEvent;
|
| 98 |
-
export const removeEdge = createRemoveEdgeEvent;
|
|
|
|
| 1 |
/**
|
| 2 |
* DOMAIN ACTION FACTORIES (SMRM Layer)
|
| 3 |
* ------------------------------------
|
| 4 |
+
* This module contains pure factory functions responsible for creating
|
| 5 |
+
* immutable business Domain Events for the Event Sourcing architecture.
|
| 6 |
+
*
|
| 7 |
+
* In accordance with Domain-Driven Event Sourcing:
|
| 8 |
+
* - Events represent pure business facts, NOT low-level graph mutations.
|
| 9 |
+
* - No graph concepts (e.g. 'NODE', 'EDGE') exist at this layer.
|
| 10 |
*
|
| 11 |
* Strict Architectural Rule:
|
| 12 |
* Functions here MUST NOT import the singleton state or directly mutate data.
|
| 13 |
* All functions are pure factories returning event descriptors to be dispatched.
|
| 14 |
*/
|
| 15 |
|
| 16 |
+
import { RELATION_TYPES } from './definitions.js';
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Creates a business event representing the registration/creation of a domain part.
|
| 20 |
+
* Pure factory function - does not mutate any external state.
|
| 21 |
+
*
|
| 22 |
+
* @param {string} partId - The unique business identifier of the part or component.
|
| 23 |
+
* @param {number} [timestamp=0] - The discrete system timestamp of the registration.
|
| 24 |
+
* @returns {Object|null} The created registration business event, or null if validation fails.
|
| 25 |
+
*/
|
| 26 |
+
export function createRegisterPartEvent(partId, timestamp = 0) {
|
| 27 |
+
if (!partId) return null;
|
| 28 |
+
const trimmedId = String(partId).trim();
|
| 29 |
+
if (!trimmedId) return null;
|
| 30 |
+
|
| 31 |
+
return {
|
| 32 |
+
id: `evt_reg_${trimmedId}`,
|
| 33 |
+
type: 'REGISTER_PART',
|
| 34 |
+
partId: trimmedId,
|
| 35 |
+
valid_from: timestamp,
|
| 36 |
+
valid_to: null
|
| 37 |
+
};
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
/**
|
| 41 |
+
* Creates a business event representing the assembly or containment of a child part into a parent entity.
|
| 42 |
* Pure factory function - does not mutate any external state.
|
| 43 |
*
|
| 44 |
+
* @param {string} parentId - The unique business identifier of the parent entity/container.
|
| 45 |
+
* @param {string} childId - The unique business identifier of the assembled child component.
|
| 46 |
+
* @param {string} [relationType='mounted_in'] - The relationship category (e.g. 'mounted_in', 'stored_at').
|
| 47 |
+
* @param {number} [timestamp=0] - The discrete system timestamp of the assembly.
|
| 48 |
+
* @returns {Object|null} The created assembly business event, or null if validation fails.
|
|
|
|
| 49 |
*/
|
| 50 |
+
export function createAssembleEvent(parentId, childId, relationType = 'mounted_in', timestamp = 0) {
|
| 51 |
+
if (!parentId || !childId) return null;
|
| 52 |
+
|
| 53 |
const trimmedParent = String(parentId).trim();
|
| 54 |
+
const trimmedChild = String(childId).trim();
|
| 55 |
+
|
| 56 |
+
// Rule 1: An entity cannot be assembled into itself
|
| 57 |
+
if (!trimmedParent || !trimmedChild || trimmedParent === trimmedChild) {
|
| 58 |
return null;
|
| 59 |
}
|
| 60 |
|
| 61 |
+
const validRelation = relationType && RELATION_TYPES.includes(relationType)
|
| 62 |
+
? relationType
|
| 63 |
+
: (relationType ? String(relationType).trim() : 'mounted_in');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
return {
|
| 66 |
+
id: `evt_asm_${trimmedChild}_${timestamp}`,
|
| 67 |
+
type: 'ASSEMBLE',
|
| 68 |
+
parentId: trimmedParent,
|
| 69 |
+
childId: trimmedChild,
|
| 70 |
+
relationType: validRelation,
|
| 71 |
+
valid_from: timestamp,
|
| 72 |
+
valid_to: null
|
| 73 |
+
};
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* Creates a business event reporting a physical defect or quality observation on an entity.
|
| 78 |
+
* Pure factory function - targetId is ALWAYS the Part/Vehicle ID, never a relationship/edge ID.
|
| 79 |
+
*
|
| 80 |
+
* @param {string} targetId - The unique identifier of the part or vehicle bearing the defect.
|
| 81 |
+
* @param {string} defectName - The characteristic or defect category (e.g. 'crack', 'dent', 'wear').
|
| 82 |
+
* @param {string|number} defectValue - The recorded measurement or severity value (e.g. '2mm', 'high').
|
| 83 |
+
* @param {number} [timestamp=0] - The discrete system timestamp of the defect observation.
|
| 84 |
+
* @returns {Object|null} The created defect report business event, or null if validation fails.
|
| 85 |
+
*/
|
| 86 |
+
export function createReportDefectEvent(targetId, defectName, defectValue, timestamp = 0) {
|
| 87 |
+
if (!targetId || !defectName) return null;
|
| 88 |
+
|
| 89 |
+
const trimmedTarget = String(targetId).trim();
|
| 90 |
+
const trimmedDefect = String(defectName).trim();
|
| 91 |
+
|
| 92 |
+
if (!trimmedTarget || !trimmedDefect) {
|
| 93 |
+
return null;
|
| 94 |
+
}
|
| 95 |
|
| 96 |
return {
|
| 97 |
+
id: `evt_def_${trimmedTarget}_${trimmedDefect}_${timestamp}`,
|
| 98 |
+
type: 'REPORT_DEFECT',
|
| 99 |
+
targetId: trimmedTarget,
|
| 100 |
+
defectName: trimmedDefect,
|
| 101 |
+
defectValue: defectValue,
|
| 102 |
+
valid_from: timestamp,
|
| 103 |
+
valid_to: null
|
| 104 |
};
|
| 105 |
}
|
| 106 |
|
| 107 |
/**
|
| 108 |
+
* Creates a business event representing the dismantling or removal of a component.
|
| 109 |
* Pure factory function - does not mutate any external state.
|
| 110 |
*
|
| 111 |
+
* @param {string} childId - The unique business identifier of the dismantled component.
|
| 112 |
+
* @param {number} [timestamp=0] - The discrete system timestamp when dismantling occurred.
|
| 113 |
+
* @returns {Object|null} The created dismantling business event, or null if validation fails.
|
|
|
|
| 114 |
*/
|
| 115 |
+
export function createDismantleEvent(childId, timestamp = 0) {
|
| 116 |
+
if (!childId) return null;
|
| 117 |
+
|
| 118 |
+
const trimmedChild = String(childId).trim();
|
| 119 |
+
if (!trimmedChild) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
return {
|
| 122 |
+
id: `evt_dsm_${trimmedChild}_${timestamp}`,
|
| 123 |
+
type: 'DISMANTLE',
|
| 124 |
+
childId: trimmedChild,
|
| 125 |
+
valid_from: timestamp
|
| 126 |
};
|
| 127 |
}
|
| 128 |
|
|
|
|
|
|
|
|
|
|
|
|
js/smrm/definitions.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* SMRM DEFINITIONS & DOMAIN VOCABULARY
|
| 3 |
+
* ------------------------------------
|
| 4 |
+
* Standard domain vocabulary and reference model definitions for the
|
| 5 |
+
* IEC 63339 Knowledge Architecture Workbench.
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Standard manufacturing domain entity classes.
|
| 10 |
+
* @type {ReadonlyArray<string>}
|
| 11 |
+
*/
|
| 12 |
+
export const ENTITY_CLASSES = Object.freeze([
|
| 13 |
+
'Vehicle',
|
| 14 |
+
'Slot',
|
| 15 |
+
'Part',
|
| 16 |
+
'Defect',
|
| 17 |
+
'Warehouse'
|
| 18 |
+
]);
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* Standard manufacturing domain relationship types.
|
| 22 |
+
* @type {ReadonlyArray<string>}
|
| 23 |
+
*/
|
| 24 |
+
export const RELATION_TYPES = Object.freeze([
|
| 25 |
+
'has_slot',
|
| 26 |
+
'mounted_in',
|
| 27 |
+
'stored_at',
|
| 28 |
+
'has_defect'
|
| 29 |
+
]);
|
| 30 |
+
|
js/sms/lpg-generator.js
CHANGED
|
@@ -42,21 +42,36 @@ export function generateLpgStorage(semanticGraph) {
|
|
| 42 |
* @returns {string} Cypher query string.
|
| 43 |
*/
|
| 44 |
export function generateLpgQuery(semanticGraph, currentTime) {
|
| 45 |
-
|
| 46 |
|
|
|
|
|
|
|
|
|
|
| 47 |
if (is4D) {
|
| 48 |
-
return `// Cypher (Neo4j) - 4D Perdurant
|
| 49 |
-
MATCH (
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
|
| 57 |
-
return `// Cypher (Neo4j) -
|
| 58 |
-
MATCH (
|
| 59 |
-
|
| 60 |
-
AND (r.validTo IS NULL OR r.validTo > ${currentTime})
|
| 61 |
-
RETURN p.id AS Parent, c.id AS Child`;
|
| 62 |
}
|
|
|
|
| 42 |
* @returns {string} Cypher query string.
|
| 43 |
*/
|
| 44 |
export function generateLpgQuery(semanticGraph, currentTime) {
|
| 45 |
+
if (!semanticGraph) return '';
|
| 46 |
|
| 47 |
+
const nodes = semanticGraph.nodes || [];
|
| 48 |
+
|
| 49 |
+
const is4D = nodes.some(n => n.type === 'State');
|
| 50 |
if (is4D) {
|
| 51 |
+
return `// Cypher (Neo4j) - 4D Perdurant Full Graph Topology
|
| 52 |
+
MATCH (n)-[r]->(m)
|
| 53 |
+
RETURN n, r, m`;
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
// Check for BFO Quality (Dependent Continuant)
|
| 57 |
+
const hasQuality = nodes.some(n => n.type === 'Quality');
|
| 58 |
+
if (hasQuality) {
|
| 59 |
+
return `// Cypher (Neo4j) - 3D BFO Full Graph Topology & Inherence
|
| 60 |
+
MATCH (n)-[r]->(m)
|
| 61 |
+
RETURN n, r, m`;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// Check if we are in domain / naive mode
|
| 65 |
+
const domainClasses = ['Vehicle', 'Slot', 'Part', 'Defect', 'Warehouse'];
|
| 66 |
+
const hasDomainNodes = nodes.some(n => domainClasses.includes(n.type));
|
| 67 |
+
|
| 68 |
+
if (hasDomainNodes) {
|
| 69 |
+
return `// Cypher (Neo4j) - Domain Graph Full Topology & Properties
|
| 70 |
+
MATCH (n)-[r]->(m)
|
| 71 |
+
RETURN n, r, m`;
|
| 72 |
}
|
| 73 |
|
| 74 |
+
return `// Cypher (Neo4j) - Full Structural Topology & Edge Properties
|
| 75 |
+
MATCH (n)-[r]->(m)
|
| 76 |
+
RETURN n, r, m`;
|
|
|
|
|
|
|
| 77 |
}
|
js/sms/rdf-generator.js
CHANGED
|
@@ -33,13 +33,30 @@ export function generateRdfStorage(semanticGraph) {
|
|
| 33 |
ttl += `:${ind.id} a iso:ActualIndividual .\n`;
|
| 34 |
});
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
const states = (semanticGraph.nodes || []).filter(n => n.type === 'State');
|
| 37 |
states.forEach(st => {
|
| 38 |
const tpoEdges = (semanticGraph.edges || []).filter(
|
| 39 |
-
e => e.from === st.id && (e.label === 'temporalPartOf' || e.type === 'classification')
|
|
|
|
|
|
|
|
|
|
| 40 |
);
|
| 41 |
const hasPartEdges = (semanticGraph.edges || []).filter(
|
| 42 |
-
e => e.from === st.id && (e.label === 'hasPart' || e.type === 'composition')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
);
|
| 44 |
|
| 45 |
const vFrom = st.properties?.validFrom;
|
|
@@ -51,10 +68,26 @@ export function generateRdfStorage(semanticGraph) {
|
|
| 51 |
ttl += ` ;\n iso:temporalPartOf :${e.to}`;
|
| 52 |
});
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
hasPartEdges.forEach(e => {
|
| 55 |
ttl += ` ;\n iso:hasPart :${e.to}`;
|
| 56 |
});
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
if (vFrom !== undefined && vFrom !== null) {
|
| 59 |
ttl += ` ;\n iso:validFrom "${vFrom}"^^xsd:integer`;
|
| 60 |
}
|
|
@@ -65,33 +98,79 @@ export function generateRdfStorage(semanticGraph) {
|
|
| 65 |
ttl += ` .\n`;
|
| 66 |
});
|
| 67 |
} else {
|
|
|
|
|
|
|
|
|
|
| 68 |
ttl += `@prefix : <http://example.org/> .\n`;
|
| 69 |
ttl += `@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n`;
|
| 70 |
-
ttl += `# 3D Continuant Graph persisted via W3C Reification\n`;
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
|
| 97 |
return ttl;
|
|
@@ -108,34 +187,44 @@ export function generateRdfQuery(semanticGraph, currentTime) {
|
|
| 108 |
const is4D = semanticGraph?.nodes?.some(n => n.type === 'State');
|
| 109 |
|
| 110 |
if (is4D) {
|
| 111 |
-
return `# SPARQL - 4D Perdurant
|
| 112 |
PREFIX iso: <http://example.org/iso15926/>
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
WHERE {
|
| 115 |
-
?
|
| 116 |
-
iso:temporalPartOf ?parent4D ;
|
| 117 |
-
iso:hasPart ?cState ;
|
| 118 |
-
iso:validFrom ?from .
|
| 119 |
-
?cState a iso:State ;
|
| 120 |
-
iso:temporalPartOf ?child4D .
|
| 121 |
-
OPTIONAL { ?pState iso:validTo ?to }
|
| 122 |
-
|
| 123 |
-
FILTER (?from <= ${currentTime} &&
|
| 124 |
-
(!bound(?to) || ?to > ${currentTime}))
|
| 125 |
}`;
|
| 126 |
}
|
| 127 |
|
| 128 |
-
return `# SPARQL -
|
| 129 |
PREFIX : <http://example.org/>
|
| 130 |
-
|
|
|
|
| 131 |
WHERE {
|
| 132 |
-
?
|
| 133 |
-
:hasParent ?parent ;
|
| 134 |
-
:hasChild ?child ;
|
| 135 |
-
:validFrom ?from .
|
| 136 |
-
OPTIONAL { ?stmt :validTo ?to }
|
| 137 |
-
|
| 138 |
-
FILTER (?from <= ${currentTime} &&
|
| 139 |
-
(!bound(?to) || ?to > ${currentTime}))
|
| 140 |
}`;
|
| 141 |
}
|
|
|
|
| 33 |
ttl += `:${ind.id} a iso:ActualIndividual .\n`;
|
| 34 |
});
|
| 35 |
|
| 36 |
+
const defectNodes = (semanticGraph.nodes || []).filter(n => n.type === 'Defect');
|
| 37 |
+
defectNodes.forEach(d => {
|
| 38 |
+
ttl += `:${d.id} a iso:DefectClass .\n`;
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
const states = (semanticGraph.nodes || []).filter(n => n.type === 'State');
|
| 42 |
states.forEach(st => {
|
| 43 |
const tpoEdges = (semanticGraph.edges || []).filter(
|
| 44 |
+
e => e.from === st.id && (e.label === 'temporalPartOf' || e.type === 'classification') && !e.to.startsWith('def')
|
| 45 |
+
);
|
| 46 |
+
const partOfEdges = (semanticGraph.edges || []).filter(
|
| 47 |
+
e => e.from === st.id && (e.label === 'mounted_in' || e.type === 'mounted_in' || e.label === 'partOf')
|
| 48 |
);
|
| 49 |
const hasPartEdges = (semanticGraph.edges || []).filter(
|
| 50 |
+
e => e.from === st.id && (e.label === 'hasPart' || (e.type === 'composition' && e.label !== 'mounted_in' && e.type !== 'mounted_in'))
|
| 51 |
+
);
|
| 52 |
+
const hasSlotEdges = (semanticGraph.edges || []).filter(
|
| 53 |
+
e => e.from === st.id && (e.label === 'has_slot' || e.type === 'has_slot')
|
| 54 |
+
);
|
| 55 |
+
const storedAtEdges = (semanticGraph.edges || []).filter(
|
| 56 |
+
e => e.from === st.id && (e.label === 'stored_at' || e.type === 'stored_at')
|
| 57 |
+
);
|
| 58 |
+
const hasDefectEdges = (semanticGraph.edges || []).filter(
|
| 59 |
+
e => e.from === st.id && (e.label === 'has_defect' || e.to.startsWith('def'))
|
| 60 |
);
|
| 61 |
|
| 62 |
const vFrom = st.properties?.validFrom;
|
|
|
|
| 68 |
ttl += ` ;\n iso:temporalPartOf :${e.to}`;
|
| 69 |
});
|
| 70 |
|
| 71 |
+
partOfEdges.forEach(e => {
|
| 72 |
+
ttl += ` ;\n iso:partOf :${e.to}`;
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
hasPartEdges.forEach(e => {
|
| 76 |
ttl += ` ;\n iso:hasPart :${e.to}`;
|
| 77 |
});
|
| 78 |
|
| 79 |
+
hasSlotEdges.forEach(e => {
|
| 80 |
+
ttl += ` ;\n iso:hasSlot :${e.to}`;
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
storedAtEdges.forEach(e => {
|
| 84 |
+
ttl += ` ;\n iso:storedAt :${e.to}`;
|
| 85 |
+
});
|
| 86 |
+
|
| 87 |
+
hasDefectEdges.forEach(e => {
|
| 88 |
+
ttl += ` ;\n iso:hasDefect :${e.to}`;
|
| 89 |
+
});
|
| 90 |
+
|
| 91 |
if (vFrom !== undefined && vFrom !== null) {
|
| 92 |
ttl += ` ;\n iso:validFrom "${vFrom}"^^xsd:integer`;
|
| 93 |
}
|
|
|
|
| 98 |
ttl += ` .\n`;
|
| 99 |
});
|
| 100 |
} else {
|
| 101 |
+
const domainClasses = ['Vehicle', 'Slot', 'Part', 'Defect', 'Warehouse'];
|
| 102 |
+
const hasDomainNodes = (semanticGraph.nodes || []).some(n => domainClasses.includes(n.type));
|
| 103 |
+
|
| 104 |
ttl += `@prefix : <http://example.org/> .\n`;
|
| 105 |
ttl += `@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n`;
|
|
|
|
| 106 |
|
| 107 |
+
if (hasDomainNodes) {
|
| 108 |
+
ttl += `# Naive Domain Graph persisted as Direct Triples & Properties\n`;
|
| 109 |
+
|
| 110 |
+
// 1. Domain entities and inline properties
|
| 111 |
+
(semanticGraph.nodes || []).forEach(n => {
|
| 112 |
+
ttl += `:${n.id} a :${n.type || 'Part'}`;
|
| 113 |
+
if (n.properties) {
|
| 114 |
+
const customProps = Object.entries(n.properties).filter(
|
| 115 |
+
([k]) => !['isCurrent', 'originalId', 'entityType', 'validFrom', 'validTo', 'ownerId'].includes(k)
|
| 116 |
+
);
|
| 117 |
+
customProps.forEach(([k, v]) => {
|
| 118 |
+
ttl += ` ;\n :${k} "${v}"`;
|
| 119 |
+
});
|
| 120 |
+
}
|
| 121 |
+
ttl += ` .\n`;
|
| 122 |
+
});
|
| 123 |
|
| 124 |
+
// 2. Direct relationships
|
| 125 |
+
(semanticGraph.edges || []).forEach(edge => {
|
| 126 |
+
const edgeRel = edge.label || 'has_part';
|
| 127 |
+
ttl += `:${edge.from} :${edgeRel} :${edge.to} .\n`;
|
| 128 |
+
});
|
| 129 |
+
} else {
|
| 130 |
+
ttl += `# 3D Continuant Graph persisted via W3C Reification & Quality Inherence\n`;
|
| 131 |
|
| 132 |
+
// 1. Base continuant entities
|
| 133 |
+
(semanticGraph.nodes || []).filter(n => n.type === 'MaterialEntity').forEach(n => {
|
| 134 |
+
ttl += `:${n.id} a :MaterialEntity .\n`;
|
| 135 |
+
});
|
| 136 |
|
| 137 |
+
// 1b. Dependent Continuants (Quality)
|
| 138 |
+
(semanticGraph.nodes || []).filter(n => n.type === 'Quality').forEach(q => {
|
| 139 |
+
ttl += `:${q.id} a :Quality`;
|
| 140 |
+
const inh = (semanticGraph.edges || []).find(e => e.from === q.id && e.label === 'inheres_in');
|
| 141 |
+
if (inh) {
|
| 142 |
+
ttl += ` ;\n :inheres_in :${inh.to}`;
|
| 143 |
+
}
|
| 144 |
+
ttl += ` .\n`;
|
| 145 |
+
});
|
| 146 |
|
| 147 |
+
// 2. Synthesise reified statements autonomously for temporal relations
|
| 148 |
+
(semanticGraph.edges || []).filter(e => e.type !== 'inherence').forEach(edge => {
|
| 149 |
+
const vFrom = edge.properties?.validFrom;
|
| 150 |
+
const vTo = edge.properties?.validTo;
|
| 151 |
+
const rel = edge.label || edge.relationType || edge.type;
|
| 152 |
+
|
| 153 |
+
// Respect semantic directionality of predicates:
|
| 154 |
+
// - mounted_in: Part (from) is mounted in Slot/Vehicle (to) => parent is edge.to, child is edge.from
|
| 155 |
+
// - has_slot / has_part / composition: parent is edge.from, child is edge.to
|
| 156 |
+
const isMountedIn = rel === 'mounted_in';
|
| 157 |
+
const parentId = isMountedIn ? edge.to : edge.from;
|
| 158 |
+
const childId = isMountedIn ? edge.from : edge.to;
|
| 159 |
+
|
| 160 |
+
ttl += `\n_:${edge.id} a :RelationalQuality ;\n`;
|
| 161 |
+
ttl += ` :hasParent :${parentId} ;\n`;
|
| 162 |
+
ttl += ` :hasChild :${childId}`;
|
| 163 |
+
|
| 164 |
+
if (vFrom !== undefined && vFrom !== null) {
|
| 165 |
+
ttl += ` ;\n :validFrom "${vFrom}"^^xsd:integer`;
|
| 166 |
+
}
|
| 167 |
+
if (vTo !== undefined && vTo !== null) {
|
| 168 |
+
ttl += ` ;\n :validTo "${vTo}"^^xsd:integer`;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
ttl += ` .\n`;
|
| 172 |
+
});
|
| 173 |
+
}
|
| 174 |
}
|
| 175 |
|
| 176 |
return ttl;
|
|
|
|
| 187 |
const is4D = semanticGraph?.nodes?.some(n => n.type === 'State');
|
| 188 |
|
| 189 |
if (is4D) {
|
| 190 |
+
return `# SPARQL (W3C RDF) - 4D Perdurant Full Graph Topology
|
| 191 |
PREFIX iso: <http://example.org/iso15926/>
|
| 192 |
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
| 193 |
+
SELECT ?subject ?predicate ?object
|
| 194 |
+
WHERE {
|
| 195 |
+
?subject ?predicate ?object .
|
| 196 |
+
}`;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
const hasQuality = semanticGraph?.nodes?.some(n => n.type === 'Quality');
|
| 200 |
+
if (hasQuality) {
|
| 201 |
+
return `# SPARQL (W3C RDF) - 3D BFO Full Graph Topology & Inherence
|
| 202 |
+
PREFIX : <http://example.org/>
|
| 203 |
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
| 204 |
+
SELECT ?subject ?predicate ?object
|
| 205 |
+
WHERE {
|
| 206 |
+
?subject ?predicate ?object .
|
| 207 |
+
}`;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
const domainClasses = ['Vehicle', 'Slot', 'Part', 'Defect', 'Warehouse'];
|
| 211 |
+
const hasDomainNodes = (semanticGraph?.nodes || []).some(n => domainClasses.includes(n.type));
|
| 212 |
+
|
| 213 |
+
if (hasDomainNodes) {
|
| 214 |
+
return `# SPARQL (W3C RDF) - Domain Graph Full Topology & Properties
|
| 215 |
+
PREFIX : <http://example.org/>
|
| 216 |
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
| 217 |
+
SELECT ?subject ?predicate ?object
|
| 218 |
WHERE {
|
| 219 |
+
?subject ?predicate ?object .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
}`;
|
| 221 |
}
|
| 222 |
|
| 223 |
+
return `# SPARQL (W3C RDF) - Full Graph Topology
|
| 224 |
PREFIX : <http://example.org/>
|
| 225 |
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
| 226 |
+
SELECT ?subject ?predicate ?object
|
| 227 |
WHERE {
|
| 228 |
+
?subject ?predicate ?object .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
}`;
|
| 230 |
}
|
js/sms/sms-graph-generator.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* SMS LAYER: PHYSICAL GRAPH GENERATOR
|
| 3 |
+
* -----------------------------------
|
| 4 |
+
* Transforms a canonical Semantic Graph (SMIM) into physical storage (SMS) per IEC 63339.
|
| 5 |
+
* RDF: Reifies 3D composition relations carrying temporal properties into W3C statement nodes.
|
| 6 |
+
* LPG: Links sequential 4D states of the same entity via TRANSITION_TO edges.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Generates a physical graph projection from a canonical semantic graph.
|
| 11 |
+
*
|
| 12 |
+
* @param {Object} semanticGraph - Standardised Semantic Graph ({ nodes: Array, edges: Array }).
|
| 13 |
+
* @param {string} storageMode - Physical storage paradigm ('LPG' or 'RDF').
|
| 14 |
+
* @returns {{ nodes: Array, edges: Array }} Transformed physical graph.
|
| 15 |
+
*/
|
| 16 |
+
export function generatePhysicalGraph(semanticGraph, storageMode) {
|
| 17 |
+
if (!semanticGraph || !Array.isArray(semanticGraph.nodes) || !Array.isArray(semanticGraph.edges)) {
|
| 18 |
+
return { nodes: [], edges: [] };
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// Deep clone nodes and edges to maintain immutability
|
| 22 |
+
const physicalNodes = semanticGraph.nodes.map(node => ({
|
| 23 |
+
...node,
|
| 24 |
+
properties: node.properties ? { ...node.properties } : {}
|
| 25 |
+
}));
|
| 26 |
+
|
| 27 |
+
const physicalEdges = semanticGraph.edges.map(edge => ({
|
| 28 |
+
...edge,
|
| 29 |
+
properties: edge.properties ? { ...edge.properties } : {}
|
| 30 |
+
}));
|
| 31 |
+
|
| 32 |
+
const is4D = physicalNodes.some(n => n.type === 'State');
|
| 33 |
+
|
| 34 |
+
// Case 1: W3C RDF Mode
|
| 35 |
+
if (storageMode === 'RDF') {
|
| 36 |
+
if (!is4D) {
|
| 37 |
+
const finalEdges = [];
|
| 38 |
+
|
| 39 |
+
physicalEdges.forEach(edge => {
|
| 40 |
+
const hasTemporalProps = edge.properties && (
|
| 41 |
+
edge.properties.validFrom !== undefined ||
|
| 42 |
+
edge.properties.validTo !== undefined
|
| 43 |
+
);
|
| 44 |
+
|
| 45 |
+
if (edge.type === 'composition' && hasTemporalProps) {
|
| 46 |
+
const stmtId = `stmt_${edge.id}`;
|
| 47 |
+
const isCurrent = edge.properties.isCurrent !== false;
|
| 48 |
+
|
| 49 |
+
physicalNodes.push({
|
| 50 |
+
id: stmtId,
|
| 51 |
+
label: `_:${edge.id}`,
|
| 52 |
+
type: 'RelationalQuality',
|
| 53 |
+
properties: { isCurrent, originalEdgeId: edge.id }
|
| 54 |
+
});
|
| 55 |
+
|
| 56 |
+
finalEdges.push({
|
| 57 |
+
id: `rel_p_${edge.id}`,
|
| 58 |
+
from: stmtId,
|
| 59 |
+
to: edge.from,
|
| 60 |
+
label: ':hasParent',
|
| 61 |
+
type: 'reification',
|
| 62 |
+
properties: { isCurrent }
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
finalEdges.push({
|
| 66 |
+
id: `rel_c_${edge.id}`,
|
| 67 |
+
from: stmtId,
|
| 68 |
+
to: edge.to,
|
| 69 |
+
label: ':hasChild',
|
| 70 |
+
type: 'reification',
|
| 71 |
+
properties: { isCurrent }
|
| 72 |
+
});
|
| 73 |
+
|
| 74 |
+
if (edge.properties.validFrom !== undefined && edge.properties.validFrom !== null) {
|
| 75 |
+
const litFromId = `lit_vf_${edge.id}`;
|
| 76 |
+
physicalNodes.push({
|
| 77 |
+
id: litFromId,
|
| 78 |
+
label: `"${edge.properties.validFrom}"^^xsd:integer`,
|
| 79 |
+
type: 'Literal',
|
| 80 |
+
properties: { value: edge.properties.validFrom }
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
finalEdges.push({
|
| 84 |
+
id: `rel_vf_${edge.id}`,
|
| 85 |
+
from: stmtId,
|
| 86 |
+
to: litFromId,
|
| 87 |
+
label: ':validFrom',
|
| 88 |
+
type: 'reification',
|
| 89 |
+
properties: { isCurrent }
|
| 90 |
+
});
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
if (edge.properties.validTo !== undefined && edge.properties.validTo !== null) {
|
| 94 |
+
const litToId = `lit_vt_${edge.id}`;
|
| 95 |
+
physicalNodes.push({
|
| 96 |
+
id: litToId,
|
| 97 |
+
label: `"${edge.properties.validTo}"^^xsd:integer`,
|
| 98 |
+
type: 'Literal',
|
| 99 |
+
properties: { value: edge.properties.validTo }
|
| 100 |
+
});
|
| 101 |
+
|
| 102 |
+
finalEdges.push({
|
| 103 |
+
id: `rel_vt_${edge.id}`,
|
| 104 |
+
from: stmtId,
|
| 105 |
+
to: litToId,
|
| 106 |
+
label: ':validTo',
|
| 107 |
+
type: 'reification',
|
| 108 |
+
properties: { isCurrent: false }
|
| 109 |
+
});
|
| 110 |
+
}
|
| 111 |
+
} else {
|
| 112 |
+
finalEdges.push(edge);
|
| 113 |
+
}
|
| 114 |
+
});
|
| 115 |
+
|
| 116 |
+
return { nodes: physicalNodes, edges: finalEdges };
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
return { nodes: physicalNodes, edges: physicalEdges };
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
// Case 2: Labeled Property Graph (LPG) Mode
|
| 123 |
+
if (storageMode === 'LPG' && is4D) {
|
| 124 |
+
const stateNodes = physicalNodes.filter(n => n.type === 'State');
|
| 125 |
+
const entityStates = new Map();
|
| 126 |
+
|
| 127 |
+
stateNodes.forEach(stateNode => {
|
| 128 |
+
let ownerId = stateNode.properties?.ownerId;
|
| 129 |
+
if (!ownerId) {
|
| 130 |
+
const tpoEdge = physicalEdges.find(e => e.from === stateNode.id && e.label === 'temporalPartOf');
|
| 131 |
+
if (tpoEdge) ownerId = tpoEdge.to.replace(/^4d_/, '');
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
if (ownerId) {
|
| 135 |
+
if (!entityStates.has(ownerId)) entityStates.set(ownerId, []);
|
| 136 |
+
entityStates.get(ownerId).push(stateNode);
|
| 137 |
+
}
|
| 138 |
+
});
|
| 139 |
+
|
| 140 |
+
entityStates.forEach((states, ownerId) => {
|
| 141 |
+
states.sort((a, b) => {
|
| 142 |
+
const fromA = a.properties?.validFrom ?? 0;
|
| 143 |
+
const fromB = b.properties?.validFrom ?? 0;
|
| 144 |
+
return fromA !== fromB ? fromA - fromB : a.id.localeCompare(b.id);
|
| 145 |
+
});
|
| 146 |
+
|
| 147 |
+
for (let i = 0; i < states.length - 1; i++) {
|
| 148 |
+
const currState = states[i];
|
| 149 |
+
const nextState = states[i + 1];
|
| 150 |
+
const transitionEdgeId = `trans_${ownerId}_${i}`;
|
| 151 |
+
|
| 152 |
+
if (!physicalEdges.some(e => e.id === transitionEdgeId)) {
|
| 153 |
+
physicalEdges.push({
|
| 154 |
+
id: transitionEdgeId,
|
| 155 |
+
from: currState.id,
|
| 156 |
+
to: nextState.id,
|
| 157 |
+
label: 'TRANSITION_TO',
|
| 158 |
+
type: 'transition',
|
| 159 |
+
properties: {
|
| 160 |
+
atTime: nextState.properties?.validFrom,
|
| 161 |
+
isCurrent: nextState.properties?.isCurrent ?? true
|
| 162 |
+
}
|
| 163 |
+
});
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
});
|
| 167 |
+
|
| 168 |
+
return { nodes: physicalNodes, edges: physicalEdges };
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
return { nodes: physicalNodes, edges: physicalEdges };
|
| 172 |
+
}
|
js/state.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { reactive } from 'vue';
|
|
|
|
| 2 |
|
| 3 |
/**
|
| 4 |
* SINGLE SOURCE OF TRUTH (Event Sourcing)
|
|
@@ -9,20 +10,35 @@ import { reactive } from 'vue';
|
|
| 9 |
*
|
| 10 |
* We only store the absolute domain truth:
|
| 11 |
* - Current Time dimension
|
| 12 |
-
* - Event Log (
|
| 13 |
-
* - Edge sequence counter
|
|
|
|
| 14 |
*/
|
| 15 |
export const state = reactive({
|
| 16 |
-
// 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
currentTime: 0,
|
| 18 |
|
| 19 |
-
//
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
eventLog: [],
|
| 23 |
|
| 24 |
-
//
|
| 25 |
-
edgeSequence: 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
});
|
| 27 |
|
| 28 |
/**
|
|
@@ -35,11 +51,23 @@ export function advanceTime() {
|
|
| 35 |
|
| 36 |
/**
|
| 37 |
* Completely replaces the current domain state.
|
| 38 |
-
* Useful for loading a saved JSON file or injecting a predefined
|
| 39 |
*
|
| 40 |
* @param {Object} newState - The data object containing the state to inject.
|
| 41 |
*/
|
| 42 |
export function loadState(newState) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
if (newState.currentTime !== undefined) {
|
| 44 |
state.currentTime = newState.currentTime;
|
| 45 |
}
|
|
@@ -51,4 +79,13 @@ export function loadState(newState) {
|
|
| 51 |
if (newState.edgeSequence !== undefined) {
|
| 52 |
state.edgeSequence = newState.edgeSequence;
|
| 53 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
|
|
|
|
|
| 1 |
import { reactive } from 'vue';
|
| 2 |
+
export { ENTITY_CLASSES, RELATION_TYPES } from './smrm/definitions.js';
|
| 3 |
|
| 4 |
/**
|
| 5 |
* SINGLE SOURCE OF TRUTH (Event Sourcing)
|
|
|
|
| 10 |
*
|
| 11 |
* We only store the absolute domain truth:
|
| 12 |
* - Current Time dimension
|
| 13 |
+
* - Event Log (domain business events over time)
|
| 14 |
+
* - Edge/Event sequence counter
|
| 15 |
+
* - Domain settings (e.g. Naive defect target variant)
|
| 16 |
*/
|
| 17 |
export const state = reactive({
|
| 18 |
+
// 1. Navigation View ('MENU' | 'SANDBOX' | 'SCENARIO')
|
| 19 |
+
currentView: 'MENU',
|
| 20 |
+
|
| 21 |
+
// 2. User Role ('UNI_ENGINEER')
|
| 22 |
+
userRole: 'UNI_ENGINEER',
|
| 23 |
+
|
| 24 |
+
// 3. Global Time Dimension
|
| 25 |
currentTime: 0,
|
| 26 |
|
| 27 |
+
// 4. Current Domain Ontology ('NAIVE_NODE' | 'NAIVE_EDGE' | 'BFO' | 'ISO15926')
|
| 28 |
+
ontology: 'NAIVE_NODE',
|
| 29 |
+
|
| 30 |
+
// 5. The Event Log (The core of our Domain-Driven Event Sourcing)
|
| 31 |
+
// Format: Pure business events (e.g. REGISTER_PART, ASSEMBLE, REPORT_DEFECT, DISMANTLE)
|
| 32 |
eventLog: [],
|
| 33 |
|
| 34 |
+
// 6. Counter to ensure unique identifiers for events
|
| 35 |
+
edgeSequence: 1,
|
| 36 |
+
|
| 37 |
+
// 7. Perspective View ('SMRM' | 'SMIM' | 'SMS')
|
| 38 |
+
perspective: 'SMRM',
|
| 39 |
+
|
| 40 |
+
// 8. Visual Graph Engine ('VIS' | 'MERMAID')
|
| 41 |
+
graphEngine: 'VIS'
|
| 42 |
});
|
| 43 |
|
| 44 |
/**
|
|
|
|
| 51 |
|
| 52 |
/**
|
| 53 |
* Completely replaces the current domain state.
|
| 54 |
+
* Useful for loading a saved JSON file or injecting a predefined scenario.
|
| 55 |
*
|
| 56 |
* @param {Object} newState - The data object containing the state to inject.
|
| 57 |
*/
|
| 58 |
export function loadState(newState) {
|
| 59 |
+
if (newState.currentView !== undefined) {
|
| 60 |
+
state.currentView = newState.currentView;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
if (newState.userRole !== undefined) {
|
| 64 |
+
state.userRole = newState.userRole;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
if (newState.ontology !== undefined) {
|
| 68 |
+
state.ontology = newState.ontology;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
if (newState.currentTime !== undefined) {
|
| 72 |
state.currentTime = newState.currentTime;
|
| 73 |
}
|
|
|
|
| 79 |
if (newState.edgeSequence !== undefined) {
|
| 80 |
state.edgeSequence = newState.edgeSequence;
|
| 81 |
}
|
| 82 |
+
|
| 83 |
+
if (newState.perspective !== undefined) {
|
| 84 |
+
state.perspective = newState.perspective;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
if (newState.graphEngine !== undefined) {
|
| 88 |
+
state.graphEngine = newState.graphEngine;
|
| 89 |
+
}
|
| 90 |
}
|
| 91 |
+
|
js/urmsm/bom-view.js
CHANGED
|
@@ -22,6 +22,11 @@ export function generateBomTree(rootId, activeEdges) {
|
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Helper function to recursively populate tree nodes while guarding against circular references.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
*
|
| 26 |
* @param {string} nodeId - Current node identifier.
|
| 27 |
* @param {Array<Object>} activeEdges - Array of active relationship edges.
|
|
@@ -36,10 +41,45 @@ function buildTreeRecursive(nodeId, activeEdges, visited = new Set()) {
|
|
| 36 |
const nextVisited = new Set(visited);
|
| 37 |
nextVisited.add(nodeId);
|
| 38 |
|
| 39 |
-
|
| 40 |
-
const
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
return {
|
| 45 |
id: nodeId,
|
|
|
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Helper function to recursively populate tree nodes while guarding against circular references.
|
| 25 |
+
* Strictly traverses the ontological hierarchy: Parent -> Slot -> Child.
|
| 26 |
+
*
|
| 27 |
+
* - When at a Parent (non-Slot): traverses outgoing has_slot or has_part edges to find contextual Slots or sub-components.
|
| 28 |
+
* - When at a Slot: traverses incoming mounted_in edges to locate the mounted Child component.
|
| 29 |
+
* - Under no circumstances does a Slot traverse backwards to its Parent, or a Child backwards to its Slot.
|
| 30 |
*
|
| 31 |
* @param {string} nodeId - Current node identifier.
|
| 32 |
* @param {Array<Object>} activeEdges - Array of active relationship edges.
|
|
|
|
| 41 |
const nextVisited = new Set(visited);
|
| 42 |
nextVisited.add(nodeId);
|
| 43 |
|
| 44 |
+
const childIds = new Set();
|
| 45 |
+
const edges = activeEdges || [];
|
| 46 |
+
|
| 47 |
+
// Determine if the current node is a contextual Slot
|
| 48 |
+
const isSlotNode = nodeId.startsWith('Slot_') ||
|
| 49 |
+
nodeId.startsWith('st_Slot_') ||
|
| 50 |
+
edges.some(e => e.to === nodeId && (e.label === 'has_slot' || e.type === 'has_slot'));
|
| 51 |
+
|
| 52 |
+
if (isSlotNode) {
|
| 53 |
+
// A Slot ONLY contains components mounted into it (Child -[mounted_in]-> Slot)
|
| 54 |
+
edges.forEach(e => {
|
| 55 |
+
const rel = e.label || e.relationType || e.type;
|
| 56 |
+
if (e.to === nodeId && (rel === 'mounted_in' || e.label === 'mounted_in')) {
|
| 57 |
+
if (!nextVisited.has(e.from)) {
|
| 58 |
+
childIds.add(e.from);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
});
|
| 62 |
+
} else {
|
| 63 |
+
// A non-Slot component/system traverses forward:
|
| 64 |
+
// 1. Outgoing slots: Parent -[has_slot]-> Slot
|
| 65 |
+
// 2. Direct sub-components: Parent -[has_part]-> Child
|
| 66 |
+
edges.forEach(e => {
|
| 67 |
+
const rel = e.label || e.relationType || e.type;
|
| 68 |
+
if (e.from === nodeId) {
|
| 69 |
+
if (rel === 'has_slot' || e.label === 'has_slot') {
|
| 70 |
+
if (!nextVisited.has(e.to)) {
|
| 71 |
+
childIds.add(e.to);
|
| 72 |
+
}
|
| 73 |
+
} else if (rel === 'has_part' || e.label === 'has_part') {
|
| 74 |
+
if (!nextVisited.has(e.to)) {
|
| 75 |
+
childIds.add(e.to);
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
});
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
const children = Array.from(childIds).map(childId => buildTreeRecursive(childId, edges, nextVisited));
|
| 83 |
|
| 84 |
return {
|
| 85 |
id: nodeId,
|
js/urmsm/smrm-view.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* URMSM LAYER: SMRM GRAPH REDUCTION VIEWPOINT (ISO 42010)
|
| 3 |
+
* -------------------------------------------------------
|
| 4 |
+
* Transforms a canonical SMIM Semantic Graph into the engineer's SMRM perspective.
|
| 5 |
+
* Visually collapses intermediate contextual Slot nodes and renders direct
|
| 6 |
+
* transitive relationships between parent and child components.
|
| 7 |
+
*
|
| 8 |
+
* Crucially preserves and transfers properties (such as defects like { crack: '2mm' })
|
| 9 |
+
* from the original mounting relationship onto the direct transitive relationship.
|
| 10 |
+
*
|
| 11 |
+
* Adheres strictly to the Rule of Isolation:
|
| 12 |
+
* Pure graph-to-graph reduction middleware without DOM or Vue coupling.
|
| 13 |
+
*
|
| 14 |
+
* @param {Object} semanticGraph - Canonical Semantic Graph ({ nodes: Array, edges: Array }).
|
| 15 |
+
* @returns {Object} Reduced Semantic Graph ({ nodes: Array, edges: Array }) for SMRM rendering.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
export function reduceGraphForSMRM(semanticGraph) {
|
| 19 |
+
if (!semanticGraph || !Array.isArray(semanticGraph.nodes) || !Array.isArray(semanticGraph.edges)) {
|
| 20 |
+
return { nodes: [], edges: [] };
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
// 1. Identify all Slot nodes in the semantic graph
|
| 24 |
+
const slotNodeIds = new Set();
|
| 25 |
+
semanticGraph.nodes.forEach(node => {
|
| 26 |
+
const isSlot = node.type === 'Slot' ||
|
| 27 |
+
node.properties?.entityClass === 'Slot' ||
|
| 28 |
+
node.id.startsWith('Slot_') ||
|
| 29 |
+
node.id.startsWith('4d_Slot_') ||
|
| 30 |
+
node.id.startsWith('st_Slot_');
|
| 31 |
+
if (isSlot) {
|
| 32 |
+
slotNodeIds.add(node.id);
|
| 33 |
+
}
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
if (slotNodeIds.size === 0) {
|
| 37 |
+
return {
|
| 38 |
+
nodes: semanticGraph.nodes.map(n => ({ ...n, properties: { ...(n.properties || {}) } })),
|
| 39 |
+
edges: semanticGraph.edges.map(e => ({ ...e, properties: { ...(e.properties || {}) } }))
|
| 40 |
+
};
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
const nodesToRemove = new Set(slotNodeIds);
|
| 44 |
+
const edgesToRemove = new Set();
|
| 45 |
+
const directTransitiveEdges = [];
|
| 46 |
+
|
| 47 |
+
// 2. Locate and collapse [Parent] -[has_slot]-> [Slot] <-[mounted_in]- [Child]
|
| 48 |
+
slotNodeIds.forEach(slotId => {
|
| 49 |
+
// Find has_slot edges from Parent to Slot
|
| 50 |
+
const hasSlotEdges = semanticGraph.edges.filter(
|
| 51 |
+
e => e.to === slotId && (e.label === 'has_slot' || e.type === 'has_slot')
|
| 52 |
+
);
|
| 53 |
+
|
| 54 |
+
// Find mounted_in edges from Child to Slot
|
| 55 |
+
const mountedInEdges = semanticGraph.edges.filter(
|
| 56 |
+
e => e.to === slotId && (e.label === 'mounted_in' || e.type === 'mounted_in' || e.type === 'composition')
|
| 57 |
+
);
|
| 58 |
+
|
| 59 |
+
hasSlotEdges.forEach(hasSlotEdge => {
|
| 60 |
+
edgesToRemove.add(hasSlotEdge.id);
|
| 61 |
+
const parentNodeId = hasSlotEdge.from;
|
| 62 |
+
|
| 63 |
+
mountedInEdges.forEach(mountedInEdge => {
|
| 64 |
+
edgesToRemove.add(mountedInEdge.id);
|
| 65 |
+
const childNodeId = mountedInEdge.from;
|
| 66 |
+
|
| 67 |
+
// Formulate direct transitive edge: Parent -> Child
|
| 68 |
+
const directEdgeId = `smrm_${parentNodeId}_${childNodeId}_${mountedInEdge.properties?.validFrom ?? 0}`;
|
| 69 |
+
|
| 70 |
+
directTransitiveEdges.push({
|
| 71 |
+
id: directEdgeId,
|
| 72 |
+
from: parentNodeId,
|
| 73 |
+
to: childNodeId,
|
| 74 |
+
label: 'has_part',
|
| 75 |
+
type: 'composition',
|
| 76 |
+
childId: childNodeId,
|
| 77 |
+
parentId: parentNodeId,
|
| 78 |
+
properties: {
|
| 79 |
+
...(mountedInEdge.properties || {})
|
| 80 |
+
}
|
| 81 |
+
});
|
| 82 |
+
});
|
| 83 |
+
});
|
| 84 |
+
|
| 85 |
+
// Also remove temporalPartOf edges linking slot state slices to 4D extents
|
| 86 |
+
semanticGraph.edges.forEach(e => {
|
| 87 |
+
if ((e.from === slotId || e.to === slotId) && e.label === 'temporalPartOf') {
|
| 88 |
+
edgesToRemove.add(e.id);
|
| 89 |
+
}
|
| 90 |
+
});
|
| 91 |
+
});
|
| 92 |
+
|
| 93 |
+
const remainingNodes = semanticGraph.nodes
|
| 94 |
+
.filter(n => !nodesToRemove.has(n.id))
|
| 95 |
+
.map(n => ({ ...n, properties: { ...(n.properties || {}) } }));
|
| 96 |
+
|
| 97 |
+
const remainingEdges = semanticGraph.edges
|
| 98 |
+
.filter(e => !edgesToRemove.has(e.id))
|
| 99 |
+
.map(e => ({ ...e, properties: { ...(e.properties || {}) } }))
|
| 100 |
+
.concat(directTransitiveEdges);
|
| 101 |
+
|
| 102 |
+
return {
|
| 103 |
+
nodes: remainingNodes,
|
| 104 |
+
edges: remainingEdges
|
| 105 |
+
};
|
| 106 |
+
}
|
narratives/Ontologies_-_Disappearing_Crack.mp3
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:70128830a78572eef8c50af4700df8285068911e4b27fba0d8b4d6d02f8dca40
|
| 3 |
+
size 3548006
|
narratives/Ontologies_-_Disappearing_Crack.srt
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:05,701
|
| 3 |
+
Welcome to the data sandbox. Currently,
|
| 4 |
+
the system is operating in 'Naive Graph'
|
| 5 |
+
|
| 6 |
+
2
|
| 7 |
+
00:00:05,701 --> 00:00:11,186
|
| 8 |
+
mode. We have no strict ontological
|
| 9 |
+
rules—just nodes and relationships. Let’s
|
| 10 |
+
|
| 11 |
+
3
|
| 12 |
+
00:00:11,186 --> 00:00:14,000
|
| 13 |
+
model a typical manufacturing scenario.
|
| 14 |
+
|
| 15 |
+
4
|
| 16 |
+
00:00:14,029 --> 00:00:19,652
|
| 17 |
+
We have a vehicle. Within it, there is a
|
| 18 |
+
suspension slot, where part "M zero one"
|
| 19 |
+
|
| 20 |
+
5
|
| 21 |
+
00:00:19,652 --> 00:00:24,361
|
| 22 |
+
is installed. Everything is
|
| 23 |
+
straightforward. But what happens when a
|
| 24 |
+
|
| 25 |
+
6
|
| 26 |
+
00:00:24,361 --> 00:00:26,189
|
| 27 |
+
real-world problem occurs?
|
| 28 |
+
|
| 29 |
+
7
|
| 30 |
+
00:00:26,230 --> 00:00:32,184
|
| 31 |
+
During an inspection, a two-millimetre
|
| 32 |
+
crack is discovered on part "M zero one".
|
| 33 |
+
|
| 34 |
+
8
|
| 35 |
+
00:00:32,184 --> 00:00:35,350
|
| 36 |
+
How do we store this fact in a naive
|
| 37 |
+
graph?
|
| 38 |
+
|
| 39 |
+
9
|
| 40 |
+
00:00:35,322 --> 00:00:40,485
|
| 41 |
+
The developer faces a dilemma. If we add
|
| 42 |
+
the property "crack: two millimetres"
|
| 43 |
+
|
| 44 |
+
10
|
| 45 |
+
00:00:40,485 --> 00:00:45,715
|
| 46 |
+
directly to the part node, then when we
|
| 47 |
+
try to query the car's condition a year
|
| 48 |
+
|
| 49 |
+
11
|
| 50 |
+
00:00:45,715 --> 00:00:50,878
|
| 51 |
+
ago, the system will answer that the part
|
| 52 |
+
was already broken. Because the node
|
| 53 |
+
|
| 54 |
+
12
|
| 55 |
+
00:00:50,878 --> 00:00:53,962
|
| 56 |
+
exists outside of time—it has been
|
| 57 |
+
overwritten.
|
| 58 |
+
|
| 59 |
+
13
|
| 60 |
+
00:00:53,923 --> 00:00:59,807
|
| 61 |
+
The obvious workaround is to attach the
|
| 62 |
+
defect information to the temporal edge:
|
| 63 |
+
|
| 64 |
+
14
|
| 65 |
+
00:00:59,807 --> 00:01:05,095
|
| 66 |
+
"MOUNTED_IN". Excellent. The crack is
|
| 67 |
+
anchored in time. The inspector is
|
| 68 |
+
|
| 69 |
+
15
|
| 70 |
+
00:01:05,095 --> 00:01:09,043
|
| 71 |
+
satisfied, and the database has saved the
|
| 72 |
+
information.
|
| 73 |
+
|
| 74 |
+
16
|
| 75 |
+
00:01:08,997 --> 00:01:14,256
|
| 76 |
+
But then comes the next day. The part is
|
| 77 |
+
removed from the vehicle and sent to the
|
| 78 |
+
|
| 79 |
+
17
|
| 80 |
+
00:01:14,256 --> 00:01:15,637
|
| 81 |
+
warehouse for repair.
|
| 82 |
+
|
| 83 |
+
18
|
| 84 |
+
00:01:15,607 --> 00:01:21,341
|
| 85 |
+
The mounting edge is closed and archived.
|
| 86 |
+
The part is now linked to the warehouse.
|
| 87 |
+
|
| 88 |
+
19
|
| 89 |
+
00:01:21,341 --> 00:01:26,438
|
| 90 |
+
Now, let’s ask the system: "How many
|
| 91 |
+
defective parts are currently in the
|
| 92 |
+
|
| 93 |
+
20
|
| 94 |
+
00:01:26,438 --> 00:01:27,287
|
| 95 |
+
warehouse?".
|
| 96 |
+
|
| 97 |
+
21
|
| 98 |
+
00:01:27,259 --> 00:01:32,747
|
| 99 |
+
The system answers: Zero. The crack has
|
| 100 |
+
disappeared from the vehicle, but in the
|
| 101 |
+
|
| 102 |
+
22
|
| 103 |
+
00:01:32,747 --> 00:01:38,097
|
| 104 |
+
warehouse, the part is registered as
|
| 105 |
+
completely flawless! The defect attribute
|
| 106 |
+
|
| 107 |
+
23
|
| 108 |
+
00:01:38,097 --> 00:01:43,099
|
| 109 |
+
remains buried in the archived mounting
|
| 110 |
+
edge. Our naive approach has just
|
| 111 |
+
|
| 112 |
+
24
|
| 113 |
+
00:01:43,099 --> 00:01:45,739
|
| 114 |
+
destroyed critical data about a fault.
|
| 115 |
+
|
| 116 |
+
25
|
| 117 |
+
00:01:45,703 --> 00:01:51,206
|
| 118 |
+
This is exactly where the naive approach
|
| 119 |
+
collapses, and an industrial ontology is
|
| 120 |
+
|
| 121 |
+
26
|
| 122 |
+
00:01:51,206 --> 00:01:56,503
|
| 123 |
+
required. We are now switching the system
|
| 124 |
+
to ISO fifteen nine twenty-six mode.
|
| 125 |
+
|
| 126 |
+
27
|
| 127 |
+
00:01:56,467 --> 00:02:01,568
|
| 128 |
+
Under this standard, a part is not a
|
| 129 |
+
static node, but a four-dimensional
|
| 130 |
+
|
| 131 |
+
28
|
| 132 |
+
00:02:01,568 --> 00:02:06,669
|
| 133 |
+
object with temporal life stages. A
|
| 134 |
+
defect is an independent entity that
|
| 135 |
+
|
| 136 |
+
29
|
| 137 |
+
00:02:06,669 --> 00:02:12,057
|
| 138 |
+
classifies the condition of a specific
|
| 139 |
+
temporal stage of the part. Now, when
|
| 140 |
+
|
| 141 |
+
30
|
| 142 |
+
00:02:12,057 --> 00:02:17,445
|
| 143 |
+
moved to the warehouse, the part takes
|
| 144 |
+
its state history with it. Data is no
|
| 145 |
+
|
| 146 |
+
31
|
| 147 |
+
00:02:17,445 --> 00:02:18,307
|
| 148 |
+
longer lost.
|
| 149 |
+
|
styles/Twemoji-16.0.1.ttf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95afd85539738fa5ebe772911ba403dce82b90c14c8cb4a13325a86fc239c7a2
|
| 3 |
+
size 3382500
|
styles/main.css
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
|
| 2 |
body { margin: 0; padding: 12px; background: #f8fafc; color: #0f172a; display: flex; flex-direction: column; height: 100vh; }
|
| 3 |
|
|
@@ -28,7 +35,11 @@ button.danger:hover { background: #dc2626; }
|
|
| 28 |
.btn-group button { border-radius: 0; background: #ffffff; color: #475569; padding: 4px 10px; border-right: 1px solid #cbd5e1; font-size: 12px; font-weight: 600; line-height: 1.2; }
|
| 29 |
.btn-group button:last-child { border-right: none; }
|
| 30 |
.btn-group button.active { background: #0284c7; color: #ffffff; }
|
| 31 |
-
.btn-group.flag-group button {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
input, select { padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12px; }
|
| 34 |
.divider { height: 18px; width: 1px; background: #cbd5e1; margin: 0 4px; }
|
|
@@ -46,6 +57,7 @@ input, select { padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px;
|
|
| 46 |
.resizer-h:hover, .resizer-h.dragging { background-color: #cbd5e1; border-color: #94a3b8; }
|
| 47 |
body.no-select { user-select: none; }
|
| 48 |
|
|
|
|
| 49 |
.graph-legend { position: absolute; bottom: 12px; left: 12px; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(4px); border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); font-size: 11px; color: #334155; z-index: 20; max-width: 330px; }
|
| 50 |
.legend-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #475569; margin-bottom: 6px; display: flex; justify-content: space-between; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
|
| 51 |
.legend-section { margin-top: 5px; }
|
|
@@ -61,6 +73,16 @@ body.no-select { user-select: none; }
|
|
| 61 |
.swatch-line-active { width: 16px; height: 2px; background: #10b981; margin-right: 8px; flex-shrink: 0; }
|
| 62 |
.swatch-line-past { width: 16px; height: 0; border-top: 2px dashed #94a3b8; margin-right: 8px; flex-shrink: 0; }
|
| 63 |
.swatch-line-transition { width: 16px; height: 2px; background: #f59e0b; margin-right: 8px; flex-shrink: 0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
.sidebar { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 350px; }
|
| 66 |
.card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; }
|
|
@@ -83,4 +105,316 @@ pre.code-block { margin: 0; font-family: monospace; font-size: 11px; color: #334
|
|
| 83 |
flex: 1;
|
| 84 |
height: 100%;
|
| 85 |
min-height: 0;
|
| 86 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@font-face {
|
| 2 |
+
font-family: 'Twemoji';
|
| 3 |
+
src: url('./Twemoji-16.0.1.ttf') format('truetype');
|
| 4 |
+
font-weight: normal;
|
| 5 |
+
font-style: normal;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
* { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
|
| 9 |
body { margin: 0; padding: 12px; background: #f8fafc; color: #0f172a; display: flex; flex-direction: column; height: 100vh; }
|
| 10 |
|
|
|
|
| 35 |
.btn-group button { border-radius: 0; background: #ffffff; color: #475569; padding: 4px 10px; border-right: 1px solid #cbd5e1; font-size: 12px; font-weight: 600; line-height: 1.2; }
|
| 36 |
.btn-group button:last-child { border-right: none; }
|
| 37 |
.btn-group button.active { background: #0284c7; color: #ffffff; }
|
| 38 |
+
.btn-group.flag-group button {
|
| 39 |
+
font-family: 'Twemoji', system-ui, sans-serif;
|
| 40 |
+
font-size: 15px;
|
| 41 |
+
padding: 3px 8px;
|
| 42 |
+
}
|
| 43 |
|
| 44 |
input, select { padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 12px; }
|
| 45 |
.divider { height: 18px; width: 1px; background: #cbd5e1; margin: 0 4px; }
|
|
|
|
| 57 |
.resizer-h:hover, .resizer-h.dragging { background-color: #cbd5e1; border-color: #94a3b8; }
|
| 58 |
body.no-select { user-select: none; }
|
| 59 |
|
| 60 |
+
.graph-caption { position: absolute; top: 12px; left: 12px; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(4px); border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); font-size: 11px; font-weight: 700; color: #1e293b; z-index: 20; display: flex; align-items: center; gap: 6px; letter-spacing: 0.02em; pointer-events: none; }
|
| 61 |
.graph-legend { position: absolute; bottom: 12px; left: 12px; background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(4px); border: 1px solid #cbd5e1; border-radius: 8px; padding: 10px 14px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); font-size: 11px; color: #334155; z-index: 20; max-width: 330px; }
|
| 62 |
.legend-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #475569; margin-bottom: 6px; display: flex; justify-content: space-between; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
|
| 63 |
.legend-section { margin-top: 5px; }
|
|
|
|
| 73 |
.swatch-line-active { width: 16px; height: 2px; background: #10b981; margin-right: 8px; flex-shrink: 0; }
|
| 74 |
.swatch-line-past { width: 16px; height: 0; border-top: 2px dashed #94a3b8; margin-right: 8px; flex-shrink: 0; }
|
| 75 |
.swatch-line-transition { width: 16px; height: 2px; background: #f59e0b; margin-right: 8px; flex-shrink: 0; }
|
| 76 |
+
.swatch-box-vehicle { width: 13px; height: 11px; background: #0284c7; border: 1px solid #0369a1; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
|
| 77 |
+
.swatch-box-slot { width: 13px; height: 11px; background: #64748b; border: 1px solid #475569; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
|
| 78 |
+
.swatch-box-part { width: 13px; height: 11px; background: #10b981; border: 1px solid #059669; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
|
| 79 |
+
.swatch-diamond-defect { width: 9px; height: 9px; background: #ef4444; border: 1px solid #dc2626; transform: rotate(45deg); margin: 0 10px 0 2px; flex-shrink: 0; }
|
| 80 |
+
.swatch-box-warehouse { width: 13px; height: 11px; background: #f97316; border: 1px solid #ea580c; border-radius: 2px; margin-right: 8px; flex-shrink: 0; }
|
| 81 |
+
.swatch-line-slot { width: 16px; height: 2px; background: #0284c7; margin-right: 8px; flex-shrink: 0; }
|
| 82 |
+
.swatch-line-mount { width: 16px; height: 2px; background: #10b981; margin-right: 8px; flex-shrink: 0; }
|
| 83 |
+
.swatch-line-store { width: 16px; height: 2px; background: #f97316; margin-right: 8px; flex-shrink: 0; }
|
| 84 |
+
.swatch-line-defect { width: 16px; height: 2px; background: #ef4444; margin-right: 8px; flex-shrink: 0; }
|
| 85 |
+
|
| 86 |
|
| 87 |
.sidebar { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 350px; }
|
| 88 |
.card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; overflow-y: auto; display: flex; flex-direction: column; }
|
|
|
|
| 105 |
flex: 1;
|
| 106 |
height: 100%;
|
| 107 |
min-height: 0;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/* Sandbox Workspace Wrapper */
|
| 111 |
+
.sandbox-workspace {
|
| 112 |
+
display: flex;
|
| 113 |
+
flex-direction: column;
|
| 114 |
+
flex: 1;
|
| 115 |
+
min-height: 0;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/* Main Menu / Landing View */
|
| 119 |
+
.landing-view {
|
| 120 |
+
display: flex;
|
| 121 |
+
flex: 1;
|
| 122 |
+
align-items: center;
|
| 123 |
+
justify-content: center;
|
| 124 |
+
min-height: 100%;
|
| 125 |
+
padding: 24px;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.menu-card {
|
| 129 |
+
max-width: 540px;
|
| 130 |
+
width: 100%;
|
| 131 |
+
background: #ffffff;
|
| 132 |
+
border: 1px solid #cbd5e1;
|
| 133 |
+
border-radius: 12px;
|
| 134 |
+
padding: 36px 32px;
|
| 135 |
+
box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
|
| 136 |
+
text-align: center;
|
| 137 |
+
display: flex;
|
| 138 |
+
flex-direction: column;
|
| 139 |
+
align-items: center;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.menu-badge {
|
| 143 |
+
display: inline-block;
|
| 144 |
+
background: #e0f2fe;
|
| 145 |
+
color: #0369a1;
|
| 146 |
+
border: 1px solid #7dd3fc;
|
| 147 |
+
padding: 4px 12px;
|
| 148 |
+
border-radius: 9999px;
|
| 149 |
+
font-size: 11px;
|
| 150 |
+
font-weight: 700;
|
| 151 |
+
letter-spacing: 0.05em;
|
| 152 |
+
text-transform: uppercase;
|
| 153 |
+
margin-bottom: 16px;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.menu-title {
|
| 157 |
+
font-size: 22px;
|
| 158 |
+
font-weight: 800;
|
| 159 |
+
color: #0f172a;
|
| 160 |
+
margin: 0 0 8px 0;
|
| 161 |
+
letter-spacing: -0.02em;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.menu-subtitle {
|
| 165 |
+
font-size: 13px;
|
| 166 |
+
color: #64748b;
|
| 167 |
+
margin: 0 0 28px 0;
|
| 168 |
+
line-height: 1.5;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.menu-actions {
|
| 172 |
+
display: flex;
|
| 173 |
+
flex-direction: column;
|
| 174 |
+
gap: 14px;
|
| 175 |
+
width: 100%;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
.menu-btn {
|
| 179 |
+
display: flex;
|
| 180 |
+
flex-direction: column;
|
| 181 |
+
align-items: flex-start;
|
| 182 |
+
text-align: left;
|
| 183 |
+
padding: 16px 20px;
|
| 184 |
+
border-radius: 8px;
|
| 185 |
+
border: 1px solid transparent;
|
| 186 |
+
cursor: pointer;
|
| 187 |
+
transition: all 0.2s ease-in-out;
|
| 188 |
+
width: 100%;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.menu-btn .btn-main-text {
|
| 192 |
+
font-size: 15px;
|
| 193 |
+
font-weight: 700;
|
| 194 |
+
margin-bottom: 4px;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.menu-btn .btn-sub-text {
|
| 198 |
+
font-size: 12px;
|
| 199 |
+
font-weight: 400;
|
| 200 |
+
opacity: 0.85;
|
| 201 |
+
line-height: 1.35;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
.menu-btn-primary {
|
| 205 |
+
background: #0284c7;
|
| 206 |
+
color: #ffffff;
|
| 207 |
+
border-color: #0369a1;
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
.menu-btn-primary:hover {
|
| 211 |
+
background: #0369a1;
|
| 212 |
+
box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
|
| 213 |
+
transform: translateY(-1px);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.menu-btn-scenario {
|
| 217 |
+
background: #ffffff;
|
| 218 |
+
color: #0f172a;
|
| 219 |
+
border-color: #cbd5e1;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
.menu-btn-scenario:hover {
|
| 223 |
+
background: #f8fafc;
|
| 224 |
+
border-color: #94a3b8;
|
| 225 |
+
box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
|
| 226 |
+
transform: translateY(-1px);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
/* Floating Home Button */
|
| 230 |
+
.floating-home-btn {
|
| 231 |
+
position: fixed;
|
| 232 |
+
bottom: 20px;
|
| 233 |
+
right: 20px;
|
| 234 |
+
z-index: 9999;
|
| 235 |
+
width: 48px;
|
| 236 |
+
height: 48px;
|
| 237 |
+
border-radius: 50%;
|
| 238 |
+
background: #0f172a;
|
| 239 |
+
color: #ffffff;
|
| 240 |
+
border: 1px solid #334155;
|
| 241 |
+
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
|
| 242 |
+
display: flex;
|
| 243 |
+
align-items: center;
|
| 244 |
+
justify-content: center;
|
| 245 |
+
padding: 0;
|
| 246 |
+
cursor: pointer;
|
| 247 |
+
transition: all 0.2s ease-in-out;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.floating-home-btn:hover {
|
| 251 |
+
background: #1e293b;
|
| 252 |
+
transform: translateY(-2px);
|
| 253 |
+
box-shadow: 0 6px 18px rgba(15, 23, 42, 0.35);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
.floating-home-btn:active {
|
| 257 |
+
transform: translateY(0);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
/* Floating Player Panel & Subtitles Overlay (Scenario Mode) */
|
| 261 |
+
.scenario-subtitles {
|
| 262 |
+
position: fixed;
|
| 263 |
+
bottom: 82px;
|
| 264 |
+
left: 50%;
|
| 265 |
+
transform: translateX(-50%);
|
| 266 |
+
z-index: 9999;
|
| 267 |
+
background: rgba(15, 23, 42, 0.88);
|
| 268 |
+
backdrop-filter: blur(6px);
|
| 269 |
+
-webkit-backdrop-filter: blur(6px);
|
| 270 |
+
color: #ffffff;
|
| 271 |
+
padding: 12px 24px;
|
| 272 |
+
border-radius: 8px;
|
| 273 |
+
font-size: 15px;
|
| 274 |
+
font-weight: 500;
|
| 275 |
+
line-height: 1.45;
|
| 276 |
+
text-align: center;
|
| 277 |
+
max-width: 680px;
|
| 278 |
+
min-width: 320px;
|
| 279 |
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
|
| 280 |
+
border: 1px solid rgba(255, 255, 255, 0.12);
|
| 281 |
+
pointer-events: none;
|
| 282 |
+
transition: opacity 0.2s ease-in-out;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.scenario-player-panel {
|
| 286 |
+
position: fixed;
|
| 287 |
+
bottom: 20px;
|
| 288 |
+
left: 50%;
|
| 289 |
+
transform: translateX(-50%);
|
| 290 |
+
z-index: 9999;
|
| 291 |
+
display: flex;
|
| 292 |
+
align-items: center;
|
| 293 |
+
gap: 12px;
|
| 294 |
+
background: #0f172a;
|
| 295 |
+
color: #f8fafc;
|
| 296 |
+
padding: 8px 18px;
|
| 297 |
+
border-radius: 40px;
|
| 298 |
+
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
|
| 299 |
+
border: 1px solid #334155;
|
| 300 |
+
user-select: none;
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
.player-btn {
|
| 304 |
+
display: inline-flex;
|
| 305 |
+
align-items: center;
|
| 306 |
+
justify-content: center;
|
| 307 |
+
width: 34px;
|
| 308 |
+
height: 34px;
|
| 309 |
+
border-radius: 50%;
|
| 310 |
+
background: #1e293b;
|
| 311 |
+
color: #ffffff;
|
| 312 |
+
border: 1px solid #475569;
|
| 313 |
+
cursor: pointer;
|
| 314 |
+
padding: 0;
|
| 315 |
+
font-size: 13px;
|
| 316 |
+
transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
.player-btn:hover {
|
| 320 |
+
background: #334155;
|
| 321 |
+
border-color: #64748b;
|
| 322 |
+
transform: scale(1.05);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
.player-btn:active {
|
| 326 |
+
transform: scale(0.95);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
.player-btn.active {
|
| 330 |
+
background: #0284c7;
|
| 331 |
+
border-color: #38bdf8;
|
| 332 |
+
color: #ffffff;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
.player-btn-cc {
|
| 336 |
+
font-size: 11px;
|
| 337 |
+
font-weight: 700;
|
| 338 |
+
letter-spacing: 0.05em;
|
| 339 |
+
border-radius: 6px;
|
| 340 |
+
width: 34px;
|
| 341 |
+
height: 30px;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
.player-progress {
|
| 345 |
+
width: 240px;
|
| 346 |
+
height: 6px;
|
| 347 |
+
-webkit-appearance: none;
|
| 348 |
+
appearance: none;
|
| 349 |
+
background: #334155;
|
| 350 |
+
border-radius: 3px;
|
| 351 |
+
outline: none;
|
| 352 |
+
cursor: pointer;
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
.player-progress::-webkit-slider-thumb {
|
| 356 |
+
-webkit-appearance: none;
|
| 357 |
+
appearance: none;
|
| 358 |
+
width: 14px;
|
| 359 |
+
height: 14px;
|
| 360 |
+
border-radius: 50%;
|
| 361 |
+
background: #38bdf8;
|
| 362 |
+
cursor: pointer;
|
| 363 |
+
box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
|
| 364 |
+
transition: transform 0.1s ease, background-color 0.15s ease;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
.player-progress::-webkit-slider-thumb:hover {
|
| 368 |
+
transform: scale(1.2);
|
| 369 |
+
background: #7dd3fc;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
.player-progress::-moz-range-thumb {
|
| 373 |
+
width: 14px;
|
| 374 |
+
height: 14px;
|
| 375 |
+
border-radius: 50%;
|
| 376 |
+
background: #38bdf8;
|
| 377 |
+
border: none;
|
| 378 |
+
cursor: pointer;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
/* Role Switcher Styling */
|
| 382 |
+
.btn-group.role-group button {
|
| 383 |
+
font-weight: 600;
|
| 384 |
+
display: inline-flex;
|
| 385 |
+
align-items: center;
|
| 386 |
+
gap: 5px;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
.btn-group.role-group button.active {
|
| 390 |
+
background: #4f46e5;
|
| 391 |
+
color: #ffffff;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
/* Universal Engineer Workspace Placeholder */
|
| 395 |
+
.uni-engineer-placeholder {
|
| 396 |
+
min-height: 52px;
|
| 397 |
+
background: #f8fafc;
|
| 398 |
+
border-top: 1px solid #e2e8f0;
|
| 399 |
+
border-bottom-left-radius: 7px;
|
| 400 |
+
border-bottom-right-radius: 7px;
|
| 401 |
+
display: flex;
|
| 402 |
+
align-items: center;
|
| 403 |
+
padding: 12px 16px;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
.player-time {
|
| 407 |
+
font-size: 12px;
|
| 408 |
+
font-variant-numeric: tabular-nums;
|
| 409 |
+
color: #94a3b8;
|
| 410 |
+
min-width: 80px;
|
| 411 |
+
text-align: center;
|
| 412 |
+
user-select: none;
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
/* Phantom User UI Highlight (Scenario Mode) */
|
| 416 |
+
.scenario-highlight {
|
| 417 |
+
box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.8) !important;
|
| 418 |
+
background-color: rgba(255, 255, 200, 0.3) !important;
|
| 419 |
+
transition: all 0.3s ease;
|
| 420 |
+
}
|