fully implemented fault light command
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user