Skip to content

Commit 303af01

Browse files
authored
Merge pull request #26 from HanSur94/wiki-update/bf84a29
docs: update wiki pages [auto-generated]
2 parents bf84a29 + 338bb01 commit 303af01

10 files changed

Lines changed: 1178 additions & 224 deletions

wiki/Architecture.md

Lines changed: 103 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- AUTO-GENERATED from source code by scripts/generate_wiki.py — do not edit manually -->
2+
13
# Architecture
24

35
## Overview
@@ -12,13 +14,16 @@ FastPlot/
1214
├── libs/
1315
│ ├── FastSense/ # Core plotting engine
1416
│ │ ├── FastSense.m # Main class
15-
│ │ ├── FastSenseGrid.m # Dashboard layout
16-
│ │ ├── FastSenseDock.m # Tabbed container
17-
│ │ ├── FastSenseToolbar.m # Interactive toolbar
18-
│ │ ├── FastSenseTheme.m # Theme system
19-
│ │ ├── FastSenseDataStore.m # SQLite-backed chunked storage
17+
│ │ ├── FastSenseGrid.m # Dashboard layout
18+
│ │ ├── FastSenseDock.m # Tabbed container
19+
│ │ ├── FastSenseToolbar.m # Interactive toolbar
20+
│ │ ├── FastSenseTheme.m # Theme system
21+
│ │ ├── FastSenseDataStore.m # SQLite-backed chunked storage
2022
│ │ ├── SensorDetailPlot.m # Sensor detail view with state bands
2123
│ │ ├── NavigatorOverlay.m # Minimap zoom navigator
24+
│ │ ├── ConsoleProgressBar.m # Progress indication
25+
│ │ ├── binary_search.m # Binary search utility
26+
│ │ ├── build_mex.m # MEX compilation script
2227
│ │ ├── mksqlite.c # SQLite3 MEX interface
2328
│ │ └── private/ # Internal algorithms + MEX sources
2429
│ ├── SensorThreshold/ # Sensor and threshold system
@@ -33,7 +38,14 @@ FastPlot/
3338
│ │ ├── EventViewer.m
3439
│ │ ├── LiveEventPipeline.m
3540
│ │ ├── NotificationService.m
36-
│ │ └── private/ # Violation grouping
41+
│ │ ├── EventStore.m
42+
│ │ ├── EventConfig.m
43+
│ │ ├── IncrementalEventDetector.m
44+
│ │ ├── DataSource.m # Abstract data source
45+
│ │ ├── MatFileDataSource.m # File-based data source
46+
│ │ ├── MockDataSource.m # Test data generation
47+
│ │ ├── NotificationRule.m # Email notification rules
48+
│ │ └── private/ # Event grouping algorithms
3749
│ ├── Dashboard/ # Dashboard engine (serializable)
3850
│ │ ├── DashboardEngine.m
3951
│ │ ├── DashboardBuilder.m
@@ -128,6 +140,28 @@ Optional C MEX functions with SIMD intrinsics (AVX2 on x86_64, NEON on arm64):
128140

129141
All share a common `simd_utils.h` abstraction layer. If MEX is unavailable, pure-MATLAB implementations are used with identical behavior.
130142

143+
## Data Flow Architecture
144+
145+
### Core Data Path
146+
```
147+
Raw Data (X, Y arrays)
148+
149+
FastSenseDataStore (optional, for large datasets)
150+
151+
Downsampling Engine (MinMax/LTTB)
152+
153+
Pyramid Cache (lazy multi-resolution)
154+
155+
Graphics Objects (line handles)
156+
157+
Interactive Display
158+
```
159+
160+
### Storage Modes
161+
- **Memory mode**: X/Y arrays held in MATLAB workspace
162+
- **Disk mode**: Data chunked into SQLite database via `FastSenseDataStore`
163+
- **Auto mode**: Switches to disk when data exceeds `MemoryLimit` (default 500MB)
164+
131165
## Sensor Threshold Resolution
132166

133167
The `Sensor.resolve()` algorithm is segment-based:
@@ -139,7 +173,7 @@ The `Sensor.resolve()` algorithm is segment-based:
139173
3. Assign threshold values per segment
140174
4. Detect violations using SIMD-accelerated comparison
141175

