Skip to content

Commit

Permalink
Fixed issue where the max chem controllers were being hit even when n…
Browse files Browse the repository at this point in the history
…ot adding one.
  • Loading branch information
rstrouse authored and tagyoureit committed Feb 11, 2021
1 parent 706e0d0 commit c8279f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controller/boards/IntelliCenterBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3412,7 +3412,7 @@ export class IntelliCenterChemControllerCommands extends ChemControllerCommands
id = sys.chemControllers.nextAvailableChemController();
isAdd = true;
}
if (typeof id === 'undefined' || id > sys.equipment.maxChemControllers) return Promise.reject(new InvalidEquipmentIdError(`Max chem controller id exceeded`, id, 'chemController'));
if (isAdd && sys.chemControllers.length >= sys.equipment.maxChemControllers) return Promise.reject(new InvalidEquipmentIdError(`Max chem controller id exceeded`, id, 'chemController'));
chem = sys.chemControllers.getItemById(id, false); // Don't add it yet if it doesn't exist we will commit later after the OCP responds.
if (isVirtual || chem.isVirtual || type !== 2) return super.setChemControllerAsync(data); // Fall back to the world of the virtual chem controller.
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError(`Invalid chemController id: ${data.id}`, data.id, 'ChemController'));
Expand Down
4 changes: 3 additions & 1 deletion controller/boards/SystemBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2814,11 +2814,13 @@ export class ChemControllerCommands extends BoardCommands {
// this is a combined chem config/state setter.
let address = typeof data.address !== 'undefined' ? parseInt(data.address, 10) : undefined;
let id = typeof data.id !== 'undefined' ? parseInt(data.id, 10) : -1;
let isAdd = false;
if (typeof address === 'undefined' && id <= 0) {
// adding a chem controller
id = sys.chemControllers.nextAvailableChemController();
isAdd = true;
}
if (typeof id === 'undefined' || id > sys.equipment.maxChemControllers) return Promise.reject(new InvalidEquipmentIdError(`Max chem controller id exceeded`, id, 'chemController'));
if (isAdd && sys.chemControllers.length >= sys.equipment.maxChemControllers) return Promise.reject(new InvalidEquipmentIdError(`Max chem controller id exceeded`, id, 'chemController'));
if (typeof address !== 'undefined' && address < 144 || address > 158) return Promise.reject(new InvalidEquipmentIdError(`Max chem controller id exceeded`, id, 'chemController'));
if (isNaN(id)) return Promise.reject(new InvalidEquipmentIdError(`Invalid chemController id: ${data.id}`, data.id, 'ChemController'));
let chem: ChemController;
Expand Down

0 comments on commit c8279f7

Please sign in to comment.