Commit 9b2e9490 authored by Thomas Eimers's avatar Thomas Eimers

filter RRD Sensors

parent 40e50451
Pipeline #95422269 failed with stages
in 15 minutes and 23 seconds
......@@ -7,6 +7,7 @@ use DateTime;
use DateTimeInterface;
use HeatingControl\HeatingException;
use HeatingControl\State\State;
use HeatingControl\State\StoreRrdInterface;
class RrdService
{
......@@ -36,6 +37,17 @@ class RrdService
dump($result);
}
protected function filterSensorValues(State ...$sensorValues)
{
foreach ($sensorValues as $key => $sensorValue) {
/** @var StoreRrdInterface $sensorValue */
if (!is_a($sensorValue, StoreRrdInterface::class)) {
unset($sensorValues[$key]);
}
}
return $sensorValues;
}
/**
* @param DateTime $date
* @param State ...$sensorValues
......@@ -44,6 +56,8 @@ class RrdService
*/
public function getImageCommand(DateTimeInterface $date, State ...$sensorValues): string
{
$sensorValues = $this->filterSensorValues($sensorValues);
if (empty($sensorValues)) {
throw new HeatingException('No Sensorvalues to show');
}
......@@ -59,6 +73,8 @@ class RrdService
*/
protected function getLines(State ...$sensorValues): string
{
$sensorValues = $this->filterSensorValues($sensorValues);
$cmd = ' ';
foreach ($sensorValues as $sensor) {
$sensorId = $sensor->getId();
......@@ -72,7 +88,7 @@ class RrdService
protected function getSensorColor(int $sensorNo): string
{
return $this->appConfig['diagrammColors'][$sensorNo];
return $this->appConfig['diagrammColors'][$sensorNo % 10];
}
/**
......
......@@ -40,10 +40,11 @@ class SensorStoreRrd implements SensorStoreInterface
// You can tell RRDtool a data source is unknown by giving it "U" as its value.
$values = array_fill(1, 10, 'U');
foreach ($sensorValues as $sensorValue) {
/** @var StoreRrdInterface $sensorValue */
if (!is_a($sensorValue, StoreRrdInterface::class)) {
continue;
continue; // Sa,e as in RRDSERvice TODO
}
$values[$sensorValue->getId()] = $sensorValue->getRrdValue();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment