From f048c77770ead9bde878276bda95d813461ab9c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Tr=C3=B6ger?= Date: Thu, 18 Jan 2024 20:15:23 +0100 Subject: [PATCH] =?UTF-8?q?=20Version=201.03:=20=20-=20Node-Instanz=20hat?= =?UTF-8?q?=20die=20R=C3=BCckmeldung=20von=20COMMAND=5FSEND=5FCFM=20und=20?= =?UTF-8?q?STATUS=5FREQUEST=5FCFM=20falsch=20ausgewertet.=20=20-=20Neue=20?= =?UTF-8?q?Scenen-Instanzen=20werden=20im=20Konfigurator=20angezeigt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KLF200Configurator/module.php | 3 ++- KLF200Gateway/module.php | 4 ++-- KLF200Node/locale.json | 2 +- KLF200Node/module.php | 29 +++++++++++------------------ KLF200Scene/locale.json | 4 ++-- KLF200Scene/module.php | 10 +++------- README.md | 4 ++++ library.json | 6 +++--- libs/KLF200Class.php | 20 +++++++++++++++++++- 9 files changed, 47 insertions(+), 35 deletions(-) diff --git a/KLF200Configurator/module.php b/KLF200Configurator/module.php index cf1dcdf..616137a 100644 --- a/KLF200Configurator/module.php +++ b/KLF200Configurator/module.php @@ -147,7 +147,6 @@ public function RemoveNode(int $Node) return true; } - //todo scenes public function GetConfigurationForm() { $Form = json_decode(file_get_contents(__DIR__ . '/form.json'), true); @@ -164,6 +163,8 @@ public function GetConfigurationForm() $Form['actions'][2]['popup']['items'][0]['caption'] = 'Splitter has no IO instance.'; } else { $NodeValues = $this->GetNodeConfigFormValues($Splitter); + $SceneValues = $this->GetSceneConfigFormValues($Splitter); + $NodeValues = array_merge($NodeValues, $SceneValues); } } $Form['actions'][1]['values'] = $NodeValues; diff --git a/KLF200Gateway/module.php b/KLF200Gateway/module.php index 4f92d2e..7f6fb19 100644 --- a/KLF200Gateway/module.php +++ b/KLF200Gateway/module.php @@ -408,7 +408,7 @@ private function GetAllNodesInformation() if ($ResultAPIData->isError()) { return false; } - return ord($ResultAPIData->Data[0]) == 1; + return ord($ResultAPIData->Data[0]) == \KLF200\Status::REQUEST_ACCEPTED; } private function SetHouseStatusMonitor() @@ -476,7 +476,7 @@ private function Connect() trigger_error($this->Translate($ResultAPIData->ErrorToString()), E_USER_NOTICE); return false; } - if ($ResultAPIData->Data != "\x00") { + if (ord($ResultAPIData->Data[0]) != \KLF200\Status::REQUEST_ACCEPTED) { $this->SendDebug('Login Error', '', 0); $this->SetStatus(IS_EBASE + 1); $this->LogMessage('Access denied', KL_ERROR); diff --git a/KLF200Node/locale.json b/KLF200Node/locale.json index b4505af..12221ac 100644 --- a/KLF200Node/locale.json +++ b/KLF200Node/locale.json @@ -88,7 +88,7 @@ "Request accepted": "Anfrage angenommen", "Invalid Parameters": "Ungültige Parameter", "Request rejected": "Anfrage abgelehnt", - "Invalid node index": "Ungültiger Node-Eintrag", + "Invalid system table index": "Ungültiger Systemtabellenindex", "Instance has no active parent.": "Instanz hat keinen aktiven Parent.", "This module is free for non-commercial use,\r\nDonations in support of the author are accepted here:": "Dieses Modul ist für die nicht kommerzielle Nutzung kostenlos,\r\nSchenkungen als Unterstützung für den Autor werden hier akzeptiert:" } diff --git a/KLF200Node/module.php b/KLF200Node/module.php index b4533e3..58f299c 100644 --- a/KLF200Node/module.php +++ b/KLF200Node/module.php @@ -259,17 +259,12 @@ public function RequestNodeInformation() if ($ResultAPIData === null) { return false; } - $State = ord($ResultAPIData->Data[0]); - switch ($State) { - case 0: - return true; - case 1: - trigger_error($this->Translate('Request rejected'), E_USER_NOTICE); - return false; - case 2: - trigger_error($this->Translate('Invalid node index'), E_USER_NOTICE); - return false; + $ResultStatus = ord($ResultAPIData->Data[0]); + if ($ResultStatus == \KLF200\Status::REQUEST_ACCEPTED) { + return true; } + trigger_error($this->Translate(\KLF200\Status::ToString($ResultStatus * 2)), E_USER_NOTICE); + return false; } public function RequestStatus() @@ -902,14 +897,11 @@ private function SendAPIData(\KLF200\APIData $APIData, int $SessionId = -1) if ($SessionId == -1) { return $ResponseAPIData; } - $ResultStatus = ord($ResponseAPIData->Data[0]); - switch ($ResultStatus) { - case \KLF200\Status::INVALID_PARAMETERS: - case \KLF200\Status::REQUEST_REJECTED: - $this->SessionQueueRemove($SessionId); - trigger_error($this->Translate(\KLF200\State::ToString($ResultStatus)), E_USER_NOTICE); - return false; - break; + $ResultStatus = ord($ResponseAPIData->Data[2]); //CommandStatus + if ($ResultStatus == \KLF200\CommandStatus::COMMAND_REJECTED) { + $this->SessionQueueRemove($SessionId); + trigger_error($this->Translate(\KLF200\Status::ToString($ResultStatus)), E_USER_NOTICE); + return false; } if (!$this->ReadPropertyBoolean(\KLF200\Node\Property::WaitForFinishSession)) { return true; @@ -926,6 +918,7 @@ private function SendAPIData(\KLF200\APIData $APIData, int $SessionId = -1) return null; } } + //################# SessionQueue private function SessionQueueAdd(int $SessionId) { diff --git a/KLF200Scene/locale.json b/KLF200Scene/locale.json index 6702559..37426b1 100644 --- a/KLF200Scene/locale.json +++ b/KLF200Scene/locale.json @@ -79,9 +79,9 @@ "Instance does not implement this function": "Instanz unterstützt diese Funktion nicht", "Invalid Ident": "Ungültiger Ident", "Request accepted": "Anfrage angenommen", - "Invalid Parameters": "Ungültige Parameter", + "Invalid parameters": "Ungültige Parameter", "Request rejected": "Anfrage abgelehnt", - "Invalid scene index": "Ungültiger Szenen-Eintrag", + "Invalid system table index": "Ungültiger Systemtabellenindex", "Instance has no active parent.": "Instanz hat keinen aktiven Parent.", "This module is free for non-commercial use,\r\nDonations in support of the author are accepted here:": "Dieses Modul ist für die nicht kommerzielle Nutzung kostenlos,\r\nSchenkungen als Unterstützung für den Autor werden hier akzeptiert:" } diff --git a/KLF200Scene/module.php b/KLF200Scene/module.php index 0b0a965..d923090 100644 --- a/KLF200Scene/module.php +++ b/KLF200Scene/module.php @@ -195,13 +195,9 @@ private function SendAPIData(\KLF200\APIData $APIData, int $SessionId = -1) if ($SessionId == -1) { return $ResponseAPIData; } - $ResultStatus = ord($ResponseAPIData->Data[0]); - switch ($ResultStatus) { - case \KLF200\Status::INVALID_PARAMETERS: - case \KLF200\Status::REQUEST_REJECTED: - trigger_error($this->Translate(\KLF200\Status::ToString($ResultStatus)), E_USER_NOTICE); - return false; - break; + $ResultStatus = ord($ResponseAPIData->Data[0]); //Status + if ($ResultStatus != \KLF200\Status::REQUEST_ACCEPTED) { + trigger_error($this->Translate(\KLF200\Status::ToString($ResultStatus)), E_USER_NOTICE); } return true; } catch (Exception $exc) { diff --git a/README.md b/README.md index 5867772..3dc656b 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,10 @@ Es wird empfohlen die Einrichtung mit der Discovery-Instanz zu starten ([KLF200 ### 2. Changelog + Version 1.03: + - Node-Instanz hat die Rückmeldung von COMMAND_SEND_CFM und STATUS_REQUEST_CFM falsch ausgewertet. + - Neue Scenen-Instanzen werden im Konfigurator angezeigt. + Version 1.02: - Timeout auf 10 Sekunden erhöht. - Neue Scenen-Instanz. diff --git a/library.json b/library.json index f02dd87..71a277b 100644 --- a/library.json +++ b/library.json @@ -6,7 +6,7 @@ "compatibility": { "version": "6.0" }, - "version": "1.00", - "build": 102, - "date": 1705389031 + "version": "1.03", + "build": 103, + "date": 1705605140 } \ No newline at end of file diff --git a/libs/KLF200Class.php b/libs/KLF200Class.php index dd03b65..6b24e86 100644 --- a/libs/KLF200Class.php +++ b/libs/KLF200Class.php @@ -169,11 +169,27 @@ public static function ToString(int $State) } } + class CommandStatus + { + public const COMMAND_REJECTED = 0; + public const COMMAND_ACCEPTED = 1; + + public static function ToString(int $Status) + { + switch ($Status) { + case self::COMMAND_REJECTED: + return 'Command is rejected'; + case self::COMMAND_ACCEPTED: + return 'Command is accepted'; + } + } + } class Status { public const REQUEST_ACCEPTED = 0; public const INVALID_PARAMETERS = 1; public const REQUEST_REJECTED = 2; + public const INVALID_SYSTEM_TABLE_INDEX = 4; // factor 2 public static function ToString(int $Status) { @@ -181,9 +197,11 @@ public static function ToString(int $Status) case self::REQUEST_ACCEPTED: return 'Request accepted'; case self::INVALID_PARAMETERS: - return 'Invalid Parameters'; + return 'Invalid parameters'; case self::REQUEST_REJECTED: return 'Request rejected'; + case self::INVALID_SYSTEM_TABLE_INDEX: + return 'Invalid system table index'; } } }