@aurora-blue/signalk-connector 0.2.0-dev.42 → 0.2.0-dev.44
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/VERSION +1 -1
- package/dist/src/connector.d.ts +1 -0
- package/dist/src/connector.js +14 -0
- package/dist/src/nmea-energy.d.ts +1 -0
- package/dist/src/nmea-energy.js +16 -3
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +1 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.0-dev.
|
|
1
|
+
0.2.0-dev.44
|
package/dist/src/connector.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class ConnectorRuntime {
|
|
|
51
51
|
private readonly autoSchedule;
|
|
52
52
|
private readonly anchorAlarm;
|
|
53
53
|
private readonly telemetryReducer;
|
|
54
|
+
private readonly nmeaEnergyReducer;
|
|
54
55
|
private readonly monotonicNow;
|
|
55
56
|
private filesystemCapacity;
|
|
56
57
|
private nextCapacityRefreshAt;
|
package/dist/src/connector.js
CHANGED
|
@@ -67,6 +67,7 @@ class ConnectorRuntime {
|
|
|
67
67
|
autoSchedule;
|
|
68
68
|
anchorAlarm;
|
|
69
69
|
telemetryReducer;
|
|
70
|
+
nmeaEnergyReducer;
|
|
70
71
|
monotonicNow;
|
|
71
72
|
filesystemCapacity = null;
|
|
72
73
|
nextCapacityRefreshAt = 0;
|
|
@@ -93,6 +94,7 @@ class ConnectorRuntime {
|
|
|
93
94
|
const startedAt = Date.parse(this.now());
|
|
94
95
|
this.anchorAlarm = new anchor_alarm_1.AnchorAlarmEngine(config.anchorAlarm, Number.isFinite(startedAt) ? startedAt : Date.now());
|
|
95
96
|
this.telemetryReducer = new telemetry_reducer_1.TelemetryReducer(config.adaptiveTelemetryEnabled, (0, telemetry_reducer_1.rulesForProfile)(config.operatingProfile));
|
|
97
|
+
this.nmeaEnergyReducer = new telemetry_reducer_1.TelemetryReducer(true, (0, telemetry_reducer_1.rulesForProfile)(config.operatingProfile));
|
|
96
98
|
this.storageBudget = (0, storage_budget_1.resolveStorageBudget)(this.storageBudgetPolicy(), { events: 0, bytes: 0, averageRecordBytes: null }, null);
|
|
97
99
|
}
|
|
98
100
|
async start() {
|
|
@@ -753,6 +755,17 @@ class ConnectorRuntime {
|
|
|
753
755
|
return;
|
|
754
756
|
if (this.nmeaEnergySupported) {
|
|
755
757
|
for (const observation of this.nmeaEnergy.observe(message, this.app.getPath("/sources"), Date.parse(this.now()))) {
|
|
758
|
+
const event = {
|
|
759
|
+
boot_id: this.bootId,
|
|
760
|
+
context: "vessels.self",
|
|
761
|
+
path: observation.path,
|
|
762
|
+
value: observation.value,
|
|
763
|
+
source_timestamp: observation.at,
|
|
764
|
+
received_at: this.now(),
|
|
765
|
+
source: observation.source,
|
|
766
|
+
};
|
|
767
|
+
if (!this.nmeaEnergyReducer.shouldEmit(event))
|
|
768
|
+
continue;
|
|
756
769
|
this.app.handleMessage("aurora-blue-signalk-connector", {
|
|
757
770
|
context: "vessels.self",
|
|
758
771
|
updates: [
|
|
@@ -765,6 +778,7 @@ class ConnectorRuntime {
|
|
|
765
778
|
},
|
|
766
779
|
],
|
|
767
780
|
});
|
|
781
|
+
this.nmeaEnergyReducer.record(event);
|
|
768
782
|
}
|
|
769
783
|
}
|
|
770
784
|
if (!this.victronInputLimitSupported)
|
package/dist/src/nmea-energy.js
CHANGED
|
@@ -11,6 +11,7 @@ class NmeaEnergy {
|
|
|
11
11
|
dcTypes = new Map();
|
|
12
12
|
inverterDcInstances = new Map();
|
|
13
13
|
states = new Map();
|
|
14
|
+
emittedModes = new Map();
|
|
14
15
|
observe(message, sources, now) {
|
|
15
16
|
const pgn = object(message), fields = object(pgn.fields);
|
|
16
17
|
if (![127506, 127508, 127507, 127509].includes(Number(pgn.pgn)) ||
|
|
@@ -135,12 +136,24 @@ class NmeaEnergy {
|
|
|
135
136
|
charger &&
|
|
136
137
|
Math.abs(clock - charger.at) <= 10000)
|
|
137
138
|
mode = chargerModes[charger.value] ?? mode;
|
|
138
|
-
if (mode)
|
|
139
|
-
|
|
139
|
+
if (mode) {
|
|
140
|
+
const emitted = this.emittedModes.get(key);
|
|
141
|
+
if (!emitted ||
|
|
142
|
+
(clock >= emitted.at &&
|
|
143
|
+
(emitted.value !== mode || clock - emitted.at >= 600_000))) {
|
|
144
|
+
emit(`electrical.inverters.${id}.inverterMode`, mode);
|
|
145
|
+
this.emittedModes.set(key, { value: mode, at: clock });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
140
148
|
}
|
|
141
149
|
}
|
|
142
150
|
}
|
|
143
|
-
for (const cache of [
|
|
151
|
+
for (const cache of [
|
|
152
|
+
this.dcTypes,
|
|
153
|
+
this.states,
|
|
154
|
+
this.inverterDcInstances,
|
|
155
|
+
this.emittedModes,
|
|
156
|
+
])
|
|
144
157
|
while (cache.size > 256)
|
|
145
158
|
cache.delete(cache.keys().next().value);
|
|
146
159
|
return observations;
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CONNECTOR_VERSION = "0.2.0-dev.
|
|
1
|
+
export declare const CONNECTOR_VERSION = "0.2.0-dev.44";
|
package/dist/src/version.js
CHANGED
package/package.json
CHANGED