no message

This commit is contained in:
belevo\mh
2025-12-17 09:49:27 +01:00
parent ca74e3d946
commit cc3cb5fd38

View File

@@ -108,13 +108,9 @@ private function RecalculateAndPush(): void
$dbgFeed = []; $dbgFeed = [];
$dbgGrid = []; $dbgGrid = [];
$prodVar = $this->ReadPropertyInteger('VarProduction'); $prod = $this->readDelta($this->ReadPropertyInteger('VarProduction'), $tStart, $tEnd, $dbgProd);
$feedVar = $this->ReadPropertyInteger('VarFeedIn'); $feed = $this->readDelta($this->ReadPropertyInteger('VarFeedIn'), $tStart, $tEnd, $dbgFeed);
$gridVar = $this->ReadPropertyInteger('VarGrid'); $grid = $this->readDelta($this->ReadPropertyInteger('VarGrid'), $tStart, $tEnd, $dbgGrid);
$prod = $this->readDelta($prodVar, $tStart, $tEnd, $dbgProd);
$feed = $this->readDelta($feedVar, $tStart, $tEnd, $dbgFeed);
$grid = $this->readDelta($gridVar, $tStart, $tEnd, $dbgGrid);
$house = $prod - $feed + $grid; $house = $prod - $feed + $grid;
if ($house < 0) $house = 0.0; if ($house < 0) $house = 0.0;
@@ -187,16 +183,16 @@ private function RecalculateAndPush(): void
} }
private function readDelta(int $varId, int $tStart, int $tEnd, array &$dbg): float private function readDelta(int $varId, int $tStart, int $tEnd, array &$dbg): float
{ {
$dbg = [ $dbg = [
'varId' => $varId, 'varId' => $varId,
'archiveId' => 0, 'archiveId' => 0,
'count' => 0, 'count' => 0,
'first' => null, 'first' => null,
'last' => null, 'last' => null,
'vStart' => null, 'vStart' => null,
'vEnd' => null 'vEnd' => null
]; ];
if ($varId <= 0 || !IPS_VariableExists($varId)) { if ($varId <= 0 || !IPS_VariableExists($varId)) {
@@ -219,26 +215,18 @@ private function RecalculateAndPush(): void
$dbg['count'] = count($values); $dbg['count'] = count($values);
$dbg['first'] = (float)$values[0]['Value']; $dbg['first'] = (float)$values[0]['Value'];
$dbg['last'] = (float)$values[count($values)-1]['Value']; $dbg['last'] = (float)$values[count($values) - 1]['Value'];
$vStart = null; $vStart = null;
$vEnd = null; $vEnd = null;
foreach ($values as $v) { foreach ($values as $v) {
$ts = (int)$v['TimeStamp']; $ts = (int)$v['TimeStamp'];
if ($ts <= $tStart) $vStart = (float)$v['Value'];
if ($ts <= $tStart) { if ($ts <= $tEnd) $vEnd = (float)$v['Value'];
$vStart = (float)$v['Value']; if ($ts > $tEnd) break;
}
if ($ts <= $tEnd) {
$vEnd = (float)$v['Value'];
}
if ($ts > $tEnd) {
break;
}
} }
// Wenn kein Wert vor Start/Ende gefunden wurde, nimm ersten/letzten im Fenster
if ($vStart === null) $vStart = $dbg['first']; if ($vStart === null) $vStart = $dbg['first'];
if ($vEnd === null) $vEnd = $dbg['last']; if ($vEnd === null) $vEnd = $dbg['last'];
@@ -250,6 +238,8 @@ private function RecalculateAndPush(): void
} }
/** /**
* Buttons for quick navigation. * Buttons for quick navigation.
*/ */