Skip to content

Commit c02bbd9

Browse files
author
Russell Green
committed
chroe: updates
1 parent 1fedbd1 commit c02bbd9

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

lib/fill/Filler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Filler {
4040
return [
4141
this.options.valves.drainPin,
4242
this.options.valves.supplyPin,
43-
this.options.valves.supplyPin
43+
this.options.valves.targetPin
4444
];
4545
}
4646

@@ -150,7 +150,7 @@ export class Filler {
150150

151151
private async skipIfAlreadyFull(): Promise<boolean> {
152152
const startLevel = this.status.startLevel as number;
153-
const isFull = startLevel <= this.levelSensor.fullLevel;
153+
const isFull = this.levelSensor.isFullValue(startLevel);
154154

155155
if (isFull) {
156156
this.log.info(`Skipping run due to level already full`);

lib/level/DP5200LevelSensor.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export class DP5200Sensor implements LevelSensor {
2929
this.log = createLogger(`LevelSensor(${options.type})`);
3030
}
3131

32+
isFullValue(value: number): boolean {
33+
return value >= this.fullLevel;
34+
}
35+
3236
async getLevel(): Promise<number> {
3337
const value = await this.piServer.getPin(this.options.readPin);
3438
return value === this.options.fullIndicatorValue ? 1 : 0;
@@ -46,11 +50,14 @@ export class DP5200Sensor implements LevelSensor {
4650
): Promise<number> {
4751
try {
4852
let level = await this.getLevelAveraged(averagingOptions);
49-
while (level < this.fullLevel) {
50-
this.log.debug(`Waiting for level ${level} to equal 1`);
53+
let isNotFull = !this.isFullValue(level);
5154

55+
while (isNotFull) {
56+
this.log.debug(`Waiting for level ${level} to equal 1`);
5257
await wait(millisecondsDelay);
58+
5359
level = await this.getLevelAveraged(averagingOptions);
60+
isNotFull = !this.isFullValue(level);
5461
}
5562

5663
this.log.debug(`Level reached`);

lib/level/LevelSensor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface WaitForLevelOptions extends Partial<AveragingOptions> {
1212
export interface LevelSensor {
1313
get fullLevel(): number;
1414
getLevel(): Promise<number>;
15+
isFullValue(value: number): boolean;
1516
getLevelAveraged(options?: Partial<AveragingOptions>): Promise<number>;
1617
waitUntilFull(
1718
averagingOptions?: Partial<AveragingOptions>,

lib/level/LevelSensorBase.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ export abstract class LevelSensorBase implements LevelSensor {
4343
this.log = createLogger(`LevelSensor(${options.type})`);
4444
}
4545

46+
isFullValue(value: number): boolean {
47+
return value <= this.fullLevel;
48+
}
49+
4650
async getLevel(): Promise<number> {
4751
const endpoint = `${this.sensorEndpoint}/${this.options.endpointPath}`;
4852
const { retryCount, retryWait } = this.options;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raspberry-pi-client",
3-
"version": "1.0.0-rc.16",
3+
"version": "1.0.0-rc.17",
44
"private": true,
55
"scripts": {
66
"dev": "next dev",

0 commit comments

Comments
 (0)