fix(v4): retry transient confirmed device reads
This commit is contained in:
@@ -49,7 +49,8 @@ trait BatterieNetzfahrplanV4RueckmeldungTrait
|
||||
return false;
|
||||
},
|
||||
$reader,
|
||||
static fn():int=>time()
|
||||
static fn():int=>time(),
|
||||
static function(int $microseconds):void { usleep($microseconds); }
|
||||
);
|
||||
$this->SetBuffer('V4ConfirmedFeedback',json_encode($result,JSON_THROW_ON_ERROR));
|
||||
return $result;
|
||||
|
||||
@@ -47,10 +47,10 @@ trait ManagerNetzfahrplanV4EmpfangTrait
|
||||
/** Appended dynamically; existing form.json and parallel portal GUI stay untouched. */
|
||||
private function netzfahrplanV4EmpfangFormular(): array
|
||||
{
|
||||
return ['type' => 'ExpansionPanel', 'caption' => 'V4 Planempfang / Sollwert-Vorschau', 'items' => [
|
||||
['type' => 'Label', 'caption' => 'NUR BEOBACHTEN. Kein Lade-/Entladebefehl. Der alte intelligente Netzfahrplan muss AUS bleiben.'],
|
||||
return ['type' => 'ExpansionPanel', 'caption' => 'V4 Planempfang / Prognosemanager', 'items' => [
|
||||
['type' => 'Label', 'caption' => 'Der alte intelligente Netzfahrplan muss AUS bleiben. Die separate Laufzeitvariable unter dem Manager schaltet den zeitlich begrenzten Testbetrieb ein oder aus.'],
|
||||
['type' => 'CheckBox', 'name' => 'NetzfahrplanV4EmpfangAktiv', 'caption' => 'V4 Schattenplan empfangen und Sollwert anzeigen (keine Steuerung)'],
|
||||
['type' => 'Label', 'caption' => 'Diagnose und Sollwerte stehen in den beiden V4-Vorschauvariablen unterhalb des Managers.'],
|
||||
['type' => 'Label', 'caption' => 'Schalter: V4 Prognosemanager aktiv (Testbetrieb). Ausschalten beendet V4 und fordert sofort 0 W an. Maximale Laufzeit ab dem ersten Einschalten: 48 Stunden.'],
|
||||
['type' => 'Button', 'caption' => 'Plan jetzt pruefen (Abruf begrenzt auf 1/min)',
|
||||
'onClick' => "IPS_RequestAction(\$id, 'NetzfahrplanV4Empfangen', true);"],
|
||||
]];
|
||||
@@ -172,6 +172,10 @@ trait ManagerNetzfahrplanV4EmpfangTrait
|
||||
if (is_string($configured) && !in_array(trim($configured),['','{}'],true)) {
|
||||
if (count($topology)!==1) throw new RuntimeException('feedback_multi_asset_adapter_required');
|
||||
$f=json_decode(ENELIX_GetV4BatterieRueckmeldung($controller),true,32,JSON_THROW_ON_ERROR);
|
||||
if (($f['status']??null)==='unavailable') {
|
||||
$reason=is_string($f['reason']??null)?$f['reason']:'unknown';
|
||||
throw new RuntimeException('feedback_unavailable:'.substr($reason,0,180));
|
||||
}
|
||||
if (($f['installationId']??null)!==$this->ReadAttributeString('LizenzInstallationID')
|
||||
|| ($f['assetId']??null)!==$asset['ID'] || ($f['managerId']??null)!==$this->InstanceID
|
||||
|| ($f['batteryInstanceId']??null)!==$controller || !is_numeric($f['batteryW']??null)
|
||||
|
||||
@@ -25,7 +25,8 @@ final class NetzfahrplanV4Geraeteabruf
|
||||
callable $moduleId,
|
||||
callable $refresh,
|
||||
callable $reader,
|
||||
callable $clock
|
||||
callable $clock,
|
||||
?callable $pause = null
|
||||
): array {
|
||||
$config = NetzfahrplanV4Rueckmeldung::configuration($config);
|
||||
$groups = [];
|
||||
@@ -43,7 +44,17 @@ final class NetzfahrplanV4Geraeteabruf
|
||||
if (!in_array($module, [self::MBUS_DEVICE, self::MODBUS_DEVICE, self::MODBUS_ADDRESS], true)) {
|
||||
throw new InvalidArgumentException('feedback_refresh_module_unsupported:' . $sources[0]['key']);
|
||||
}
|
||||
if ($refresh($parentId, $module) !== true) {
|
||||
$confirmed = false;
|
||||
for ($attempt = 1; $attempt <= 4; ++$attempt) {
|
||||
if ($refresh($parentId, $module) === true) {
|
||||
$confirmed = true;
|
||||
break;
|
||||
}
|
||||
if ($attempt < 4 && $pause !== null) {
|
||||
$pause(200000);
|
||||
}
|
||||
}
|
||||
if (!$confirmed) {
|
||||
throw new InvalidArgumentException('feedback_device_read_failed:' . $sources[0]['key']);
|
||||
}
|
||||
$confirmedAt = $clock();
|
||||
|
||||
Reference in New Issue
Block a user