Subversion Repositories HomeAutomation

Rev

Go to most recent revision | Blame | Last modification | View Log | SVN | RSS feed

  1.  
  2.  
  3. CanServices = new Array();
  4.  
  5. function legacyOnState(fullId, moduleId, moduleName, available)
  6. {
  7.     var service = ServiceManager.getService("Can", moduleName, moduleId)
  8.    
  9.     if (service != null)
  10.     {
  11.         if (available)
  12.         {
  13.             service.setOnline();
  14.         }
  15.         else
  16.         {
  17.             service.setOffline();
  18.         }
  19.        
  20.         CanServices[fullId] = service;
  21.     }
  22.     else
  23.     {
  24.         log("No such service found: " + moduleName + "\n");
  25.     }
  26.    
  27. }
  28.  
  29. function legacyOnMessage(fullId, moduleId, moduleName, commandName, data)
  30. {
  31.     var canMessage = new CanMessage("", "From_Owner", moduleName, moduleId, commandName, data);
  32.    
  33.     if (CanServices[fullId])
  34.     {
  35.         // Tell the service to handle the message, a module service must implement canMessageHandler or derive from CanService-class
  36.         CanServices[fullId].canMessageHandler(canMessage);
  37.     }
  38.     else if (canMessage.getModuleName() == "Debug")
  39.     {
  40.         var service = ServiceManager.getService("Can", canMessage.getModuleName(), canMessage.getModuleId())
  41.         if (service != null)
  42.         {
  43.             CanServices[fullId] = service;
  44.             CanServices[fullId].canMessageHandler(canMessage);
  45.         }
  46.     }
  47. }
  48.  
  49.  
  50.  
  51. // This is used to send messages to the can network
  52. function sendMessage(canMessage)
  53. {
  54.     var data = new Array();
  55.    
  56.     for (var key in canMessage.myData)
  57.     {
  58.         var obj = {};
  59.         obj[key] = canMessage.myData[key];
  60.        
  61.         data[data.length] = obj;
  62.     }
  63.    
  64.     SendModuleMessage(canMessage.getModuleName() + ":" + canMessage.getModuleId(), canMessage.getCommandName(), data);
  65. }
  66.  
  67.