hydraloop-diagram-react 0.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flow-diagram.d.ts +11 -0
- package/dist/flow-diagram.js +513 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/model.d.ts +320 -0
- package/dist/model.js +662 -0
- package/dist/styles.css +586 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/license +15 -0
- package/package.json +39 -3
- package/readme.md +125 -0
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
export type Side = "A" | "B";
|
|
2
|
+
export type RoutineSide = Side | "SYSTEM";
|
|
3
|
+
export type TankId = "t1a" | "t2a" | "t1b" | "t2b" | "t3";
|
|
4
|
+
export declare const TANK_IDS: TankId[];
|
|
5
|
+
/**
|
|
6
|
+
* IO names as returned by `hydraloop.local.graph.getIo()`. B-side IOs of the
|
|
7
|
+
* H600 have a `_b` suffix. The roles were derived by correlating the signals
|
|
8
|
+
* with each other and with the routines of an H600 (firmware 9.24).
|
|
9
|
+
*/
|
|
10
|
+
export declare const IO: {
|
|
11
|
+
/** Sends incoming greywater to the sewer while on */
|
|
12
|
+
readonly bypass: "grey_water_bypass";
|
|
13
|
+
/**
|
|
14
|
+
* Selects the train that receives greywater (0: A, 1: B). Switched when a
|
|
15
|
+
* train starts filth removal, and for a minute during a restart
|
|
16
|
+
*/
|
|
17
|
+
readonly abSelector: "grey_water_ab_selection_valve";
|
|
18
|
+
readonly uvValve: "uv_valve";
|
|
19
|
+
readonly uvPower: "uv_power";
|
|
20
|
+
readonly auxiliary: "auxiliary";
|
|
21
|
+
/** Outlets are supplied from T4 while on (stays on for hours) */
|
|
22
|
+
readonly backupWater: "backup_water";
|
|
23
|
+
readonly preBackupWater: "pre_backup_water_valve";
|
|
24
|
+
readonly backFlush: "back_flush";
|
|
25
|
+
/** Drains T3 */
|
|
26
|
+
readonly wasteStorageTank: "waste_storage_tank";
|
|
27
|
+
readonly distributionPump: "distribution_pump";
|
|
28
|
+
/** A valve, despite its name: routes the distribution pump back through UV into T3 */
|
|
29
|
+
readonly circulation: "circulation_pump";
|
|
30
|
+
/** Demand sensors of the outlets */
|
|
31
|
+
readonly toilet: "toilet";
|
|
32
|
+
readonly wash: "wash";
|
|
33
|
+
/** Float sensors of T4 */
|
|
34
|
+
readonly t4Max: "tank4";
|
|
35
|
+
readonly t4Min: "tank4_enough_water";
|
|
36
|
+
};
|
|
37
|
+
export declare function sideIo(name: string, side: Side): string;
|
|
38
|
+
/** A value at a time. `t` is milliseconds since epoch. */
|
|
39
|
+
export type Point = {
|
|
40
|
+
t: number;
|
|
41
|
+
v: number;
|
|
42
|
+
};
|
|
43
|
+
export type RoutineEvent = {
|
|
44
|
+
t: number;
|
|
45
|
+
side: RoutineSide;
|
|
46
|
+
routine: number;
|
|
47
|
+
name: string;
|
|
48
|
+
state: string;
|
|
49
|
+
};
|
|
50
|
+
export type DeviceInfo = {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
serial: string | null;
|
|
54
|
+
type: string | null;
|
|
55
|
+
firmware: string | null;
|
|
56
|
+
online: boolean | null;
|
|
57
|
+
/** Which outlets are connected, from the device configuration */
|
|
58
|
+
outlets: {
|
|
59
|
+
toilet: boolean | null;
|
|
60
|
+
washingMachine: boolean | null;
|
|
61
|
+
auxiliary: boolean | null;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** Normalized data of a time range, for both the live and history views */
|
|
65
|
+
export type Dataset = {
|
|
66
|
+
device: DeviceInfo;
|
|
67
|
+
demo: boolean;
|
|
68
|
+
from: number;
|
|
69
|
+
until: number;
|
|
70
|
+
fetchedAt: number;
|
|
71
|
+
/** Tank levels in liters (see `t1PointsToLiters` and `pressureToLiters`) */
|
|
72
|
+
tanks: Record<TankId, Point[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Scale in liters: T1's capacity, else the last entry of the calibration
|
|
75
|
+
* table (the most the sensor can report, not the tank's capacity)
|
|
76
|
+
*/
|
|
77
|
+
tankMax: Record<TankId, number>;
|
|
78
|
+
/** IO values by IO name, one point per change, sorted by time */
|
|
79
|
+
io: Record<string, Point[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Whether an IO is switched manually (1) instead of by the firmware (0),
|
|
82
|
+
* e.g. by a technician or a maintenance procedure in the HDM web app. Same
|
|
83
|
+
* shape as `io`.
|
|
84
|
+
*/
|
|
85
|
+
manual?: Record<string, Point[]>;
|
|
86
|
+
/** Human readable IO names from the graph config */
|
|
87
|
+
captions: Record<string, string>;
|
|
88
|
+
/** Routine changes, sorted by time. Includes the last one before `from`. */
|
|
89
|
+
routines: RoutineEvent[];
|
|
90
|
+
/** Firmware behaviors (e.g. `fullT1T2WasteSoapBombA`) overlapping the range */
|
|
91
|
+
behaviors: Behavior[];
|
|
92
|
+
/**
|
|
93
|
+
* Restarts and connection losses from `getOutageSummaries()`. Undefined if
|
|
94
|
+
* they could not be loaded.
|
|
95
|
+
*/
|
|
96
|
+
outages?: Outage[];
|
|
97
|
+
/**
|
|
98
|
+
* T2 in liters at the last venting of each train before `from`, as tank
|
|
99
|
+
* levels are only loaded from `from` (see `ventedLevels`)
|
|
100
|
+
*/
|
|
101
|
+
ventedBefore?: Partial<Record<Side, Point>>;
|
|
102
|
+
/**
|
|
103
|
+
* Time left of filth removal per train, as last reported by the H600
|
|
104
|
+
* (`cleaningTimeLeftA/B` of `getTankTreatmentState()`), and when it was
|
|
105
|
+
* reported. Only loaded for the live views.
|
|
106
|
+
*/
|
|
107
|
+
cleaningTimeLeft?: Partial<Record<Side, {
|
|
108
|
+
t: number;
|
|
109
|
+
ms: number;
|
|
110
|
+
}>>;
|
|
111
|
+
/**
|
|
112
|
+
* Calibration tables of T2 and T3, to convert the pressure points of live
|
|
113
|
+
* messages to liters in the browser. Undefined if they could not be loaded.
|
|
114
|
+
*/
|
|
115
|
+
levelTables?: {
|
|
116
|
+
t1t2: LevelTable;
|
|
117
|
+
t3: LevelTable;
|
|
118
|
+
};
|
|
119
|
+
/** Data that could not be loaded */
|
|
120
|
+
warnings: string[];
|
|
121
|
+
};
|
|
122
|
+
/** An outage from `getOutageSummaries()`, e.g. a `scheduled_restart` */
|
|
123
|
+
export type Outage = {
|
|
124
|
+
start: number;
|
|
125
|
+
end: number;
|
|
126
|
+
classification: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* A firmware behavior from the `behavior` list of `getIo()`, from its
|
|
130
|
+
* `engaged` to its `disengaged` event. Behaviors explain why the controller
|
|
131
|
+
* acts, e.g. `fullT1T2WasteSoapBombA` while it empties train A to the drain.
|
|
132
|
+
*/
|
|
133
|
+
export type Behavior = {
|
|
134
|
+
name: string;
|
|
135
|
+
typeId: number;
|
|
136
|
+
side: RoutineSide;
|
|
137
|
+
label: string;
|
|
138
|
+
start: number;
|
|
139
|
+
end: number;
|
|
140
|
+
/** Not disengaged by the end of the range */
|
|
141
|
+
open: boolean;
|
|
142
|
+
};
|
|
143
|
+
/** Calibration table of a tank: pressure points to liters */
|
|
144
|
+
export type LevelTable = {
|
|
145
|
+
p: number;
|
|
146
|
+
l: number;
|
|
147
|
+
}[];
|
|
148
|
+
/** Physical capacity in liters, estimated from the H600 CAD model */
|
|
149
|
+
export declare const TANK_CAPACITY: Partial<Record<TankId, number>>;
|
|
150
|
+
/** `PASSIVE_CIRCULATE` → `Passive circulate` */
|
|
151
|
+
export declare function humanize(text: string): string;
|
|
152
|
+
/**
|
|
153
|
+
* Behaviors that explain nothing the app shows. `pressingOptButton` is
|
|
154
|
+
* engaged for about 12 hours at a time, nearly always.
|
|
155
|
+
*/
|
|
156
|
+
export declare const OTHER_BEHAVIORS: Set<string>;
|
|
157
|
+
export declare function caption(captions: Record<string, string>, name: string): string;
|
|
158
|
+
/** Step value: the last known value at or before `t` */
|
|
159
|
+
export declare function stepAt(points: Point[] | undefined, t: number): Point | undefined;
|
|
160
|
+
/** Linearly interpolated value at `t`, undefined outside of the data */
|
|
161
|
+
export declare function valueAt(points: Point[] | undefined, t: number): number | undefined;
|
|
162
|
+
export type Confidence = "reported" | "valve" | "inferred" | "unknown";
|
|
163
|
+
export type TrainPhase = "cleaning" | "transferring" | "receiving" | "treating" | "idle" | "other" | "unknown";
|
|
164
|
+
export declare function routinePhase(name: string): TrainPhase;
|
|
165
|
+
export type IoValue = {
|
|
166
|
+
on: boolean;
|
|
167
|
+
value: number;
|
|
168
|
+
since: number | undefined;
|
|
169
|
+
/** Switched manually instead of by the firmware */
|
|
170
|
+
manual: boolean;
|
|
171
|
+
};
|
|
172
|
+
export type TankLevel = {
|
|
173
|
+
liters: number | undefined;
|
|
174
|
+
/** Scale in liters, see `Dataset.tankMax` */
|
|
175
|
+
max: number;
|
|
176
|
+
/** Physical capacity, estimated from the H600 CAD model (see TANK_CAPACITY) */
|
|
177
|
+
capacity: number | undefined;
|
|
178
|
+
pct: number | undefined;
|
|
179
|
+
/** Liters per minute over the previous 10 minutes */
|
|
180
|
+
trend: number | undefined;
|
|
181
|
+
};
|
|
182
|
+
export type TrainState = {
|
|
183
|
+
side: Side;
|
|
184
|
+
phase: TrainPhase;
|
|
185
|
+
/** HDM routine name, or a phase label when there is no routine */
|
|
186
|
+
label: string;
|
|
187
|
+
/** HDM routine sub-state */
|
|
188
|
+
detail: string | undefined;
|
|
189
|
+
confidence: Confidence;
|
|
190
|
+
since: number | undefined;
|
|
191
|
+
evidence: string[];
|
|
192
|
+
lastIncoming: number | undefined;
|
|
193
|
+
lastTransfer: number | undefined;
|
|
194
|
+
/** Water flows from T2 into T1, inferred from a falling T2 level */
|
|
195
|
+
t2ToT1: boolean;
|
|
196
|
+
/** Firmware behaviors of this train that are engaged */
|
|
197
|
+
behaviors: Behavior[];
|
|
198
|
+
/**
|
|
199
|
+
* Filth and foam spill over the skim overflow of T1 to the drain, inferred
|
|
200
|
+
* from the `FILTH_REMOVAL` routine (the overflow has no valve signal)
|
|
201
|
+
*/
|
|
202
|
+
skimming: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* T2 holds air pressure: air was last added to it after its release air
|
|
205
|
+
* valve was last opened. Also while air is being added
|
|
206
|
+
*/
|
|
207
|
+
pressurized: boolean;
|
|
208
|
+
};
|
|
209
|
+
export type T3State = {
|
|
210
|
+
label: string;
|
|
211
|
+
confidence: Confidence;
|
|
212
|
+
evidence: string[];
|
|
213
|
+
receivingFrom: Side[];
|
|
214
|
+
uv: boolean | undefined;
|
|
215
|
+
circulating: boolean | undefined;
|
|
216
|
+
draining: boolean | undefined;
|
|
217
|
+
};
|
|
218
|
+
export type SupplyState = {
|
|
219
|
+
pumping: boolean | undefined;
|
|
220
|
+
/** The pump pressurizes the outlets, also while it circulates through UV */
|
|
221
|
+
toOutlets: boolean | undefined;
|
|
222
|
+
source: "recycled" | "backup" | "unknown";
|
|
223
|
+
toilet: boolean | undefined;
|
|
224
|
+
wash: boolean | undefined;
|
|
225
|
+
auxiliary: boolean | undefined;
|
|
226
|
+
};
|
|
227
|
+
export type T4State = {
|
|
228
|
+
max: boolean | undefined;
|
|
229
|
+
min: boolean | undefined;
|
|
230
|
+
label: string;
|
|
231
|
+
};
|
|
232
|
+
export type InletState = {
|
|
233
|
+
bypass: boolean | undefined;
|
|
234
|
+
receiving: Side[];
|
|
235
|
+
};
|
|
236
|
+
export type DeviceState = {
|
|
237
|
+
t: number;
|
|
238
|
+
tanks: Record<TankId, TankLevel>;
|
|
239
|
+
io: Record<string, IoValue | undefined>;
|
|
240
|
+
routine: Partial<Record<RoutineSide, RoutineEvent>>;
|
|
241
|
+
inlet: InletState;
|
|
242
|
+
trains: Record<Side, TrainState>;
|
|
243
|
+
t3: T3State;
|
|
244
|
+
t4: T4State;
|
|
245
|
+
supply: SupplyState;
|
|
246
|
+
/** Engaged firmware behaviors that don't belong to a train */
|
|
247
|
+
systemBehaviors: Behavior[];
|
|
248
|
+
/** Estimated room for greywater before it is bypassed */
|
|
249
|
+
room: Room;
|
|
250
|
+
};
|
|
251
|
+
/** `FILTH_REMOVAL` sub-states while T1 is held at the skim overflow */
|
|
252
|
+
export declare const SKIM_STATES: Set<string>;
|
|
253
|
+
/** The current routine of a side and when it started (first sub-state) */
|
|
254
|
+
export declare function routineAt(ds: Pick<Dataset, "routines">, side: RoutineSide, t: number): {
|
|
255
|
+
current: RoutineEvent | undefined;
|
|
256
|
+
start: number | undefined;
|
|
257
|
+
lastIncoming: number | undefined;
|
|
258
|
+
lastTransfer: number | undefined;
|
|
259
|
+
};
|
|
260
|
+
export declare function stateAt(ds: Dataset, t: number): DeviceState;
|
|
261
|
+
/** T2 at which a train is full and starts FILTH_REMOVAL */
|
|
262
|
+
export declare const TRAIN_FULL_LITERS = 134;
|
|
263
|
+
/** Routines in which a train accepts greywater */
|
|
264
|
+
export declare const ACCEPTING_ROUTINES: Set<string>;
|
|
265
|
+
/**
|
|
266
|
+
* Whether a bypass opening is from the controller's scheduled restart every
|
|
267
|
+
* 12 hours. The bypass valve falls open while the controller is down. Falls
|
|
268
|
+
* back to the duration if the outages could not be loaded.
|
|
269
|
+
*/
|
|
270
|
+
export declare function isScheduledRestart(ds: Pick<Dataset, "outages">, interval: Interval): boolean;
|
|
271
|
+
/**
|
|
272
|
+
* The train that the A/B valve sends greywater to. The valve is also
|
|
273
|
+
* switched for a minute during a restart, which is skipped.
|
|
274
|
+
*/
|
|
275
|
+
export declare function fillingTrain(ds: Dataset, t: number): Side | undefined;
|
|
276
|
+
/** Openings of a release air valve that are long enough to settle T2 */
|
|
277
|
+
export declare function ventings(points: Point[] | undefined, until: number): Interval[];
|
|
278
|
+
/** T2 in liters at the end of a venting: the median of its second half */
|
|
279
|
+
export declare function ventedLevel(t2: Point[], vent: Interval): Point | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* T2 in liters, measured while it was vented, one point per venting.
|
|
282
|
+
* Starts with the last venting before the range, if it was loaded.
|
|
283
|
+
*/
|
|
284
|
+
export declare function ventedLevels(ds: Dataset, side: Side): Point[];
|
|
285
|
+
export type TrainRoom = {
|
|
286
|
+
side: Side;
|
|
287
|
+
/** Liters the train can still take, 0 while it doesn't accept water */
|
|
288
|
+
liters: number | undefined;
|
|
289
|
+
/** T2 at the last venting */
|
|
290
|
+
t2: number | undefined;
|
|
291
|
+
measuredAt: number | undefined;
|
|
292
|
+
accepting: boolean | undefined;
|
|
293
|
+
reason: string;
|
|
294
|
+
};
|
|
295
|
+
export type Room = {
|
|
296
|
+
/** Liters the H600 can take before greywater is bypassed */
|
|
297
|
+
liters: number | undefined;
|
|
298
|
+
/** Only one train is known, so `liters` is a lower bound */
|
|
299
|
+
partial: boolean;
|
|
300
|
+
/** The bypass is open, not counting the scheduled restart */
|
|
301
|
+
bypass: boolean;
|
|
302
|
+
/** The bypass is open for the scheduled restart, which doesn't count as full */
|
|
303
|
+
restart: boolean;
|
|
304
|
+
/** The train that receives greywater, and starts filth removal next */
|
|
305
|
+
filling: Side | undefined;
|
|
306
|
+
trains: Record<Side, TrainRoom>;
|
|
307
|
+
};
|
|
308
|
+
export declare function roomAt(ds: Dataset, t: number): Room;
|
|
309
|
+
export type Interval = {
|
|
310
|
+
start: number;
|
|
311
|
+
end: number;
|
|
312
|
+
/** Still on at the end of the range */
|
|
313
|
+
open: boolean;
|
|
314
|
+
/** Started before the range */
|
|
315
|
+
clipped: boolean;
|
|
316
|
+
};
|
|
317
|
+
/** Intervals during which an IO was on, within [from, until] */
|
|
318
|
+
export declare function onIntervals(points: Point[] | undefined, from: number, until: number): Interval[];
|
|
319
|
+
/** Explains the capacity of a tank whose scale is the sensor's range */
|
|
320
|
+
export declare function capacityNote(level: TankLevel): string;
|