0
Completed

HDL Watchdog

Ekaterina (head of support) 9 years ago in Products / HDL-BUS Pro updated by AlexDr 7 years ago 7
This simple script make you able to see if the communication with HDL bus stopped.
In case of UDP broadcast connections it is not possible to see the online status of HDL IP module, so you have to look at the traffic from HDL, and if it is stopped for awhile you can show "Offline message".
See the example attached.
You can choose a time without traffic indicates the offline. It is 10 sec by default.

!HDL Online indicator.irpz
Since I program the scene setting in Switch Panel. I want to control the scene via switch panel. Can I do this?
DLP panels supports only "Panel Control" and "Universal Switch" commands. You can lounch the Sceen with executing device supports "Sceen Control" operation code.

I'm using this script in real project with Raspberry Pi server. But in the latest version of the Iridium server many errors have appeared (one after another):

[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:36.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       WARNING SCRIPT  Script exception: RangeError: /var/lib/iRidium Server/Documents/RaspberryPi_Server/scripts/HDL_service.js:46: error
[15-04-2017 20:25:37.000]       DEBUG   SCRIPT  Script garbage memory collected. 

After performing the garbage collection, it disappears for a while, but then appears again.


function initHDLWatchdog(){
   IR.AddListener(IR.EVENT_TAG_CHANGE, HDLdevice, function(name, value){
      IR.SetVariable("Server.Tags.HDLWatchdog", 1);   
      IR.ClearInterval(idHDLWatchdogTimer); 
      idHDLWatchdogTimer = IR.SetTimeout(10000, function(){  //This line is followed by the error text                               
         debug("===There is no Data from the HDL bus for a 10 sec, offline indicated");
         IR.SetVariable("Server.Tags.HDLWatchdog", 0); 
      });    
   }); 
}


This is JS for i2 control only, not for server ;)

ok, but how check HDL is online on server?

Hello

Here is a server script


var id//global variable for timer

function offline()//function that start if hdl bus does not answer

{

IR.Log("hdl is ofline")

}

IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetDevice("HDL-BUS Pro Network (UDP)"), function(name,value)

{

IR.ClearInterval(id);//clear interval if hdl bus answer

id = IR.SetTimeout(10000, offline);//set new timer

});

I share the working decision. Today I tested it on a real server. Can someone else come in handy


var idHDLWatchdogTimer = 0; 
            
function initHDLWatchdog(){
   IR.AddListener(IR.EVENT_TAG_CHANGE, HDLdevice, function(name, value){ 
                                                
      if(IR.GetVariable("Server.Tags.HDLWatchdog") == false || idHDLWatchdogTimer){ 
         IR.ClearInterval(idHDLWatchdogTimer);
         idHDLWatchdogTimer = 0;                
         
         IR.SetTimeout(5000, function(){            
            //wait until 500ms for HDL bus activity, and restrt 10 sec timeout        
            idHDLWatchdogTimer = IR.SetTimeout(500, function(){  
               //if no activity - reset watchdog variable      
               IR.Log("===There is no Data from the HDL bus for a 10 sec, offline indicated");
               IR.SetVariable("Server.Tags.HDLWatchdog", false);
               idHDLWatchdogTimer = 0;
            });  
         });                            
         IR.SetVariable("Server.Tags.HDLWatchdog", true);  
      } 
   }); 
}