Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1.  
  2. function output(type, name, id)
  3. {
  4.     this.CanService(type, name, id);
  5.     this.myLastValue = new Array();
  6. }
  7.  
  8. extend(output, CanService);
  9.  
  10. output.prototype.myReportInterval = null;
  11. output.prototype.myLastValue = null;
  12.  
  13. output.prototype.canMessageHandler = function(canMessage)
  14. {
  15.     if (canMessage.getDirectionFlag() == "From_Owner")
  16.     {
  17.         switch (canMessage.getCommandName())
  18.         {
  19.         case "SetPin":
  20.         //log(this.myName + ":" + this.myId + "> New value: " + canMessage.getData("Value") + "\n");
  21.         this.myLastValue[canMessage.getData("PinId")] = canMessage.getData("Status");
  22.         this.callEvent("newValue", canMessage.getData("PinId"));
  23.         break;
  24.         /*
  25.         case "Report_Interval":
  26.         log(this.myName + ":" + this.myId + "> New report interval: " + canMessage.getData("Time") + "\n");
  27.         this.myReportInterval = canMessage.getData("Time");
  28.         break;*/
  29.         }
  30.     }
  31.    
  32.     this.CanService.prototype.canMessageHandler.call(this, canMessage);
  33. }
  34.  
  35. output.prototype.getValue = function(chnId)
  36. {
  37.     return this.myLastValue[chnId];
  38. }
  39.  
  40. output.prototype.setPin = function(status, chnId)
  41. {
  42.     var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "SetPin");
  43.     canMessage.setData("PinId", chnId);
  44.     canMessage.setData("Status", status);
  45.     sendMessage(canMessage);   
  46.     this.myLastValue[chnId] = status;
  47. }
  48.  
  49.  
  50.  
  51.