Skip to content

Commit f53cfd6

Browse files
Enhance IntelliCenterBoard and PumpCommands to support big-endian payload handling for IntelliCenter v3. Update command destination addressing logic and streamline payload processing for pump configurations. This includes conditional handling for speed and flow values based on the equipment version, ensuring compatibility with v3.004+ protocols. #1090
1 parent c149f36 commit f53cfd6

2 files changed

Lines changed: 79 additions & 24 deletions

File tree

controller/boards/IntelliCenterBoard.ts

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ export class IntelliCenterBoard extends SystemBoard {
779779
}
780780
}
781781
public get commandSourceAddress(): number { return Message.pluginAddress; }
782-
public get commandDestAddress(): number { return 15; }
782+
public get commandDestAddress(): number { return sys.equipment.isIntellicenterV3 ? 16 : 15; }
783783
public static getAckResponse(action: number, source?: number, dest?: number): Response { return Response.create({ source: source, dest: dest || sys.board.commandSourceAddress, action: 1, payload: [action] }); }
784784
}
785785
class IntelliCenterConfigRequest extends ConfigRequest {
@@ -3033,42 +3033,64 @@ class IntelliCenterPumpCommands extends PumpCommands {
30333033
// supplied then we will use what we already have. This will make sure the information is valid and any change can be applied without the complete
30343034
// definition of the pump. This is important since additional attributes may be added in the future and this keeps us current no matter what
30353035
// the endpoint capability is.
3036-
let outc = Outbound.create({ action: 168, payload: [4, 0, id - 1, ntype, 0] });
3036+
const isV3 = sys.equipment.isIntellicenterV3;
3037+
const dest = isV3 ? 16 : 15;
3038+
let outc = Outbound.create({ dest, action: 168, payload: [4, 0, id - 1, ntype, 0] });
30373039
outc.appendPayloadByte(parseInt(data.address, 10), id + 95); // 5
3038-
outc.appendPayloadInt(parseInt(data.minSpeed, 10), pump.minSpeed); // 6
3039-
outc.appendPayloadInt(parseInt(data.maxSpeed, 10), pump.maxSpeed); // 8
3040+
// v3.004+ uses big-endian for 16-bit speed/flow values
3041+
if (isV3) {
3042+
outc.appendPayloadIntBE(parseInt(data.minSpeed, 10), pump.minSpeed); // 6
3043+
outc.appendPayloadIntBE(parseInt(data.maxSpeed, 10), pump.maxSpeed); // 8
3044+
} else {
3045+
outc.appendPayloadInt(parseInt(data.minSpeed, 10), pump.minSpeed); // 6
3046+
outc.appendPayloadInt(parseInt(data.maxSpeed, 10), pump.maxSpeed); // 8
3047+
}
30403048
outc.appendPayloadByte(parseInt(data.minFlow, 10), pump.minFlow); // 10
30413049
outc.appendPayloadByte(parseInt(data.maxFlow, 10), pump.maxFlow); // 11
30423050
outc.appendPayloadByte(parseInt(data.flowStepSize, 10), pump.flowStepSize || 1); // 12
3043-
outc.appendPayloadInt(parseInt(data.primingSpeed, 10), pump.primingSpeed || 2500); // 13
3051+
if (isV3) {
3052+
outc.appendPayloadIntBE(parseInt(data.primingSpeed, 10), pump.primingSpeed || 2500); // 13
3053+
} else {
3054+
outc.appendPayloadInt(parseInt(data.primingSpeed, 10), pump.primingSpeed || 2500); // 13
3055+
}
30443056
outc.appendPayloadByte(typeof data.speedStepSize !== 'undefined' ? parseInt(data.speedStepSize, 10) / 10 : pump.speedStepSize / 10, 1); // 15
30453057
outc.appendPayloadByte(parseInt(data.primingTime, 10), pump.primingTime || 0); // 17
30463058
outc.appendPayloadByte(255); //
30473059
outc.appendPayloadBytes(255, 8); // 18
30483060
outc.appendPayloadBytes(0, 8); // 26
3049-
let outn = Outbound.create({ action: 168, payload: [4, 1, id - 1] });
3061+
let outn = Outbound.create({ dest, action: 168, payload: [4, 1, id - 1] });
30503062
outn.appendPayloadBytes(0, 16);
30513063
outn.appendPayloadString(data.name, 16, pump.name || type.name);
30523064
if (type.name === 'ss') {
30533065
outc.setPayloadByte(5, 0); // Clear the pump address
30543066

30553067
// At some point we may add these to the pump model.
3056-
outc.setPayloadInt(6, type.minSpeed, 450);
3057-
outc.setPayloadInt(8, type.maxSpeed, 3450);
3068+
// v3.004+ uses big-endian for 16-bit speed/flow values
3069+
if (isV3) {
3070+
outc.setPayloadIntBE(6, type.minSpeed, 450);
3071+
outc.setPayloadIntBE(8, type.maxSpeed, 3450);
3072+
} else {
3073+
outc.setPayloadInt(6, type.minSpeed, 450);
3074+
outc.setPayloadInt(8, type.maxSpeed, 3450);
3075+
}
30583076
outc.setPayloadByte(10, type.minFlow, 0);
30593077
outc.setPayloadByte(11, type.maxFlow, 130);
30603078
outc.setPayloadByte(12, 1);
3061-
outc.setPayloadInt(13, type.primingSpeed, 2500);
3079+
if (isV3) {
3080+
outc.setPayloadIntBE(13, type.primingSpeed, 2500);
3081+
} else {
3082+
outc.setPayloadInt(13, type.primingSpeed, 2500);
3083+
}
30623084
outc.setPayloadByte(15, 10);
30633085
outc.setPayloadByte(16, 1);
30643086
outc.setPayloadByte(17, 5);
30653087
outc.setPayloadByte(18, data.body, pump.body);
30663088
outc.setPayloadByte(26, 0);
3067-
outn.setPayloadInt(3, 0);
3089+
if (isV3) outn.setPayloadIntBE(3, 0); else outn.setPayloadInt(3, 0);
30683090
for (let i = 1; i < 8; i++) {
30693091
outc.setPayloadByte(i + 18, 255);
30703092
outc.setPayloadByte(i + 26, 0);
3071-
outn.setPayloadInt((i * 2) + 3, 1000);
3093+
if (isV3) outn.setPayloadIntBE((i * 2) + 3, 1000); else outn.setPayloadInt((i * 2) + 3, 1000);
30723094
}
30733095
}
30743096
else {
@@ -3090,13 +3112,13 @@ class IntelliCenterPumpCommands extends PumpCommands {
30903112
// The incoming data does not include this circuit so we will set it to 255.
30913113
outc.setPayloadByte(i + 18, 255);
30923114
if (typeof type.minSpeed !== 'undefined')
3093-
outn.setPayloadInt((i * 2) + 3, type.minSpeed);
3115+
isV3 ? outn.setPayloadIntBE((i * 2) + 3, type.minSpeed) : outn.setPayloadInt((i * 2) + 3, type.minSpeed);
30943116
else if (typeof type.minFlow !== 'undefined') {
3095-
outn.setPayloadInt((i * 2) + 3, type.minFlow);
3117+
isV3 ? outn.setPayloadIntBE((i * 2) + 3, type.minFlow) : outn.setPayloadInt((i * 2) + 3, type.minFlow);
30963118
outc.setPayloadByte(i + 26, 1);
30973119
}
30983120
else
3099-
outn.setPayloadInt((i * 2) + 3, 0);
3121+
isV3 ? outn.setPayloadIntBE((i * 2) + 3, 0) : outn.setPayloadInt((i * 2) + 3, 0);
31003122
}
31013123
else {
31023124
let c = data.circuits[i];
@@ -3111,11 +3133,11 @@ class IntelliCenterPumpCommands extends PumpCommands {
31113133
outc.setPayloadByte(i + 18, circuit - 1, circ.circuit - 1);
31123134
if (typeof type.minSpeed !== 'undefined' && (parseInt(c.units, 10) === 0 || isNaN(parseInt(c.units, 10)))) {
31133135
outc.setPayloadByte(i + 26, 0); // Set to rpm
3114-
outn.setPayloadInt((i * 2) + 3, Math.max(speed, type.minSpeed), circ.speed);
3136+
isV3 ? outn.setPayloadIntBE((i * 2) + 3, Math.max(speed, type.minSpeed), circ.speed) : outn.setPayloadInt((i * 2) + 3, Math.max(speed, type.minSpeed), circ.speed);
31153137
}
31163138
else if (typeof type.minFlow !== 'undefined' && (parseInt(c.units, 10) === 1 || isNaN(parseInt(c.units, 10)))) {
31173139
outc.setPayloadByte(i + 26, 1); // Set to gpm
3118-
outn.setPayloadInt((i * 2) + 3, Math.max(flow, type.minFlow), circ.flow);
3140+
isV3 ? outn.setPayloadIntBE((i * 2) + 3, Math.max(flow, type.minFlow), circ.flow) : outn.setPayloadInt((i * 2) + 3, Math.max(flow, type.minFlow), circ.flow);
31193141
}
31203142
}
31213143
}
@@ -3235,14 +3257,25 @@ class IntelliCenterPumpCommands extends PumpCommands {
32353257
if (pump.master === 1) return super.deletePumpAsync(data);
32363258

32373259
if (typeof pump.type === 'undefined') return Promise.reject(new InvalidEquipmentIdError(`Pump #${data.id} does not exist in configuration`, data.id, 'Schedule'));
3260+
const isV3 = sys.equipment.isIntellicenterV3;
32383261
let outc = Outbound.create({ action: 168, payload: [4, 0, id - 1, 0, 0, id + 95] });
3239-
outc.appendPayloadInt(450); // 6
3240-
outc.appendPayloadInt(3450); // 8
3262+
if (isV3) {
3263+
outc.appendPayloadIntBE(450); // 6
3264+
outc.appendPayloadIntBE(3450); // 8
3265+
} else {
3266+
outc.appendPayloadInt(450); // 6
3267+
outc.appendPayloadInt(3450); // 8
3268+
}
32413269
outc.appendPayloadByte(15); // 10
32423270
outc.appendPayloadByte(130); // 11
32433271
outc.appendPayloadByte(1); // 12
3244-
outc.appendPayloadInt(1000); // 13
3245-
outc.appendPayloadInt(10); // 15
3272+
if (isV3) {
3273+
outc.appendPayloadIntBE(1000); // 13
3274+
outc.appendPayloadIntBE(10); // 15
3275+
} else {
3276+
outc.appendPayloadInt(1000); // 13
3277+
outc.appendPayloadInt(10); // 15
3278+
}
32463279
outc.appendPayloadByte(5); // 17
32473280
outc.appendPayloadBytes(255, 8); // 18
32483281
outc.appendPayloadBytes(0, 8); // 26
@@ -3709,14 +3742,20 @@ class IntelliCenterScheduleCommands extends ScheduleCommands {
37093742
if (endTimeType !== 0) runOnce |= (1 << (endTimeType + 3));
37103743
// This was always the cooling setpoint for ultratemp.
37113744
//let flags = (circuit === 1 || circuit === 6) ? 81 : 100;
3745+
// v3.004+ uses big-endian for 16-bit time values
3746+
let startTimeLo = startTime - Math.floor(startTime / 256) * 256;
3747+
let startTimeHi = Math.floor(startTime / 256);
3748+
let endTimeLo = endTime - Math.floor(endTime / 256) * 256;
3749+
let endTimeHi = Math.floor(endTime / 256);
3750+
let isV3 = sys.equipment.isIntellicenterV3;
37123751
let out = Outbound.createMessage(168, [
37133752
3
37143753
, 0
37153754
, id - 1 // IntelliCenter schedules start at 0.
3716-
, startTime - Math.floor(startTime / 256) * 256
3717-
, Math.floor(startTime / 256)
3718-
, endTime - Math.floor(endTime / 256) * 256
3719-
, Math.floor(endTime / 256)
3755+
, isV3 ? startTimeHi : startTimeLo
3756+
, isV3 ? startTimeLo : startTimeHi
3757+
, isV3 ? endTimeHi : endTimeLo
3758+
, isV3 ? endTimeLo : endTimeHi
37203759
, circuit - 1
37213760
, runOnce
37223761
, schedDays

controller/comms/messages/Messages.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,14 @@ export class Outbound extends OutboundCommon {
11861186
if (ndx + 1 < this.payload.length) this.payload[ndx + 1] = b1;
11871187
return this;
11881188
}
1189+
public setPayloadIntBE(ndx: number, value: number, def?: number) {
1190+
if (typeof value === 'undefined' || isNaN(value)) value = def;
1191+
let b1 = Math.floor(value / 256);
1192+
let b0 = value - (b1 * 256);
1193+
if (ndx < this.payload.length) this.payload[ndx] = b1;
1194+
if (ndx + 1 < this.payload.length) this.payload[ndx + 1] = b0;
1195+
return this;
1196+
}
11891197
public appendPayloadInt(value: number, def?: number) {
11901198
if (typeof value === 'undefined' || isNaN(value)) value = def;
11911199
let b1 = Math.floor(value / 256);
@@ -1194,6 +1202,14 @@ export class Outbound extends OutboundCommon {
11941202
this.payload.push(b1);
11951203
return this;
11961204
}
1205+
public appendPayloadIntBE(value: number, def?: number) {
1206+
if (typeof value === 'undefined' || isNaN(value)) value = def;
1207+
let b1 = Math.floor(value / 256);
1208+
let b0 = value - (b1 * 256);
1209+
this.payload.push(b1);
1210+
this.payload.push(b0);
1211+
return this;
1212+
}
11971213
public insertPayloadInt(ndx: number, value: number, def?: number) {
11981214
if (typeof value === 'undefined' || isNaN(value)) value = def;
11991215
let b1 = Math.floor(value / 256);

0 commit comments

Comments
 (0)