diff --git a/tools/cfg_util/general/__init__.py b/tools/cfg_util/general/__init__.py index 72a817e7..d1f5af3b 100644 --- a/tools/cfg_util/general/__init__.py +++ b/tools/cfg_util/general/__init__.py @@ -14,6 +14,11 @@ DEFAULT_DATA = [ "Hostname", "Hashrate", "Temperature", + "Total Chips", + "Nominal Chips", + "Left Board", + "Center Board", + "Right Board", "Pool User", "Pool 1", "Pool 1 User", diff --git a/tools/cfg_util/layout.py b/tools/cfg_util/layout.py index 1cf2db01..357da401 100644 --- a/tools/cfg_util/layout.py +++ b/tools/cfg_util/layout.py @@ -92,6 +92,15 @@ TABLE_HEADERS = { "Pool User", "Wattage", ], + "BOARDS": [ + "IP", + "Model", + "Total Chips", + "Nominal Chips", + "Left Board", + "Center Board", + "Right Board", + ], "CMD": ["IP", "Model", "Output"], "POOLS_ALL": [ "IP", @@ -117,6 +126,7 @@ TABLE_HEADERS = { TABLE_KEYS = { "table": [ "scan_table", + "boards_table", "pools_table", "pools_1_table", "pools_2_table", @@ -164,6 +174,8 @@ TEMP_COL_WIDTH = 8 USER_COL_WIDTH = 33 WATTAGE_COL_WIDTH = 10 SPLIT_COL_WIDTH = 8 +TOTAL_CHIP_WIDTH = 14 +NOMINAL_CHIP_WIDTH = 16 SCAN_COL_WIDTHS = [ IP_COL_WIDTH, MODEL_COL_WIDTH, @@ -260,6 +272,70 @@ def get_scan_layout(): return scan_layout +def get_boards_layout(): + BOARDS_COL_WIDTHS = [ + IP_COL_WIDTH, + MODEL_COL_WIDTH, + TOTAL_CHIP_WIDTH, + NOMINAL_CHIP_WIDTH, + ] + add_length = TABLE_TOTAL_WIDTH - sum(BOARDS_COL_WIDTHS) + for i in range(3): + BOARDS_COL_WIDTHS.append(round(add_length / 3)) + boards_layout = [ + [sg.Text("", pad=((0, 0), (10, 1)))], + [ + sg.Button( + "ALL", + key="boards_all", + border_width=BTN_BORDER, + disabled_button_color=BTN_DISABLED, + pad=((0, 5), (1, 1)), + ), + sg.Button( + "REFRESH DATA", + key="boards_refresh", + border_width=BTN_BORDER, + disabled_button_color=BTN_DISABLED, + ), + sg.Button( + "OPEN IN WEB", + key="boards_web", + border_width=BTN_BORDER, + disabled_button_color=BTN_DISABLED, + ), + ], + [ + sg.Table( + values=[], + headings=[heading for heading in TABLE_HEADERS["BOARDS"]], + auto_size_columns=False, + max_col_width=15, + justification="center", + key="boards_table", + col_widths=BOARDS_COL_WIDTHS, + background_color=TABLE_BG, + text_color=TABLE_TEXT, + header_background_color=TABLE_HEADERS_COLOR, + header_text_color=TABLE_HEADERS_TEXT_COLOR, + border_width=TABLE_BORDER, + header_border_width=TABLE_HEADER_BORDER, + sbar_trough_color=SCROLLBAR_TROUGH_COLOR, + sbar_background_color=SCROLLBAR_BACKGROUND_COLOR, + sbar_arrow_color=SCROLLBAR_ARROW_COLOR, + sbar_width=SCROLLBAR_WIDTH, + sbar_arrow_width=SCROLLBAR_ARROW_WIDTH, + sbar_relief=SCROLLBAR_RELIEF, + size=(TABLE_TOTAL_WIDTH, TABLE_HEIGHT), + expand_x=True, + enable_click_events=True, + pad=TABLE_PAD, + ) + ], + ] + return boards_layout + + def get_command_layout(): data = sg.TreeData() col_widths = [ @@ -634,6 +710,14 @@ layout = [ pad=TAB_PAD, ) ], + [ + sg.Tab( + "Boards", + get_boards_layout(), + background_color=MAIN_TABS_BG, + pad=TAB_PAD, + ) + ], [ sg.Tab( "Pools", diff --git a/tools/cfg_util/tables.py b/tools/cfg_util/tables.py index 7b0410da..918e1cf2 100644 --- a/tools/cfg_util/tables.py +++ b/tools/cfg_util/tables.py @@ -84,6 +84,7 @@ class TableManager(metaclass=Singleton): tables = { "SCAN": [["" for _ in TABLE_HEADERS["SCAN"]] for _ in self.data], "CMD": [["" for _ in TABLE_HEADERS["CMD"]] for _ in self.data], + "BOARDS": [["" for _ in TABLE_HEADERS["BOARDS"]] for _ in self.data], "POOLS_ALL": [["" for _ in TABLE_HEADERS["POOLS_ALL"]] for _ in self.data], "POOLS_1": [["" for _ in TABLE_HEADERS["POOLS_1"]] for _ in self.data], "POOLS_2": [["" for _ in TABLE_HEADERS["POOLS_2"]] for _ in self.data], @@ -97,6 +98,7 @@ class TableManager(metaclass=Singleton): table_names = { "SCAN": "scan_table", + "BOARDS": "boards_table", "POOLS_ALL": "pools_table", "POOLS_1": "pools_1_table", "POOLS_2": "pools_2_table", @@ -144,6 +146,7 @@ class TableManager(metaclass=Singleton): tables[table][data_idx][idx] = item[_key] window["scan_table"].update(tables["SCAN"]) + window["boards_table"].update(tables["BOARDS"]) window["pools_table"].update(tables["POOLS_ALL"]) window["pools_1_table"].update(tables["POOLS_1"]) window["pools_2_table"].update(tables["POOLS_2"]) diff --git a/tools/cfg_util/ui.py b/tools/cfg_util/ui.py index ef7f7624..c776e864 100644 --- a/tools/cfg_util/ui.py +++ b/tools/cfg_util/ui.py @@ -110,7 +110,6 @@ async def ui(): mgr.update_sort_key(table.heading(event[2][1])["text"]) # scan tab - if event == "scan_all": _table = "scan_table" btn_all(_table, value[_table]) @@ -123,6 +122,17 @@ async def ui(): if event == "btn_scan": asyncio.create_task(btn_scan(value["scan_ip"])) + # boards tab + if event == "boards_all": + _table = "boards_table" + btn_all(_table, value[_table]) + if event == "boards_web": + _table = "boards_table" + btn_web(_table, value[_table]) + if event == "boards_refresh": + _table = "boards_table" + asyncio.create_task(btn_refresh(_table, value[_table])) + # pools tab if event == "pools_all": _table = "pools_table"