Subversion Repositories HomeAutomation

Rev

Rev 1146 | Go to most recent revision | 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.         var dataArray = new Array();
  26.         dataArray["service"] = self;
  27.         dataArray["sensor"] = canMessage.getData("SensorId");
  28.         dataArray["value"] = canMessage.getData("Value");
  29.         dataArray["moduleName"] = canMessage.getModuleName();
  30.         dataArray["moduleId"] = canMessage.getModuleId();
  31.         this.callEvent("newValue", dataArray);
  32.         break;
  33.        
  34.         case "Humidity_Percent":
  35.         log(this.myName + ":" + this.myId + "> New humidity value: " + canMessage.getData("Value") + "\n");
  36.         this.myLastValueHumi[canMessage.getData("SensorId")] = canMessage.getData("Value");
  37.         this.callEvent("newHumidityValue", canMessage.getData("SensorId"));
  38.         break;
  39.  
  40.         case "Sensor_Report_Interval":
  41.         log(this.myName + ":" + this.myId + "> New report interval: " + canMessage.getData("Time") + "\n");
  42.         this.myReportInterval = canMessage.getData("Time");
  43.         break;
  44.         }
  45.     }
  46.    
  47.     this.CanService.prototype.canMessageHandler.call(this, canMessage);
  48. }
  49.  
  50. FOST02.prototype.getValueTemp = function(sensorId)
  51. {
  52.     return this.myLastValueTemp[sensorId];
  53. }
  54.  
  55. FOST02.prototype.getValueHumi = function(sensorId)
  56. {
  57.     return this.myLastValueHumi[sensorId];
  58. }
  59.  
  60. FOST02.prototype.setReportInterval = function(time)
  61. {
  62.     var canMessage = new CanMessage("sns", "To_Owner", this.myName, this.myId, "Sensor_Report_Interval");
  63.     canMessage.setData("Time", time);
  64.     sendMessage(canMessage);
  65. }
  66.