ui constants cleanup

This commit is contained in:
Patrick Haßel 2024-10-21 14:20:52 +02:00
parent b6ae6db00b
commit 4fcd1126ba
4 changed files with 26 additions and 30 deletions

View File

@ -1,3 +1,5 @@
import {ValueConstant} from "../value/Value";
export const ELECTRICITY_GRID_PURCHASED_ENERGY = 'electricity.grid.purchase.energy'; export const ELECTRICITY_GRID_PURCHASED_ENERGY = 'electricity.grid.purchase.energy';
export const ELECTRICITY_GRID_DELIVERED_ENERGY = 'electricity.grid.delivery.energy'; export const ELECTRICITY_GRID_DELIVERED_ENERGY = 'electricity.grid.delivery.energy';
export const ELECTRICITY_GRID_POWER = 'electricity.grid.power'; export const ELECTRICITY_GRID_POWER = 'electricity.grid.power';
@ -25,3 +27,13 @@ export const HEATING_BUFFER_HOT_TEMPERATURE = 'heating.buffer.hot.temperature';
export const HEATING_BUFFER_CIRCULATION_TEMPERATURE = 'heating.buffer.circulation.temperature'; export const HEATING_BUFFER_CIRCULATION_TEMPERATURE = 'heating.buffer.circulation.temperature';
export const HEATING_LOOP_SUPPLY_TEMPERATURE = 'heating.loop.supply.temperature'; export const HEATING_LOOP_SUPPLY_TEMPERATURE = 'heating.loop.supply.temperature';
export const HEATING_LOOP_RETURN_TEMPERATURE = 'heating.loop.return.temperature'; export const HEATING_LOOP_RETURN_TEMPERATURE = 'heating.loop.return.temperature';
export const ELECTRICITY_GRID_PURCHASED_FEW = 7.7;
export const ELECTRICITY_GRID_PURCHASED_MUCH = 9.7;
export const ELECTRICITY_GRID_POWER_MUCH = 400;
export const ELECTRICITY_PHOTOVOLTAIC_PRODUCED_FEW = 0.7;
export const ELECTRICITY_PHOTOVOLTAIC_PRODUCED_MUCH = 2;
export const ELECTRICITY_PHOTOVOLTAIC_POWER_FEW = 50;
export const ELECTRICITY_PHOTOVOLTAIC_POWER_MUCH = 200;
export const ELECTRICITY_PHOTOVOLTAIC_PRODUCED_BEFORE_METER_CHANGE = new ValueConstant(287.995, "kWh");

View File

