fix light functionality to work as intended
This commit is contained in:
@@ -34,6 +34,8 @@ async def flip_light(ip):
|
|||||||
if "light+bad" in index_tags:
|
if "light+bad" in index_tags:
|
||||||
index_tags.remove("light+bad")
|
index_tags.remove("light+bad")
|
||||||
index_tags.append("bad")
|
index_tags.append("bad")
|
||||||
|
if "light" in index_tags:
|
||||||
|
index_tags.remove("light")
|
||||||
ip_list.item(index + 1, tags=index_tags)
|
ip_list.item(index + 1, tags=index_tags)
|
||||||
await miner.fault_light_off()
|
await miner.fault_light_off()
|
||||||
|
|
||||||
@@ -104,30 +106,14 @@ async def refresh_data(ip_list: list):
|
|||||||
board_left = " ".join(
|
board_left = " ".join(
|
||||||
[chain["chip_status"] for chain in data_point["data"][0]]
|
[chain["chip_status"] for chain in data_point["data"][0]]
|
||||||
).replace("o", "•")
|
).replace("o", "•")
|
||||||
else:
|
|
||||||
row_colors.append((ip_table_index, "white", "red"))
|
|
||||||
if 1 in data_point["data"].keys():
|
if 1 in data_point["data"].keys():
|
||||||
board_center = " ".join(
|
board_center = " ".join(
|
||||||
[chain["chip_status"] for chain in data_point["data"][1]]
|
[chain["chip_status"] for chain in data_point["data"][1]]
|
||||||
).replace("o", "•")
|
).replace("o", "•")
|
||||||
else:
|
|
||||||
row_colors.append((ip_table_index, "white", "red"))
|
|
||||||
if 2 in data_point["data"].keys():
|
if 2 in data_point["data"].keys():
|
||||||
board_right = " ".join(
|
board_right = " ".join(
|
||||||
[chain["chip_status"] for chain in data_point["data"][2]]
|
[chain["chip_status"] for chain in data_point["data"][2]]
|
||||||
).replace("o", "•")
|
).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 = [
|
||||||
data_point["IP"],
|
data_point["IP"],
|
||||||
data_point["model"],
|
data_point["model"],
|
||||||
@@ -139,7 +125,7 @@ async def refresh_data(ip_list: list):
|
|||||||
board_right,
|
board_right,
|
||||||
]
|
]
|
||||||
ip_table_data[ip_table_index] = data
|
ip_table_data[ip_table_index] = data
|
||||||
window["ip_table"].update(ip_table_data, row_colors=row_colors)
|
window["ip_table"].update(ip_table_data)
|
||||||
progress_bar_len += 1
|
progress_bar_len += 1
|
||||||
asyncio.create_task(update_prog_bar(progress_bar_len))
|
asyncio.create_task(update_prog_bar(progress_bar_len))
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
@@ -292,9 +278,6 @@ async def scan_and_get_data(network):
|
|||||||
|
|
||||||
# configure "bad" tag to highlight red
|
# configure "bad" tag to highlight red
|
||||||
table = window["ip_table"].Widget
|
table = window["ip_table"].Widget
|
||||||
table.tag_configure("bad", foreground="white", background="orange")
|
|
||||||
table.tag_configure("light", foreground="white", background="red")
|
|
||||||
table.tag_configure("light+bad", foreground="white", background="red")
|
|
||||||
|
|
||||||
# set tags on the row if they have been set
|
# set tags on the row if they have been set
|
||||||
for row in row_colors:
|
for row in row_colors:
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ async def ui():
|
|||||||
table = window["ip_table"].Widget
|
table = window["ip_table"].Widget
|
||||||
table.bind("<Control-Key-c>", lambda x: copy_from_table(table))
|
table.bind("<Control-Key-c>", lambda x: copy_from_table(table))
|
||||||
table.bind("<Control-Key-a>", lambda x: table_select_all())
|
table.bind("<Control-Key-a>", lambda x: table_select_all())
|
||||||
|
# light tag shows red row for fault lights
|
||||||
|
table.tag_configure("bad", foreground="white", background="orange")
|
||||||
|
table.tag_configure("light", foreground="white", background="red")
|
||||||
|
table.tag_configure("light+bad", foreground="white", background="red")
|
||||||
while True:
|
while True:
|
||||||
event, value = window.read(timeout=0)
|
event, value = window.read(timeout=0)
|
||||||
if event in (None, "Close", sg.WIN_CLOSED):
|
if event in (None, "Close", sg.WIN_CLOSED):
|
||||||
|
|||||||
Reference in New Issue
Block a user