142-
Complexity: O(S x R) where S = state segments and R = rules, instead of O(N x R) per-point evaluation.
176+
Complexity: O(S × R) where S = state segments and R = rules, instead of O(N × R) per-point evaluation.
143177

144178
## Disk-Backed Data Storage
145179

@@ -221,6 +255,44 @@ Clicking "Edit" in the toolbar creates a `DashboardBuilder` instance:
221255
- **Load:** JSON is decoded, widgets array is normalized to cell, and `configToWidgets()` dispatches to each widget class's `fromStruct()` static method. An optional `SensorResolver` function handle re-binds Sensor objects by name.
222256
- **Export script:** generates a `.m` file with `DashboardEngine` constructor calls and `addWidget` calls for each widget.
223257

258+
## Event Detection Architecture
259+
260+
The event detection system provides real-time threshold violation monitoring with configurable notifications and data persistence.
261+
262+
### Core Components
263+
264+
```
265+
LiveEventPipeline
266+
├── DataSourceMap — Maps sensor keys to data sources
267+
├── IncrementalEventDetector — Tracks per-sensor state and open events
268+
├── EventStore — Thread-safe .mat file persistence
269+
├── NotificationService — Rule-based email alerts
270+
└── EventViewer — Interactive Gantt chart + filterable table
271+
```
272+
273+
### Data Sources
274+
275+
- **MatFileDataSource**: Polls .mat files for new data
276+
- **MockDataSource**: Generates realistic test signals with violations
277+
- **Custom sources**: Implement `DataSource.fetchNew()` interface
278+
279+
### Event Detection Flow
280+
281+
1. `LiveEventPipeline.runCycle()` polls all data sources
282+
2. New data is passed to `IncrementalEventDetector.process()`
283+
3. Sensor state is evaluated via `Sensor.resolve()`
284+
4. Violations are grouped into events with debouncing (`MinDuration`)
285+
5. Events are stored via `EventStore.append()` (atomic .mat writes)
286+
6. `NotificationService` sends rule-based email alerts with plot snapshots
287+
7. Active `EventViewer` instances auto-refresh to show new events
288+
289+
### Escalation Logic
290+
291+
When `EscalateSeverity` is enabled, events are promoted to the highest violated threshold:
292+
- A violation starts at "Warning" level
293+
- If "Alarm" threshold is also crossed, the event is escalated to "Alarm"
294+
- The event retains the highest severity level encountered
295+
224296
## WebBridge Architecture
225297

226298
The `WebBridge` class provides a TCP server that bridges MATLAB dashboards to web-based visualization. It uses NDJSON (newline-delimited JSON) for message framing over TCP.
@@ -231,14 +303,14 @@ All messages are JSON objects terminated by a newline character. The protocol is
231303

232304
| Message Type | Direction | Description |
233305
|-------------|-----------|-------------|
234-
| `init` | MATLAB -> Bridge | Initial handshake with signal list, dashboard config, and registered actions |
235-
| `data_changed` | MATLAB -> Bridge | Notify that signal data has been updated |
236-
| `config_changed` | MATLAB -> Bridge | Dashboard layout/theme has changed |
237-
| `actions_changed` | MATLAB -> Bridge | Available custom actions have changed |
238-
| `action` | Bridge -> MATLAB | Execute a registered action (with optional args) |
239-
| `action_result` | MATLAB -> Bridge | Result of action execution (ok/error) |
240-
| `bridge_ready` | Bridge -> MATLAB | Bridge reports its HTTP port |
241-
| `shutdown` | MATLAB -> Bridge | Graceful shutdown signal |
306+
| `init` | MATLAB Bridge | Initial handshake with signal list, dashboard config, and registered actions |
307+
| `data_changed` | MATLAB Bridge | Notify that signal data has been updated |
308+
| `config_changed` | MATLAB Bridge | Dashboard layout/theme has changed |
309+
| `actions_changed` | MATLAB Bridge | Available custom actions have changed |
310+
| `action` | Bridge MATLAB | Execute a registered action (with optional args) |
311+
| `action_result` | MATLAB Bridge | Result of action execution (ok/error) |
312+
| `bridge_ready` | Bridge MATLAB | Bridge reports its HTTP port |
313+
| `shutdown` | MATLAB Bridge | Graceful shutdown signal |
242314

