Refactor property registration in MonitoringServer class for improved readability and consistency; update SQL ID handling logic

This commit is contained in:
jhartworks
2026-03-19 14:17:35 +01:00
parent 6bbce403a6
commit 4fcaeb2010
+21 -21
View File
@@ -7,13 +7,13 @@ class MonitoringServer extends IPSModule {
// Diese Zeile nicht löschen. // Diese Zeile nicht löschen.
parent::Create(); parent::Create();
$this->RegisterPropertyInteger("ParseNotifyCategoryID","0"); $this->RegisterPropertyInteger("ParseNotifyCategoryID",0);
$this->RegisterPropertyInteger("ParseAlarmCategoryID","0"); $this->RegisterPropertyInteger("ParseAlarmCategoryID",0);
$this->RegisterPropertyInteger("ParseAnalogCategoryID","0"); $this->RegisterPropertyInteger("ParseAnalogCategoryID",0);
$this->RegisterPropertyInteger("ISP","1"); $this->RegisterPropertyInteger("ISP",1);
$this->RegisterPropertyInteger("SqlId","27624"); $this->RegisterPropertyInteger("SqlId",28137);
$this->RegisterPropertyInteger("VisuId","0"); $this->RegisterPropertyInteger("VisuId",0);
$this->RegisterPropertyInteger("Projectnumber",123456); $this->RegisterPropertyInteger("Projectnumber",123456);
$this->RegisterPropertyString("Projectname","Musterprojekt"); $this->RegisterPropertyString("Projectname","Musterprojekt");
$this->RegisterPropertyString("InfluxDatabase","monitoring"); $this->RegisterPropertyString("InfluxDatabase","monitoring");
@@ -46,10 +46,10 @@ class MonitoringServer extends IPSModule {
$this->RegisterPropertyInteger("InfluxPort",8086); $this->RegisterPropertyInteger("InfluxPort",8086);
$this->RegisterPropertyInteger("UpdateintervallValues","30"); $this->RegisterPropertyInteger("UpdateintervallValues",30);
$this->RegisterPropertyInteger("UpdateintervallAlarms","10"); $this->RegisterPropertyInteger("UpdateintervallAlarms",10);
$this->RegisterPropertyInteger("UpdateintervallForceValues","30"); $this->RegisterPropertyInteger("UpdateintervallForceValues",30);
$this->RegisterPropertyInteger("UpdateintervallSendFtp","30"); $this->RegisterPropertyInteger("UpdateintervallSendFtp",30);
$this->RegisterTimer("UpdateAlarms", 0, 'SEMS_checkAlarms('.$this->InstanceID.');'); $this->RegisterTimer("UpdateAlarms", 0, 'SEMS_checkAlarms('.$this->InstanceID.');');
@@ -228,7 +228,7 @@ class MonitoringServer extends IPSModule {
$actAnalogCount = GetValueInteger($this->GetIDForIdent("AnalogVarCount")); $actAnalogCount = GetValueInteger($this->GetIDForIdent("AnalogVarCount"));
$oldAnalogCount = $this->ReadAttributeInteger("AnalogVarCountOld"); $oldAnalogCount = $this->ReadAttributeInteger("AnalogVarCountOld");
if($actAnalogCount <> $oldAnalogCount){ if($actAnalogCount <> $oldAnalogCount){
$this->WriteAttributeInteger("AnalogVarCountOld", $actAlarmCount); $this->WriteAttributeInteger("AnalogVarCountOld", $actAnalogCount);
$this->clearNames(); $this->clearNames();
} }
@@ -408,9 +408,9 @@ class MonitoringServer extends IPSModule {
private function notify($trigid, $webfrontid, $targetid, $projectnumber, $projectname, $ispnr){ private function notify($trigid, $webfrontid, $targetid, $projectnumber, $projectname, $ispnr){
$projectnumber = $this->ReadPropertyInteger("Projectnumber"); //$projectnumber = $this->ReadPropertyInteger("Projectnumber");
$projectname = $this->ReadPropertyString("Projectname"); //$projectname = $this->ReadPropertyString("Projectname");
$ispnumber = $this->ReadPropertyInteger("ISP"); $ispnumber = $ispnr; /// $this->ReadPropertyInteger("ISP");
$sendit = $this->ReadPropertyBoolean("SendNotification"); $sendit = $this->ReadPropertyBoolean("SendNotification");
$sendwhatsapp = $this->ReadPropertyBoolean("SendWhatsapp"); $sendwhatsapp = $this->ReadPropertyBoolean("SendWhatsapp");
@@ -429,9 +429,9 @@ class MonitoringServer extends IPSModule {
$tdOld = $this->ReadAttributeString("AtAlarmtable"); $tdOld = $this->ReadAttributeString("AtAlarmtable");
$td = $tdOld; $td = $tdOld;
if ($idSql > 0 && $idSql != 12345){ if ($idSql > 1 && $idSql != 12345){
MySQL_Open($idSql); MySQL_Open($idSql);
}
// === Helfer: Escaping für Strings === // === Helfer: Escaping für Strings ===
if (function_exists('MySQL_RealEscapeString')) { if (function_exists('MySQL_RealEscapeString')) {
@@ -440,7 +440,7 @@ class MonitoringServer extends IPSModule {
// Fallback, falls Modul-Funktion nicht verfügbar ist // Fallback, falls Modul-Funktion nicht verfügbar ist
$esc = fn(string $s) => addslashes($s); $esc = fn(string $s) => addslashes($s);
} }
}
$time = date("Y-m-d H:i:s"); $time = date("Y-m-d H:i:s");
$art = $projectnumber." | ".$projectname. " | ISP ".$ispnr; $art = $projectnumber." | ".$projectname. " | ISP ".$ispnr;
@@ -497,14 +497,14 @@ class MonitoringServer extends IPSModule {
$error = curl_error($ch); $error = curl_error($ch);
curl_close($ch); curl_close($ch);
header('Content-Type: text/plain'); /* header('Content-Type: text/plain');
echo "HTTP-Code: $httpcode\n"; echo "HTTP-Code: $httpcode\n";
if ($error) { if ($error) {
echo "cURL Error: $error\n"; echo "cURL Error: $error\n";
} else { } else {
echo "Response:\n$response\n"; echo "Response:\n$response\n";
} } */
// IPS_LogMessage ("Send Whatsapp " .$projectnumber , "Whatsapp an folgende Nummer gesendet: ". $number ); // IPS_LogMessage ("Send Whatsapp " .$projectnumber , "Whatsapp an folgende Nummer gesendet: ". $number );
} }
@@ -538,7 +538,7 @@ class MonitoringServer extends IPSModule {
)", )",
$esc($smname), $esc($phonenumber) $esc($smname), $esc($phonenumber)
); );
if ($idSql > 0 && $idSql != 12345){ if ($idSql > 1 && $idSql != 12345){
// === Ausführen === // === Ausführen ===
@@ -615,7 +615,7 @@ class MonitoringServer extends IPSModule {
(int)$mail, $esc($email_address), (int)$mailed, (int)$mail, $esc($email_address), (int)$mailed,
(int)$push (int)$push
); );
if ($idSql > 0 && $idSql != 12345){ if ($idSql > 1 && $idSql != 12345){
// === Ausführen === // === Ausführen ===
$ok = MySQL_ExecuteSimple($idSql, $sql); $ok = MySQL_ExecuteSimple($idSql, $sql);
if (!$ok) { if (!$ok) {