Subversion Repositories HomeAutomation

Rev

Rev 1146 | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. function FOST02(type, name, id)
  3. {
  4.     this.CanService(type, name, id);
  5.    
  6.     this.myLastValueTemp = new Array();
  7.     this.myLastValueHumi = new Array();
  8. }
  9.  
  10. extend(FOST02, CanService);
  11.  
  12. FOST02.prototype.myReportInterval = null;
  13. FOST02.prototype.myLastValue = null;
  14.  
  15. FOST02.prototype.canMessageHandler = function(canMessage)
  16. {
  17.     if (canMessage.getDirectionFlag() == "From_Owner")
  18.     {
  19.         switch (canMessage.getCommandName())
  20.         {
  21.         case "Temperature_Celsius":
  22.         log(this.myName + ":" + this.myId + "> New temperature value: " + canMessage.getData("Value") + "\n");
  23.         this.myLastValueTemp[canMessage.getData("SensorId")] = canMessage.getData("Value");
  24.         this.callEvent("newValue", canMessage.getData("SensorId"));
  25.         break;
  26.        
  27.         case "Humidity_Percent":
  28.         log(this.myName + ":" + this.myId + "> New humidity value: " + canMessage.getData("Value") + "\n");
  29.         this.myLastValueHumi[canMessage.getData("SensorId")] = canMessage.getData("Value");
  30.         this.callEvent("newValue", canMessage.getData("SensorId"));
  31.         break;
  32.  
  33.         case "Sensor_Report_Interval":
  34.         log(this.myName + ":" + this.myId + "> New report interval: " + canMessage.getData("Time") + "\n");
  35.         this.myReportInterval = canMessage.getData("Time");
  36.         break;
  37.         }
  38.     }
  39.    
  40.     this.CanService.prototype.canMessageHandler.call(this, canMessage);
  41. }
  42.  
  43. FOST02.prototype.getValueTemp = function(sensorId)
  44. {
  45.     return this.myLastValueTemp[sensorId];
  46. }
  47.  
  48. FOST02.prototype.getValueHumi = function(sensorId)
  49. {
  50.     return this.myLastValueHumi[sensorId];
  51. }
  52.  
  53. FOST02.prototype.setReportInterval = function(time)
  54. {
  55.     var canMessage = new CanMessage("sns", "To_Owner", this.myName, this.myId, "Sensor_Report_Interval");
  56.     canMessage.setData("Time", time);
  57.     sendMessage(canMessage);
  58. }
  59.