24 lines
2.2 KiB
PHP
24 lines
2.2 KiB
PHP
<?php
|
|
// Exact Battery message builder with no optional visible diagnostic variables.
|
|
if(function_exists('IPS_GetKernelVersion'))throw new RuntimeException('Offline only');
|
|
class IPSModule {
|
|
public int $InstanceID=44234;public array $buffers=['V4FeedbackEstimated'=>'1'];public bool $valid=true;
|
|
protected function GetBuffer($k){return $this->buffers[$k]??'';}
|
|
protected function GetValue($k){throw new RuntimeException('No diagnostic variables exist: '.$k);}
|
|
protected function ReadAttributeBoolean($k){return $k==='ZustandLadezustandGueltig'?$this->valid:false;}
|
|
protected function ReadAttributeInteger($k){return 0;}
|
|
protected function ReadAttributeFloat($k){return 0.0;}
|
|
protected function ReadAttributeString($k){return $k==='Leistungsangebot'?'[0]':($k==='Betriebsart'?'Auto':'');}
|
|
protected function ReadPropertyInteger($k){return 1;}
|
|
}
|
|
require __DIR__.'/../../Batterie/module.php';
|
|
use Belevo\EnelixEMS\Nachrichtenvertrag as N;
|
|
$b=new Batterie();$read=new ReflectionMethod(Batterie::class,'baueVerbraucherdaten');$count=0;
|
|
function ck($v,$s){global$count;if(!$v)throw new RuntimeException('FAIL '.$s);$count++;echo "PASS $s\n";}
|
|
$d=$read->invoke($b,17004);ck($d['Leistungsquelle']===N::LEISTUNGSQUELLE_BERECHNET,'partition source quality independent of hidden diagnostic variables');
|
|
$b->buffers['V4FeedbackEstimated']='0';$d=$read->invoke($b,17004);ck($d['Leistungsquelle']===N::LEISTUNGSQUELLE_GEMESSEN,'ordinary physical source marked measured');
|
|
$b->valid=false;$d=$read->invoke($b,17004);ck($d['Leistungsquelle']===N::LEISTUNGSQUELLE_NICHT_VORHANDEN&&$d['Istleistung_W']===null,'invalid sample never published as measured');
|
|
$b->valid=true;$b->buffers['V4FeedbackEstimated']='1';$b->buffers['V4BatteryTrialSession']='{}';$d=$read->invoke($b,17004);ck($d['Leistungsquelle']===N::LEISTUNGSQUELLE_BERECHNET,'last estimate not relabelled measured immediately after trial ends');
|
|
$source=file_get_contents(__DIR__.'/../../Batterie/module.php');ck(str_contains($source,"SetBuffer('V4FeedbackEstimated', (\$messwerte['V4FeedbackEstimated'] ?? false) ? '1' : '0')"),'fresh measurement updates internal source quality');
|
|
echo "TOTAL $count actual message-builder checks passed. No real variables or writes.\n";
|