@ -1,5 +1,3 @@
import {ValueConstant} from "./ValueConstant";
export class Value { export class Value {
constructor( constructor(
@ -113,3 +111,14 @@ export class Value {
} }
export class ValueConstant extends Value {
constructor(
value: number | null,
unit: string,
) {
super(new Date(Date.now()), value, unit);
}
}

View File

@ -1,12 +0,0 @@
import {Value} from "./Value";
export class ValueConstant extends Value {
constructor(
value: number | null,
unit: string,
) {
super(new Date(Date.now()), value, unit);
}
}

View File

@ -1,24 +1,11 @@
import {Component, Input} from '@angular/core'; import {Component, Input} from '@angular/core';
import {ValueListComponent} from "../../../shared/value-list/value-list.component"; import {ValueListComponent} from "../../../shared/value-list/value-list.component";
import {Display, DisplayValue} from "../../../api/value/Display"; import {Display, DisplayValue} from "../../../api/value/Display";
import {ValueConstant} from "../../../api/value/ValueConstant";
import {SeriesCacheService} from "../../../api/series/series-cache.service"; import {SeriesCacheService} from "../../../api/series/series-cache.service";
import {SliceService} from "../../../api/series/consumption/slice/slice.service"; import {SliceService} from "../../../api/series/consumption/slice/slice.service";
import {Slice} from "../../../api/series/consumption/slice/Slice"; import {Slice} from "../../../api/series/consumption/slice/Slice";
import {Interval} from "../../../api/series/consumption/interval/Interval"; import {Interval} from "../../../api/series/consumption/interval/Interval";
import {ELECTRICITY_GRID_DELIVERED_ENERGY, ELECTRICITY_GRID_PURCHASED_ENERGY, ELECTRICITY_PHOTOVOLTAIC_PRODUCED} from "../../../api/series/constants"; import {ELECTRICITY_GRID_DELIVERED_ENERGY, ELECTRICITY_GRID_POWER_MUCH, ELECTRICITY_GRID_PURCHASED_ENERGY, ELECTRICITY_GRID_PURCHASED_FEW, ELECTRICITY_GRID_PURCHASED_MUCH, ELECTRICITY_PHOTOVOLTAIC_POWER_FEW, ELECTRICITY_PHOTOVOLTAIC_POWER_MUCH, ELECTRICITY_PHOTOVOLTAIC_PRODUCED, ELECTRICITY_PHOTOVOLTAIC_PRODUCED_BEFORE_METER_CHANGE, ELECTRICITY_PHOTOVOLTAIC_PRODUCED_FEW, ELECTRICITY_PHOTOVOLTAIC_PRODUCED_MUCH} from "../../../api/series/constants";
const PRODUCED_BEFORE_METER_CHANGE = new ValueConstant(287.995, "kWh");
const ELECTRICITY_GRID_PURCHASED_FEW = 7.7;
const ELECTRICITY_GRID_PURCHASED_MUCH = 9.7;
const ELECTRICITY_GRID_POWER_MUCH = 400;
const ELECTRICITY_PHOTOVOLTAIC_PRODUCED_FEW = 0.7;
const ELECTRICITY_PHOTOVOLTAIC_PRODUCED_MUCH = 2;
@Component({ @Component({
selector: 'app-dashboard-electricity-tile', selector: 'app-dashboard-electricity-tile',
@ -65,7 +52,7 @@ export class DashboardElectricityTileComponent {
} }
getDisplayList(): Display[] { getDisplayList(): Display[] {
const producedAfterChange = this.seriesCacheService.photovoltaicProduced.minus(PRODUCED_BEFORE_METER_CHANGE); const producedAfterChange = this.seriesCacheService.photovoltaicProduced.minus(ELECTRICITY_PHOTOVOLTAIC_PRODUCED_BEFORE_METER_CHANGE);
const selfAfterChange = producedAfterChange.minus(this.seriesCacheService.gridDelivered); const selfAfterChange = producedAfterChange.minus(this.seriesCacheService.gridDelivered);
const selfRatio = selfAfterChange.div(producedAfterChange); const selfRatio = selfAfterChange.div(producedAfterChange);
const selfConsumed = selfRatio.mul(this.seriesCacheService.photovoltaicProduced); const selfConsumed = selfRatio.mul(this.seriesCacheService.photovoltaicProduced);
@ -86,7 +73,7 @@ export class DashboardElectricityTileComponent {
new DisplayValue('Produziert', this.seriesCacheService.photovoltaicProduced, ''), new DisplayValue('Produziert', this.seriesCacheService.photovoltaicProduced, ''),
new DisplayValue('Selbst verbraucht', selfConsumed, ''), new DisplayValue('Selbst verbraucht', selfConsumed, ''),
'Leistung', 'Leistung',
new DisplayValue('Produktion', this.seriesCacheService.photovoltaicPower, this.seriesCacheService.photovoltaicPower.color(50, 200, 'red', 'orange', 'green')), new DisplayValue('Produktion', this.seriesCacheService.photovoltaicPower, this.seriesCacheService.photovoltaicPower.color(ELECTRICITY_PHOTOVOLTAIC_POWER_FEW, ELECTRICITY_PHOTOVOLTAIC_POWER_MUCH, 'red', 'orange', 'green')),
new DisplayValue('Netz', this.seriesCacheService.gridPower, gridColor), new DisplayValue('Netz', this.seriesCacheService.gridPower, gridColor),
new DisplayValue('Verbrauch', consumptionPower, ''), new DisplayValue('Verbrauch', consumptionPower, ''),
'Heute', 'Heute',