Skip to content

Commit

Permalink
[clearPlanner] fix issue of NerlPlanner - "Clear" Button
Browse files Browse the repository at this point in the history
  • Loading branch information
NoaShapira8 committed May 17, 2024
1 parent eaa87f8 commit 40e854c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
45 changes: 45 additions & 0 deletions src_py/nerlPlanner/Handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)



7 changes: 6 additions & 1 deletion src_py/nerlPlanner/JsonDistributedConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 40e854c

Please sign in to comment.