Skip to content

Commit

Permalink
#896 - Removing weight data from meticulus
Browse files Browse the repository at this point in the history
#897 - Fixing weight doubling
#898 - Make tiles and graph bigger for tablet
  • Loading branch information
graphefruit committed Feb 1, 2025
1 parent 83fc621 commit 39d9cc6
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 42 deletions.
8 changes: 4 additions & 4 deletions src/app/brew/brew-flow/brew-flow.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ion-chip (click)="brewComponent.brewBrewingGraphEl.toggleChartLines('pressure')"
[outline]="!brewComponent.brewBrewingGraphEl.traces.pressureTrace?.visible" class="pressure">{{'BREW_PRESSURE_FLOW' | translate}}</ion-chip>
}
@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)) {
<ion-chip (click)="brewComponent.brewBrewingGraphEl.toggleChartLines('temperature')"
[outline]="!brewComponent.brewBrewingGraphEl.traces.temperatureTrace?.visible" class="temperature">{{'BREW_TEMPERATURE_REALTIME' |
translate}}</ion-chip>
Expand Down Expand Up @@ -45,9 +45,9 @@
<div #smartScaleWeightDetail>? g</div>
<div #smartScaleWeightSecondDetail *ngIf="brewComponent?.brewBrewingGraphEl?.uiSmartScaleConnectedSupportsTwoWeights">?g</div>
@if(brewComponent.timer.timer.runTimer) {
<span #smartScaleBrewRatio style='font-size:16px;'></span>
<span class="smartScaleRatio" #smartScaleBrewRatio></span>
} @else {
<span style='font-size:16px;'>({{brewComponent.brewBrewingGraphEl.data | brewFunctionPipe: [BREW_FUNCTION_PIPE_ENUM.GET_BREW_RATIO,brewComponent.brewBrewingGraphEl.data.brew_beverage_quantity,brewComponent.brewBrewingGraphEl.data.brew_quantity]}})</span>
<span class="smartScaleRatio" >({{brewComponent.brewBrewingGraphEl.data | brewFunctionPipe: [BREW_FUNCTION_PIPE_ENUM.GET_BREW_RATIO,brewComponent.brewBrewingGraphEl.data.brew_beverage_quantity,brewComponent.brewBrewingGraphEl.data.brew_quantity]}})</span>
}

</ion-card-header>
Expand Down Expand Up @@ -81,7 +81,7 @@
</ion-card-content>
</ion-card>
</ion-col>
<ion-col *ngIf="brewComponent?.brewBrewingGraphEl?.uiTemperatureConnected || brewComponent?.brewBrewingPreparationDeviceEl?.uiPreparationDeviceConnected"
<ion-col *ngIf="brewComponent?.brewBrewingGraphEl?.uiTemperatureConnected || (brewComponent?.brewBrewingPreparationDeviceEl?.uiPreparationDeviceConnected && brewComponent.brewBrewingGraphEl.uiPreparationDeviceType !== PREPARATION_DEVICE_TYPE_ENUM.METICULOUS)"
size="{{graphIconColSize}}" style="padding-right:5px;">
<ion-card class="flow-profile ion-text-center temperature-card" style="height: 100%;">
<ion-card-header>
Expand Down
13 changes: 13 additions & 0 deletions src/app/brew/brew-flow/brew-flow.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions src/app/brew/brew-flow/brew-flow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -287,8 +286,6 @@ export class BrewFlowComponent implements OnDestroy, OnInit {
informationContainerHeight = 0;
}

this.heightInformationBlock = informationContainerHeight;

this.brewComponent.brewBrewingGraphEl.lastChartLayout.height =
flowHeight - informationContainerHeight;

Expand Down
42 changes: 27 additions & 15 deletions src/classes/devices/bluetoothDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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({
Expand All @@ -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%.
Expand All @@ -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.
Expand All @@ -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({
Expand All @@ -186,7 +198,7 @@ export class BluetoothScale {
}
protected calculateSmoothedWeight(
_actualWeight: number,
_smoothedWeight: number
_smoothedWeight: number,
): number {
return _actualWeight * 0.3 + _smoothedWeight * 0.7;
}
Expand All @@ -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({
Expand All @@ -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({
Expand Down
25 changes: 14 additions & 11 deletions src/classes/preparationDevice/meticulous/meticulousDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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(
Expand All @@ -123,7 +126,7 @@ export class MeticulousDevice extends PreparationDevice {
(error) => {
console.log(error);
reject();
}
},
)
.catch((error) => {
console.log(error);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h2>{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE" | translate}}</h
<ion-chip (click)="toggleChartLines('pressure')"
[outline]="!this.traces.pressureTrace?.visible" class="pressure">{{'BREW_PRESSURE_FLOW' | translate}}</ion-chip>
}
@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)) {
<ion-chip (click)="toggleChartLines('temperature')"
[outline]="!this.traces.temperatureTrace?.visible" class="temperature">{{'BREW_TEMPERATURE_REALTIME' |
translate}}</ion-chip>
Expand Down Expand Up @@ -91,7 +91,7 @@ <h2>{{"SMART_SCALE_ESPRESSO_WEIGHT_DOUBLING_JUST_ONE_CUP_TITLE" | translate}}</h
</ion-card-content>
</ion-card>
</ion-col>
<ion-col *ngIf="uiTemperatureConnected || uiPreparationDeviceConnected"
<ion-col *ngIf="uiTemperatureConnected || (uiPreparationDeviceConnected && uiPreparationDeviceType !== PREPARATION_DEVICE_TYPE_ENUM.METICULOUS)"
size="{{graphIconColSize}}">
<ion-card class="flow-profile ion-text-center temperature-card" style="height: 100%;">
<ion-card-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
display: flex;
justify-content: space-evenly;
flex-direction: column;
font-weight:bold;
}

ion-card-content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 39d9cc6

Please sign in to comment.