fully implemented fault light command

This commit is contained in:
UpstreamData
2022-05-06 11:36:57 -06:00
parent 725b14e583
commit a2b071af4f
6 changed files with 102 additions and 45 deletions

View File

@@ -1,20 +1,24 @@
from miners.miner_factory import MinerFactory
from tools.cfg_util.cfg_util_qt.layout import window
from tools.cfg_util.cfg_util_qt.tables import update_tree
from tools.cfg_util.cfg_util_qt.imgs import TkImages
from tools.cfg_util.cfg_util_qt.tables import TableManager
async def btn_light(ips: list):
table_manager = TableManager()
_table = window["cmd_table"].Widget
data = []
iids = _table.get_children()
for idx in ips:
item = _table.item(iids[idx])
data.append(
{
"IP": item["values"][0],
"Model": item["values"][1],
"Command Output": item["values"][2],
"Light": True,
}
)
await update_tree(data)
ip = item["values"][0]
new_light_val = not table_manager.data[ip]["Light"]
miner = await MinerFactory().get_miner(ip)
if new_light_val:
success = await miner.fault_light_on()
else:
success = await miner.fault_light_off()
if success:
table_manager.data[ip]["Light"] = new_light_val
table_manager.data[ip]["Command Output"] = "Fault Light command succeeded."
else:
table_manager.data[ip]["Command Output"] = "Fault Light command failed."
table_manager.update_tables()