File tree Expand file tree Collapse file tree 5 files changed +17
-5
lines changed
Expand file tree Collapse file tree 5 files changed +17
-5
lines changed Original file line number Diff line number Diff 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` ) ;
Original file line number Diff line number Diff 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` ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export interface WaitForLevelOptions extends Partial<AveragingOptions> {
1212export 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 > ,
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change 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" ,
You can’t perform that action at this time.
0 commit comments