Rev 1765 | Rev 2271 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1765 | Rev 2076 | ||
|---|---|---|---|
| 1 | 1 | ||
| 2 | PID_ModuleNames = [ "PID" ]; |
2 | PID_ModuleNames = [ "PID" ]; |
| 3 | PID_Intervals = function() { return [ 1, 5, 10, 15, 20 ]; }; |
3 | PID_Intervals = function() { return [ 1, 5, 10, 15, 20 ]; }; |
| 4 | //PID_Energy = function() { return [ 0, 500, 1000, 5000, 10000 ]; }; |
4 | //PID_Energy = function() { return [ 0, 500, 1000, 5000, 10000 ]; }; |
| 5 | PID_Temperatures = function() { return [ 20, 25, 30, 35 ]; }; |
5 | PID_Temperatures = function() { return [ 20, 25, 30, 35 ]; }; |
| 6 | PID_Aliases = function() { return Module_GetAliasNames(PID_ModuleNames); }; |
6 | PID_Aliases = function() { return Module_GetAliasNames(PID_ModuleNames); }; |
| 7 | PID_AvailableIds = function() { return Module_GetAvailableIds(PID_ModuleNames); }; |
7 | PID_AvailableIds = function() { return Module_GetAvailableIds(PID_ModuleNames); }; |
| 8 | 8 | ||
| 9 | function PID_SetReportInterval(alias_name, interval) |
9 | function PID_SetReportInterval(alias_name, interval) |
| 10 | { |
10 | { |
| 11 | if (arguments.length < 2) |
11 | if (arguments.length < 2) |
| 12 | { |
12 | { |
| 13 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
13 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 14 | return false; |
14 | return false; |
| 15 | } |
15 | } |
| 16 | 16 | ||
| 17 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
17 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 18 | var found = false; |
18 | var found = false; |
| 19 | 19 | ||
| 20 | for (var name in aliases_data) |
20 | for (var name in aliases_data) |
| 21 | { |
21 | { |
| 22 | var variables = {"Time" : interval }; |
22 | var variables = {"Time" : interval }; |
| 23 | 23 | ||
| 24 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
24 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
| 25 | { |
25 | { |
| 26 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
26 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 27 | } |
27 | } |
| 28 | else |
28 | else |
| 29 | { |
29 | { |
| 30 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
30 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 31 | } |
31 | } |
| 32 | 32 | ||
| 33 | found = true; |
33 | found = true; |
| 34 | } |
34 | } |
| 35 | 35 | ||
| 36 | if (!found) |
36 | if (!found) |
| 37 | { |
37 | { |
| 38 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
38 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 39 | return false; |
39 | return false; |
| 40 | } |
40 | } |
| 41 | 41 | ||
| 42 | return true; |
42 | return true; |
| 43 | } |
43 | } |
| 44 | Console_RegisterCommand(PID_SetReportInterval, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Intervals()); }); |
44 | Console_RegisterCommand(PID_SetReportInterval, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Intervals()); }); |
| 45 | 45 | ||
| 46 | 46 | ||
| 47 | function PID_setValue(alias_name, temperature) |
47 | function PID_setValue(alias_name, temperature) |
| 48 | { |
48 | { |
| 49 | if (arguments.length < 2) |
49 | if (arguments.length < 2) |
| 50 | { |
50 | { |
| 51 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
51 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 52 | return false; |
52 | return false; |
| 53 | } |
53 | } |
| 54 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
54 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 55 | var found = false; |
55 | var found = false; |
| 56 | 56 | ||
| 57 | Log ("Called SetValue: "+temperature+"\n"); |
57 | Log ("Called SetValue: "+temperature+"\n"); |
| 58 | 58 | ||
| 59 | for (var name in aliases_data) |
59 | for (var name in aliases_data) |
| 60 | { |
60 | { |
| 61 | var variables = { "Value" : temperature, |
61 | var variables = { "Value" : temperature, |
| 62 | "SensorId" : 0 }; |
62 | "SensorId" : 0 }; |
| 63 | 63 | ||
| 64 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Temperature_Celsius", variables)) |
64 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Temperature_Celsius", variables)) |
| 65 | { |
65 | { |
| 66 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
66 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 67 | } |
67 | } |
| 68 | else |
68 | else |
| 69 | { |
69 | { |
| 70 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
70 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 71 | } |
71 | } |
| 72 | 72 | ||
| 73 | found = true; |
73 | found = true; |
| 74 | } |
74 | } |
| 75 | 75 | ||
| 76 | if (!found) |
76 | if (!found) |
| 77 | { |
77 | { |
| 78 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
78 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 79 | return false; |
79 | return false; |
| 80 | } |
80 | } |
| 81 | 81 | ||
| 82 | return true; |
82 | return true; |
| 83 | } |
83 | } |
| 84 | Console_RegisterCommand(PID_setValue, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Temperatures()); }); |
84 | Console_RegisterCommand(PID_setValue, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Temperatures()); }); |
| 85 | 85 | ||
| 86 | 86 | ||
| 87 | function PID_setParameters(alias_name, KP,KI,KD,Time,Unit) |
87 | function PID_setParameters(alias_name, KP,KI,KD,Time,Unit) |
| 88 | { |
88 | { |
| 89 | if (arguments.length < 6) |
89 | if (arguments.length < 6) |
| 90 | { |
90 | { |
| 91 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
91 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 92 | return false; |
92 | return false; |
| 93 | } |
93 | } |
| 94 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
94 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 95 | var found = false; |
95 | var found = false; |
| 96 | 96 | ||
| 97 | for (var name in aliases_data) |
97 | for (var name in aliases_data) |
| 98 | { |
98 | { |
| 99 | var variables = { "K_P" : KP, |
99 | var variables = { "K_P" : KP, |
| 100 | "K_I" : KI, |
100 | "K_I" : KI, |
| 101 | "K_D" : KD, |
101 | "K_D" : KD, |
| 102 | "RegulatorTime" : Time, |
102 | "RegulatorTime" : Time, |
| 103 | "TimeUnit" : Unit }; |
103 | "TimeUnit" : Unit }; |
| 104 | 104 | ||
| 105 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
105 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
| 106 | { |
106 | { |
| 107 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
107 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
| 108 | Log("\033[32mK_P = " + KP + "K_I = " + KI + "K_D = " + KD + "RegTime = " + Time + "Unit = " + Unit + ".\033[0m\n"); |
108 | Log("\033[32mK_P = " + KP + "K_I = " + KI + "K_D = " + KD + "RegTime = " + Time + "Unit = " + Unit + ".\033[0m\n"); |
| 109 | } |
109 | } |
| 110 | else |
110 | else |
| 111 | { |
111 | { |
| 112 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
112 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 113 | } |
113 | } |
| 114 | 114 | ||
| 115 | found = true; |
115 | found = true; |
| 116 | } |
116 | } |
| 117 | 117 | ||
| 118 | if (!found) |
118 | if (!found) |
| 119 | { |
119 | { |
| 120 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
120 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 121 | return false; |
121 | return false; |
| 122 | } |
122 | } |
| 123 | 123 | ||
| 124 | return true; |
124 | return true; |
| 125 | } |
125 | } |
| 126 | 126 | ||
| 127 | function PID_getConfiguration(alias_name) |
127 | function PID_getConfiguration(alias_name) |
| 128 | { |
128 | { |
| 129 | if (arguments.length < 1) |
129 | if (arguments.length < 1) |
| 130 | { |
130 | { |
| 131 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
131 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 132 | return false; |
132 | return false; |
| 133 | } |
133 | } |
| 134 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
134 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 135 | var found = false; |
135 | var found = false; |
| 136 | 136 | ||
| 137 | for (var name in aliases_data) |
137 | for (var name in aliases_data) |
| 138 | { |
138 | { |
| 139 | var variables = {}; |
139 | var variables = {}; |
| 140 | 140 | ||
| 141 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_SENSOR", variables)) |
141 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_SENSOR", variables)) |
| 142 | { |
142 | { |
| 143 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
143 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 144 | } |
144 | } |
| 145 | else |
145 | else |
| 146 | { |
146 | { |
| 147 | Log("\033[31mFailed to send command 1 to " + name + ".\033[0m\n"); |
147 | Log("\033[31mFailed to send command 1 to " + name + ".\033[0m\n"); |
| 148 | } |
148 | } |
| 149 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ACTUATOR", variables)) |
149 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ACTUATOR", variables)) |
| 150 | { |
150 | { |
| 151 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
151 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 152 | } |
152 | } |
| 153 | else |
153 | else |
| 154 | { |
154 | { |
| 155 | Log("\033[31mFailed to send command 2 to " + name + ".\033[0m\n"); |
155 | Log("\033[31mFailed to send command 2 to " + name + ".\033[0m\n"); |
| 156 | } |
156 | } |
| 157 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
157 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
| 158 | { |
158 | { |
| 159 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
159 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 160 | } |
160 | } |
| 161 | else |
161 | else |
| 162 | { |
162 | { |
| 163 | Log("\033[31mFailed to send command 3 to " + name + ".\033[0m\n"); |
163 | Log("\033[31mFailed to send command 3 to " + name + ".\033[0m\n"); |
| 164 | } |
164 | } |
| 165 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
165 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
| 166 | { |
166 | { |
| 167 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
167 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 168 | } |
168 | } |
| 169 | else |
169 | else |
| 170 | { |
170 | { |
| 171 | Log("\033[31mFailed to send command 4 to " + name + ".\033[0m\n"); |
171 | Log("\033[31mFailed to send command 4 to " + name + ".\033[0m\n"); |
| 172 | } |
172 | } |
| 173 | 173 | ||
| 174 | found = true; |
174 | found = true; |
| 175 | } |
175 | } |
| 176 | 176 | ||
| 177 | if (!found) |
177 | if (!found) |
| 178 | { |
178 | { |
| 179 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
179 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 180 | return false; |
180 | return false; |
| 181 | } |
181 | } |
| 182 | 182 | ||
| 183 | return true; |
183 | return true; |
| 184 | } |
184 | } |
| 185 | Console_RegisterCommand(PID_getConfiguration, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases()); }); |
185 | Console_RegisterCommand(PID_getConfiguration, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases()); }); |
| 186 | 186 | ||
| 187 | function PID_OnMessage(module_name, module_id, command, variables) |
187 | function PID_OnMessage(module_name, module_id, command, variables) |
| 188 | { |
188 | { |
| 189 | if (in_array(PID_ModuleNames, module_name)) |
189 | if (in_array(PID_ModuleNames, module_name)) |
| 190 | { |
190 | { |
| 191 | var aliases_data = Module_LookupAliases({ |
191 | var aliases_data = Module_LookupAliases({ |
| 192 | "module_name" : module_name, |
192 | "module_name" : module_name, |
| 193 | "module_id" : module_id, |
193 | "module_id" : module_id, |
| 194 | "group" : false |
194 | "group" : false |
| 195 | }); |
195 | }); |
| 196 | 196 | ||
| 197 | switch (command) |
197 | switch (command) |
| 198 | { |
198 | { |
| 199 | case "DEBUG": |
199 | case "DEBUG": |
| 200 | for (var alias_name in aliases_data) |
200 | for (var alias_name in aliases_data) |
| 201 | { |
201 | { |
| 202 | var last_value = {}; |
202 | var last_value = {}; |
| 203 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
203 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 204 | 204 | ||
| 205 | if (last_value_string) |
205 | if (last_value_string) |
| 206 | { |
206 | { |
| 207 | last_value = eval("(" + last_value_string + ")"); |
207 | last_value = eval("(" + last_value_string + ")"); |
| 208 | } |
208 | } |
| 209 | 209 | ||
| 210 | last_value["Debug"] = { " |
210 | last_value["Debug"] = { "value" : { "P_term" : variables["P_term"],"I_term" : variables["I_term"],"D_term" : variables["D_term"],"Sum" : variables["Sum"] }, "timestamp" : get_time() }; |
| 211 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
211 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 212 | //Log("Got message DEBUG"); |
212 | //Log("Got message DEBUG"); |
| 213 | } |
213 | } |
| 214 | break; |
214 | break; |
| 215 | case "CONFIG_SENSOR": |
215 | case "CONFIG_SENSOR": |
| 216 | for (var alias_name in aliases_data) |
216 | for (var alias_name in aliases_data) |
| 217 | { |
217 | { |
| 218 | var last_value = {}; |
218 | var last_value = {}; |
| 219 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
219 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 220 | 220 | ||
| 221 | if (last_value_string) |
221 | if (last_value_string) |
| 222 | { |
222 | { |
| 223 | last_value = eval("(" + last_value_string + ")"); |
223 | last_value = eval("(" + last_value_string + ")"); |
| 224 | } |
224 | } |
| 225 | 225 | ||
| 226 | last_value["Sensor"] = { " |
226 | last_value["Sensor"] = { "value" : { "sensorModuleType" : variables["sensorModuleType"],"sensorModuleId" : variables["sensorModuleId"],"sensorId" : variables["sensorId"] }, "timestamp" : get_time() }; |
| 227 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
227 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 228 | } |
228 | } |
| 229 | break; |
229 | break; |
| 230 | case "CONFIG_ACTUATOR": |
230 | case "CONFIG_ACTUATOR": |
| 231 | for (var alias_name in aliases_data) |
231 | for (var alias_name in aliases_data) |
| 232 | { |
232 | { |
| 233 | var last_value = {}; |
233 | var last_value = {}; |
| 234 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
234 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 235 | 235 | ||
| 236 | if (last_value_string) |
236 | if (last_value_string) |
| 237 | { |
237 | { |
| 238 | last_value = eval("(" + last_value_string + ")"); |
238 | last_value = eval("(" + last_value_string + ")"); |
| 239 | } |
239 | } |
| 240 | 240 | ||
| 241 | last_value["Actuator"] = { " |
241 | last_value["Actuator"] = { "value" : { "actuatorModuleType" : variables["actuatorModuleType"],"actuatorModuleId" : variables["actuatorModuleId"],"actuatorId" : variables["actuatorId"] }, "timestamp" : get_time() }; |
| 242 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
242 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 243 | } |
243 | } |
| 244 | break; |
244 | break; |
| 245 | case "CONFIG_PARAMETER": |
245 | case "CONFIG_PARAMETER": |
| 246 | for (var alias_name in aliases_data) |
246 | for (var alias_name in aliases_data) |
| 247 | { |
247 | { |
| 248 | var last_value = {}; |
248 | var last_value = {}; |
| 249 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
249 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 250 | 250 | ||
| 251 | if (last_value_string) |
251 | if (last_value_string) |
| 252 | { |
252 | { |
| 253 | last_value = eval("(" + last_value_string + ")"); |
253 | last_value = eval("(" + last_value_string + ")"); |
| 254 | } |
254 | } |
| 255 | 255 | ||
| 256 | last_value["Parameters"] = { " |
256 | last_value["Parameters"] = { "value" : { "K_P" : variables["K_P"],"K_I" : variables["K_I"],"K_D" : variables["K_D"],"TimeUnit" : variables["TimeUnit"],"RegulatorTime" : variables["RegulatorTime"] }, "timestamp" : get_time() }; |
| 257 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
257 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 258 | } |
258 | } |
| 259 | break; |
259 | break; |
| 260 | case "PID_STATUS": |
260 | case "PID_STATUS": |
| 261 | for (var alias_name in aliases_data) |
261 | for (var alias_name in aliases_data) |
| 262 | { |
262 | { |
| 263 | var last_value = {}; |
263 | var last_value = {}; |
| 264 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
264 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 265 | 265 | ||
| 266 | if (last_value_string) |
266 | if (last_value_string) |
| 267 | { |
267 | { |
| 268 | last_value = eval("(" + last_value_string + ")"); |
268 | last_value = eval("(" + last_value_string + ")"); |
| 269 | } |
269 | } |
| 270 | 270 | ||
| 271 | last_value["PID_status"] = { " |
271 | last_value["PID_status"] = { "value" : { "Measurment" : variables["Measurment"],"Reference" : variables["Reference"],"PWM" : variables["PWM"],"Sum" : variables["Sum"] }, "timestamp" : get_time() }; |
| 272 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
272 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 273 | } |
273 | } |
| 274 | //log("PID status: mea:" + this.Measurment + " ref:" + this.Reference + " pwm:" + this.PWM/100 + " sum:" + this.Sum + "\n"); |
274 | //log("PID status: mea:" + this.Measurment + " ref:" + this.Reference + " pwm:" + this.PWM/100 + " sum:" + this.Sum + "\n"); |
| 275 | //this.callEvent("newValue", canMessage.getData("Id")); |
275 | //this.callEvent("newValue", canMessage.getData("Id")); |
| 276 | 276 | ||
| 277 | //var self = this; |
277 | //var self = this; |
| 278 | // this.myHTTP.request(function(result, header, content) { self.httpCallback(result, header, content); }, "linuxz.mine.nu/canlogg/add.php?measurment="+ this.Measurment + "&reference="+this.Reference+"&pwm="+this.PWM/100+"&sum="+this.Sum+"&p="+this.K_P+"&i="+this.K_I+"&d="+this.K_D+"&timeunit="+this.TimeUnit+"&pidtime="+this.RegulatorTime+""); |
278 | // this.myHTTP.request(function(result, header, content) { self.httpCallback(result, header, content); }, "linuxz.mine.nu/canlogg/add.php?measurment="+ this.Measurment + "&reference="+this.Reference+"&pwm="+this.PWM/100+"&sum="+this.Sum+"&p="+this.K_P+"&i="+this.K_I+"&d="+this.K_D+"&timeunit="+this.TimeUnit+"&pidtime="+this.RegulatorTime+""); |
| 279 | break; |
279 | break; |
| 280 | case "Temperature_Celsius": |
280 | case "Temperature_Celsius": |
| 281 | for (var alias_name in aliases_data) |
281 | for (var alias_name in aliases_data) |
| 282 | { |
282 | { |
| 283 | var last_value = {}; |
283 | var last_value = {}; |
| 284 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
284 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 285 | 285 | ||
| 286 | if (last_value_string) |
286 | if (last_value_string) |
| 287 | { |
287 | { |
| 288 | last_value = eval("(" + last_value_string + ")"); |
288 | last_value = eval("(" + last_value_string + ")"); |
| 289 | } |
289 | } |
| 290 | 290 | ||
| 291 | last_value["Reference"] = { " |
291 | last_value["Reference"] = { "value" : variables["Value"], "timestamp" : get_time() }; |
| 292 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
292 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 293 | } |
293 | } |
| 294 | break; |
294 | break; |
| 295 | case "Report_Interval": |
295 | case "Report_Interval": |
| 296 | this.myReportInterval = canMessage.getData("Time"); |
296 | this.myReportInterval = canMessage.getData("Time"); |
| 297 | break; |
297 | break; |
| 298 | } |
298 | } |
| 299 | } |
299 | } |
| 300 | } |
300 | } |
| 301 | Module_RegisterToOnMessage("all", PID_OnMessage); |
301 | Module_RegisterToOnMessage("all", PID_OnMessage); |
| 302 | 302 | ||