Skip to content

Commit

Permalink
chemController Updates - virtual mode!
Browse files Browse the repository at this point in the history
  • Loading branch information
tagyoureit committed Sep 17, 2020
1 parent 5d0ec39 commit 7c7ebe1
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 115 deletions.
37 changes: 19 additions & 18 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/* nodejs-poolController. An application to control pool equipment.
Copyright (C) 2016, 2017. Russell Goldin, tagyoureit. [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* nodejs-poolController. An application to control pool equipment.
Copyright (C) 2016, 2017. Russell Goldin, tagyoureit. [email protected]
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// add source map support for .js to .ts files
require('source-map-support').install();

Expand Down Expand Up @@ -75,9 +75,10 @@ export async function stopAsync(): Promise<void> {
}
if (process.platform === 'win32') {
let rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.on('SIGINT', function() { stopAsync(); });
rl.on('SIGINT', async function() { stopAsync(); });
}
else {
process.on('SIGINT', function() { return stopAsync(); });
process.stdin.resume()
process.on('SIGINT', async function() { return stopAsync(); });
}
initAsync();
18 changes: 12 additions & 6 deletions controller/Equipment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,25 @@ export class PoolSystem implements IPoolSystem {
}
public searchForAdditionalDevices() {
if (this.controllerType === ControllerType.Unknown || typeof this.controllerType === 'undefined' && !conn.mockPort){
logger.info("Searching for chlorinators and pumps");
logger.info("Searching chlorinators, pumps and chem controllers");
EquipmentStateMessage.initVirtual();
sys.board.virtualChlorinatorController.search();
sys.board.virtualPumpControllers.search();
sys.board.virtualChemControllers.search();
}
else if (this.controllerType === ControllerType.Virtual){
else {
if (this.controllerType === ControllerType.Virtual){
state.mode = 0;
state.status = 1;
sys.equipment.setEquipmentIds();
state.emitControllerChange();
}
// try to start any virtual controllers that are present irregardless of overall controller virtual status
sys.board.virtualPumpControllers.start();
sys.board.virtualChlorinatorController.start();
state.mode = 0;
state.status = 1;
sys.equipment.setEquipmentIds();
state.emitControllerChange();
sys.board.virtualChemControllers.start();
}

}
public board: SystemBoard=new SystemBoard(this);
public processVersionChanges(ver: ConfigVersion) { this.board.requestConfiguration(ver); }
Expand Down
2 changes: 1 addition & 1 deletion controller/boards/EasyTouchBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export class EasyTouchBoard extends SystemBoard {
this.checkConfiguration();
}

public async stopAsync() { this._configQueue.close(); return Promise.resolve([]); }
public async stopAsync() { this._configQueue.close(); return super.stopAsync(); }
}
export class TouchConfigRequest extends ConfigRequest {
constructor(setcat: number, items?: number[], oncomplete?: Function) {
Expand Down
2 changes: 1 addition & 1 deletion controller/boards/IntelliCenterBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class IntelliCenterBoard extends SystemBoard {
sys.configVersion.valves = ver.valves;
}
}
public async stopAsync() { this._configQueue.close(); return Promise.resolve([]);}
public async stopAsync() { this._configQueue.close(); return super.stopAsync();}
public initExpansionModules(ocp0A: number, ocp0B: number, ocp1A: number, ocp2A: number, ocp3A: number) {
let inv = { bodies: 0, circuits: 0, valves: 0, shared: false, dual: false, covers: 0, chlorinators: 0, chemControllers: 0 };
this.processMasterModules(sys.equipment.modules, ocp0A, ocp0B, inv);
Expand Down
Loading

0 comments on commit 7c7ebe1

Please sign in to comment.