diff --git a/src_py/nerlPlanner/Handlers.py b/src_py/nerlPlanner/Handlers.py index cbbe146b..34c53f16 100644 --- a/src_py/nerlPlanner/Handlers.py +++ b/src_py/nerlPlanner/Handlers.py @@ -649,6 +649,13 @@ def sync_fields_with_json_dc_inst(window, values): last_workers_list_state_not_occupied = [x for x in last_workers_list_state if x not in json_dc_inst.get_clients_workers()] window[KEY_CLIENTS_WORKERS_LIST_COMBO_BOX].update("", last_workers_list_state_not_occupied) +def dc_json_reset_inputs_ui(window): + global dc_json_import_file + global dc_json_export_file + global json_dc_inst + window[KEY_DC_JSON_IMPORT_INPUT].update('') + window[KEY_DC_JSON_EXPORT_TO_INPUT_DIR].update('') + window[KEY_DC_JSON_EXPORT_TO_INPUT_FILENAME].update('') def dc_json_handler(window, event, values): global dc_json_import_file @@ -682,3 +689,41 @@ def dc_json_handler(window, event, values): json_dc_inst = json_dc_inst_tmp sync_fields_with_json_dc_inst(window, values) + if event == KEY_DC_JSON_CLEAR_BUTTON: + json_dc_inst.clear_nerlplanner() + + #clean settings and special Entities windows + settings_reset_inputs_ui(window) + settings_special_entities_reset_inputs_ui(window) + window[KEY_SETTINGS_MAIN_SERVER_STATUS_BAR].update(f"Main Server, {main_server_inst}, None") + window[KEY_SETTINGS_API_SERVER_STATUS_BAR].update(f"Api Server, {api_server_inst}, None") + window[KEY_SETTINGS_STATUS_BAR].update("") + + #clean dc json window + dc_json_reset_inputs_ui(window) + + #clean clients window + window[KEY_CLIENTS_WORKERS_LIST_COMBO_BOX].update("") + window[KEY_CLIENTS_WORKERS_LIST_BOX_CLIENT_FOCUS].update("") + clients_reset_inputs_ui(window) + + #clean sources window + sources_reset_inputs_ui(window) + + #clean routers window + routers_reset_inputs_ui(window) + + #clean workers window + window[KEY_WORKERS_LIST_BOX].update("") + window[KEY_WORKERS_INFO_BAR].update("") + window[KEY_WORKERS_NAME_INPUT].update("") + window[KEY_WORKERS_INPUT_LOAD_WORKER_PATH].update("") + + #clean devices window + window[KEY_DEVICES_SELECTED_ENTITY_COMBO].update("") + window[KEY_DEVICES_LIST_BOX_DEVICE_ENTITIES].update("") + window[KEY_DEVICES_LIST_BOX_DEVICES].update(json_dc_inst.get_devices_names()) + devices_reset_inputs_ui(window) + + + \ No newline at end of file diff --git a/src_py/nerlPlanner/JsonDistributedConfig.py b/src_py/nerlPlanner/JsonDistributedConfig.py index 97d2e02e..83c1360d 100644 --- a/src_py/nerlPlanner/JsonDistributedConfig.py +++ b/src_py/nerlPlanner/JsonDistributedConfig.py @@ -129,7 +129,8 @@ def add_device(self, device : Device) -> int: def remove_device(self, device_name : str): # device_inst = self.main_dict[KEY_DEVICES][device_name] # device_inst.entities_dict = None - del(self.main_dict[KEY_DEVICES][device_name]) + if device_name in self.main_dict[KEY_DEVICES]: + del(self.main_dict[KEY_DEVICES][device_name]) ENTITIY_TO_DEVICE_ADD_ISSUE_WITH_PORT = -1 @@ -447,4 +448,8 @@ def import_dc_json(self, json_file_path : str) : self.add_device(new_device_loaded) return self.IMPORT_DC_JSON_SUCCESS + + def clear_nerlplanner(self): + self.clear() + self.default_frequency = None \ No newline at end of file