Rev 2280 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2280 | Rev 2300 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | PID_ActModuleNames = [ "hwPWM", "softPWM", "SlowPWM", "PCAPWM" ]; |
4 | PID_ActModuleNames = [ "hwPWM", "softPWM", "SlowPWM", "PCAPWM" ]; |
| 5 | 5 | PID_Algos = function() { return [ "ZIEGLER_NICHOLS_PI", "ZIEGLER_NICHOLS_PID", "TYREUS_LUYBEN_PI", "TYREUS_LUYBEN_PID", "CIANCONE_MARLIN_PI", "CIANCONE_MARLIN_PID", "AMIGOF_PI", "PESSEN_INTEGRAL_PID", "SOME_OVERSHOOT_PID", "NO_OVERSHOOT_PID" , "STOP" ]; }; |
|
| 6 | PID_Intervals = function() { return [ 1, 5, 10, 15, 20 ]; }; |
6 | PID_Intervals = function() { return [ 1, 5, 10, 15, 20 ]; }; |
| 7 |
|
7 | PID_Outputs = function() { return [ 0, 500, 1000, 5000, 10000 ]; }; |
| 8 | PID_Temperatures = function() { return [ 20, 25, 30, 35 ]; }; |
8 | PID_Temperatures = function() { return [ 20, 25, 30, 35 ]; }; |
| 9 | PID_Constants = function() { return [ 0, 0.1, 0.5, 1, 10, 100, 1000 ]; }; |
9 | PID_Constants = function() { return [ 0, 0.1, 0.5, 1, 10, 100, 1000 ]; }; |
| - | 10 | PID_LookBackTimes = function() { return [ 0, 1, 10, 100, 255 ]; }; |
|
| 10 | PID_TimeUnits = function() { return [ "s", "ms"]; }; |
11 | PID_TimeUnits = function() { return [ "s", "ms"]; }; |
| 11 | PID_ControllerDirection = function() { return [ "direct", "reverse"]; }; |
12 | PID_ControllerDirection = function() { return [ "direct", "reverse"]; }; |
| 12 | PID_Times = function() { return [ 1, 5, 10, 15, 20, 40, 60]; }; |
13 | PID_Times = function() { return [ 1, 5, 10, 15, 20, 40, 60]; }; |
| 13 | PID_Aliases = function() { return Module_GetAliasNames(PID_ModuleNames); }; |
14 | PID_Aliases = function() { return Module_GetAliasNames(PID_ModuleNames); }; |
| 14 | PID_AvailableIds = function() { return Module_GetAvailableIds(PID_ModuleNames); }; |
15 | PID_AvailableIds = function() { return Module_GetAvailableIds(PID_ModuleNames); }; |
| 15 | PID_SensorAliases = function() { return Module_GetAliasNames(PID_SensorModuleNames); }; |
16 | PID_SensorAliases = function() { return Module_GetAliasNames(PID_SensorModuleNames); }; |
| 16 | PID_ActAliases = function() { return Module_GetAliasNames(PID_ActModuleNames); }; |
17 | PID_ActAliases = function() { return Module_GetAliasNames(PID_ActModuleNames); }; |
| 17 | 18 | ||
| 18 | function PID_SetReportInterval(alias_name, interval) |
19 | function PID_SetReportInterval(alias_name, interval) |
| 19 | { |
20 | { |
| 20 | if (arguments.length < 2) |
21 | if (arguments.length < 2) |
| 21 | { |
22 | { |
| 22 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
23 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 23 | return false; |
24 | return false; |
| 24 | } |
25 | } |
| 25 | 26 | ||
| 26 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
27 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 27 | var found = false; |
28 | var found = false; |
| 28 | 29 | ||
| Line 31... | Line 32... | ||
| 31 | var variables = {"Time" : interval }; |
32 | var variables = {"Time" : interval }; |
| 32 | 33 | ||
| 33 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
34 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
| 34 | { |
35 | { |
| 35 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
36 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 36 | } |
37 | } |
| 37 | else |
38 | else |
| 38 | { |
39 | { |
| 39 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
40 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 40 | } |
41 | } |
| 41 | 42 | ||
| 42 | found = true; |
43 | found = true; |
| 43 | } |
44 | } |
| 44 | 45 | ||
| Line 49... | Line 50... | ||
| 49 | } |
50 | } |
| 50 | 51 | ||
| 51 | return true; |
52 | return true; |
| 52 | } |
53 | } |
| 53 | Console_RegisterCommand(PID_SetReportInterval, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Intervals()); }); |
54 | Console_RegisterCommand(PID_SetReportInterval, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Intervals()); }); |
| 54 | 55 | ||
| 55 | 56 | ||
| 56 | function PID_setValue(alias_name, temperature) |
57 | function PID_setValue(alias_name, temperature) |
| 57 | { |
58 | { |
| 58 | if (arguments.length < 2) |
59 | if (arguments.length < 2) |
| 59 | { |
60 | { |
| 60 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
61 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| Line 67... | Line 68... | ||
| 67 | 68 | ||
| 68 | for (var name in aliases_data) |
69 | for (var name in aliases_data) |
| 69 | { |
70 | { |
| 70 | var variables = { "Value" : temperature, |
71 | var variables = { "Value" : temperature, |
| 71 | "SensorId" : 0 }; |
72 | "SensorId" : 0 }; |
| 72 | 73 | ||
| 73 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Temperature_Celsius", variables)) |
74 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Temperature_Celsius", variables)) |
| 74 | { |
75 | { |
| 75 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
76 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 76 | } |
77 | } |
| 77 | else |
78 | else |
| 78 | { |
79 | { |
| 79 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
80 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 80 | } |
81 | } |
| 81 | 82 | ||
| 82 | found = true; |
83 | found = true; |
| 83 | } |
84 | } |
| 84 | 85 | ||
| 85 | if (!found) |
86 | if (!found) |
| 86 | { |
87 | { |
| 87 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
88 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 88 | return false; |
89 | return false; |
| 89 | } |
90 | } |
| 90 | 91 | ||
| 91 | return true; |
92 | return true; |
| 92 | } |
93 | } |
| 93 | Console_RegisterCommand(PID_setValue, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Temperatures()); }); |
94 | Console_RegisterCommand(PID_setValue, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Temperatures()); }); |
| Line 108... | Line 109... | ||
| 108 | { |
109 | { |
| 109 | if (first == false) |
110 | if (first == false) |
| 110 | { |
111 | { |
| 111 | Log("\033[31mNo sensor by the name " + alias_sensor + " were applicable for this command, or alias was a group.\033[0m\n"); |
112 | Log("\033[31mNo sensor by the name " + alias_sensor + " were applicable for this command, or alias was a group.\033[0m\n"); |
| 112 | return false; |
113 | return false; |
| 113 | } |
114 | } |
| 114 | Log ("Called Set Sensor:\n"); |
115 | Log ("Called Set Sensor:\n"); |
| 115 | Log ("sensorModuleType: " + sensor_aliases_data[sensor]["module_name"]+"\n"); |
116 | Log ("sensorModuleType: " + sensor_aliases_data[sensor]["module_name"]+"\n"); |
| 116 | Log ("sensorModuleId: " + sensor_aliases_data[sensor]["module_id"]+"\n"); |
117 | Log ("sensorModuleId: " + sensor_aliases_data[sensor]["module_id"]+"\n"); |
| 117 | Log ("SensorId: " + sensor_aliases_data[sensor]["specific"]["SensorId"]+"\n"); |
118 | Log ("SensorId: " + sensor_aliases_data[sensor]["specific"]["SensorId"]+"\n"); |
| 118 | var id = 0; |
119 | var id = 0; |
| Line 134... | Line 135... | ||
| 134 | for (var name in aliases_data) |
135 | for (var name in aliases_data) |
| 135 | { |
136 | { |
| 136 | var variables = { "sensorModuleType" : id, |
137 | var variables = { "sensorModuleType" : id, |
| 137 | "sensorModuleId" : sensor_aliases_data[sensor]["module_id"], |
138 | "sensorModuleId" : sensor_aliases_data[sensor]["module_id"], |
| 138 | "sensorId" : sensor_aliases_data[sensor]["specific"]["SensorId"] }; |
139 | "sensorId" : sensor_aliases_data[sensor]["specific"]["SensorId"] }; |
| 139 | 140 | ||
| 140 | 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)) |
| 141 | { |
142 | { |
| 142 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
143 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 143 | } |
144 | } |
| 144 | else |
145 | else |
| 145 | { |
146 | { |
| 146 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
147 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 147 | } |
148 | } |
| 148 | 149 | ||
| 149 | found = true; |
150 | found = true; |
| 150 | } |
151 | } |
| 151 | first = false; |
152 | first = false; |
| 152 | if (!found) |
153 | if (!found) |
| 153 | { |
154 | { |
| 154 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
155 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 155 | return false; |
156 | return false; |
| 156 | } |
157 | } |
| Line 165... | Line 166... | ||
| 165 | return true; |
166 | return true; |
| 166 | } |
167 | } |
| 167 | Console_RegisterCommand(PID_setSensor, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_SensorAliases()); }); |
168 | Console_RegisterCommand(PID_setSensor, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_SensorAliases()); }); |
| 168 | 169 | ||
| 169 | function PID_setActuator(alias_name, alias_actuator) |
170 | function PID_setActuator(alias_name, alias_actuator) |
| 170 | { |
171 | { |
| 171 | if (arguments.length < 2) |
172 | if (arguments.length < 2) |
| 172 | { |
173 | { |
| 173 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
174 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 174 | return false; |
175 | return false; |
| 175 | } |
176 | } |
| Line 201... | Line 202... | ||
| 201 | return; break; |
202 | return; break; |
| 202 | } |
203 | } |
| 203 | 204 | ||
| 204 | 205 | ||
| 205 | for (var name in aliases_data) |
206 | for (var name in aliases_data) |
| 206 | { |
207 | { |
| 207 | var variables = { "actuatorModuleType" : id, |
208 | var variables = { "actuatorModuleType" : id, |
| 208 | "actuatorModuleId" : act_aliases_data[act]["module_id"], |
209 | "actuatorModuleId" : act_aliases_data[act]["module_id"], |
| 209 | "actuatorId" : act_aliases_data[act]["specific"]["Channel"] }; |
210 | "actuatorId" : act_aliases_data[act]["specific"]["Channel"] }; |
| 210 | 211 | ||
| 211 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ACTUATOR", variables)) |
212 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ACTUATOR", variables)) |
| Line 218... | Line 219... | ||
| 218 | } |
219 | } |
| 219 | 220 | ||
| 220 | found = true; |
221 | found = true; |
| 221 | } |
222 | } |
| 222 | first = false; |
223 | first = false; |
| 223 | if (!found) |
224 | if (!found) |
| 224 | { |
225 | { |
| 225 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
226 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| - | 227 | return false; |
|
| - | 228 | } |
|
| - | 229 | } |
|
| - | 230 | ||
| - | 231 | if (!found) |
|
| - | 232 | { |
|
| - | 233 | Log("\033[31mNo actuator aliases by the name " + alias_actuator + " were applicable for this command.\033[0m\n"); |
|
| 226 | return false; |
234 | return false; |
| 227 | } |
- | |
| 228 | } |
235 | } |
| 229 | 236 | ||
| 230 | if (!found) |
- | |
| 231 | { |
- | |
| 232 | Log("\033[31mNo actuator aliases by the name " + alias_actuator + " were applicable for this command.\033[0m\n"); |
- | |
| 233 | return false; |
- | |
| 234 | } |
- | |
| 235 | - | ||
| 236 | return true; |
237 | return true; |
| 237 | } |
238 | } |
| 238 | Console_RegisterCommand(PID_setActuator, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_ActAliases()); }); |
239 | Console_RegisterCommand(PID_setActuator, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_ActAliases()); }); |
| 239 | 240 | ||
| 240 | 241 | ||
| 241 | function PID_setParameters(alias_name, KP,KI,KD,Time,Unit,ControllerDirection) |
242 | function PID_setParameters(alias_name, KP,KI,KD,Time,Unit,ControllerDirection) |
| 242 | { |
243 | { |
| 243 | if (arguments.length < 6) |
244 | if (arguments.length < 6) |
| Line 263... | Line 264... | ||
| 263 | "TimeUnit" : Unit }; |
264 | "TimeUnit" : Unit }; |
| 264 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
265 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
| 265 | { |
266 | { |
| 266 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
267 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
| 267 | Log("\033[32mK_P = " + KP + "K_I = " + KI + "K_D = " + KD + "RegTime = " + Time + "Unit = " + Unit + ".\033[0m\n"); |
268 | Log("\033[32mK_P = " + KP + "K_I = " + KI + "K_D = " + KD + "RegTime = " + Time + "Unit = " + Unit + ".\033[0m\n"); |
| 268 | } |
269 | } |
| 269 | else |
270 | else |
| 270 | { |
271 | { |
| 271 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
272 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 272 | } |
273 | } |
| 273 | 274 | ||
| 274 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_P_I", variables_P_I)) |
275 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_P_I", variables_P_I)) |
| 275 | { |
276 | { |
| 276 | Log("\033[32mK_P = " + KP + "K_I = " + KI + ".\033[0m\n"); |
277 | Log("\033[32mK_P = " + KP + "K_I = " + KI + ".\033[0m\n"); |
| 277 | } |
- | |
| 278 | else |
- | |
| 279 | { |
- | |
| 280 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
- | |
| 281 | } |
- | |
| 282 | - | ||
| 283 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_D_T", variables_D_T)) |
- | |
| 284 | { |
- | |
| 285 | Log("\033[32mK_D = " + KD + " RegTime = " + Time + " Unit = " + Unit + " Direction = " + ControllerDirection +".\033[0m\n"); |
- | |
| 286 | } |
278 | } |
| 287 | else |
279 | else |
| 288 | { |
280 | { |
| 289 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
281 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 290 | } |
282 | } |
| 291 | 283 | ||
| 292 | found = true; |
- | |
| 293 | } |
- | |
| 294 | - | ||
| 295 | if (!found) |
- | |
| - | 284 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_D_T", variables_D_T)) |
|
| 296 | { |
285 | { |
| 297 | Log( |
286 | Log("\033[32mK_D = " + KD + " RegTime = " + Time + " Unit = " + Unit + " Direction = " + ControllerDirection +".\033[0m\n"); |
| 298 | return false; |
- | |
| 299 | } |
287 | } |
| - | 288 | else |
|
| - | 289 | { |
|
| - | 290 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| - | 291 | } |
|
| - | 292 | ||
| - | 293 | found = true; |
|
| - | 294 | } |
|
| 300 | 295 | ||
| - | 296 | if (!found) |
|
| - | 297 | { |
|
| - | 298 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
|
| - | 299 | return false; |
|
| - | 300 | } |
|
| - | 301 | ||
| 301 | return true; |
302 | return true; |
| 302 | } |
303 | } |
| 303 | Console_RegisterCommand(PID_setParameters, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Constants(), PID_Constants(), PID_Constants(), PID_Times(), PID_TimeUnits(), PID_ControllerDirection()); }); |
304 | Console_RegisterCommand(PID_setParameters, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Constants(), PID_Constants(), PID_Constants(), PID_Times(), PID_TimeUnits(), PID_ControllerDirection()); }); |
| 304 | 305 | ||
| 305 | 306 | ||
| 306 | function PID_setOutputMaxMin(alias_name, Max,Min) |
307 | function PID_setOutputMaxMin(alias_name, Max,Min) |
| 307 | { |
308 | { |
| 308 | if (arguments.length < 3) |
309 | if (arguments.length < 3) |
| 309 | { |
310 | { |
| 310 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
311 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 311 | return false; |
312 | return false; |
| 312 | } |
313 | } |
| 313 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
314 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 314 | var found = false; |
315 | var found = false; |
| 315 | 316 | ||
| 316 | for (var name in aliases_data) |
317 | for (var name in aliases_data) |
| 317 | { |
318 | { |
| 318 | var variables = { "Min" : Min, |
319 | var variables = { "Min" : Min, |
| 319 | "Max" : Max }; |
320 | "Max" : Max }; |
| 320 | 321 | ||
| 321 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "OutMinMax", variables)) |
322 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "OutMinMax", variables)) |
| 322 | { |
323 | { |
| 323 | Log("\033[32mMin = " + Min + "Max = " + Max + ".\033[0m\n"); |
324 | Log("\033[32mMin = " + Min + "Max = " + Max + ".\033[0m\n"); |
| 324 | } |
325 | } |
| 325 | else |
326 | else |
| 326 | { |
327 | { |
| 327 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
328 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 328 | } |
329 | } |
| 329 | 330 | ||
| 330 | found = true; |
331 | found = true; |
| 331 | } |
332 | } |
| 332 | 333 | ||
| 333 | if (!found) |
334 | if (!found) |
| 334 | { |
335 | { |
| 335 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
336 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 336 | return false; |
337 | return false; |
| 337 | } |
338 | } |
| 338 | 339 | ||
| 339 | return true; |
340 | return true; |
| 340 | } |
341 | } |
| 341 | Console_RegisterCommand(PID_setOutputMaxMin, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), |
342 | Console_RegisterCommand(PID_setOutputMaxMin, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Outputs(), PID_Outputs()); }); |
| 342 | 343 | ||
| 343 | function PID_getConfiguration(alias_name) |
344 | function PID_getConfiguration(alias_name) |
| 344 | { |
345 | { |
| 345 | if (arguments.length < 1) |
346 | if (arguments.length < 1) |
| 346 | { |
347 | { |
| 347 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
348 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 348 | return false; |
349 | return false; |
| 349 | } |
350 | } |
| Line 361... | Line 362... | ||
| 361 | else |
362 | else |
| 362 | { |
363 | { |
| 363 | Log("\033[31mFailed to send command 1 to " + name + ".\033[0m\n"); |
364 | Log("\033[31mFailed to send command 1 to " + name + ".\033[0m\n"); |
| 364 | } |
365 | } |
| 365 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ACTUATOR", variables)) |
366 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ACTUATOR", variables)) |
| 366 | { |
367 | { |
| 367 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
368 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 368 | } |
369 | } |
| 369 | else |
370 | else |
| 370 | { |
371 | { |
| 371 | Log("\033[31mFailed to send command 2 to " + name + ".\033[0m\n"); |
372 | Log("\033[31mFailed to send command 2 to " + name + ".\033[0m\n"); |
| 372 | } |
373 | } |
| 373 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
374 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
| 374 | { |
375 | { |
| 375 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
376 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 376 | } |
377 | } |
| Line 385... | Line 386... | ||
| 385 | else |
386 | else |
| 386 | { |
387 | { |
| 387 | Log("\033[31mFailed to send command 4 to " + name + ".\033[0m\n"); |
388 | Log("\033[31mFailed to send command 4 to " + name + ".\033[0m\n"); |
| 388 | } |
389 | } |
| 389 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_P_I", variables)) |
390 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_P_I", variables)) |
| 390 | { |
391 | { |
| 391 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
392 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 392 | } |
393 | } |
| 393 | else |
394 | else |
| 394 | { |
395 | { |
| 395 | Log("\033[31mFailed to send command 5 to " + name + ".\033[0m\n"); |
396 | Log("\033[31mFailed to send command 5 to " + name + ".\033[0m\n"); |
| 396 | } |
397 | } |
| 397 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_D_T", variables)) |
398 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_D_T", variables)) |
| 398 | { |
399 | { |
| 399 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
400 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 400 | } |
401 | } |
| 401 | else |
402 | else |
| 402 | { |
403 | { |
| 403 | Log("\033[31mFailed to send command 6 to " + name + ".\033[0m\n"); |
404 | Log("\033[31mFailed to send command 6 to " + name + ".\033[0m\n"); |
| 404 | } |
405 | } |
| 405 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "OutMinMax", variables)) |
406 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "OutMinMax", variables)) |
| 406 | { |
407 | { |
| 407 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
408 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| - | 409 | } |
|
| - | 410 | else |
|
| - | 411 | { |
|
| - | 412 | Log("\033[31mFailed to send command 7 to " + name + ".\033[0m\n"); |
|
| - | 413 | } |
|
| - | 414 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "RUN_AUTOTUNE", variables)) |
|
| - | 415 | { |
|
| - | 416 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 417 | } |
|
| - | 418 | else |
|
| - | 419 | { |
|
| - | 420 | Log("\033[31mFailed to send command 8 to " + name + ".\033[0m\n"); |
|
| - | 421 | } |
|
| - | 422 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_AUTOTUNE_NOISE_STEP", variables)) |
|
| - | 423 | { |
|
| - | 424 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 425 | } |
|
| - | 426 | else |
|
| - | 427 | { |
|
| - | 428 | Log("\033[31mFailed to send command 9 to " + name + ".\033[0m\n"); |
|
| - | 429 | } |
|
| - | 430 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PID_START_VALUE", variables)) |
|
| - | 431 | { |
|
| - | 432 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 433 | } |
|
| - | 434 | else |
|
| - | 435 | { |
|
| - | 436 | Log("\033[31mFailed to send command 9 to " + name + ".\033[0m\n"); |
|
| - | 437 | } |
|
| - | 438 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ONOFF_REGULATOR", variables)) |
|
| - | 439 | { |
|
| - | 440 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 441 | } |
|
| - | 442 | else |
|
| - | 443 | { |
|
| - | 444 | Log("\033[31mFailed to send command 9 to " + name + ".\033[0m\n"); |
|
| - | 445 | } |
|
| - | 446 | ||
| - | 447 | found = true; |
|
| - | 448 | } |
|
| - | 449 | ||
| - | 450 | if (!found) |
|
| - | 451 | { |
|
| - | 452 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
|
| - | 453 | return false; |
|
| - | 454 | } |
|
| - | 455 | ||
| - | 456 | return true; |
|
| - | 457 | } |
|
| - | 458 | Console_RegisterCommand(PID_getConfiguration, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases()); }); |
|
| - | 459 | ||
| - | 460 | ||
| - | 461 | ||
| - | 462 | function PID_startAutoTune(alias_name, Algo ,lookbacktime) |
|
| - | 463 | { |
|
| - | 464 | if (arguments.length < 3) |
|
| - | 465 | { |
|
| - | 466 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
|
| - | 467 | return false; |
|
| - | 468 | } |
|
| - | 469 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
|
| - | 470 | var found = false; |
|
| - | 471 | ||
| - | 472 | for (var name in aliases_data) |
|
| - | 473 | { |
|
| - | 474 | var variables= { "Method" : Algo, |
|
| - | 475 | "LookBackTime" : lookbacktime }; |
|
| - | 476 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "RUN_AUTOTUNE", variables)) |
|
| - | 477 | { |
|
| - | 478 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
|
| - | 479 | Log("\033[32mMethod = " + Algo + "LookBackTime = " + lookbacktime + ".\033[0m\n"); |
|
| - | 480 | } |
|
| - | 481 | else |
|
| - | 482 | { |
|
| - | 483 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| - | 484 | } |
|
| - | 485 | ||
| - | 486 | found = true; |
|
| - | 487 | } |
|
| - | 488 | ||
| - | 489 | if (!found) |
|
| - | 490 | { |
|
| - | 491 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
|
| - | 492 | return false; |
|
| - | 493 | } |
|
| - | 494 | ||
| - | 495 | return true; |
|
| - | 496 | } |
|
| - | 497 | Console_RegisterCommand(PID_startAutoTune, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Algos(), PID_LookBackTimes()); }); |
|
| - | 498 | ||
| - | 499 | function PID_AutoTuneNoiceStep(alias_name, NoiseBand ,OutputStep) |
|
| - | 500 | { |
|
| - | 501 | if (arguments.length < 3) |
|
| - | 502 | { |
|
| - | 503 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
|
| - | 504 | return false; |
|
| - | 505 | } |
|
| - | 506 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
|
| - | 507 | var found = false; |
|
| - | 508 | ||
| - | 509 | for (var name in aliases_data) |
|
| - | 510 | { |
|
| - | 511 | var variables= { "NoiseBand" : NoiseBand, |
|
| - | 512 | "OutputStep" : OutputStep }; |
|
| - | 513 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_AUTOTUNE_NOISE_STEP", variables)) |
|
| - | 514 | { |
|
| - | 515 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
|
| - | 516 | Log("\033[32mNoiseBand = " + NoiseBand + "OutputStep = " + OutputStep + ".\033[0m\n"); |
|
| - | 517 | } |
|
| - | 518 | else |
|
| - | 519 | { |
|
| - | 520 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| - | 521 | } |
|
| - | 522 | ||
| - | 523 | found = true; |
|
| - | 524 | } |
|
| - | 525 | ||
| - | 526 | if (!found) |
|
| - | 527 | { |
|
| - | 528 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
|
| - | 529 | return false; |
|
| - | 530 | } |
|
| - | 531 | ||
| - | 532 | return true; |
|
| - | 533 | } |
|
| - | 534 | Console_RegisterCommand(PID_AutoTuneNoiceStep, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Constants(), PID_Constants()); }); |
|
| - | 535 | ||
| - | 536 | ||
| - | 537 | function PID_ConfigStartValue(alias_name, Factor, Offset) |
|
| - | 538 | { |
|
| - | 539 | if (arguments.length < 3) |
|
| - | 540 | { |
|
| - | 541 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
|
| - | 542 | return false; |
|
| - | 543 | } |
|
| - | 544 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
|
| - | 545 | var found = false; |
|
| - | 546 | ||
| - | 547 | for (var name in aliases_data) |
|
| - | 548 | { |
|
| - | 549 | var variables= { "Factor" : Factor, |
|
| - | 550 | "Offset" : Offset}; |
|
| - | 551 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PID_START_VALUE", variables)) |
|
| - | 552 | { |
|
| - | 553 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
|
| - | 554 | Log("\033[32mFactor = " + Factor+ "Offset = " + Offset+ ".\033[0m\n"); |
|
| - | 555 | } |
|
| - | 556 | else |
|
| - | 557 | { |
|
| - | 558 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| 408 | } |
559 | } |
| - | 560 | ||
| - | 561 | found = true; |
|
| - | 562 | } |
|
| - | 563 | ||
| - | 564 | if (!found) |
|
| - | 565 | { |
|
| - | 566 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
|
| - | 567 | return false; |
|
| - | 568 | } |
|
| - | 569 | ||
| - | 570 | return true; |
|
| - | 571 | } |
|
| - | 572 | Console_RegisterCommand(PID_ConfigStartValue, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Constants(), PID_Constants()); }); |
|
| - | 573 | ||
| - | 574 | function PID_ConfigOnOff(alias_name, OnValue, OffValue, OuterRange, InnerRange) |
|
| - | 575 | { |
|
| - | 576 | if (arguments.length < 5) |
|
| - | 577 | { |
|
| - | 578 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
|
| - | 579 | return false; |
|
| - | 580 | } |
|
| - | 581 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
|
| - | 582 | var found = false; |
|
| - | 583 | ||
| - | 584 | for (var name in aliases_data) |
|
| - | 585 | { |
|
| - | 586 | var variables= { "OnValue" : OnValue, |
|
| - | 587 | "OffValue" : OffValue, |
|
| - | 588 | "OuterRange" : OuterRange, |
|
| - | 589 | "InnerRange" : InnerRange}; |
|
| - | 590 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_ONOFF_REGULATOR", variables)) |
|
| - | 591 | { |
|
| - | 592 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
|
| - | 593 | Log("\033[32mOnValue = " + OnValue+ "OffValue= " + OffValue+ "OuterRange= " + OuterRange+ "InnerRange= " + InnerRange+ ".\033[0m\n"); |
|
| - | 594 | } |
|
| 409 | else |
595 | else |
| 410 | { |
596 | { |
| 411 | Log("\033[31mFailed to send command |
597 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 412 | } |
598 | } |
| - | 599 | ||
| 413 | found = true; |
600 | found = true; |
| 414 | } |
601 | } |
| 415 | 602 | ||
| 416 | if (!found) |
603 | if (!found) |
| 417 | { |
604 | { |
| 418 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
605 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 419 | return false; |
606 | return false; |
| 420 | } |
607 | } |
| 421 | 608 | ||
| 422 | return true; |
609 | return true; |
| 423 | } |
610 | } |
| 424 | Console_RegisterCommand( |
611 | Console_RegisterCommand(PID_ConfigOnOff, function(arg_index, args) { return Console_StandardAutocomplete(arg_index, args, PID_Aliases(), PID_Temperatures(), PID_Temperatures(), PID_Outputs(), PID_Outputs()); }); |
| - | 612 | ||
| - | 613 | ||
| 425 | 614 | ||
| 426 | function PID_OnMessage(module_name, module_id, command, variables) |
615 | function PID_OnMessage(module_name, module_id, command, variables) |
| 427 | { |
616 | { |
| 428 | if (in_array(PID_ModuleNames, module_name)) |
617 | if (in_array(PID_ModuleNames, module_name)) |
| 429 | { |
618 | { |
| Line 434... | Line 623... | ||
| 434 | }); |
623 | }); |
| 435 | 624 | ||
| 436 | switch (command) |
625 | switch (command) |
| 437 | { |
626 | { |
| 438 | case "DEBUG": |
627 | case "DEBUG": |
| 439 | for (var alias_name in aliases_data) |
628 | for (var alias_name in aliases_data) |
| 440 | { |
629 | { |
| 441 | var last_value = {}; |
630 | var last_value = {}; |
| 442 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
631 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 443 | 632 | ||
| 444 | if (last_value_string) |
633 | if (last_value_string) |
| 445 | { |
634 | { |
| 446 | last_value = eval("(" + last_value_string + ")"); |
635 | last_value = eval("(" + last_value_string + ")"); |
| 447 | } |
636 | } |
| 448 | 637 | ||
| 449 | 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() }; |
638 | 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() }; |
| Line 544... | Line 733... | ||
| 544 | if (last_value_string) |
733 | if (last_value_string) |
| 545 | { |
734 | { |
| 546 | last_value = eval("(" + last_value_string + ")"); |
735 | last_value = eval("(" + last_value_string + ")"); |
| 547 | } |
736 | } |
| 548 | 737 | ||
| 549 | last_value["Parameters"] = { "value" : { |
738 | last_value["Parameters"] = { "value" : { |
| - | 739 | "K_P" : variables["K_P"], |
|
| - | 740 | "K_I" : variables["K_I"], |
|
| - | 741 | "K_D" : last_value["Parameters"]["value"]["K_D"], |
|
| - | 742 | "ControllerDirection" : last_value["Parameters"]["value"]["ControllerDirection"], |
|
| - | 743 | "TimeUnit" : last_value["Parameters"]["value"]["TimeUnit"], |
|
| - | 744 | "RegulatorTime" : last_value["Parameters"]["value"]["RegulatorTime"], |
|
| - | 745 | "OnValue" : last_value["Parameters"]["value"]["OnValue"], |
|
| - | 746 | "OffValue" : last_value["Parameters"]["value"]["OffValue"] , |
|
| - | 747 | "OuterRange" : last_value["Parameters"]["value"]["OuterRange"] , |
|
| - | 748 | "InnerRange" : last_value["Parameters"]["value"]["InnerRange"] , |
|
| - | 749 | "Factor" : last_value["Parameters"]["value"]["Factor"] , |
|
| - | 750 | "Offset" : last_value["Parameters"]["value"]["Offset"] |
|
| - | 751 | }, "timestamp" : get_time() }; |
|
| 550 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
752 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| - | 753 | //Log("Stored PI"); |
|
| 551 | } |
754 | } |
| - | 755 | break; |
|
| 552 | case "CONFIG_PARAMETER_D_T": |
756 | case "CONFIG_PARAMETER_D_T": |
| - | 757 | for (var alias_name in aliases_data) |
|
| - | 758 | { |
|
| - | 759 | var last_value = {}; |
|
| - | 760 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
|
| - | 761 | ||
| - | 762 | if (last_value_string) |
|
| - | 763 | { |
|
| - | 764 | last_value = eval("(" + last_value_string + ")"); |
|
| - | 765 | } |
|
| - | 766 | last_value["Parameters"] = { "value" : { |
|
| - | 767 | "K_P" : last_value["Parameters"]["value"]["K_P"], |
|
| - | 768 | "K_I" : last_value["Parameters"]["value"]["K_I"], |
|
| - | 769 | "K_D" : variables["K_D"], |
|
| - | 770 | "ControllerDirection" : variables["ControllerDirection"], |
|
| - | 771 | "TimeUnit" : variables["TimeUnit"], |
|
| - | 772 | "RegulatorTime" : variables["RegulatorTime"], |
|
| - | 773 | "OnValue" : last_value["Parameters"]["value"]["OnValue"], |
|
| - | 774 | "OffValue" : last_value["Parameters"]["value"]["OffValue"] , |
|
| - | 775 | "OuterRange" : last_value["Parameters"]["value"]["OuterRange"] , |
|
| - | 776 | "InnerRange" : last_value["Parameters"]["value"]["InnerRange"] , |
|
| - | 777 | "Factor" : last_value["Parameters"]["value"]["Factor"] , |
|
| - | 778 | "Offset" : last_value["Parameters"]["value"]["Offset"] |
|
| - | 779 | }, "timestamp" : get_time() }; |
|
| - | 780 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
|
| - | 781 | //Log("Stored DT for "+ alias_name); |
|
| - | 782 | } |
|
| - | 783 | break; |
|
| - | 784 | case "CONFIG_ONOFF_REGULATOR": |
|
| - | 785 | for (var alias_name in aliases_data) |
|
| - | 786 | { |
|
| - | 787 | var last_value = {}; |
|
| - | 788 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
|
| - | 789 | ||
| - | 790 | if (last_value_string) |
|
| - | 791 | { |
|
| - | 792 | last_value = eval("(" + last_value_string + ")"); |
|
| - | 793 | } |
|
| - | 794 | last_value["Parameters"] = { "value" : { |
|
| - | 795 | "K_P" : last_value["Parameters"]["value"]["K_P"], |
|
| - | 796 | "K_I" : last_value["Parameters"]["value"]["K_I"], |
|
| - | 797 | "K_D" : last_value["Parameters"]["value"]["K_D"], |
|
| - | 798 | "ControllerDirection" : last_value["Parameters"]["value"]["ControllerDirection"], |
|
| - | 799 | "TimeUnit" : last_value["Parameters"]["value"]["TimeUnit"], |
|
| - | 800 | "RegulatorTime" : last_value["Parameters"]["value"]["RegulatorTime"], |
|
| - | 801 | "OnValue" : variables["OnValue"], |
|
| - | 802 | "OffValue" : variables["OffValue"] , |
|
| - | 803 | "OuterRange" : variables["OuterRange"] , |
|
| - | 804 | "InnerRange" : variables["InnerRange"] , |
|
| - | 805 | "Factor" : last_value["Parameters"]["value"]["Factor"] , |
|
| - | 806 | "Offset" : last_value["Parameters"]["value"]["Offset"] |
|
| - | 807 | }, "timestamp" : get_time() }; |
|
| - | 808 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
|
| - | 809 | //Log("Stored DT for "+ alias_name); |
|
| - | 810 | } |
|
| - | 811 | break; |
|
| - | 812 | case "CONFIG_PID_START_VALUE": |
|
| 553 | for (var alias_name in aliases_data) |
813 | for (var alias_name in aliases_data) |
| 554 | { |
814 | { |
| 555 | var last_value = {}; |
815 | var last_value = {}; |
| 556 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
816 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 557 | 817 | ||
| 558 | if (last_value_string) |
818 | if (last_value_string) |
| 559 | { |
819 | { |
| 560 | last_value = eval("(" + last_value_string + ")"); |
820 | last_value = eval("(" + last_value_string + ")"); |
| 561 | } |
821 | } |
| 562 | last_value["Parameters"] = { "value" : { |
822 | last_value["Parameters"] = { "value" : { |
| - | 823 | "K_P" : last_value["Parameters"]["value"]["K_P"], |
|
| - | 824 | "K_I" : last_value["Parameters"]["value"]["K_I"], |
|
| - | 825 | "K_D" : last_value["Parameters"]["value"]["K_D"], |
|
| - | 826 | "ControllerDirection" : last_value["Parameters"]["value"]["ControllerDirection"], |
|
| - | 827 | "TimeUnit" : last_value["Parameters"]["value"]["TimeUnit"], |
|
| - | 828 | "RegulatorTime" : last_value["Parameters"]["value"]["RegulatorTime"], |
|
| - | 829 | "OnValue" : last_value["Parameters"]["value"]["OnValue"], |
|
| - | 830 | "OffValue" : last_value["Parameters"]["value"]["OffValue"] , |
|
| - | 831 | "OuterRange" : last_value["Parameters"]["value"]["OuterRange"] , |
|
| - | 832 | "InnerRange" : last_value["Parameters"]["value"]["InnerRange"] , |
|
| - | 833 | "Factor" : variables["Factor"] , |
|
| - | 834 | "Offset" : variables["Offset"] |
|
| - | 835 | }, "timestamp" : get_time() }; |
|
| 563 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
836 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| - | 837 | //Log("Stored DT for "+ alias_name); |
|
| 564 | } |
838 | } |
| - | 839 | break; |
|
| 565 | case "P_I_term": |
840 | case "P_I_term": |
| 566 | for (var alias_name in aliases_data) |
841 | for (var alias_name in aliases_data) |
| 567 | { |
842 | { |
| 568 | var last_value = {}; |
843 | var last_value = {}; |
| 569 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
844 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 570 | 845 | ||
| 571 | if (last_value_string) |
846 | if (last_value_string) |
| 572 | { |
847 | { |
| 573 | last_value = eval("(" + last_value_string + ")"); |
848 | last_value = eval("(" + last_value_string + ")"); |
| 574 | } |
849 | } |
| 575 | 850 | ||
| 576 | last_value["Debug"] = { "value" : { "P_term" : variables["P_term"],"I_term" : variables["I_term"],"D_term" : last_value["Debug"]["value"]["D_term"],"Output" : last_value["Debug"]["value"]["Output"],"Min" : last_value["Debug"]["value"]["Min"],"Max" : last_value["Debug"]["value"]["Max"] }, "timestamp" : get_time() }; |
851 | last_value["Debug"] = { "value" : { "P_term" : variables["P_term"],"I_term" : variables["I_term"],"D_term" : last_value["Debug"]["value"]["D_term"],"Output" : last_value["Debug"]["value"]["Output"],"Min" : last_value["Debug"]["value"]["Min"],"Max" : last_value["Debug"]["value"]["Max"] }, "timestamp" : get_time() }; |
| 577 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
852 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| Line 587... | Line 862... | ||
| 587 | if (last_value_string) |
862 | if (last_value_string) |
| 588 | { |
863 | { |
| 589 | last_value = eval("(" + last_value_string + ")"); |
864 | last_value = eval("(" + last_value_string + ")"); |
| 590 | } |
865 | } |
| 591 | 866 | ||
| 592 | Log |
867 | //Log("Got message DEBUG"); |
| 593 | 868 | ||
| 594 | last_value["Debug"] = { "value" : { "P_term" : last_value["Debug"]["value"]["P_term"],"I_term" : last_value["Debug"]["value"]["I_term"],"D_term" : variables["D_term"],"Output" : variables["Output"],"Min" : last_value["Debug"]["value"]["Min"],"Max" : last_value["Debug"]["value"]["Max"] }, "timestamp" : get_time() }; |
869 | last_value["Debug"] = { "value" : { "P_term" : last_value["Debug"]["value"]["P_term"],"I_term" : last_value["Debug"]["value"]["I_term"],"D_term" : variables["D_term"],"Output" : variables["Output"],"Min" : last_value["Debug"]["value"]["Min"],"Max" : last_value["Debug"]["value"]["Max"] }, "timestamp" : get_time() }; |
| 595 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
870 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 596 | //Log("Got message DEBUG"); |
871 | //Log("Got message DEBUG"); |
| 597 | } |
872 | } |
| Line 605... | Line 880... | ||
| 605 | if (last_value_string) |
880 | if (last_value_string) |
| 606 | { |
881 | { |
| 607 | last_value = eval("(" + last_value_string + ")"); |
882 | last_value = eval("(" + last_value_string + ")"); |
| 608 | } |
883 | } |
| 609 | 884 | ||
| 610 | last_value["Debug"] = { "value" : { |
885 | last_value["Debug"] = { "value" : { |
| - | 886 | "P_term" : last_value["Debug"]["value"]["P_term"], |
|
| - | 887 | "I_term" : last_value["Debug"]["value"]["I_term"], |
|
| - | 888 | "D_term" : last_value["Debug"]["value"]["D_term"], |
|
| - | 889 | "Output" : last_value["Debug"]["value"]["Output"], |
|
| - | 890 | "Min" : variables["Min"], |
|
| - | 891 | "Max" : variables["Max"] |
|
| - | 892 | },"timestamp" : get_time() }; |
|
| 611 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
893 | Storage_SetParameter("LastValues", alias_name, JSON.stringify(last_value)); |
| 612 | //Log("Got message DEBUG"); |
894 | //Log("Got message DEBUG"); |
| 613 | } |
895 | } |
| 614 | break; |
896 | break; |
| 615 | } |
897 | } |
| 616 | } |
898 | } |
| 617 | } |
899 | } |
| 618 | Module_RegisterToOnMessage("all", PID_OnMessage); |
900 | Module_RegisterToOnMessage("all", PID_OnMessage); |
| - | 901 | /*PID={"rrd":{"file":"/var/www/CANgraph/PID.rrd","Period_s":"10"}, "rrdNames":{"Pterm":{"Module":"PID","data":"Debug","value":"P_term"},"Iterm":{"Module":"PID","data":"Debug","value":"I_term"}."Dterm":{"Module":"PID","data":"Debug","value":"D_term"},"KP":{"Module":"PID","data":"Parameters","value":"K_P"},"KI":{"Module":"PID","data":"Parameters","value":"K_I"},"KD":{"Module":"PID","data":"Parameters","value":"K_D"},"out":{"Module":"PID","data":"Debug","value":"Output"},"ref":{"Module":"PID","data":"Reference","value":"value"},"in":{"Module":"PID","data":"PID_status","value":"Measurment"}}}*/ |
|