This commit is contained in:
Patrick Haßel 2025-04-17 12:18:43 +02:00
parent d7ee5062e4
commit 6aac9b2662
7 changed files with 76 additions and 15 deletions

View File

@ -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},
];

View File

@ -0,0 +1,18 @@
<table class="vertical">
<tr>
<th>Füllgrad</th>
<td class="valueInteger">{{seriesService.cisternHeight.series?.lastValue?.percent(93.5)?.localeString}}</td>
<td class="unit">%</td>
</tr>
<tr>
<th>Füllhöhe</th>
<td class="valueInteger">{{seriesService.cisternHeight.series?.lastValue?.localeString}}</td>
<td class="unit">{{seriesService.cisternHeight.series?.lastValue?.unit?.unit}}</td>
</tr>
<tr>
<th>Volumen</th>
<td class="valueInteger">{{seriesService.cisternVolume.series?.lastValue?.localeString}}</td>
<td class="unit">{{seriesService.cisternVolume.series?.lastValue?.unit?.unit}}</td>
</tr>
</table>
<img width="100%" src="http://localhost:8081/Series/Graph/{{seriesService.cisternVolume.series?.id}}/400/100/FIVE/0/288" alt="Graf">

View File

@ -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());
}
}

View File

@ -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,
];
}

View File

@ -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,

View File

@ -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);