Rev 2076 | Rev 2275 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2076 | Rev 2271 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 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_Constants = function() { return [ 0, 0.1, 0.5, 1, 10, 100, 1000 ]; }; |
|
| - | 7 | PID_TimeUnits = function() { return [ "s", "ms"]; }; |
|
| - | 8 | PID_Times = function() { return [ 1, 5, 10, 15, 20, 40, 60]; }; |
|
| 6 | PID_Aliases = function() { return Module_GetAliasNames(PID_ModuleNames); }; |
9 | PID_Aliases = function() { return Module_GetAliasNames(PID_ModuleNames); }; |
| 7 | PID_AvailableIds = function() { return Module_GetAvailableIds(PID_ModuleNames); }; |
10 | PID_AvailableIds = function() { return Module_GetAvailableIds(PID_ModuleNames); }; |
| 8 | 11 | ||
| 9 | function PID_SetReportInterval(alias_name, interval) |
12 | function PID_SetReportInterval(alias_name, interval) |
| 10 | { |
13 | { |
| Line 99... | Line 102... | ||
| 99 | var variables = { "K_P" : KP, |
102 | var variables = { "K_P" : KP, |
| 100 | "K_I" : KI, |
103 | "K_I" : KI, |
| 101 | "K_D" : KD, |
104 | "K_D" : KD, |
| 102 | "RegulatorTime" : Time, |
105 | "RegulatorTime" : Time, |
| 103 | "TimeUnit" : Unit }; |
106 | "TimeUnit" : Unit }; |
| - | 107 | var variables_P_I = { "K_P" : KP, |
|
| 104 | 108 | "K_I" : KI }; |
|
| - | 109 | var variables_D_T = { "K_D" : KD, |
|
| - | 110 | "RegulatorTime" : Time, |
|
| - | 111 | "TimeUnit" : Unit }; |
|
| 105 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
112 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
| 106 | { |
113 | { |
| 107 | Log("\033[32mCommand sent successfully to " + name + ".\033[0m"); |
114 | 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"); |
115 | Log("\033[32mK_P = " + KP + "K_I = " + KI + "K_D = " + KD + "RegTime = " + Time + "Unit = " + Unit + ".\033[0m\n"); |
| - | 116 | } |
|
| - | 117 | else |
|
| - | 118 | { |
|
| - | 119 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| - | 120 | } |
|
| - | 121 | ||
| - | 122 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_P_I", variables_P_I)) |
|
| - | 123 | { |
|
| - | 124 | Log("\033[32mK_P = " + KP + "K_I = " + KI + ".\033[0m\n"); |
|
| - | 125 | } |
|
| - | 126 | else |
|
| - | 127 | { |
|
| - | 128 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
|
| - | 129 | } |
|
| - | 130 | ||
| - | 131 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_D_T", variables_D_T)) |
|
| - | 132 | { |
|
| - | 133 | Log("\033[32mK_D = " + KD + "RegTime = " + Time + "Unit = " + Unit + ".\033[0m\n"); |
|
| 109 | } |
134 | } |
| 110 | else |
135 | else |
| 111 | { |
136 | { |
| 112 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
137 | Log("\033[31mFailed to send command to " + name + ".\033[0m\n"); |
| 113 | } |
138 | } |
| Line 116... | Line 141... | ||
| 116 | } |
141 | } |
| 117 | 142 | ||
| 118 | if (!found) |
143 | if (!found) |
| 119 | { |
144 | { |
| 120 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
145 | Log("\033[31mNo aliases by the name " + alias_name + " were applicable for this command.\033[0m\n"); |
| 121 | return false; |
146 | return false; |
| 122 | } |
147 | } |
| 123 | 148 | ||
| 124 | return true; |
149 | return true; |
| 125 | } |
150 | } |
| - | 151 | 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()); }); |
|
| 126 | 152 | ||
| 127 | function PID_getConfiguration(alias_name) |
153 | function PID_getConfiguration(alias_name) |
| 128 | { |
154 | { |
| 129 | if (arguments.length < 1) |
155 | if (arguments.length < 1) |
| 130 | { |
156 | { |
| 131 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
157 | Log("\033[31mNot enough parameters given.\033[0m\n"); |
| 132 | return false; |
158 | return false; |
| 133 | } |
159 | } |
| 134 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
160 | var aliases_data = Module_ResolveAlias(alias_name, PID_ModuleNames); |
| 135 | var found = false; |
161 | var found = false; |
| 136 | 162 | ||
| 137 | for (var name in aliases_data) |
163 | for (var name in aliases_data) |
| 138 | { |
164 | { |
| 139 | var variables = {}; |
165 | var variables = {}; |
| 140 | 166 | ||
| 141 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_SENSOR", variables)) |
167 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_SENSOR", variables)) |
| 142 | { |
168 | { |
| 143 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
169 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| Line 151... | Line 177... | ||
| 151 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
177 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 152 | } |
178 | } |
| 153 | else |
179 | else |
| 154 | { |
180 | { |
| 155 | Log("\033[31mFailed to send command 2 to " + name + ".\033[0m\n"); |
181 | Log("\033[31mFailed to send command 2 to " + name + ".\033[0m\n"); |
| 156 | } |
182 | } |
| 157 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
183 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER", variables)) |
| 158 | { |
184 | { |
| 159 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
185 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 160 | } |
186 | } |
| 161 | else |
187 | else |
| 162 | { |
188 | { |
| 163 | Log("\033[31mFailed to send command 3 to " + name + ".\033[0m\n"); |
189 | Log("\033[31mFailed to send command 3 to " + name + ".\033[0m\n"); |
| 164 | } |
190 | } |
| 165 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
191 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "Report_Interval", variables)) |
| - | 192 | { |
|
| - | 193 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 194 | } |
|
| - | 195 | else |
|
| - | 196 | { |
|
| - | 197 | Log("\033[31mFailed to send command 4 to " + name + ".\033[0m\n"); |
|
| - | 198 | } |
|
| - | 199 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_P_I", variables)) |
|
| - | 200 | { |
|
| - | 201 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
|
| - | 202 | } |
|
| - | 203 | else |
|
| - | 204 | { |
|
| - | 205 | Log("\033[31mFailed to send command 5 to " + name + ".\033[0m\n"); |
|
| - | 206 | } |
|
| - | 207 | if (Module_SendMessage(aliases_data[name]["module_name"], aliases_data[name]["module_id"], "CONFIG_PARAMETER_D_T", variables)) |
|
| 166 | { |
208 | { |
| 167 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
209 | //Log("\033[32mCommand sent successfully to " + name + ".\033[0m\n"); |
| 168 | } |
210 | } |
| 169 | else |
211 | else |
| 170 | { |
212 | { |
| 171 | Log("\033[31mFailed to send command |
213 | Log("\033[31mFailed to send command 6 to " + name + ".\033[0m\n"); |
| 172 | } |
214 | } |
| 173 | - | ||
| 174 | found = true; |
215 | found = true; |
| 175 | } |
216 | } |
| 176 | 217 | ||
| 177 | if (!found) |
218 | if (!found) |
| 178 | { |
219 | { |