Subversion Repositories HomeAutomation

Rev

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