modbus/web_settings.py
changeset 2675 3ca5611d6308
parent 2673 80e7eb44cab4
child 2676 b276d05bdb09
equal deleted inserted replaced
2674:a8975ff44cd1 2675:3ca5611d6308
   213 
   213 
   214 
   214 
   215 
   215 
   216 def _SetSavedConfiguration(WebNode_id, newConfig):
   216 def _SetSavedConfiguration(WebNode_id, newConfig):
   217     """ Stores a dictionary in a persistant file containing the Modbus parameter configuration """
   217     """ Stores a dictionary in a persistant file containing the Modbus parameter configuration """
   218     
   218     WebNode_entry = _WebNodeList[WebNode_id]
   219     # Add the addr_type and node_type to the data that will be saved to file
   219 
   220     # This allows us to confirm the saved data contains the correct addr_type
   220     if WebNode_entry["DefaultConfiguration"] == newConfig:
   221     # when loading from file
   221 
   222     save_info = {}
   222         _DelSavedConfiguration(WebNode_id)
   223     save_info["addr_type"] = _WebNodeList[WebNode_id]["addr_type"]
   223         WebNode_entry["SavedConfiguration"] = None
   224     save_info["node_type"] = _WebNodeList[WebNode_id]["node_type"]
   224 
   225     save_info["config"   ] = newConfig
   225     else:
   226     
   226 
   227     filename = _WebNodeList[WebNode_id]["filename"]
   227         # Add the addr_type and node_type to the data that will be saved to file
   228 
   228         # This allows us to confirm the saved data contains the correct addr_type
   229     with open(os.path.realpath(filename), 'w') as f:
   229         # when loading from file
   230         json.dump(save_info, f, sort_keys=True, indent=4)
   230         save_info = {}
       
   231         save_info["addr_type"] = ["addr_type"]
       
   232         save_info["node_type"] = WebNode_entry["node_type"]
       
   233         save_info["config"   ] = newConfig
   231         
   234         
   232     _WebNodeList[WebNode_id]["SavedConfiguration"] = newConfig
   235         filename = WebNode_entry["filename"]
       
   236 
       
   237         with open(os.path.realpath(filename), 'w') as f:
       
   238             json.dump(save_info, f, sort_keys=True, indent=4)
       
   239             
       
   240         WebNode_entry["SavedConfiguration"] = newConfig
   233 
   241 
   234 
   242 
   235 
   243 
   236 
   244 
   237 def _DelSavedConfiguration(WebNode_id):
   245 def _DelSavedConfiguration(WebNode_id):