nodejs-poolcontroller 8.0.1 → 8.0.4
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/.github/workflows/docker-publish-njsPC-linux.yml +50 -0
- package/Dockerfile +5 -3
- package/README.md +4 -1
- package/config/Config.ts +1 -1
- package/controller/Constants.ts +164 -67
- package/controller/Equipment.ts +78 -18
- package/controller/Lockouts.ts +15 -0
- package/controller/State.ts +281 -7
- package/controller/boards/EasyTouchBoard.ts +225 -101
- package/controller/boards/IntelliCenterBoard.ts +84 -23
- package/controller/boards/IntelliTouchBoard.ts +2 -4
- package/controller/boards/NixieBoard.ts +84 -27
- package/controller/boards/SunTouchBoard.ts +8 -2
- package/controller/boards/SystemBoard.ts +3262 -3242
- package/controller/comms/ScreenLogic.ts +47 -44
- package/controller/comms/messages/Messages.ts +4 -4
- package/controller/comms/messages/config/ChlorinatorMessage.ts +10 -3
- package/controller/comms/messages/config/ExternalMessage.ts +4 -1
- package/controller/comms/messages/config/PumpMessage.ts +8 -7
- package/controller/comms/messages/config/RemoteMessage.ts +48 -43
- package/controller/comms/messages/status/ChlorinatorStateMessage.ts +8 -2
- package/controller/comms/messages/status/EquipmentStateMessage.ts +9 -4
- package/controller/comms/messages/status/PumpStateMessage.ts +1 -1
- package/controller/nixie/NixieEquipment.ts +1 -1
- package/controller/nixie/bodies/Body.ts +1 -1
- package/controller/nixie/chemistry/ChemController.ts +37 -28
- package/controller/nixie/circuits/Circuit.ts +48 -7
- package/controller/nixie/heaters/Heater.ts +24 -5
- package/controller/nixie/pumps/Pump.ts +159 -97
- package/controller/nixie/schedules/Schedule.ts +207 -126
- package/defaultConfig.json +3 -3
- package/logger/DataLogger.ts +7 -7
- package/package.json +2 -2
- package/sendSocket.js +32 -0
- package/web/Server.ts +17 -11
- package/web/bindings/homeassistant.json +2 -2
- package/web/interfaces/mqttInterface.ts +18 -18
- package/web/services/config/Config.ts +34 -1
- package/web/services/state/State.ts +10 -3
- package/web/services/state/StateSocket.ts +7 -3
- package/web/services/utilities/Utilities.ts +3 -3
|
@@ -65,7 +65,8 @@ export class NixiePumpCollection extends NixieEquipmentCollection<NixiePump> {
|
|
|
65
65
|
for (let i = 0; i < pumps.length; i++) {
|
|
66
66
|
let pump = pumps.getItemByIndex(i);
|
|
67
67
|
if (pump.master === 1) {
|
|
68
|
-
|
|
68
|
+
let p: NixiePump = this.find(elem => elem.id === pump.id) as NixiePump;
|
|
69
|
+
if (typeof p === 'undefined') {
|
|
69
70
|
let type = sys.board.valueMaps.pumpTypes.getName(pump.type);
|
|
70
71
|
let npump = this.pumpFactory(pump);
|
|
71
72
|
logger.info(`Initializing Nixie Pump ${npump.id}-${pump.name}`);
|
|
@@ -81,7 +82,9 @@ export class NixiePumpCollection extends NixieEquipmentCollection<NixiePump> {
|
|
|
81
82
|
try {
|
|
82
83
|
for (let i = this.length - 1; i >= 0; i--) {
|
|
83
84
|
try {
|
|
84
|
-
|
|
85
|
+
try {
|
|
86
|
+
await this[i].closeAsync();
|
|
87
|
+
} catch (err) { logger.error(`Error attempting to close pump ${this[i].id}`); }
|
|
85
88
|
this.splice(i, 1);
|
|
86
89
|
} catch (err) { logger.error(`Error stopping Nixie Pump ${err}`); }
|
|
87
90
|
}
|
|
@@ -101,14 +104,16 @@ export class NixiePumpCollection extends NixieEquipmentCollection<NixiePump> {
|
|
|
101
104
|
try {
|
|
102
105
|
let c: NixiePump = this.find(elem => elem.id === pump.id) as NixiePump;
|
|
103
106
|
if (pump.master === 1) {
|
|
104
|
-
// if pump exists, close it so we can re-init
|
|
107
|
+
// if pump exists, close it so we can re-init
|
|
105
108
|
// (EG if pump type changes, we need to setup a new instance of the pump)
|
|
106
109
|
if (typeof c !== 'undefined' && c.pump.type !== pump.type) {
|
|
107
110
|
await c.closeAsync();
|
|
111
|
+
await this.deletePumpAsync(pump.id);
|
|
108
112
|
c = this.pumpFactory(pump);
|
|
113
|
+
this.push(c);
|
|
109
114
|
}
|
|
110
|
-
logger.info(`Initializing Nixie Pump ${c.id}-${pump.name}`);
|
|
111
|
-
|
|
115
|
+
logger.info(`Initializing Existing Nixie Pump ${c.id}-${pump.name}`);
|
|
116
|
+
|
|
112
117
|
}
|
|
113
118
|
return c;
|
|
114
119
|
} catch (err) { return Promise.reject(logger.error(`Nixie Controller: initPumpAsync Error: ${err.message}`)); }
|
|
@@ -140,13 +145,21 @@ export class NixiePumpCollection extends NixieEquipmentCollection<NixiePump> {
|
|
|
140
145
|
// loop through all pumps and update rates based on circuit changes
|
|
141
146
|
// this would happen in <2s anyway based on pollAsync but this is immediate.
|
|
142
147
|
for (let i = this.length - 1; i >= 0; i--) {
|
|
148
|
+
let pump = this[i] as NixiePump;
|
|
149
|
+
if (!pump.suspendPolling) setTimeoutSync(async () => { await pump.pollEquipmentAsync(); }, 100);
|
|
150
|
+
else {
|
|
151
|
+
pump.setTargetSpeed(state.pumps.getItemById(pump.id));
|
|
152
|
+
}
|
|
153
|
+
// RKS: 05-16-23 - Below backs up the processing.
|
|
154
|
+
/*
|
|
155
|
+
|
|
143
156
|
setTimeoutSync(async () => {
|
|
144
157
|
let pump = this[i] as NixiePump;
|
|
145
158
|
try {
|
|
146
159
|
if (!pump.closing) await pump.pollEquipmentAsync();
|
|
147
160
|
} catch (err) { }
|
|
148
161
|
}, 100);
|
|
149
|
-
|
|
162
|
+
*/
|
|
150
163
|
}
|
|
151
164
|
}
|
|
152
165
|
}
|
|
@@ -157,7 +170,10 @@ export class NixiePump extends NixieEquipment {
|
|
|
157
170
|
protected _targetSpeed: number;
|
|
158
171
|
protected _suspendPolling = 0;
|
|
159
172
|
public get suspendPolling(): boolean { return this._suspendPolling > 0; }
|
|
160
|
-
public set suspendPolling(val: boolean) {
|
|
173
|
+
public set suspendPolling(val: boolean) {
|
|
174
|
+
this._suspendPolling = Math.max(0, this._suspendPolling + (val ? 1 : -1));
|
|
175
|
+
if (this._suspendPolling > 1) console.log(`Suspend Polling ${this._suspendPolling}`);
|
|
176
|
+
}
|
|
161
177
|
public closing = false;
|
|
162
178
|
public async setServiceModeAsync() {
|
|
163
179
|
let pstate = state.pumps.getItemById(this.pump.id);
|
|
@@ -192,7 +208,6 @@ export class NixiePump extends NixieEquipment {
|
|
|
192
208
|
}
|
|
193
209
|
public async setPumpAsync(data: any): Promise<InterfaceServerResponse> {
|
|
194
210
|
try {
|
|
195
|
-
|
|
196
211
|
this.pump.master = 1;
|
|
197
212
|
// if (typeof data.isVirtual !== 'undefined') this.pump.isVirtual = data.isVirtual;
|
|
198
213
|
this.pump.isActive = true;
|
|
@@ -226,7 +241,7 @@ export class NixiePump extends NixieEquipment {
|
|
|
226
241
|
case 'ds':
|
|
227
242
|
case 'sf':
|
|
228
243
|
case 'hwrly':
|
|
229
|
-
c.units =
|
|
244
|
+
c.units = undefined;
|
|
230
245
|
break;
|
|
231
246
|
}
|
|
232
247
|
if (isNaN(units)) units = typeof cd !== 'undefined' ? cd.units : sys.board.valueMaps.pumpUnits.getValue('rpm');
|
|
@@ -245,6 +260,7 @@ export class NixiePump extends NixieEquipment {
|
|
|
245
260
|
c.relay = relay;
|
|
246
261
|
}
|
|
247
262
|
}
|
|
263
|
+
else data.circuits = [];
|
|
248
264
|
this.pump.set(data); // Sets all the data back to the pump. This also sets the relays should it exist on the data.
|
|
249
265
|
let spump = state.pumps.getItemById(this.pump.id, true);
|
|
250
266
|
spump.name = this.pump.name;
|
|
@@ -264,16 +280,19 @@ export class NixiePump extends NixieEquipment {
|
|
|
264
280
|
// RSG 8-2022. Refactored to add initasync. With this.pollEquipmentAsync inside the
|
|
265
281
|
// constructor we could get here before the pump is initialized. The added check
|
|
266
282
|
// for the 112 address prevented that previously, but now is just a final fail safe.
|
|
267
|
-
if (this.suspendPolling || this.closing || this.pump.address > 112) return;
|
|
268
283
|
if (typeof this._pollTimer !== 'undefined' || this._pollTimer) clearTimeout(this._pollTimer);
|
|
269
284
|
this._pollTimer = null;
|
|
270
|
-
|
|
285
|
+
if (this.suspendPolling || this.closing || this.pump.address > 112) {
|
|
286
|
+
if (this.suspendPolling) logger.info(`Pump ${this.id} Polling Suspended`);
|
|
287
|
+
if (this.closing) logger.info(`Pump ${this.id} is closing`);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
271
290
|
let pstate = state.pumps.getItemById(this.pump.id);
|
|
272
291
|
this.setTargetSpeed(pstate);
|
|
273
292
|
await this.setPumpStateAsync(pstate);
|
|
274
293
|
}
|
|
275
294
|
catch (err) { logger.error(`Nixie Error running pump sequence - ${err}`); }
|
|
276
|
-
finally { if (!
|
|
295
|
+
finally { if (!self.closing) this._pollTimer = setTimeoutSync(async () => await self.pollEquipmentAsync(), self.pollingInterval || 2000); }
|
|
277
296
|
}
|
|
278
297
|
private async checkHardwareStatusAsync(connectionId: string, deviceBinding: string) {
|
|
279
298
|
try {
|
|
@@ -304,7 +323,7 @@ export class NixiePump extends NixieEquipment {
|
|
|
304
323
|
catch (err) { logger.error(`Nixie Pump closeAsync: ${err.message}`); return Promise.reject(err); }
|
|
305
324
|
}
|
|
306
325
|
public logData(filename: string, data: any) { this.controlPanel.logData(filename, data); }
|
|
307
|
-
|
|
326
|
+
public setTargetSpeed(pstate: PumpState) { };
|
|
308
327
|
protected isBodyOn(bodyCode: number) {
|
|
309
328
|
let assoc = sys.board.valueMaps.pumpBodies.transform(bodyCode);
|
|
310
329
|
switch (assoc.name) {
|
|
@@ -555,27 +574,29 @@ export class NixiePumpRS485 extends NixiePump {
|
|
|
555
574
|
finally { this.suspendPolling = false; }
|
|
556
575
|
};
|
|
557
576
|
protected async setDriveStateAsync(running: boolean = true) {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
577
|
+
try {
|
|
578
|
+
if (conn.isPortEnabled(this.pump.portId || 0)) {
|
|
579
|
+
let out = Outbound.create({
|
|
580
|
+
portId: this.pump.portId || 0,
|
|
581
|
+
protocol: Protocol.Pump,
|
|
582
|
+
dest: this.pump.address,
|
|
583
|
+
action: 6,
|
|
584
|
+
payload: running && this._targetSpeed > 0 ? [10] : [4],
|
|
585
|
+
retries: 1,
|
|
586
|
+
response: true
|
|
587
|
+
});
|
|
588
|
+
try {
|
|
589
|
+
await out.sendAsync();
|
|
590
|
+
}
|
|
591
|
+
catch (err) {
|
|
592
|
+
logger.error(`Error sending setDriveState for ${this.pump.name}: ${err.message}`);
|
|
593
|
+
}
|
|
570
594
|
}
|
|
571
|
-
|
|
572
|
-
|
|
595
|
+
else {
|
|
596
|
+
let pstate = state.pumps.getItemById(this.pump.id);
|
|
597
|
+
pstate.command = pstate.rpm > 0 || pstate.flow > 0 ? 10 : 0;
|
|
573
598
|
}
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
let pstate = state.pumps.getItemById(this.pump.id);
|
|
577
|
-
pstate.command = pstate.rpm > 0 || pstate.flow > 0 ? 10 : 0;
|
|
578
|
-
}
|
|
599
|
+
} catch (err) { logger.error(`Error setting driveState for ${this.pump.name}: ${err.message}`); }
|
|
579
600
|
};
|
|
580
601
|
protected async requestPumpStatusAsync() {
|
|
581
602
|
if (conn.isPortEnabled(this.pump.portId || 0)) {
|
|
@@ -597,44 +618,48 @@ export class NixiePumpRS485 extends NixiePump {
|
|
|
597
618
|
}
|
|
598
619
|
};
|
|
599
620
|
protected async setPumpToRemoteControlAsync(running: boolean = true) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
621
|
+
try {
|
|
622
|
+
if (conn.isPortEnabled(this.pump.portId || 0)) {
|
|
623
|
+
let out = Outbound.create({
|
|
624
|
+
portId: this.pump.portId || 0,
|
|
625
|
+
protocol: Protocol.Pump,
|
|
626
|
+
dest: this.pump.address,
|
|
627
|
+
action: 4,
|
|
628
|
+
payload: running ? [255] : [0], // when stopAsync is called, pass false to return control to pump panel
|
|
629
|
+
retries: 1,
|
|
630
|
+
response: true
|
|
631
|
+
});
|
|
632
|
+
try {
|
|
633
|
+
await out.sendAsync();
|
|
634
|
+
}
|
|
635
|
+
catch (err) {
|
|
636
|
+
logger.error(`Error sending setPumpToRemoteControl for ${this.pump.name}: ${err.message}`);
|
|
637
|
+
}
|
|
615
638
|
}
|
|
616
|
-
}
|
|
639
|
+
} catch (err) { logger.error(`Error setting pump to Remote Control for ${this.pump.name}: ${err.message}`); }
|
|
617
640
|
}
|
|
618
641
|
protected async setPumpFeatureAsync(feature?: number) {
|
|
619
642
|
// empty payload (possibly 0?, too) is no feature
|
|
620
643
|
// 6: Feature 1
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
644
|
+
try {
|
|
645
|
+
if (conn.isPortEnabled(this.pump.portId || 0)) {
|
|
646
|
+
let out = Outbound.create({
|
|
647
|
+
portId: this.pump.portId || 0,
|
|
648
|
+
protocol: Protocol.Pump,
|
|
649
|
+
dest: this.pump.address,
|
|
650
|
+
action: 5,
|
|
651
|
+
payload: typeof feature === 'undefined' ? [] : [feature],
|
|
652
|
+
retries: 2,
|
|
653
|
+
response: true
|
|
654
|
+
});
|
|
655
|
+
try {
|
|
656
|
+
await out.sendAsync();
|
|
657
|
+
}
|
|
658
|
+
catch (err) {
|
|
659
|
+
logger.error(`Error sending setPumpFeature for ${this.pump.name}: ${err.message}`);
|
|
660
|
+
}
|
|
636
661
|
}
|
|
637
|
-
}
|
|
662
|
+
} catch (err) { logger.error(`Error setting pump feature for ${this.pump.name}: ${err.message}`); }
|
|
638
663
|
};
|
|
639
664
|
protected async setPumpRPMAsync() {
|
|
640
665
|
if (conn.isPortEnabled(this.pump.portId || 0)) {
|
|
@@ -691,7 +716,7 @@ export class NixiePumpRS485 extends NixiePump {
|
|
|
691
716
|
//await this.setPumpFeature();
|
|
692
717
|
//await this.setDriveStateAsync(false);
|
|
693
718
|
await this.setPumpToRemoteControlAsync(false);
|
|
694
|
-
// Make sure the polling timer is dead after we have
|
|
719
|
+
// Make sure the polling timer is dead after we have closed this all off. That way we do not
|
|
695
720
|
// have another process that revives it from the dead.
|
|
696
721
|
if (typeof this._pollTimer !== 'undefined' || this._pollTimer) clearTimeout(this._pollTimer);
|
|
697
722
|
this._pollTimer = null;
|
|
@@ -735,14 +760,42 @@ export class NixiePumpVF extends NixiePumpRS485 {
|
|
|
735
760
|
if (this._targetSpeed !== 0) Math.min(Math.max(this.pump.minFlow, this._targetSpeed), this.pump.maxFlow);
|
|
736
761
|
if (this._targetSpeed !== _newSpeed) logger.info(`NCP: Setting Pump ${this.pump.name} to ${_newSpeed} GPM.`);
|
|
737
762
|
}
|
|
763
|
+
public async setPumpStateAsync(pstate: PumpState) {
|
|
764
|
+
// Don't poll while we are seting the state.
|
|
765
|
+
this.suspendPolling = true;
|
|
766
|
+
try {
|
|
767
|
+
let pt = sys.board.valueMaps.pumpTypes.get(this.pump.type);
|
|
768
|
+
if (state.mode === 0) {
|
|
769
|
+
// Since these process are async the closing flag can be set
|
|
770
|
+
// between calls. We need to check it in between each call. // 4, 6, 5, 7
|
|
771
|
+
// When we are 0 then it sends 4[255], 6[4], 5[6]
|
|
772
|
+
// When we are not 0 then it sends 4[255], 6[10], 5[6], 1[flow]
|
|
773
|
+
if (!this.closing) await this.setPumpToRemoteControlAsync(); // Action 4
|
|
774
|
+
if (!this.closing && this._targetSpeed > 0) await this.setPumpGPMAsync(); // Action 1
|
|
775
|
+
if (!this.closing && this._targetSpeed > 0) await this.setPumpFeatureAsync(6); // Action 5
|
|
776
|
+
// RKS: 07-21-24 - This used to send an empty payload when the pump should be off. For VF pumps it
|
|
777
|
+
// appears that not setting the feature or target flow will set the pump off when it gets to
|
|
778
|
+
// the drive state.
|
|
779
|
+
//if (!this.closing) await this.setPumpFeatureAsync(this._targetSpeed > 0 ? 6 : undefined); // Action 5
|
|
780
|
+
if (!this.closing) await this.setDriveStateAsync(); // Action 6
|
|
781
|
+
if (!this.closing) await setTimeout(200);
|
|
782
|
+
if (!this.closing) await this.requestPumpStatusAsync(); // Action 7
|
|
783
|
+
}
|
|
784
|
+
return new InterfaceServerResponse(200, 'Success');
|
|
785
|
+
}
|
|
786
|
+
catch (err) {
|
|
787
|
+
logger.error(`Error running pump sequence for ${this.pump.name}: ${err.message}`);
|
|
788
|
+
return Promise.reject(err);
|
|
789
|
+
}
|
|
790
|
+
finally { this.suspendPolling = false; }
|
|
791
|
+
};
|
|
738
792
|
}
|
|
739
793
|
export class NixiePumpVSF extends NixiePumpRS485 {
|
|
740
794
|
public setTargetSpeed(pState: PumpState) {
|
|
741
795
|
let _newSpeed = 0;
|
|
742
796
|
let maxRPM = 0;
|
|
743
797
|
let maxGPM = 0;
|
|
744
|
-
let
|
|
745
|
-
let speeds = 0;
|
|
798
|
+
let useFlow = false;
|
|
746
799
|
if (!pState.pumpOnDelay) {
|
|
747
800
|
let pumpCircuits = this.pump.circuits.get();
|
|
748
801
|
let pt = sys.board.valueMaps.pumpTypes.get(this.pump.type);
|
|
@@ -750,13 +803,19 @@ export class NixiePumpVSF extends NixiePumpRS485 {
|
|
|
750
803
|
// if there is a mix in the circuit array then they will not work. In IntelliCenter if there is an RPM setting in the mix it will use RPM by converting
|
|
751
804
|
// the GPM to RPM but if there is none then it will use GPM.
|
|
752
805
|
let toRPM = (flowRate: number, minSpeed: number = 450, maxSpeed: number = 3450) => {
|
|
806
|
+
// eff = 114.4365
|
|
807
|
+
// gpm = 80
|
|
808
|
+
// speed = 2412
|
|
753
809
|
let eff = .03317 * maxSpeed;
|
|
754
|
-
let rpm = Math.min((flowRate * maxSpeed) / eff, maxSpeed);
|
|
810
|
+
let rpm = Math.min(Math.round((flowRate * maxSpeed) / eff), maxSpeed);
|
|
755
811
|
return rpm > 0 ? Math.max(rpm, minSpeed) : 0;
|
|
756
812
|
};
|
|
757
813
|
let toGPM = (speed: number, maxSpeed: number = 3450, minFlow: number = 15, maxFlow: number = 140) => {
|
|
814
|
+
// eff = 114.4365
|
|
815
|
+
// speed = 1100
|
|
816
|
+
// gpm = (114.4365 * 1100)/3450 = 36
|
|
758
817
|
let eff = .03317 * maxSpeed;
|
|
759
|
-
let gpm = Math.min((eff * speed) / maxSpeed, maxFlow);
|
|
818
|
+
let gpm = Math.min(Math.round((eff * speed) / maxSpeed), maxFlow);
|
|
760
819
|
return gpm > 0 ? Math.max(gpm, minFlow) : 0;
|
|
761
820
|
}
|
|
762
821
|
for (let i = 0; i < pumpCircuits.length; i++) {
|
|
@@ -764,23 +823,24 @@ export class NixiePumpVSF extends NixiePumpRS485 {
|
|
|
764
823
|
let pc = pumpCircuits[i];
|
|
765
824
|
if (circ.isOn) {
|
|
766
825
|
if (pc.units > 0) {
|
|
826
|
+
let rpm = toRPM(pc.flow, pt.minSpeed, pt.MaxSpeed);
|
|
827
|
+
if (rpm > maxRPM) useFlow = true;
|
|
767
828
|
maxGPM = Math.max(maxGPM, pc.flow);
|
|
768
|
-
|
|
769
|
-
maxRPM = Math.max(maxGPM, toRPM(pc.flow, pt.minSpeed, pt.maxSpeed));
|
|
770
|
-
flows++;
|
|
829
|
+
rpm = Math.max(maxRPM, rpm);
|
|
771
830
|
}
|
|
772
831
|
else {
|
|
832
|
+
let gpm = toGPM(pc.speed, pt.maxSpeed, pt.minFlow, pt.maxFlow);
|
|
833
|
+
if (gpm > maxGPM) useFlow = false;
|
|
773
834
|
maxRPM = Math.max(maxRPM, pc.speed);
|
|
774
|
-
maxGPM = Math.max(maxGPM,
|
|
775
|
-
speeds++;
|
|
835
|
+
maxGPM = Math.max(maxGPM, gpm);
|
|
776
836
|
}
|
|
777
837
|
}
|
|
778
838
|
}
|
|
779
|
-
_newSpeed =
|
|
839
|
+
_newSpeed = useFlow ? maxGPM : maxRPM;
|
|
780
840
|
}
|
|
781
841
|
if (isNaN(_newSpeed)) _newSpeed = 0;
|
|
782
842
|
// Send the flow message if it is flow and the rpm message if it is rpm.
|
|
783
|
-
if (this._targetSpeed !== _newSpeed) logger.info(`NCP: Setting Pump ${this.pump.name} to ${_newSpeed} ${
|
|
843
|
+
if (this._targetSpeed !== _newSpeed) logger.info(`NCP: Setting Pump ${this.pump.name} to ${_newSpeed} ${useFlow ? 'GPM' : 'RPM'}.`);
|
|
784
844
|
this._targetSpeed = _newSpeed;
|
|
785
845
|
}
|
|
786
846
|
protected async setPumpRPMAsync() {
|
|
@@ -846,7 +906,7 @@ export class NixiePumpHWVS extends NixiePumpRS485 {
|
|
|
846
906
|
this._targetSpeed = 0;
|
|
847
907
|
await this.setPumpRPMAsync();
|
|
848
908
|
}
|
|
849
|
-
public async setDriveStateAsync(running: boolean = false) { }
|
|
909
|
+
public async setDriveStateAsync(running: boolean = false) { return Promise.resolve(); }
|
|
850
910
|
public async setPumpStateAsync(pstate: PumpState) {
|
|
851
911
|
// Don't poll while we are seting the state.
|
|
852
912
|
this.suspendPolling = true;
|
|
@@ -865,29 +925,31 @@ export class NixiePumpHWVS extends NixiePumpRS485 {
|
|
|
865
925
|
protected async requestPumpStatusAsync() { return Promise.resolve(); };
|
|
866
926
|
protected setPumpFeatureAsync(feature?: number) { return Promise.resolve(); }
|
|
867
927
|
protected async setPumpToRemoteControlAsync(running: boolean = true) {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
if (
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
928
|
+
try {
|
|
929
|
+
// We do nothing on this pump to set it to remote control. That is unless we are turning it off.
|
|
930
|
+
if (conn.isPortEnabled(this.pump.portId || 0)) {
|
|
931
|
+
if (!running) {
|
|
932
|
+
let out = Outbound.create({
|
|
933
|
+
portId: this.pump.portId || 0,
|
|
934
|
+
protocol: Protocol.Hayward,
|
|
935
|
+
source: 12, // Use the broadcast address
|
|
936
|
+
dest: this.pump.address,
|
|
937
|
+
action: 1,
|
|
938
|
+
payload: [0], // when stopAsync is called, pass false to return control to pump panel
|
|
939
|
+
// payload: spump.virtualControllerStatus === sys.board.valueMaps.virtualControllerStatus.getValue('running') ? [255] : [0],
|
|
940
|
+
retries: 1,
|
|
941
|
+
response: Response.create({ protocol: Protocol.Hayward, action: 12, source: this.pump.address - 96 })
|
|
942
|
+
});
|
|
943
|
+
try {
|
|
944
|
+
await out.sendAsync();
|
|
945
|
+
}
|
|
946
|
+
catch (err) {
|
|
947
|
+
logger.error(`Error sending setPumpToRemoteControl for ${this.pump.name}: ${err.message}`);
|
|
887
948
|
|
|
949
|
+
}
|
|
888
950
|
}
|
|
889
951
|
}
|
|
890
|
-
}
|
|
952
|
+
} catch(err) { `Error sending setPumpToRemoteControl message for ${this.pump.name}: ${err.message}` };
|
|
891
953
|
}
|
|
892
954
|
protected async setPumpRPMAsync() {
|
|
893
955
|
// Address 1
|