modbus/web_settings.py
changeset 2719 745b64e7c695
parent 2703 32ffdb32b14e
child 3163 7cf38cd0d820
equal deleted inserted replaced
2718:76e8ec46828a 2719:745b64e7c695
   181     #                                                                       annotate.Integer, ...)
   181     #                                                                       annotate.Integer, ...)
   182     ("device"           , _("Serial Port")           , ctypes.c_char_p,    MB_StrippedString),
   182     ("device"           , _("Serial Port")           , ctypes.c_char_p,    MB_StrippedString),
   183     ("baud"             , _("Baud Rate")             , ctypes.c_int,       MB_Baud         ),
   183     ("baud"             , _("Baud Rate")             , ctypes.c_int,       MB_Baud         ),
   184     ("parity"           , _("Parity")                , ctypes.c_int,       MB_Parity       ),
   184     ("parity"           , _("Parity")                , ctypes.c_int,       MB_Parity       ),
   185     ("stop_bits"        , _("Stop Bits")             , ctypes.c_int,       MB_StopBits     ),
   185     ("stop_bits"        , _("Stop Bits")             , ctypes.c_int,       MB_StopBits     ),
   186     ("slave_id"         , _("Slave ID")              , ctypes.c_ulonglong, annotate.Integer)
   186     ("slave_id"         , _("Slave ID")              , ctypes.c_ubyte,     annotate.Integer)
   187     ]
   187     ]
   188 
   188 
   189 
   189 
   190 
   190 
   191 
   191 
   226 
   226 
   227         # Add the addr_type and node_type to the data that will be saved to file
   227         # Add the addr_type and node_type to the data that will be saved to file
   228         # This allows us to confirm the saved data contains the correct addr_type
   228         # This allows us to confirm the saved data contains the correct addr_type
   229         # when loading from file
   229         # when loading from file
   230         save_info = {}
   230         save_info = {}
   231         save_info["addr_type"] = ["addr_type"]
   231         save_info["addr_type"] = WebNode_entry["addr_type"]
   232         save_info["node_type"] = WebNode_entry["node_type"]
   232         save_info["node_type"] = WebNode_entry["node_type"]
   233         save_info["config"   ] = newConfig
   233         save_info["config"   ] = newConfig
   234         
   234         
   235         filename = WebNode_entry["filename"]
   235         filename = WebNode_entry["filename"]
   236 
   236 
   260     addr_type of the WebNode_id), then return None
   260     addr_type of the WebNode_id), then return None
   261     """
   261     """
   262     filename = _WebNodeList[WebNode_id]["filename"]
   262     filename = _WebNodeList[WebNode_id]["filename"]
   263     try:
   263     try:
   264         #if os.path.isfile(filename):
   264         #if os.path.isfile(filename):
   265         save_info = json.load(open(filename))
   265         save_info = json.load(open(os.path.realpath(filename)))
   266     except Exception:    
   266     except Exception:    
   267         return None
   267         return None
   268 
   268 
   269     if save_info["addr_type"] != _WebNodeList[WebNode_id]["addr_type"]:
   269     if save_info["addr_type"] != _WebNodeList[WebNode_id]["addr_type"]:
   270         return None
   270         return None
   524         __OnButtonReset)
   524         __OnButtonReset)
   525 
   525 
   526 
   526 
   527 
   527 
   528 
   528 
   529 def _runtime_modbus_websettings_%(location_str)s_init():
   529 def _runtime_%(location_str)s_modbus_websettings_init():
   530     """
   530     """
   531     Callback function, called (by PLCObject.py) when a new PLC program
   531     Callback function, called (by PLCObject.py) when a new PLC program
   532     (i.e. XXX.so file) is transfered to the PLC runtime
   532     (i.e. XXX.so file) is transfered to the PLC runtime
   533     and loaded into memory
   533     and loaded into memory
   534     """
   534     """
   607 
   607 
   608 
   608 
   609 
   609 
   610 
   610 
   611 
   611 
   612 def _runtime_modbus_websettings_%(location_str)s_cleanup():
   612 def _runtime_%(location_str)s_modbus_websettings_cleanup():
   613     """
   613     """
   614     Callback function, called (by PLCObject.py) when a PLC program is unloaded from memory
   614     Callback function, called (by PLCObject.py) when a PLC program is unloaded from memory
   615     """
   615     """
   616 
   616 
   617     #PLCObject.LogMessage("Modbus web server extension::OnUnLoadPLC() Called...")
   617     #PLCObject.LogMessage("Modbus web server extension::OnUnLoadPLC() Called...")