fixed more bugs

This commit is contained in:
UpstreamData
2022-04-14 18:38:29 -06:00
parent eb5a00b706
commit b5c455ffa4
3 changed files with 21 additions and 14 deletions

View File

@@ -47,6 +47,7 @@ class TestbenchMiner:
await asyncio.sleep(1)
async def install_start(self):
await ConnectionManager().broadcast_json({"IP": str(self.host), "Light": "hide"})
if not await ping_miner(self.host, 80):
await self.add_to_output("Waiting for miner connection...")
return

View File

@@ -34,14 +34,17 @@ async def ws(websocket: WebSocket):
data = await websocket.receive_json()
if "IP" in data.keys():
miner = await MinerFactory().get_miner(data["IP"])
if data["Data"] == "unlight":
if data["IP"] in ConnectionManager.lit_miners:
ConnectionManager.lit_miners.remove(data["IP"])
await miner.fault_light_off()
if data["Data"] == "light":
if data["IP"] not in ConnectionManager().lit_miners:
ConnectionManager.lit_miners.append(data["IP"])
await miner.fault_light_on()
try:
if data["Data"] == "unlight":
if data["IP"] in ConnectionManager.lit_miners:
ConnectionManager.lit_miners.remove(data["IP"])
await miner.fault_light_off()
if data["Data"] == "light":
if data["IP"] not in ConnectionManager().lit_miners:
ConnectionManager.lit_miners.append(data["IP"])
await miner.fault_light_on()
except AttributeError:
await ConnectionManager().broadcast_json({"IP": data["IP"], "text": "Fault light command failed, miner is not running BraiinsOS."})
except WebSocketDisconnect:
ConnectionManager().disconnect(websocket)
except RuntimeError:

View File

@@ -227,7 +227,8 @@ ws.onmessage = function(event) {
// create light button container
var container_light = document.createElement('div');
container_light.className = "form-check form-switch d-flex justify-content-evenly"
container_light.className = "form-check form-switch justify-content-evenly"
container_light.style = "display: none;"
container_light.id = miner["IP"] + "-light_container"
// create light button
@@ -365,7 +366,7 @@ ws.onmessage = function(event) {
var fan_2_data = [{label: "Fan Speed", data: [fan_2_rpm, 6000-fan_2_rpm], backgroundColor: ["rgba(103, 0, 221, 1)", secondary_col_2]}]
fan_2_graph.data.datasets = fan_2_data;
fan_2_graph.update();
} else {
} else if (data.hasOwnProperty("text")) {
var miner_graphs = document.getElementById(data["IP"] + "-graphs")
miner_graphs.hidden = true
var miner_stdout = document.getElementById(data["IP"] + "-stdout_text")
@@ -374,12 +375,14 @@ ws.onmessage = function(event) {
};
if (data.hasOwnProperty("Light")) {
light_box = document.getElementById(data["IP"] + "-light_container")
console.log(data)
if (data["Light"] == "show") {
light_box.hidden = false
} else {
light_box.hidden = true
console.log(light_box)
light_box.style = "display: flex;"
} else if (data["Light"] == "hide") {
light_box.style = "display: none;"
}
};
}
}
</script>