Improve category checks in MonitoringServer for robustness and clarity
This commit is contained in:
+114
-165
@@ -68,17 +68,21 @@ class MonitoringClient extends IPSModule {
|
|||||||
|
|
||||||
$module_id = "{01C00ADD-D04E-452E-B66A-D253278743FE}" /* Module ID of MQTT Server Device */;
|
$module_id = "{01C00ADD-D04E-452E-B66A-D253278743FE}" /* Module ID of MQTT Server Device */;
|
||||||
$ident = "TempMQTTDevice";
|
$ident = "TempMQTTDevice";
|
||||||
|
// Each client instance owns its temporary device. Do not let different
|
||||||
|
// Monitoring Client instances block each other during a force update.
|
||||||
|
$semaphore = $ident . "_" . $this->InstanceID;
|
||||||
|
|
||||||
// enter semaphore to ensure the temporary device gets used by one thread at a time
|
// enter semaphore to ensure the temporary device gets used by one thread at a time
|
||||||
if(IPS_SemaphoreEnter($ident, 100)) {
|
if(IPS_SemaphoreEnter($semaphore, 5000)) {
|
||||||
|
try {
|
||||||
// get temporary MQTT Server Device or create if needed
|
// get temporary MQTT Server Device or create if needed
|
||||||
$id = @IPS_GetObjectIDByIdent($ident, $_IPS['SELF']);
|
$id = @IPS_GetObjectIDByIdent($ident, $this->InstanceID);
|
||||||
if($id === false) {
|
if($id === false) {
|
||||||
$id = @IPS_CreateInstance($module_id);
|
$id = @IPS_CreateInstance($module_id);
|
||||||
if($id === false) {
|
if($id === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
IPS_SetParent($id, $_IPS['SELF']);
|
IPS_SetParent($id, $this->InstanceID);
|
||||||
IPS_SetIdent($id, $ident);
|
IPS_SetIdent($id, $ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,14 +116,20 @@ class MonitoringClient extends IPSModule {
|
|||||||
|
|
||||||
// get Value variable and use it to publish the payload
|
// get Value variable and use it to publish the payload
|
||||||
$var_id = @IPS_GetObjectIDByIdent("Value", $id);
|
$var_id = @IPS_GetObjectIDByIdent("Value", $id);
|
||||||
RequestAction($var_id, $payload);
|
if ($var_id === false) {
|
||||||
|
IPS_LogMessage("Monitoring Client", "MQTT device has no Value variable for topic: " . $topic);
|
||||||
IPS_SemaphoreLeave($ident);
|
|
||||||
} else { // semaphore timeout
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
RequestAction($var_id, $payload);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} finally {
|
||||||
|
IPS_SemaphoreLeave($semaphore);
|
||||||
|
}
|
||||||
|
} else { // semaphore timeout
|
||||||
|
IPS_LogMessage("Monitoring Client", "MQTT publish timed out waiting for topic: " . $topic);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // MQTT_Publish
|
} // MQTT_Publish
|
||||||
|
|
||||||
public function MqttSync($server_id, $topic, $payload, $retain, $ident, $source) {
|
public function MqttSync($server_id, $topic, $payload, $retain, $ident, $source) {
|
||||||
@@ -240,8 +250,79 @@ class MonitoringClient extends IPSModule {
|
|||||||
return true;
|
return true;
|
||||||
} // MQTT_Sync
|
} // MQTT_Sync
|
||||||
|
|
||||||
|
private function resolveLinkTarget($objectId) {
|
||||||
|
$visited = array();
|
||||||
|
while ($objectId > 0 && IPS_LinkExists($objectId)) {
|
||||||
|
if (isset($visited[$objectId])) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$visited[$objectId] = true;
|
||||||
|
$objectId = IPS_GetLink($objectId)["TargetID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $objectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return every variable directly represented by a monitoring category.
|
||||||
|
* The parent name is deliberately kept from the visible object/link in the
|
||||||
|
* configured tree, so existing MQTT topic names remain unchanged.
|
||||||
|
*/
|
||||||
|
private function getCategoryVariables($categoryId) {
|
||||||
|
$variables = array();
|
||||||
|
if (!IPS_CategoryExists($categoryId)) {
|
||||||
|
return $variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (IPS_GetChildrenIDs($categoryId) as $entryId) {
|
||||||
|
$entryName = IPS_GetName($entryId);
|
||||||
|
$targetId = $this->resolveLinkTarget($entryId);
|
||||||
|
if ($targetId <= 0 || !IPS_ObjectExists($targetId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A variable or a link to a variable is located directly in the category.
|
||||||
|
if (IPS_VariableExists($targetId)) {
|
||||||
|
$variables[] = array(
|
||||||
|
"id" => $targetId,
|
||||||
|
"parent" => $entryName,
|
||||||
|
"name" => IPS_GetName($targetId),
|
||||||
|
"direct" => true
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// An object (or a link to an object) may contain one or several values.
|
||||||
|
foreach (IPS_GetChildrenIDs($targetId) as $childId) {
|
||||||
|
$variableId = $this->resolveLinkTarget($childId);
|
||||||
|
if ($variableId <= 0 || !IPS_VariableExists($variableId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variables[] = array(
|
||||||
|
"id" => $variableId,
|
||||||
|
"parent" => $entryName,
|
||||||
|
"name" => IPS_GetName($variableId),
|
||||||
|
"direct" => false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $variables;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getTopicForVariable($top, $variable, $force) {
|
||||||
|
// The old force path used the bare variable name for values directly in
|
||||||
|
// the category. Keep that legacy topic spelling intact.
|
||||||
|
if ($force && $variable["direct"]) {
|
||||||
|
return $top . $variable["name"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $top . $variable["parent"] . "_" . $variable["name"];
|
||||||
|
}
|
||||||
|
|
||||||
public function SendTopic() {
|
public function SendTopic() {
|
||||||
|
|
||||||
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
|
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
|
||||||
$projectyear = $this->ReadPropertyInteger("Projectyear");
|
$projectyear = $this->ReadPropertyInteger("Projectyear");
|
||||||
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
||||||
@@ -249,190 +330,58 @@ class MonitoringClient extends IPSModule {
|
|||||||
$ispnumber = $this->ReadPropertyInteger("ISP");
|
$ispnumber = $this->ReadPropertyInteger("ISP");
|
||||||
$updatetime = $this->ReadPropertyInteger("Updatetime");
|
$updatetime = $this->ReadPropertyInteger("Updatetime");
|
||||||
|
|
||||||
$catIds[0]["id"] = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
$catIds = array(
|
||||||
$catIds[0]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Notify/";
|
array("id" => $this->ReadPropertyInteger("ParseNotifyCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Notify/", "setpoint" => false),
|
||||||
$catIds[0]["setpoint"] = false;
|
array("id" => $this->ReadPropertyInteger("ParseAlarmCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Alarm/", "setpoint" => false),
|
||||||
$catIds[1]["id"] = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
array("id" => $this->ReadPropertyInteger("ParseAnalogCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Analog/", "setpoint" => false),
|
||||||
$catIds[1]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Alarm/";
|
array("id" => $this->ReadPropertyInteger("ParseSetpointCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Setpoint/", "setpoint" => true)
|
||||||
$catIds[1]["setpoint"] = false;
|
);
|
||||||
$catIds[2]["id"] = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
|
||||||
$catIds[2]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Analog/";
|
|
||||||
$catIds[2]["setpoint"] = false;
|
|
||||||
$catIds[3]["id"] = $this->ReadPropertyInteger("ParseSetpointCategoryID");
|
|
||||||
$catIds[3]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Setpoint/";
|
|
||||||
$catIds[3]["setpoint"] = true;
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($catIds as $catId) {
|
foreach ($catIds as $catId) {
|
||||||
|
foreach ($this->getCategoryVariables($catId["id"]) as $variable) {
|
||||||
$isSetpoint = isset($catId["setpoint"]) ? $catId["setpoint"] : false;
|
$varInfo = IPS_GetVariable($variable["id"]);
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catId["id"]);
|
|
||||||
|
|
||||||
foreach ($catChilds as $catChild) {
|
|
||||||
|
|
||||||
$childids = IPS_GetChildrenIDs($catChild);
|
|
||||||
|
|
||||||
$parname = IPS_GetName($catChild);
|
|
||||||
|
|
||||||
if (IPS_VariableExists($catChild) != 1 && IPS_LinkExists($catChild) != 1){
|
|
||||||
|
|
||||||
foreach ($childids as $childid){
|
|
||||||
|
|
||||||
foreach ($childids as $childid){
|
|
||||||
if (IPS_VariableExists($childid) != 1){
|
|
||||||
|
|
||||||
if(IPS_LinkExists($childid) == 1){
|
|
||||||
$linkInfo = IPS_GetLink($childid);
|
|
||||||
$linkTarget = $linkInfo["TargetID"];
|
|
||||||
$childid = $linkTarget;
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
$changedtime = $varInfo["VariableChanged"];
|
$changedtime = $varInfo["VariableChanged"];
|
||||||
$varname = IPS_GetName($childid);
|
$topic = $this->getTopicForVariable($catId["top"], $variable, false);
|
||||||
$topic = $catId["top"]. $parname."_".$varname;
|
$payload = round(GetValue($variable["id"]), 2);
|
||||||
$syncname = $parname."_".$varname;
|
|
||||||
$payload = round(getvalue($childid), 2);
|
|
||||||
$time = time();
|
|
||||||
|
|
||||||
$isSetpoint = isset($catId["setpoint"]) ? $catId["setpoint"] : false;
|
if ($catId["setpoint"]) {
|
||||||
|
$syncname = $variable["parent"] . "_" . $variable["name"];
|
||||||
if ($isSetpoint == true){
|
IPS_LogMessage("Monitoring Client", "Sync Setpoint: " . $topic . " mit Payload: " . $payload . " und Source: " . $variable["id"] . " und Ident: " . $syncname);
|
||||||
IPS_LogMessage("Monitoring Client", "Sync Setpoint: " . $topic . " mit Payload: " . $payload. " und Source: " . $childid . " und Ident: " . $syncname);
|
$this->MqttSync($mqttId, $topic, $payload, false, $syncname, $variable["id"]);
|
||||||
$this->MqttSync($mqttId, $topic, $payload, false, $syncname, $childid);
|
} elseif ($changedtime > time() - $updatetime) {
|
||||||
|
|
||||||
}else{
|
|
||||||
if($changedtime > $time - $updatetime){
|
|
||||||
$this->MqttPublish($mqttId, $topic, $payload, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$childid = $catChild;
|
|
||||||
if (IPS_VariableExists($childid) != 1){
|
|
||||||
|
|
||||||
if(IPS_LinkExists($childid) == 1){
|
|
||||||
$linkInfo = IPS_GetLink($childid);
|
|
||||||
$linkTarget = $linkInfo["TargetID"];
|
|
||||||
$childid = $linkTarget;
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
$changedtime = $varInfo["VariableChanged"];
|
|
||||||
$varname = IPS_GetName($childid);
|
|
||||||
$topic = $catId["top"]. $parname."_".$varname;
|
|
||||||
$payload = round(getvalue($childid), 2);
|
|
||||||
$time = time();
|
|
||||||
|
|
||||||
$isSetpoint = isset($catId["setpoint"]) ? $catId["setpoint"] : false;
|
|
||||||
|
|
||||||
if ($isSetpoint == true){
|
|
||||||
IPS_LogMessage("Monitoring Client", "Sync Setpoint: " . $topic . " mit Payload: " . $payload. " und Source: " . $childid . " und Ident: " . $syncname);
|
|
||||||
$this->MqttSync($mqttId, $topic, $payload, false, $parname."_".$varname, $childid);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
if($changedtime > $time - $updatetime){
|
|
||||||
$this->MqttPublish($mqttId, $topic, $payload, false);
|
$this->MqttPublish($mqttId, $topic, $payload, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$topic = "Projekte" . $projectyear . "/" . $projectnumber . "/ISP" . $ispnumber . "/Name";
|
$topic = "Projekte" . $projectyear . "/" . $projectnumber . "/ISP" . $ispnumber . "/Name";
|
||||||
$this->MqttPublish($mqttId, $topic, $projectname, false);
|
$this->MqttPublish($mqttId, $topic, $projectname, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ForceSendTopic() {
|
public function ForceSendTopic() {
|
||||||
|
|
||||||
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
|
$mqttId = $this->ReadPropertyInteger("MqttCLientID");
|
||||||
$projectyear = $this->ReadPropertyInteger("Projectyear");
|
$projectyear = $this->ReadPropertyInteger("Projectyear");
|
||||||
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
||||||
$projectname = $this->ReadPropertyString("Projectname");
|
$projectname = $this->ReadPropertyString("Projectname");
|
||||||
$ispnumber = $this->ReadPropertyInteger("ISP");
|
$ispnumber = $this->ReadPropertyInteger("ISP");
|
||||||
$updatetime = $this->ReadPropertyInteger("Updatetime");
|
|
||||||
|
|
||||||
$catIds[0]["id"] = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
|
||||||
$catIds[0]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Notify/";
|
|
||||||
$catIds[1]["id"] = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
|
||||||
$catIds[1]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Alarm/";
|
|
||||||
$catIds[2]["id"] = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
|
||||||
$catIds[2]["top"] = "Projekte". $projectyear."/P".$projectnumber. "/ISP" .$ispnumber. "/Analog/";
|
|
||||||
|
|
||||||
|
|
||||||
|
$catIds = array(
|
||||||
|
array("id" => $this->ReadPropertyInteger("ParseNotifyCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Notify/"),
|
||||||
|
array("id" => $this->ReadPropertyInteger("ParseAlarmCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Alarm/"),
|
||||||
|
array("id" => $this->ReadPropertyInteger("ParseAnalogCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Analog/"),
|
||||||
|
array("id" => $this->ReadPropertyInteger("ParseSetpointCategoryID"), "top" => "Projekte" . $projectyear . "/P" . $projectnumber . "/ISP" . $ispnumber . "/Setpoint/")
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($catIds as $catId) {
|
foreach ($catIds as $catId) {
|
||||||
|
foreach ($this->getCategoryVariables($catId["id"]) as $variable) {
|
||||||
$catChilds = IPS_GetChildrenIDs($catId["id"]);
|
$topic = $this->getTopicForVariable($catId["top"], $variable, true);
|
||||||
|
$payload = round(GetValue($variable["id"]), 2);
|
||||||
foreach ($catChilds as $catChild) {
|
|
||||||
|
|
||||||
$childids = IPS_GetChildrenIDs($catChild);
|
|
||||||
|
|
||||||
$parname = IPS_GetName($catChild);
|
|
||||||
|
|
||||||
if (IPS_VariableExists($catChild) != 1 && IPS_LinkExists($catChild) != 1){
|
|
||||||
|
|
||||||
foreach ($childids as $childid){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($childids as $childid){
|
|
||||||
if (IPS_VariableExists($childid) != 1){
|
|
||||||
|
|
||||||
if(IPS_LinkExists($childid) == 1){
|
|
||||||
$linkInfo = IPS_GetLink($childid);
|
|
||||||
$linkTarget = $linkInfo["TargetID"];
|
|
||||||
$childid = $linkTarget;
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
$varname = IPS_GetName($childid);
|
|
||||||
$topic = $catId["top"]. $parname."_".$varname;
|
|
||||||
$payload = round(getvalue($childid), 2);
|
|
||||||
|
|
||||||
$this->MqttPublish($mqttId, $topic, $payload, false);
|
$this->MqttPublish($mqttId, $topic, $payload, false);
|
||||||
// IPS_LogMessage("Monitoring Client", "Force Update with Parent: " . $topic . " mit Payload: " . $payload);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$childid = $catChild;
|
|
||||||
if (IPS_VariableExists($childid) != 1){
|
|
||||||
|
|
||||||
if(IPS_LinkExists($childid) == 1){
|
|
||||||
$linkInfo = IPS_GetLink($childid);
|
|
||||||
$linkTarget = $linkInfo["TargetID"];
|
|
||||||
$childid = $linkTarget;
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
|
||||||
$varname = IPS_GetName($childid);
|
|
||||||
$topic = $catId["top"].$varname;
|
|
||||||
$payload = round(getvalue($childid), 2);
|
|
||||||
|
|
||||||
$this->MqttPublish($mqttId, $topic, $payload, false);
|
|
||||||
// IPS_LogMessage("Monitoring Client", "Force Update none Parent: " . $topic . " mit Payload: " . $payload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$topic = "Projekte" . $projectyear . "/" . $projectnumber . "/ISP" . $ispnumber . "/Name";
|
$topic = "Projekte" . $projectyear . "/" . $projectnumber . "/ISP" . $ispnumber . "/Name";
|
||||||
$this->MqttPublish($mqttId, $topic, $projectname, false);
|
$this->MqttPublish($mqttId, $topic, $projectname, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -182,9 +182,8 @@ class MonitoringServer extends IPSModule {
|
|||||||
|
|
||||||
$inalarmcount = 0;
|
$inalarmcount = 0;
|
||||||
$alarmvalues = 0;
|
$alarmvalues = 0;
|
||||||
|
if (IPS_CategoryExists($catAlarmId)){
|
||||||
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
||||||
|
|
||||||
if ($catAlarmId > 0){
|
|
||||||
foreach ($catChilds as $catChild) {
|
foreach ($catChilds as $catChild) {
|
||||||
|
|
||||||
|
|
||||||
@@ -192,6 +191,9 @@ class MonitoringServer extends IPSModule {
|
|||||||
$parname = IPS_GetName($catChild);
|
$parname = IPS_GetName($catChild);
|
||||||
|
|
||||||
foreach ($childids as $childid){
|
foreach ($childids as $childid){
|
||||||
|
if (!IPS_VariableExists($childid)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($childid);
|
$varInfo = IPS_GetVariable($childid);
|
||||||
$changedtime = $varInfo["VariableChanged"];
|
$changedtime = $varInfo["VariableChanged"];
|
||||||
@@ -212,6 +214,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
}
|
}
|
||||||
SetValueInteger($this->GetIDForIdent("AlarmVarCount"),$alarmvalues);
|
SetValueInteger($this->GetIDForIdent("AlarmVarCount"),$alarmvalues);
|
||||||
SetValueInteger($this->GetIDForIdent("AlarmActiveCount"),$inalarmcount);
|
SetValueInteger($this->GetIDForIdent("AlarmActiveCount"),$inalarmcount);
|
||||||
|
if (IPS_CategoryExists($catAlarmId)) {
|
||||||
$rootcat = IPS_GetParent($catAlarmId);
|
$rootcat = IPS_GetParent($catAlarmId);
|
||||||
if ($inalarmcount > 0 && $rootcat >0){
|
if ($inalarmcount > 0 && $rootcat >0){
|
||||||
IPS_SetIcon($rootcat,"Alert");
|
IPS_SetIcon($rootcat,"Alert");
|
||||||
@@ -219,6 +222,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
IPS_SetIcon($rootcat,"");
|
IPS_SetIcon($rootcat,"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function checkIfSomethingChanged()
|
public function checkIfSomethingChanged()
|
||||||
{
|
{
|
||||||
@@ -256,6 +260,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
|
|
||||||
$catNotifyId = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
$catNotifyId = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
||||||
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
||||||
|
$catSetpointId = $this->ReadPropertyInteger("ParseSetpointCategoryID");
|
||||||
|
|
||||||
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
$projectnumber = $this->ReadPropertyInteger("Projectnumber");
|
||||||
$projectname = $this->ReadPropertyString("Projectname");
|
$projectname = $this->ReadPropertyString("Projectname");
|
||||||
@@ -274,7 +279,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($catAnalogId > 0){
|
if (IPS_CategoryExists($catAnalogId)){
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catAnalogId);
|
$catChilds = IPS_GetChildrenIDs($catAnalogId);
|
||||||
|
|
||||||
@@ -285,6 +290,9 @@ class MonitoringServer extends IPSModule {
|
|||||||
$parname = IPS_GetName($catChild);
|
$parname = IPS_GetName($catChild);
|
||||||
|
|
||||||
foreach ($objchildids as $objchildid){
|
foreach ($objchildids as $objchildid){
|
||||||
|
if (!IPS_VariableExists($objchildid)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($objchildid);
|
$varInfo = IPS_GetVariable($objchildid);
|
||||||
$changedtime = $varInfo["VariableChanged"];
|
$changedtime = $varInfo["VariableChanged"];
|
||||||
@@ -348,7 +356,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
SetValueInteger($this->GetIDForIdent("AnalogVarCount"),$numberofvalues);
|
SetValueInteger($this->GetIDForIdent("AnalogVarCount"),$numberofvalues);
|
||||||
$numberofvalues = 0;
|
$numberofvalues = 0;
|
||||||
|
|
||||||
if ($catSetpointId > 0){
|
if (IPS_CategoryExists($catSetpointId)){
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catSetpointId);
|
$catChilds = IPS_GetChildrenIDs($catSetpointId);
|
||||||
|
|
||||||
@@ -366,11 +374,10 @@ class MonitoringServer extends IPSModule {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetValueInteger($this->GetIDForIdent("SetpointVarCount"),$numberofvalues);
|
SetValueInteger($this->GetIDForIdent("SetpointVarCount"),$numberofvalues);
|
||||||
$numberofvalues = 0;
|
$numberofvalues = 0;
|
||||||
|
|
||||||
if ($catNotifyId > 0){
|
if (IPS_CategoryExists($catNotifyId)){
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catNotifyId);
|
$catChilds = IPS_GetChildrenIDs($catNotifyId);
|
||||||
|
|
||||||
@@ -381,6 +388,9 @@ class MonitoringServer extends IPSModule {
|
|||||||
$parname = IPS_GetName($catChild);
|
$parname = IPS_GetName($catChild);
|
||||||
|
|
||||||
foreach ($objchildids as $objchildid){
|
foreach ($objchildids as $objchildid){
|
||||||
|
if (!IPS_VariableExists($objchildid)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$varInfo = IPS_GetVariable($objchildid);
|
$varInfo = IPS_GetVariable($objchildid);
|
||||||
$changedtime = $varInfo["VariableChanged"];
|
$changedtime = $varInfo["VariableChanged"];
|
||||||
@@ -709,7 +719,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
||||||
$catAlarmId = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
$catAlarmId = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
||||||
|
|
||||||
if ($catNotifyId > 0){
|
if (IPS_CategoryExists($catNotifyId)){
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catNotifyId);
|
$catChilds = IPS_GetChildrenIDs($catNotifyId);
|
||||||
|
|
||||||
@@ -723,7 +733,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($catAnalogId > 0){
|
if (IPS_CategoryExists($catAnalogId)){
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catAnalogId);
|
$catChilds = IPS_GetChildrenIDs($catAnalogId);
|
||||||
|
|
||||||
@@ -737,7 +747,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($catAlarmId > 0){
|
if (IPS_CategoryExists($catAlarmId)){
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
$catChilds = IPS_GetChildrenIDs($catAlarmId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user