243315
### Data Flow
244316

@@ -266,3 +338,19 @@ MATLAB (DashboardEngine)
266338
- **Custom actions:** MATLAB callbacks registered via `registerAction(name, callback)` are exposed to the web UI and invoked over TCP
267339
- **Config polling:** a timer periodically hashes the dashboard config JSON and sends `config_changed` when the layout changes
268340
- **WAL mode:** SQLite DataStore databases are switched to WAL (Write-Ahead Logging) mode during serving for concurrent MATLAB writes and bridge reads
341+
342+
## Interactive Features
343+
344+
### Progress Indication
345+
`ConsoleProgressBar` provides hierarchical progress feedback:
346+
- Single-line ASCII/Unicode bars with backspace-based updates
347+
- Indentation support for nested operations (e.g., dock → tabs → tiles)
348+
- Freeze/finish modes for permanent status lines
349+
350+
### Toolbars and Navigation
351+
- **FastSenseToolbar**: Data cursor, crosshair, grid toggle, autoscale, export, live mode
352+
- **DashboardToolbar**: Live toggle, edit mode, save/export, name editing
353+
- **NavigatorOverlay**: Minimap with draggable zoom rectangle for `SensorDetailPlot`
354+
355+
### Link Groups
356+
Multiple FastSense instances can share synchronized zoom/pan via `LinkGroup` strings. When one plot's XLim changes, all plots in the same group update automatically.

wiki/Datetime-Guide.md

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
<!-- AUTO-GENERATED from source code by scripts/generate_wiki.py — do not edit manually -->
2+
13
# Datetime Guide
24

3-
FastPlot supports time series data with datetime X-axes. Both datenum values and MATLAB datetime objects are supported.
5+
FastSense supports time series data with datetime X-axes. Both datenum values and MATLAB datetime objects are supported.
46

57
---
68

@@ -77,11 +79,11 @@ fig = FastSenseGrid(2, 1, 'Theme', 'dark');
7779
7880
fp1 = fig.tile(1);
7981
fp1.addLine(x, sin(2*pi*(1:1e6)/86400)*20+50, 'XType', 'datenum', 'DisplayName', 'Pressure');
80-
fig.tileTitle(1, 'Pressure');
82+
fig.setTileTitle(1, 'Pressure');
8183
8284
fp2 = fig.tile(2);
8385
fp2.addLine(x, cos(2*pi*(1:1e6)/86400)*10+25, 'XType', 'datenum', 'DisplayName', 'Temperature');
84-
fig.tileTitle(2, 'Temperature');
86+
fig.setTileTitle(2, 'Temperature');
8587
8688
fig.renderAll();
8789
```
@@ -146,6 +148,31 @@ fp.render();
146148

147149
---
148150

151+
## SensorDetailPlot with Datetime
152+
153+
The `SensorDetailPlot` component supports datetime X-axes through the `'XType'` parameter:
154+
155+
```matlab
156+
% Create sensor with datenum timestamps
157+
tStart = datetime(2024, 3, 11, 8, 0, 0);
158+
tEnd = datetime(2024, 3, 11, 10, 0, 0);
159+
tDatetime = linspace(tStart, tEnd, 72000);
160+
tNum = datenum(tDatetime);
161+
162+
s = Sensor('pressure', 'Name', 'Line Pressure');
163+
s.X = tNum;
164+
s.Y = 4.2 + 0.6*sin(2*pi*tNum*24/1.5) + 0.15*randn(1, 72000);
165+
s.resolve();
166+
167+
% Create detail plot with datetime formatting
168+
sdp = SensorDetailPlot(s, 'XType', 'datenum', 'Theme', 'light');
169+
sdp.render();
170+
```
171+
172+
The navigator and main plot both show human-readable time labels.
173+
174+
---
175+
149176
## GNU Octave Notes
150177

151178
- Octave does not support MATLAB's `datetime` class

0 commit comments

Comments
 (0)