Improve category checks in MonitoringServer for robustness and clarity
This commit is contained in:
@@ -182,9 +182,8 @@ class MonitoringServer extends IPSModule {
|
||||
|
||||
$inalarmcount = 0;
|
||||
$alarmvalues = 0;
|
||||
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
||||
|
||||
if ($catAlarmId > 0){
|
||||
if (IPS_CategoryExists($catAlarmId)){
|
||||
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
||||
foreach ($catChilds as $catChild) {
|
||||
|
||||
|
||||
@@ -192,6 +191,9 @@ class MonitoringServer extends IPSModule {
|
||||
$parname = IPS_GetName($catChild);
|
||||
|
||||
foreach ($childids as $childid){
|
||||
if (!IPS_VariableExists($childid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$varInfo = IPS_GetVariable($childid);
|
||||
$changedtime = $varInfo["VariableChanged"];
|
||||
@@ -212,11 +214,13 @@ class MonitoringServer extends IPSModule {
|
||||
}
|
||||
SetValueInteger($this->GetIDForIdent("AlarmVarCount"),$alarmvalues);
|
||||
SetValueInteger($this->GetIDForIdent("AlarmActiveCount"),$inalarmcount);
|
||||
$rootcat = IPS_GetParent($catAlarmId);
|
||||
if ($inalarmcount > 0 && $rootcat >0){
|
||||
IPS_SetIcon($rootcat,"Alert");
|
||||
}else{
|
||||
IPS_SetIcon($rootcat,"");
|
||||
if (IPS_CategoryExists($catAlarmId)) {
|
||||
$rootcat = IPS_GetParent($catAlarmId);
|
||||
if ($inalarmcount > 0 && $rootcat >0){
|
||||
IPS_SetIcon($rootcat,"Alert");
|
||||
}else{
|
||||
IPS_SetIcon($rootcat,"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +260,7 @@ class MonitoringServer extends IPSModule {
|
||||
|
||||
$catNotifyId = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
||||
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
||||
$catSetpointId = $this->ReadPropertyInteger("ParseSetpointCategoryID");
|
||||
|
||||
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
||||
$projectname = $this->ReadPropertyString("Projectname");
|
||||
@@ -274,7 +279,7 @@ class MonitoringServer extends IPSModule {
|
||||
|
||||
|
||||
|
||||
if ($catAnalogId > 0){
|
||||
if (IPS_CategoryExists($catAnalogId)){
|
||||
|
||||
$catChilds = IPS_GetChildrenIDs($catAnalogId);
|
||||
|
||||
@@ -285,6 +290,9 @@ class MonitoringServer extends IPSModule {
|
||||
$parname = IPS_GetName($catChild);
|
||||
|
||||
foreach ($objchildids as $objchildid){
|
||||
if (!IPS_VariableExists($objchildid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$varInfo = IPS_GetVariable($objchildid);
|
||||
$changedtime = $varInfo["VariableChanged"];
|
||||
@@ -348,7 +356,7 @@ class MonitoringServer extends IPSModule {
|
||||
SetValueInteger($this->GetIDForIdent("AnalogVarCount"),$numberofvalues);
|
||||
$numberofvalues = 0;
|
||||
|
||||
if ($catSetpointId > 0){
|
||||
if (IPS_CategoryExists($catSetpointId)){
|
||||
|
||||
$catChilds = IPS_GetChildrenIDs($catSetpointId);
|
||||
|
||||
@@ -366,11 +374,10 @@ class MonitoringServer extends IPSModule {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SetValueInteger($this->GetIDForIdent("SetpointVarCount"),$numberofvalues);
|
||||
$numberofvalues = 0;
|
||||
|
||||
if ($catNotifyId > 0){
|
||||
if (IPS_CategoryExists($catNotifyId)){
|
||||
|
||||
$catChilds = IPS_GetChildrenIDs($catNotifyId);
|
||||
|
||||
@@ -381,6 +388,9 @@ class MonitoringServer extends IPSModule {
|
||||
$parname = IPS_GetName($catChild);
|
||||
|
||||
foreach ($objchildids as $objchildid){
|
||||
if (!IPS_VariableExists($objchildid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$varInfo = IPS_GetVariable($objchildid);
|
||||
$changedtime = $varInfo["VariableChanged"];
|
||||
@@ -709,7 +719,7 @@ class MonitoringServer extends IPSModule {
|
||||
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
||||
$catAlarmId = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
||||
|
||||
if ($catNotifyId > 0){
|
||||
if (IPS_CategoryExists($catNotifyId)){
|
||||
|
||||
$catChilds = IPS_GetChildrenIDs($catNotifyId);
|
||||
|
||||
@@ -723,7 +733,7 @@ class MonitoringServer extends IPSModule {
|
||||
|
||||
}
|
||||
}
|
||||
if ($catAnalogId > 0){
|
||||
if (IPS_CategoryExists($catAnalogId)){
|
||||
|
||||
$catChilds = IPS_GetChildrenIDs($catAnalogId);
|
||||
|
||||
@@ -737,7 +747,7 @@ class MonitoringServer extends IPSModule {
|
||||
|
||||
}
|
||||
}
|
||||
if ($catAlarmId > 0){
|
||||
if (IPS_CategoryExists($catAlarmId)){
|
||||
|
||||
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
||||
|
||||
@@ -879,4 +889,4 @@ private function generateAndUploadCsv($catId, $ftp, $remotePath, $localPath) {
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user