Skip to content

Commit

Permalink
Merge branch 'master' into docker
Browse files Browse the repository at this point in the history
  • Loading branch information
tagyoureit committed Jun 9, 2024
2 parents 8976989 + 1335dd1 commit 9bbbaa6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
14 changes: 10 additions & 4 deletions controller/boards/IntelliCenterBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2173,20 +2173,22 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
255, 255, 0, 0, 0, 0], // 30-35
3);


// Circuits are always contiguous so we don't have to worry about
// them having a strange offset like features and groups. However, in
// single body systems they start with 2.
for (let i = 0; i < state.data.circuits.length; i++) {
// We are using the index and setting the circuits based upon
// the index. This way it doesn't matter what the sort happens to
// be and whether there are gaps in the ids or not. The ordinal is the bit number.
let circuit = state.circuits.getItemByIndex(i);
let ordinal = circuit.id - 1;
let cstate = state.circuits.getItemByIndex(i);
let ordinal = cstate.id - 1;
if (ordinal >= 40) continue;
let ndx = Math.floor(ordinal / 8);
let byte = out.payload[ndx + 3];
let bit = ordinal - (ndx * 8);
if (circuit.id === id) byte = isOn ? byte = byte | (1 << bit) : byte;
else if (circuit.isOn) byte = byte | (1 << bit);
if (cstate.id === id) byte = isOn ? byte = byte | (1 << bit) : byte;
else if (cstate.isOn) byte = byte | (1 << bit);
out.payload[ndx + 3] = byte;
}
// Set the bits for the features.
Expand All @@ -2196,6 +2198,7 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
// be and whether there are gaps in the ids or not. The ordinal is the bit number.
let feature = state.features.getItemByIndex(i);
let ordinal = feature.id - sys.board.equipmentIds.features.start;
if (ordinal >= 32) continue;
let ndx = Math.floor(ordinal / 8);
let byte = out.payload[ndx + 9];
let bit = ordinal - (ndx * 8);
Expand All @@ -2207,6 +2210,7 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
for (let i = 0; i < state.data.circuitGroups.length; i++) {
let group = state.circuitGroups.getItemByIndex(i);
let ordinal = group.id - sys.board.equipmentIds.circuitGroups.start;
if (ordinal >= 16) continue;
let ndx = Math.floor(ordinal / 8);
let byte = out.payload[ndx + 13];
let bit = ordinal - (ndx * 8);
Expand All @@ -2218,6 +2222,7 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
for (let i = 0; i < state.data.lightGroups.length; i++) {
let group = state.lightGroups.getItemByIndex(i);
let ordinal = group.id - sys.board.equipmentIds.circuitGroups.start;
if (ordinal >= 16) continue;
let ndx = Math.floor(ordinal / 8);
let byte = out.payload[ndx + 13];
let bit = ordinal - (ndx * 8);
Expand Down Expand Up @@ -2253,6 +2258,7 @@ class IntelliCenterCircuitCommands extends CircuitCommands {
for (let i = 0; i < state.data.schedules.length; i++) {
let sched = state.schedules.getItemByIndex(i);
let ordinal = sched.id - 1;
if (ordinal >= 100) continue;
let ndx = Math.floor(ordinal / 8);
let byte = out.payload[ndx + 15];
let bit = ordinal - (ndx * 8);
Expand Down
5 changes: 3 additions & 2 deletions controller/boards/NixieBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import * as extend from 'extend';
import { ncp } from "../nixie/Nixie";
import { NixieHeaterBase } from "../nixie/heaters/Heater";
import { utils } from '../Constants';
import { Timestamp, utils } from '../Constants';
import {SystemBoard, byteValueMap, BodyCommands, FilterCommands, PumpCommands, SystemCommands, CircuitCommands, FeatureCommands, ValveCommands, HeaterCommands, ChlorinatorCommands, ChemControllerCommands, EquipmentIdRange} from './SystemBoard';
import { logger } from '../../logger/Logger';
import { state, CircuitState, ICircuitState, ICircuitGroupState, LightGroupState, ValveState, FilterState, BodyTempState, FeatureState } from '../State';
Expand Down Expand Up @@ -784,8 +784,9 @@ export class NixieCircuitCommands extends CircuitCommands {
}
if (sys.general.options.cleanerStartDelay && sys.general.options.cleanerStartDelayTime) {
let bcstate = state.circuits.getItemById(bstate.circuit);
let stime = typeof bcstate.startTime === 'undefined' ? dtNow : (dtNow - bcstate.startTime.getTime());
// So we should be started. Lets determine whethere there should be any delay.
delayTime = Math.max(Math.round(((sys.general.options.cleanerStartDelayTime * 1000) - (dtNow - bcstate.startTime.getTime())) / 1000), delayTime);
delayTime = Math.max(Math.round(((sys.general.options.cleanerStartDelayTime * 1000) - stime) / 1000), delayTime);
logger.info(`Cleaner delay time calculated to ${delayTime}`);
}
}
Expand Down
6 changes: 6 additions & 0 deletions controller/nixie/schedules/Schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export class NixieScheduleCollection extends NixieEquipmentCollection<NixieSched
circ.sscheds.push(sscheds[i]);
}
}
// Sort this so that body circuits are evaluated first. This is required when there are schedules for things like cleaner
// or delay circuits. If we do not do this then a schedule that requires the pool to be on for instance will never
// get triggered.
circuits.sort((x, y) => y.circuitId === 6 || y.circuitId === 1 ? 1 : y.circuitId - x.circuitId);


/*
RSG 5-8-22
Manual OP needs to play a role here.From the IC manual:
Expand Down
6 changes: 5 additions & 1 deletion web/services/state/StateSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ export class StateSocket {
try {
data = JSON.parse(data);
let id = parseInt(data.id, 10);
if (!isNaN(id) && (typeof data.isOn !== 'undefined' || typeof data.state !== 'undefined')) {
if (!isNaN(id) && typeof data.toggle !== 'undefined')
if (utils.makeBool(data.toggle)) await sys.board.circuits.toggleCircuitStateAsync(id);
else if (!isNaN(id) && (typeof data.isOn !== 'undefined' || typeof data.state !== 'undefined')) {
await sys.board.circuits.setCircuitStateAsync(id, utils.makeBool(data.isOn || typeof data.state));
}
}
Expand All @@ -203,6 +205,8 @@ export class StateSocket {
try {
data = JSON.parse(data);
let id = parseInt(data.id, 10);
if (!isNaN(id) && typeof data.toggle !== 'undefined')
if (utils.makeBool(data.toggle)) await sys.board.features.toggleFeatureStateAsync(id);
if (!isNaN(id) && (typeof data.isOn !== 'undefined' || typeof data.state !== 'undefined')) {
await sys.board.features.setFeatureStateAsync(id, utils.makeBool(data.isOn || typeof data.state));
}
Expand Down

0 comments on commit 9bbbaa6

Please sign in to comment.