0
Отвечен

IR.GetServer doesn't work

Marco Tanis 8 лет назад в iRidium Script обновлен 8 лет назад 9

Hello,


I want to execute an command when one of my server tags changes, so i tried using IR.GetServer but that doesn't work i get a syntaxerror


here an example:


IR.AddListener(IR.EVENT_TAG_CHANGE, IR.GetServer(), function(name, value){
if(name == "test" && value == 0)
{
testoff();
}
else if(name == "test" && value == 1)

{
teston();
}

});

function testoff()

{
IR.GetDevice("KNX").Set("address1", 0);

IR.GetDevice("KNX").Set("address1", 0);
}


function teston()

{
IR.GetDevice("KNX").Set("address1", 1);
IR.GetDevice("KNX").Set("address1", 1);
}


does anyone know whats wrong here, or maybe another solution?


Thanks,

Marco

Hi

http://dev.iridiummobile.net/Systems_API/en#IR.EVENT_GLOBAL_TAG_CHANGE


I tend to use Global_Tag_Change in the client, for example

var SIPDriver = IR.GetDevice("SIP");
IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, function(name, value){
  // IR.Log(  "========SetGlobalListener name: " + name + "  value: " + value)
   switch (name){
      case "Drivers.iRidium Server.Clipsal C-Gate.Level 254/57/ 51":
          Ground_ExtLight()
      break;
      case "Drivers.iRidium Server.Clipsal C-Gate.Level 254/57/ 44":
          Ground_ExtLight()
      break;
      case "Drivers.iRidium Server.Clipsal C-Gate.Level 254/57/ 41":
         Ground_ExtLight()
      break; 
      case "Drivers.iRidium Server.Clipsal C-Gate.Level 254/56/ 78":
         //the front door has been opened, stop sip ringing
         SIP_Close();
         IR.HidePopup("Intercom");
         SIPDriver.Set("CANCEL", "");
      break; 
      case "Drivers.iRidium Server.Integriti.History_Summary":
           if (value >1)
               IR.ShowPopup("Room17_AlarmAlert");
           else
               IR.HidePopup("Room17_AlarmAlert");
      break;            
   }
});
IR.SubscribeTagChange("Drivers.iRidium Server.Clipsal C-Gate.Level 254/57/ 51");
IR.SubscribeTagChange("Drivers.iRidium Server.Clipsal C-Gate.Level 254/57/ 44");
IR.SubscribeTagChange("Drivers.iRidium Server.Clipsal C-Gate.Level 254/57/ 41");
IR.SubscribeTagChange("Drivers.iRidium Server.Clipsal C-Gate.Level 254/56/ 78");
IR.SubscribeTagChange("Drivers.iRidium Server.Integriti.History_Summary");

Отвечен

If you see the error like this:

SCRIPT    Script exception: TypeError: C:\Users\...\Newscript.js:1: Function is not defined

it means that you try to use IR.GetServer() method in i3 pro app. This method can be used only on Server side.

For the Client side you have to use IR.GetDevice("iRidium Server") method.

If you see another error please share more details.

I run the script on iridium server.

This is the error i get in the server log screen:

WARNING SCRIPT Script exception: SyntaxError: C:\users\...\test.js:1:

I don't see any errors when start your script on iRIdium server in empty project.


Please send your own project with error, please tell the version of Server you use

"SyntaxError" doesn't mean that some IR. method doesn't work. It means there is some syntax error (ha-ha). Like you lost some comma or bracket. Pls check it again

I will check extra tonight, if i still got the error i will send you the project. How can i send it to you?


Yesterday i tried to replace the getserver for a getdevice to a knx object and than the same script did work.

please send your projects and questions to support team to support@iridiummobile.ru

When i got the errors last night i tested the server by downloading my server project from iridium cloud.

Now i tried it in test mode trough file transfer.

Now i don't get the error in the server log, but the script still doesn't work.


I made a simple project with one script for testing, i will upload it here. Can you tell me if i did anything wrong in this project?


Thanks

testserver.sirpz

testpanel.irpz

Сервис поддержки клиентов работает на платформе UserEcho