added chip count and fixed refreshing data

This commit is contained in:
UpstreamData
2022-01-25 15:20:21 -07:00
parent 6fd631df5b
commit 66792e1ab9
2 changed files with 31 additions and 6 deletions

View File

@@ -55,22 +55,44 @@ async def refresh_data(ip_list: list):
data_gen = asyncio.as_completed([get_formatted_data(miner) for miner in ips])
ip_table_data = window["ip_table"].Values
ordered_all_ips = [item[0] for item in ip_table_data]
row_colors = []
for all_data in data_gen:
data_point = await all_data
if data_point["IP"] in ordered_all_ips:
ip_table_index = ordered_all_ips.index(data_point["IP"])
board_6 = " ".join([chain["chip_status"] for chain in data_point["data"][6]]).replace("o", "")
board_7 = " ".join([chain["chip_status"] for chain in data_point["data"][7]]).replace("o", "")
board_8 = " ".join([chain["chip_status"] for chain in data_point["data"][8]]).replace("o", "")
board_6 = ""
board_7 = ""
board_8 = ""
if data_point["data"]:
if 6 in data_point["data"].keys():
board_6 = " ".join([chain["chip_status"] for chain in data_point["data"][6]]).replace("o", "")
else:
row_colors.append((ip_table_index, "white", "red"))
if 7 in data_point["data"].keys():
board_7 = " ".join([chain["chip_status"] for chain in data_point["data"][7]]).replace("o", "")
else:
row_colors.append((ip_table_index, "white", "red"))
if 8 in data_point["data"].keys():
board_8 = " ".join([chain["chip_status"] for chain in data_point["data"][8]]).replace("o", "")
else:
row_colors.append((ip_table_index, "white", "red"))
if False in [chain["nominal"] for chain in [data_point["data"][key] for key in data_point["data"].keys()][0]]:
row_colors.append((ip_table_index, "white", "red"))
else:
row_colors.append((ip_table_index, "white", "red"))
data = [
data_point["IP"],
data_point["model"],
len(board_6),
board_6,
len(board_7),
board_7,
len(board_8),
board_8
]
ip_table_data[ip_table_index] = data
window["ip_table"].update(ip_table_data)
window["ip_table"].update(ip_table_data, row_colors=row_colors)
progress_bar_len += 1
asyncio.create_task(update_prog_bar(progress_bar_len))
await update_ui_with_data("status", "")
@@ -140,8 +162,11 @@ async def scan_and_get_data(network):
data = [
data_point["IP"],
data_point["model"],
len(board_6),
board_6,
len(board_7),
board_7,
len(board_8),
board_8
]
ip_table_data[ip_table_index] = data

View File

@@ -29,12 +29,12 @@ layout = [
[sg.Table(
values=[],
font=("Arial", 9),
headings=["IP", "Model", "Board 6 Chips", "Board 7 Chips", "Board 8 Chips"],
headings=["IP", "Model", "6 Count", "Board 6 Chips", "7 Count", "Board 7 Chips", "8 Count", "Board 8 Chips"],
auto_size_columns=False,
max_col_width=15,
justification="center",
key="ip_table",
col_widths=[9, 7, 47, 47, 47],
col_widths=[9, 7, 7, 40, 7, 40, 7, 40],
background_color="white",
text_color="black",
size=(125, 27),