128 |
128 |
129 |
129 |
130 |
130 |
131 # Parameters we will need to get from the C code, but that will not be shown |
131 # Parameters we will need to get from the C code, but that will not be shown |
132 # on the web interface. Common to all modbus entry types (client/server, tcp/rtu/ascii) |
132 # on the web interface. Common to all modbus entry types (client/server, tcp/rtu/ascii) |
|
133 # |
|
134 # The annotate type entry is basically useless and is completely ignored. |
|
135 # We kee that entry so that this list can later be correctly merged with the |
|
136 # following lists... |
133 General_parameters = [ |
137 General_parameters = [ |
134 # param. name label ctype type annotate type |
138 # param. name label ctype type annotate type |
135 # (C code var name) (used on web interface) (C data type) (web data type) |
139 # (C code var name) (used on web interface) (C data type) (web data type) |
136 # (annotate.String, |
140 # (annotate.String, |
137 # annotate.Integer, ...) |
141 # annotate.Integer, ...) |
208 |
212 |
209 |
213 |
210 |
214 |
211 |
215 |
212 |
216 |
213 #def _CheckPortnumber(port_number): |
|
214 # """ check validity of the port number """ |
|
215 # try: |
|
216 # portnum = int(port_number) |
|
217 # if (portnum < 0) or (portnum > 65535): |
|
218 # raise Exception |
|
219 # except Exception: |
|
220 # return False |
|
221 # |
|
222 # return True |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 #def _CheckConfiguration(BACnetConfig): |
|
228 # res = True |
|
229 # res = res and _CheckPortnumber(BACnetConfig["port_number"]) |
|
230 # res = res and _CheckDeviceID (BACnetConfig["device_id"]) |
|
231 # return res |
|
232 |
|
233 |
|
234 |
|
235 #def _CheckWebConfiguration(BACnetConfig): |
|
236 # res = True |
|
237 # |
|
238 # # check the port number |
|
239 # if not _CheckPortnumber(BACnetConfig["port_number"]): |
|
240 # raise annotate.ValidateError( |
|
241 # {"port_number": "Invalid port number: " + str(BACnetConfig["port_number"])}, |
|
242 # _("Modbus configuration error:")) |
|
243 # res = False |
|
244 # |
|
245 # if not _CheckDeviceID(BACnetConfig["device_id"]): |
|
246 # raise annotate.ValidateError( |
|
247 # {"device_id": "Invalid device ID: " + str(BACnetConfig["device_id"])}, |
|
248 # _("Modbus configuration error:")) |
|
249 # res = False |
|
250 # |
|
251 # return res |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 def _SetSavedConfiguration(WebNode_id, newConfig): |
217 def _SetSavedConfiguration(WebNode_id, newConfig): |
259 """ Stores a dictionary in a persistant file containing the Modbus parameter configuration """ |
218 """ Stores a dictionary in a persistant file containing the Modbus parameter configuration """ |
260 |
219 |
261 # Add the addr_type and node_type to the data that will be saved to file |
220 # Add the addr_type and node_type to the data that will be saved to file |
262 # This allows us to confirm the saved data contains the correct addr_type |
221 # This allows us to confirm the saved data contains the correct addr_type |
419 newConfig[par_name] = value |
378 newConfig[par_name] = value |
420 |
379 |
421 _WebNodeList[WebNode_id]["WebviewConfiguration"] = newConfig |
380 _WebNodeList[WebNode_id]["WebviewConfiguration"] = newConfig |
422 |
381 |
423 # First check if configuration is OK. |
382 # First check if configuration is OK. |
424 ## TODO... |
383 # Note that this is not currently required, as we use drop down choice menus |
|
384 # for baud, parity and sop bits, so the values should always be correct! |
425 #if not _CheckWebConfiguration(newConfig): |
385 #if not _CheckWebConfiguration(newConfig): |
426 # return |
386 # return |
427 |
387 |
428 # store to file the new configuration so that |
388 # store to file the new configuration so that |
429 # we can recoup the configuration the next time the PLC |
389 # we can recoup the configuration the next time the PLC |
430 # has a cold start (i.e. when Beremiz_service.py is retarted) |
390 # has a cold start (i.e. when Beremiz_service.py is retarted) |
431 _SetSavedConfiguration(WebNode_id, newConfig) |
391 _SetSavedConfiguration(WebNode_id, newConfig) |
432 |
392 |