InstanceID = $id; } public function Create(): void {} public function ApplyChanges(): void {} public function EnableAction(string $ident): void {} public function SetStatus(int $status): void { $this->testStatus = $status; } public function SetTimerInterval(string $ident, int $interval): void { $this->testTimers[$ident] = $interval; } public function RegisterTimer(string $ident, int $interval, string $script): void { $this->SetTimerInterval($ident, $interval); } public function SendDebug(string $sender, string $text, int $format): void {} public function __call(string $method, array $arguments) { if (preg_match('/^(Register|Read|Write)(Property|Attribute)(Boolean|Integer|Float|String)$/', $method, $parts)) { $storage = $parts[2] === 'Property' ? 'testProperties' : 'testAttributes'; $ident = $arguments[0]; if ($parts[1] === 'Register') { $this->{$storage}[$ident] = $this->{$storage}[$ident] ?? $arguments[1]; return null; } if ($parts[1] === 'Write') { $this->{$storage}[$ident] = $arguments[1]; return null; } if (!array_key_exists($ident, $this->{$storage})) { throw new RuntimeException('Unregistered test property/attribute: ' . $ident); } return $this->{$storage}[$ident]; } if (preg_match('/^RegisterVariable(Boolean|Integer|Float|String)$/', $method, $parts)) { $ident = $arguments[0]; $id = LadestationRuntime::$children[$this->InstanceID][$ident] ?? ++LadestationRuntime::$nextID; LadestationRuntime::$children[$this->InstanceID][$ident] = $id; LadestationRuntime::$variables[$id] = LadestationRuntime::$variables[$id] ?? ['Boolean' => false, 'Integer' => 0, 'Float' => 0.0, 'String' => ''][$parts[1]]; return $id; } throw new BadMethodCallException('Unsupported test call: ' . $method); } public function GetIDForIdent(string $ident): int { return LadestationRuntime::$children[$this->InstanceID][$ident] ?? 0; } public function SetValue(string $ident, $value): void { $id = $this->GetIDForIdent($ident); if (!$id) { throw new RuntimeException('Unregistered test variable: ' . $ident); } LadestationRuntime::$variables[$id] = $value; if ($ident === 'LetzterGeraetebefehl') { LadestationRuntime::$commands[] = json_decode($value, true, 512, JSON_THROW_ON_ERROR); } } public function GetValue(string $ident) { return LadestationRuntime::$variables[$this->GetIDForIdent($ident)]; } public function UnregisterVariable(string $ident): void { unset(LadestationRuntime::$variables[$this->GetIDForIdent($ident)], LadestationRuntime::$children[$this->InstanceID][$ident]); } } function IPS_VariableExists(int $id): bool { return array_key_exists($id, LadestationRuntime::$variables); } function IPS_GetInstanceListByModuleID(string $id): array { return array_keys(LadestationRuntime::$managers); } function IPS_GetProperty(int $id, string $property) { return LadestationRuntime::$managers[$id][$property]; } function IPS_RequestAction(int $id, string $ident, $value): bool { LadestationRuntime::$messages[] = [$id, $ident, $value]; return true; }