Subversion Repositories HomeAutomation

Rev

Rev 1374 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1374 Rev 1380
Line 56... Line 56...
56
        break;
56
        break;
57
        case "CONFIG_SENSOR":
57
        case "CONFIG_SENSOR":
58
            this.sensorModuleType= canMessage.getData("sensorModuleType");
58
            this.sensorModuleType= canMessage.getData("sensorModuleType");
59
            this.sensorModuleId= canMessage.getData("sensorModuleId");
59
            this.sensorModuleId= canMessage.getData("sensorModuleId");
60
            this.sensorId= canMessage.getData("sensorId");
60
            this.sensorId= canMessage.getData("sensorId");
-
 
61
              log("conf_sensor: " + this.sensorModuleType + " " + this.sensorModuleId + " " + this.sensorId + "\n");
61
            //this.callEvent("newValue", canMessage.getData("Id"));
62
            //this.callEvent("newValue", canMessage.getData("Id"));
62
        break;
63
        break;
63
        case "CONFIG_ACTUATOR":
64
        case "CONFIG_ACTUATOR":
64
            this.actuatorModuleType= canMessage.getData("actuatorModuleType");
65
            this.actuatorModuleType= canMessage.getData("actuatorModuleType");
65
            this.actuatorModuleId= canMessage.getData("actuatorModuleId");
66
            this.actuatorModuleId= canMessage.getData("actuatorModuleId");
66
            this.actuatorId= canMessage.getData("actuatorId");
67
            this.actuatorId= canMessage.getData("actuatorId");
67
            //this.callEvent("newValue", canMessage.getData("Id"));
68
            //this.callEvent("newValue", canMessage.getData("Id"));
-
 
69
log("conf_act: " + this.actuatorModuleType + " " + this.actuatorModuleId + " " + this.actuatorId + "\n");
68
 
70
 
69
        break;
71
        break;
70
        case "CONFIG_PARAMETER":
72
        case "CONFIG_PARAMETER":
71
            this.K_P= canMessage.getData("K_P");
73
            this.K_P= canMessage.getData("K_P");
72
            this.K_I= canMessage.getData("K_I");
74
            this.K_I= canMessage.getData("K_I");
73
            this.K_D= canMessage.getData("K_D");
75
            this.K_D= canMessage.getData("K_D");
74
            this.TimeUnit= canMessage.getData("TimeUnit");
76
            this.TimeUnit= canMessage.getData("TimeUnit");
75
            this.RegulatorTime= canMessage.getData("RegulatorTime");
77
            this.RegulatorTime= canMessage.getData("RegulatorTime");
-
 
78
log("conf_param: " + this.K_P + " " + this.K_I + " " + this.K_D + " " + this.RegulatorTime +  " " + this.TimeUnit + "\n");
76
            //this.callEvent("newValue", canMessage.getData("Id"));
79
            //this.callEvent("newValue", canMessage.getData("Id"));
77
        break;
80
        break;
78
        case "PID_STATUS":
81
        case "PID_STATUS":
79
            this.Measurment= canMessage.getData("Measurment");
82
            this.Measurment= canMessage.getData("Measurment");
80
            this.Reference= canMessage.getData("Reference");
83
            this.Reference= canMessage.getData("Reference");
81
            this.PWM= canMessage.getData("PWM");
84
            this.PWM= canMessage.getData("PWM");
82
            this.Sum= canMessage.getData("Sum");
85
            this.Sum= canMessage.getData("Sum");
-
 
86
log("PID status: mea:" + this.Measurment + " ref:" + this.Reference + " pwm:" + this.PWM/100 + " sum:" + this.Sum + "\n");
83
            //this.callEvent("newValue", canMessage.getData("Id"));
87
            //this.callEvent("newValue", canMessage.getData("Id"));
84
        break;
88
        break;
85
        case "Temperature_Celsius":
89
        case "Temperature_Celsius":
86
            this.Reference= canMessage.getData("Value");
90
            this.Reference= canMessage.getData("Value");
-
 
91
log("PID status: ref:" + this.Reference + "\n");
87
            //this.callEvent("newValue", canMessage.getData("Id"));
92
            //this.callEvent("newValue", canMessage.getData("Id"));
88
        break;
93
        break;
89
        case "Report_Interval":
94
        case "Report_Interval":
90
            this.myReportInterval = canMessage.getData("Time");
95
            this.myReportInterval = canMessage.getData("Time");
91
        break;
96
        break;
Line 94... Line 99...
94
    this.CanService.prototype.canMessageHandler.call(this, canMessage);
99
    this.CanService.prototype.canMessageHandler.call(this, canMessage);
95
}
100
}
96
 
101
 
97
PID.prototype.setValue = function(temperature)
102
PID.prototype.setValue = function(temperature)
98
{
103
{
-
 
104
log ("Called SetValue: "+temperature+"\n");
99
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Temperature_Celsius");
105
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Temperature_Celsius");
100
    canMessage.setData("Value", temperature);
106
    canMessage.setData("Value", ""+temperature);
101
    canMessage.setData("SensorId", 0);
107
    canMessage.setData("SensorId", 0);
-
 
108
log ("> "+canMessage.toString()+"\n");
-
 
109
    sendMessage(canMessage);
-
 
110
 
-
 
111
 
-
 
112
}
-
 
113
 
-
 
114
PID.prototype.getConfiguration = function()
-
 
115
{
-
 
116
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "CONFIG_SENSOR");
-
 
117
    sendMessage(canMessage);
-
 
118
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "CONFIG_ACTUATOR");
-
 
119
    sendMessage(canMessage);
-
 
120
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "CONFIG_PARAMETER");
-
 
121
    sendMessage(canMessage);
-
 
122
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "Report_Interval");
-
 
123
    sendMessage(canMessage);
-
 
124
}
-
 
125
 
-
 
126
PID.prototype.setParameters = function(KP,KI,KD,Time,Unit)
-
 
127
{
-
 
128
    var canMessage = new CanMessage("act", "To_Owner", this.myName, this.myId, "CONFIG_PARAMETER");
-
 
129
    canMessage.setData("K_P", ""+KP);
-
 
130
    canMessage.setData("K_I", ""+KI);
-
 
131
    canMessage.setData("K_D", ""+KD);
-
 
132
    canMessage.setData("RegulatorTime", ""+Time);
-
 
133
    canMessage.setData("TimeUnit", ""+Unit);
-
 
134
//log ("> "+canMessage.toString()+"\n");
102
    sendMessage(canMessage);
135
    sendMessage(canMessage);
103
}
136
}
104
 
137
 
105
 
138
 
106
PID.prototype.setReportInterval = function(time)
139
PID.prototype.setReportInterval = function(time)