From 39d9cc64bfc7f59c96bdbd5e432905e4e5339b1b Mon Sep 17 00:00:00 2001 From: Lars Saalbach Date: Sat, 1 Feb 2025 20:07:38 +0100 Subject: [PATCH] #896 - Removing weight data from meticulus #897 - Fixing weight doubling #898 - Make tiles and graph bigger for tablet --- .../brew/brew-flow/brew-flow.component.html | 8 ++-- .../brew/brew-flow/brew-flow.component.scss | 13 ++++++ src/app/brew/brew-flow/brew-flow.component.ts | 3 -- src/classes/devices/bluetoothDevice.ts | 42 ++++++++++++------- .../meticulous/meticulousDevice.ts | 25 ++++++----- .../brew-brewing-graph.component.html | 4 +- .../brew-brewing-graph.component.scss | 1 + .../brew-brewing-graph.component.ts | 17 ++++---- 8 files changed, 71 insertions(+), 42 deletions(-) diff --git a/src/app/brew/brew-flow/brew-flow.component.html b/src/app/brew/brew-flow/brew-flow.component.html index 0ac1391e..d3fb688d 100644 --- a/src/app/brew/brew-flow/brew-flow.component.html +++ b/src/app/brew/brew-flow/brew-flow.component.html @@ -14,7 +14,7 @@ {{'BREW_PRESSURE_FLOW' | translate}} } - @if(brewComponent.brewBrewingGraphEl.uiTemperatureConnected || ( brewComponent.brewBrewingGraphEl.uiPreparationDeviceConnected) || (isDetail === true && brewComponent.brewBrewingGraphEl.traces.temperatureTrace?.x?.length >0)) { + @if(brewComponent.brewBrewingGraphEl.uiTemperatureConnected || ( brewComponent.brewBrewingGraphEl.uiPreparationDeviceConnected && brewComponent.brewBrewingGraphEl.uiPreparationDeviceType !== PREPARATION_DEVICE_TYPE_ENUM.METICULOUS) || (isDetail === true && brewComponent.brewBrewingGraphEl.traces.temperatureTrace?.x?.length >0)) { {{'BREW_TEMPERATURE_REALTIME' | translate}} @@ -45,9 +45,9 @@
? g
?g
@if(brewComponent.timer.timer.runTimer) { - + } @else { - ({{brewComponent.brewBrewingGraphEl.data | brewFunctionPipe: [BREW_FUNCTION_PIPE_ENUM.GET_BREW_RATIO,brewComponent.brewBrewingGraphEl.data.brew_beverage_quantity,brewComponent.brewBrewingGraphEl.data.brew_quantity]}}) + ({{brewComponent.brewBrewingGraphEl.data | brewFunctionPipe: [BREW_FUNCTION_PIPE_ENUM.GET_BREW_RATIO,brewComponent.brewBrewingGraphEl.data.brew_beverage_quantity,brewComponent.brewBrewingGraphEl.data.brew_quantity]}}) } @@ -81,7 +81,7 @@ - diff --git a/src/app/brew/brew-flow/brew-flow.component.scss b/src/app/brew/brew-flow/brew-flow.component.scss index 6146ca45..7ed03be0 100644 --- a/src/app/brew/brew-flow/brew-flow.component.scss +++ b/src/app/brew/brew-flow/brew-flow.component.scss @@ -67,6 +67,19 @@ flex-direction: column; min-height:50px; height:50px; + font-weight:bold; + .smartScaleRatio { + font-size:16px; + } + } + @media (min-width: 750px) and (min-height: 750px) { + ion-card-header { + height:90px; + font-size:30px; + .smartScaleRatio { + font-size:30px; + } + } } @media (max-width: 480px) { ion-card-header { diff --git a/src/app/brew/brew-flow/brew-flow.component.ts b/src/app/brew/brew-flow/brew-flow.component.ts index 0ada6a96..4bc7f3e2 100644 --- a/src/app/brew/brew-flow/brew-flow.component.ts +++ b/src/app/brew/brew-flow/brew-flow.component.ts @@ -88,7 +88,6 @@ export class BrewFlowComponent implements OnDestroy, OnInit { private disableHardwareBack; protected readonly PREPARATION_STYLE_TYPE = PREPARATION_STYLE_TYPE; - protected heightInformationBlock: number = 50; public graphIconColSize: number = 2.4; public bluetoothSubscription: Subscription = undefined; @@ -287,8 +286,6 @@ export class BrewFlowComponent implements OnDestroy, OnInit { informationContainerHeight = 0; } - this.heightInformationBlock = informationContainerHeight; - this.brewComponent.brewBrewingGraphEl.lastChartLayout.height = flowHeight - informationContainerHeight; diff --git a/src/classes/devices/bluetoothDevice.ts b/src/classes/devices/bluetoothDevice.ts index d1aa4de5..85307f10 100644 --- a/src/classes/devices/bluetoothDevice.ts +++ b/src/classes/devices/bluetoothDevice.ts @@ -54,6 +54,7 @@ export class BluetoothScale { protected blueToothParentlogger: Logger; private scaleType = undefined; + private doubleWeight: boolean = false; constructor(data: PeripheralData, type: ScaleType) { this.device_id = data.id; this.supportsTaring = true; @@ -82,6 +83,10 @@ export class BluetoothScale { return 0; } + public setDoubleWeight(_doubleIt: boolean) { + this.doubleWeight = _doubleIt; + } + public resetSmoothedValue() { this.weight.smoothed = 0; this.weight.oldSmoothed = 0; @@ -109,26 +114,33 @@ export class BluetoothScale { // Each value effect the current weight bei 10%. // (A3 * 03 + b2 * 0.7) // Actual value * 03 + smoothed value * 0.7 - - this.weight.notMutatedWeight = _newWeight; + let newWeight = _newWeight; + this.weight.notMutatedWeight = newWeight; this.blueToothParentlogger.log( - 'Bluetooth Scale - New weight recieved ' + _newWeight + 'Bluetooth Scale - New weight recieved ' + newWeight, ); + if (this.doubleWeight) { + newWeight = newWeight * 2; + this.blueToothParentlogger.log( + 'Bluetooth Scale - Weight doubled' + newWeight, + ); + } + this.weight.oldSmoothed = this.weight.smoothed; this.weight.smoothed = this.calculateSmoothedWeight( - _newWeight, - this.weight.smoothed + newWeight, + this.weight.smoothed, ); // We passed every shake change, seems like everything correct, set the new weight. - this.weight.actual = _newWeight; + this.weight.actual = newWeight; try { this.blueToothParentlogger.log( 'Bluetooth Scale - Are weight subscriptions existing? ' + - this.weightChange?.observers?.length + this.weightChange?.observers?.length, ); } catch (ex) {} this.weightChange.emit({ @@ -140,12 +152,12 @@ export class BluetoothScale { notMutatedWeight: this.weight.notMutatedWeight, }); this.triggerFlow(_stableWeight); - this.weight.old = _newWeight; + this.weight.old = newWeight; } protected setSecondWeight( _newWeight: number, - _stableWeight: boolean = false + _stableWeight: boolean = false, ) { // Allow negative weight // Each value effect the current weight bei 10%. @@ -155,13 +167,13 @@ export class BluetoothScale { this.secondWeight.notMutatedWeight = _newWeight; this.blueToothParentlogger.log( - 'Bluetooth Scale - New weight recieved ' + _newWeight + 'Bluetooth Scale - New weight recieved ' + _newWeight, ); this.secondWeight.oldSmoothed = this.secondWeight.smoothed; this.secondWeight.smoothed = this.calculateSmoothedWeight( _newWeight, - this.secondWeight.smoothed + this.secondWeight.smoothed, ); // We passed every shake change, seems like everything correct, set the new weight. @@ -170,7 +182,7 @@ export class BluetoothScale { try { this.blueToothParentlogger.log( 'Bluetooth Scale - Are weight subscriptions existing? ' + - this.weightSecondChange?.observers?.length + this.weightSecondChange?.observers?.length, ); } catch (ex) {} this.weightSecondChange.emit({ @@ -186,7 +198,7 @@ export class BluetoothScale { } protected calculateSmoothedWeight( _actualWeight: number, - _smoothedWeight: number + _smoothedWeight: number, ): number { return _actualWeight * 0.3 + _smoothedWeight * 0.7; } @@ -197,7 +209,7 @@ export class BluetoothScale { try { this.blueToothParentlogger.log( 'Bluetooth Scale - Are flow subscriptions existing? ' + - this.flowChange?.observers?.length + this.flowChange?.observers?.length, ); } catch (ex) {} this.flowChange.emit({ @@ -217,7 +229,7 @@ export class BluetoothScale { try { this.blueToothParentlogger.log( 'Bluetooth Scale - Are flow second subscriptions existing? ' + - this.flowSecondChange?.observers?.length + this.flowSecondChange?.observers?.length, ); } catch (ex) {} this.flowSecondChange.emit({ diff --git a/src/classes/preparationDevice/meticulous/meticulousDevice.ts b/src/classes/preparationDevice/meticulous/meticulousDevice.ts index 25a0daf6..82dfc6f8 100644 --- a/src/classes/preparationDevice/meticulous/meticulousDevice.ts +++ b/src/classes/preparationDevice/meticulous/meticulousDevice.ts @@ -68,22 +68,25 @@ export class MeticulousDevice extends PreparationDevice { pressureFlow.old_pressure = 0; newBrewFlow.pressureFlow.push(pressureFlow); - const temperatureFlow: IBrewTemperatureFlow = {} as IBrewTemperatureFlow; + /**const temperatureFlow: IBrewTemperatureFlow = {} as IBrewTemperatureFlow; temperatureFlow.timestamp = timestamp; temperatureFlow.brew_time = ''; temperatureFlow.actual_temperature = shotEntry.temperature; temperatureFlow.old_temperature = 0; - newBrewFlow.temperatureFlow.push(temperatureFlow); + newBrewFlow.temperatureFlow.push(temperatureFlow);**/ } return newBrewFlow; } - constructor(protected httpClient: HttpClient, _preparation: Preparation) { + constructor( + protected httpClient: HttpClient, + _preparation: Preparation, + ) { super(httpClient, _preparation); this.meticulousShotData = undefined; this.metApi = new Api( undefined, - _preparation.connectedPreparationDevice.url + _preparation.connectedPreparationDevice.url, ); this.serverURL = _preparation.connectedPreparationDevice.url; @@ -104,13 +107,13 @@ export class MeticulousDevice extends PreparationDevice { sort: 'desc', max_results: 20, }, - httpOptions + httpOptions, ) .pipe( timeout(10000), catchError((e) => { return of(null); - }) + }), ) .toPromise() .then( @@ -123,7 +126,7 @@ export class MeticulousDevice extends PreparationDevice { (error) => { console.log(error); reject(); - } + }, ) .catch((error) => { console.log(error); @@ -231,9 +234,9 @@ export class MeticulousDevice extends PreparationDevice { return this.meticulousShotData.pressure; } - public getTemperature() { + /** public getTemperature() { return this.meticulousShotData.temperature; - } + }**/ public getWeight() { return this.meticulousShotData.weight; @@ -294,7 +297,7 @@ export class MeticulousDevice extends PreparationDevice { currentShotData.weight = data.sensors.w; currentShotData.pressure = data.sensors.p; currentShotData.shotTime = data.time; - currentShotData.temperature = data.sensors.t; + //currentShotData.temperature = data.sensors.t; currentShotData.extracting = data.extracting; this.meticulousShotData = currentShotData; @@ -304,7 +307,7 @@ export class MeticulousDevice extends PreparationDevice { this.meticulousShotData.setWeight(data.sensors.w); this.meticulousShotData.pressure = data.sensors.p; this.meticulousShotData.shotTime = data.time; - this.meticulousShotData.temperature = data.sensors.t; + //this.meticulousShotData.temperature = data.sensors.t; this.meticulousShotData.extracting = data.extracting; } }); diff --git a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.html b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.html index 52d68adb..7020b15a 100644 --- a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.html +++ b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.html @@ -29,7 +29,7 @@

{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE" | translate}}{{'BREW_PRESSURE_FLOW' | translate}} } - @if(uiTemperatureConnected || ( uiPreparationDeviceConnected) || (isDetail === true && this.traces.temperatureTrace?.x?.length >0)) { + @if(uiTemperatureConnected || ( uiPreparationDeviceConnected && uiPreparationDeviceType !== PREPARATION_DEVICE_TYPE_ENUM.METICULOUS) || (isDetail === true && this.traces.temperatureTrace?.x?.length >0)) { {{'BREW_TEMPERATURE_REALTIME' | translate}} @@ -91,7 +91,7 @@

{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE" | translate}} - diff --git a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.scss b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.scss index a3de4471..f80f4377 100644 --- a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.scss +++ b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.scss @@ -18,6 +18,7 @@ display: flex; justify-content: space-evenly; flex-direction: column; + font-weight:bold; } ion-card-content { diff --git a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts index 7185ed41..e8049475 100644 --- a/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts +++ b/src/components/brews/brew-brewing-graph/brew-brewing-graph.component.ts @@ -1647,10 +1647,11 @@ export class BrewBrewingGraphComponent implements OnInit { actual: shotData.pressure, old: shotData.pressure, }); - this.__setTemperatureFlow({ + + /** this.__setTemperatureFlow({ actual: shotData.temperature, old: shotData.temperature, - }); + });**/ this.__setFlowProfile({ actual: shotData.weight, @@ -2192,6 +2193,10 @@ export class BrewBrewingGraphComponent implements OnInit { this.scaleFlowSecondSubscription.unsubscribe(); this.scaleFlowSecondSubscription = undefined; } + const scale: BluetoothScale = this.bleManager.getScale(); + if (scale) { + scale.setDoubleWeight(false); + } } public deattachToFlowChange() { @@ -2763,19 +2768,17 @@ export class BrewBrewingGraphComponent implements OnInit { } } - let oneEspressoCup: boolean = false; if ( this.espressoJustOneCup === true && this.data.getPreparation().style_type === PREPARATION_STYLE_TYPE.ESPRESSO ) { - oneEspressoCup = true; + scale.setDoubleWeight(true); + } else { + scale.setDoubleWeight(false); } this.scaleFlowSubscription = scale.flowChange.subscribe((_valChange) => { - if (oneEspressoCup === true) { - _valChange.actual = _valChange.actual * 2; - } let _val; if (this.ignoreScaleWeight === false) { _val = this.mutateWeightAndSeeAnomalys(