Implemented history writer
This commit is contained in:
@@ -101,6 +101,27 @@ Every transition is broadcast as a `triggerState` event.
|
||||
- `signals` — comma-separated full keys; absent → all signals of all sources.
|
||||
- The reply is **unicast** to the requesting client only.
|
||||
|
||||
### `historyZoom`
|
||||
|
||||
```json
|
||||
{"type":"historyZoom","reqId":42,"t0":1765360000.0,"t1":1765370000.0,
|
||||
"n":2400,"signals":"s1:Sine,s2:Wave"}
|
||||
```
|
||||
- Reads from **disk-backed history** instead of the in-memory ring buffer.
|
||||
Identical semantics to `zoom` but queries the `.shist` files written by
|
||||
`HistoryWriter`.
|
||||
- `reqId`, `t0`/`t1`, `n`, `signals` — same meaning as `zoom`.
|
||||
- If history is not enabled, the reply contains `"error":"history not enabled"`.
|
||||
- Reply is **unicast** (same shape as `zoom` reply, but `"type":"historyZoom"`).
|
||||
|
||||
### `historyInfo`
|
||||
|
||||
```json
|
||||
{"type":"historyInfo"}
|
||||
```
|
||||
Request the hub to send a `historyInfo` event (unicast). Also sent automatically
|
||||
on client connect.
|
||||
|
||||
### `setMaxPoints`
|
||||
|
||||
```json
|
||||
@@ -164,6 +185,34 @@ trigger has fired.
|
||||
`t` is serialised with `%.17g` (full float64 precision — required for
|
||||
µs windows at Unix-epoch magnitudes), `v` with `%.9g`.
|
||||
|
||||
### `historyInfo`
|
||||
|
||||
Sent on client connect (if history is enabled) and on `historyInfo` command:
|
||||
|
||||
```json
|
||||
{"type":"historyInfo","enabled":true,"durationHours":1.0,"decimation":10,
|
||||
"signals":{
|
||||
"scalar:Sine1":{"t0":1765360000.0,"t1":1765370000.0,"count":360000,"capacity":360000},
|
||||
"scalar:Sine2":{"t0":1765360000.0,"t1":1765370000.0,"count":360000,"capacity":360000}}}
|
||||
```
|
||||
- `enabled` — `true` if the `+History` config block is present and valid.
|
||||
- `durationHours` — configured history duration.
|
||||
- `decimation` — samples-to-disk decimation factor (1 = every sample).
|
||||
- `signals` — per-signal metadata keyed by `"sourceId:signalName"`:
|
||||
- `t0`/`t1` — oldest/newest timestamp stored on disk (Unix seconds).
|
||||
- `count` — number of valid entries currently in the circular file.
|
||||
- `capacity` — total capacity of the circular file.
|
||||
|
||||
### `historyZoom` (reply)
|
||||
|
||||
Same shape as `zoom` reply, but `"type":"historyZoom"`:
|
||||
|
||||
```json
|
||||
{"type":"historyZoom","reqId":42,"signals":{
|
||||
"s1:Sine":{"t":[1765360000.1230000,"…"],"v":[0.123456789,"…"]}}}
|
||||
```
|
||||
If history is not enabled: `{"type":"historyZoom","error":"history not enabled"}`.
|
||||
|
||||
### `maxPointsUpdated`
|
||||
|
||||
```json
|
||||
|
||||
Reference in New Issue
Block a user