From 6aac9b26620ba29fc3472db59c7a4081165e471a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Thu, 17 Apr 2025 12:18:43 +0200 Subject: [PATCH] Cistern --- src/main/angular/src/app/app.routes.ts | 5 +++- .../src/app/cistern/cistern.component.html | 18 +++++++++++ .../src/app/cistern/cistern.component.less | 0 .../src/app/cistern/cistern.component.ts | 28 +++++++++++++++++ .../angular/src/app/series/series.service.ts | 6 ++++ src/main/angular/src/app/value/Unit.ts | 4 +++ .../java/de/ph87/data/series/graph/Graph.java | 30 ++++++++++--------- 7 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 src/main/angular/src/app/cistern/cistern.component.html create mode 100644 src/main/angular/src/app/cistern/cistern.component.less create mode 100644 src/main/angular/src/app/cistern/cistern.component.ts diff --git a/src/main/angular/src/app/app.routes.ts b/src/main/angular/src/app/app.routes.ts index b8fb359..515a779 100644 --- a/src/main/angular/src/app/app.routes.ts +++ b/src/main/angular/src/app/app.routes.ts @@ -1,6 +1,7 @@ import {Routes} from '@angular/router'; import {ElectroComponent} from './electro/electro.component'; import {GreenhouseComponent} from './greenhouse/greenhouse/greenhouse.component'; +import {CisternComponent} from './cistern/cistern.component'; export class Path { @@ -20,7 +21,8 @@ export class Path { export const ROUTING = { ENERGY: new Path('Energy', 'Energie', true), - GREENHOUSE: new Path('Greenhouse', 'Gewächshaus', true), + CISTERN: new Path('CISTERN', 'Zisterne', true), + GREENHOUSE: new Path('Greenhouse', 'Gewächshaus', false), } export function menubar(): Path[] { @@ -29,6 +31,7 @@ export function menubar(): Path[] { export const routes: Routes = [ {path: ROUTING.ENERGY.path, component: ElectroComponent}, + {path: ROUTING.CISTERN.path, component: CisternComponent}, {path: ROUTING.GREENHOUSE.path, component: GreenhouseComponent}, {path: '**', redirectTo: ROUTING.ENERGY.path}, ]; diff --git a/src/main/angular/src/app/cistern/cistern.component.html b/src/main/angular/src/app/cistern/cistern.component.html new file mode 100644 index 0000000..cc75240 --- /dev/null +++ b/src/main/angular/src/app/cistern/cistern.component.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + +
Füllgrad{{seriesService.cisternHeight.series?.lastValue?.percent(93.5)?.localeString}}%
Füllhöhe{{seriesService.cisternHeight.series?.lastValue?.localeString}}{{seriesService.cisternHeight.series?.lastValue?.unit?.unit}}
Volumen{{seriesService.cisternVolume.series?.lastValue?.localeString}}{{seriesService.cisternVolume.series?.lastValue?.unit?.unit}}
+Graf diff --git a/src/main/angular/src/app/cistern/cistern.component.less b/src/main/angular/src/app/cistern/cistern.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/main/angular/src/app/cistern/cistern.component.ts b/src/main/angular/src/app/cistern/cistern.component.ts new file mode 100644 index 0000000..90c2a4e --- /dev/null +++ b/src/main/angular/src/app/cistern/cistern.component.ts @@ -0,0 +1,28 @@ +import {Component, OnDestroy, OnInit} from '@angular/core'; +import {SeriesService} from '../series/series.service'; +import {Subscription} from 'rxjs'; + +@Component({ + selector: 'app-cistern', + imports: [], + templateUrl: './cistern.component.html', + styleUrl: './cistern.component.less' +}) +export class CisternComponent implements OnInit, OnDestroy { + + private subs: Subscription[] = []; + + constructor( + readonly seriesService: SeriesService, + ) { + } + + ngOnInit(): void { + this.subs.push(this.seriesService.subscribeAny()); + } + + ngOnDestroy(): void { + this.subs.forEach(sub => sub.unsubscribe()); + } + +} diff --git a/src/main/angular/src/app/series/series.service.ts b/src/main/angular/src/app/series/series.service.ts index 07b6301..8e498f5 100644 --- a/src/main/angular/src/app/series/series.service.ts +++ b/src/main/angular/src/app/series/series.service.ts @@ -28,6 +28,10 @@ export class SeriesService extends AbstractRepositoryService { readonly greenhouseIlluminance: SeriesWrapper = new SeriesWrapper("greenhouse/illuminance", this.onSubscribe, this.onUnsubscribe); + readonly cisternHeight: SeriesWrapper = new SeriesWrapper("Cistern/height", this.onSubscribe, this.onUnsubscribe); + + readonly cisternVolume: SeriesWrapper = new SeriesWrapper("Cistern/volume", this.onSubscribe, this.onUnsubscribe); + protected get liveValues(): SeriesWrapper[] { return [ this.powerConsumed, @@ -38,6 +42,8 @@ export class SeriesService extends AbstractRepositoryService { this.greenhouseHumidityRelative, this.greenhouseHumidityAbsolute, this.greenhouseIlluminance, + this.cisternHeight, + this.cisternVolume, ]; } diff --git a/src/main/angular/src/app/value/Unit.ts b/src/main/angular/src/app/value/Unit.ts index a44c292..c64b016 100644 --- a/src/main/angular/src/app/value/Unit.ts +++ b/src/main/angular/src/app/value/Unit.ts @@ -36,6 +36,10 @@ export class Unit { static readonly LIGHT_BOOLEAN = new Unit('LIGHT_BOOLEAN', ''); + static readonly VOLUME_L = new Unit('VOLUME_L', 'l'); + + static readonly LENGTH_CM = new Unit('LENGTH_CM', 'cm'); + private constructor( readonly name: string, readonly unit: string, diff --git a/src/main/java/de/ph87/data/series/graph/Graph.java b/src/main/java/de/ph87/data/series/graph/Graph.java index b65a9c9..d7a09d2 100644 --- a/src/main/java/de/ph87/data/series/graph/Graph.java +++ b/src/main/java/de/ph87/data/series/graph/Graph.java @@ -1,17 +1,19 @@ package de.ph87.data.series.graph; -import de.ph87.data.series.*; -import de.ph87.data.value.*; -import jakarta.annotation.*; -import lombok.*; +import de.ph87.data.series.Aligned; +import de.ph87.data.series.SeriesDto; +import de.ph87.data.series.SeriesType; +import de.ph87.data.value.Autoscale; +import jakarta.annotation.Nullable; +import lombok.NonNull; import java.awt.*; -import java.awt.geom.*; -import java.awt.image.*; +import java.awt.geom.Line2D; +import java.awt.image.BufferedImage; import java.util.List; -import java.util.function.*; +import java.util.function.Function; -import static java.lang.Math.*; +import static java.lang.Math.max; public class Graph { @@ -117,14 +119,14 @@ public class Graph { final Graphics2D g = (Graphics2D) image.getGraphics(); final int fontH3_4 = (int) Math.round(g.getFontMetrics().getHeight() * 0.75); - g.setColor(Color.gray); - final String string = "%s [%s]".formatted(series.getTitle(), autoscale.unit); - g.drawString(string, border, border + fontH3_4); +// g.setColor(Color.gray); +// final String string = "%s [%s]".formatted(series.getTitle(), autoscale.unit); +// g.drawString(string, border, border + fontH3_4); - yLabel(g, valueMax, DASHED, Color.red); - yLabel(g, valueAvg, DASHED, new Color(0, 127, 0)); + yLabel(g, valueMax, DASHED, Color.red.darker().darker()); +// yLabel(g, valueAvg, DASHED, new Color(0, 127, 0)); yLabel(g, 0, NORMAL, Color.BLACK); - yLabel(g, valueMin, DASHED, Color.blue); + yLabel(g, valueMin, DASHED, new Color(64, 128, 255).darker().darker()); g.translate(border, height - border); g.scale(1, -1);