|
| 1 | +--- |
| 2 | +icon: material/animation-play |
| 3 | +search: |
| 4 | + exclude: false |
| 5 | +tags: |
| 6 | + - tutorial |
| 7 | + - example |
| 8 | + - interactive |
| 9 | +--- |
| 10 | +# Engine Timeline Visualizer |
| 11 | + |
| 12 | +## Engine communication |
| 13 | + |
| 14 | +This interactive tutorial helps you explore how we envision [[Anomian|engines]] |
| 15 | +communicating through message passing. The visualization tool takes a JSON |
| 16 | +configuration and renders an animated timeline of message interactions between |
| 17 | +engines. |
| 18 | + |
| 19 | +<div class="interactive-timeline-wrapper"> |
| 20 | +<iframe |
| 21 | +class="interactive-timeline" |
| 22 | +src="app.html" |
| 23 | +width="100%" |
| 24 | +height="500px"> |
| 25 | +</iframe> |
| 26 | +</div> |
| 27 | + |
| 28 | +## Getting Started |
| 29 | + |
| 30 | +### how to use |
| 31 | + |
| 32 | +1. **Start the visualization** by clicking dotted message lines. |
| 33 | +2. **Hover over elements** to see detailed tooltips. |
| 34 | +3. **Watch the timeline scroll** automatically as messages propagate. |
| 35 | +4. **Observe engine states** update in real-time above each engine. |
| 36 | + |
| 37 | +### Visual interface overview |
| 38 | + |
| 39 | +- **Engine Nodes**: Coloured boxes at top representing system components. |
| 40 | +- **Timeline**: Vertical lines showing message history and potential paths. |
| 41 | +- **Message Types**: |
| 42 | + - **Dotted Lines**: Potential messages (click to send). |
| 43 | + - **Solid Lines**: Active message animations |
| 44 | + - **Faded Lines**: Historical messages |
| 45 | + |
| 46 | +## Core Concepts |
| 47 | + |
| 48 | +### message lifecycle |
| 49 | + |
| 50 | +1. **Initiation**: Click potential message (dotted line). |
| 51 | +2. **Transmission**: Animation shows message travelling between engines. |
| 52 | +3. **Processing**: Receiving engine evaluates message against handlers. |
| 53 | +4. **Response**: New potential messages generated based on updated state. |
| 54 | + |
| 55 | +### Configuration Guide |
| 56 | + |
| 57 | +??? example "JSON Schema Structure" |
| 58 | + ```json |
| 59 | + { |
| 60 | + "engines": [ |
| 61 | + { |
| 62 | + "name": "EngineName", |
| 63 | + "initialState": any, |
| 64 | + "messageHandlers": [ |
| 65 | + { |
| 66 | + "stateEffect": "return state + 1;", |
| 67 | + "guard": "return messageType === 'messageType1';", |
| 68 | + "generateMessages": [ |
| 69 | + { |
| 70 | + "to": "TargetEngineName", |
| 71 | + "type": "responseMessageType", |
| 72 | + "payload": null |
| 73 | + } |
| 74 | + ] |
| 75 | + } |
| 76 | + ], |
| 77 | + "initialMessages": [ |
| 78 | + { |
| 79 | + "to": "TargetEngineName", |
| 80 | + "type": "initialMessageType", |
| 81 | + "payload": null |
| 82 | + } |
| 83 | + ] |
| 84 | + } |
| 85 | + ] |
| 86 | + } |
| 87 | + ``` |
| 88 | + |
| 89 | +??? note "Field Reference" |
| 90 | + |
| 91 | + #### Engine configuration |
| 92 | + |
| 93 | + | Field | Type | Description | |
| 94 | + |-------|------|-------------| |
| 95 | + | `name` | string | Unique engine identifier | |
| 96 | + | `initialState` | any | Starting state value | |
| 97 | + | `messageHandlers` | array | Message processing rules | |
| 98 | + | `initialMessages` | array | Initial outgoing messages | |
| 99 | + |
| 100 | + #### Handler configuration |
| 101 | + |
| 102 | + | Field | Context Variables | Description | |
| 103 | + |-------|-------------------|-------------| |
| 104 | + | `stateEffect` | `state`, `payload` | JS code returning new state | |
| 105 | + | `guard` | `state`, `payload`, `messageType` | JS condition for handler activation | |
| 106 | + | `generateMessages` | `state`, `payload` | Messages to send if guard passes | |
| 107 | + |
| 108 | +### Advanced Features |
| 109 | + |
| 110 | +!!! tip "Special Message Handling" |
| 111 | + |
| 112 | + - **Loopback Messages**: Use `"to": "from"` to return messages to sender |
| 113 | + - **Dynamic Payloads**: Include JS code in payload strings: |
| 114 | + ```json |
| 115 | + "payload": "return {timestamp: Date.now(), value: state}" |
| 116 | + ``` |
| 117 | + - **State Access**: Handlers can access: |
| 118 | + - `state`: Current engine state |
| 119 | + - `payload`: Received message data |
| 120 | + - `from`: Sender engine name |
| 121 | + - `messageType`: Type of received message |
0 commit comments