fixed more bugs
This commit is contained in:
committed by
UpstreamData
parent
a6df7a83d6
commit
4b767c5427
@@ -47,6 +47,7 @@ class TestbenchMiner:
|
|||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def install_start(self):
|
async def install_start(self):
|
||||||
|
await ConnectionManager().broadcast_json({"IP": str(self.host), "Light": "hide"})
|
||||||
if not await ping_miner(self.host, 80):
|
if not await ping_miner(self.host, 80):
|
||||||
await self.add_to_output("Waiting for miner connection...")
|
await self.add_to_output("Waiting for miner connection...")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -34,14 +34,17 @@ async def ws(websocket: WebSocket):
|
|||||||
data = await websocket.receive_json()
|
data = await websocket.receive_json()
|
||||||
if "IP" in data.keys():
|
if "IP" in data.keys():
|
||||||
miner = await MinerFactory().get_miner(data["IP"])
|
miner = await MinerFactory().get_miner(data["IP"])
|
||||||
if data["Data"] == "unlight":
|
try:
|
||||||
if data["IP"] in ConnectionManager.lit_miners:
|
if data["Data"] == "unlight":
|
||||||
ConnectionManager.lit_miners.remove(data["IP"])
|
if data["IP"] in ConnectionManager.lit_miners:
|
||||||
await miner.fault_light_off()
|
ConnectionManager.lit_miners.remove(data["IP"])
|
||||||
if data["Data"] == "light":
|
await miner.fault_light_off()
|
||||||
if data["IP"] not in ConnectionManager().lit_miners:
|
if data["Data"] == "light":
|
||||||
ConnectionManager.lit_miners.append(data["IP"])
|
if data["IP"] not in ConnectionManager().lit_miners:
|
||||||
await miner.fault_light_on()
|
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:
|
except WebSocketDisconnect:
|
||||||
ConnectionManager().disconnect(websocket)
|
ConnectionManager().disconnect(websocket)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
|
|||||||
@@ -227,7 +227,8 @@ ws.onmessage = function(event) {
|
|||||||
|
|
||||||
// create light button container
|
// create light button container
|
||||||
var container_light = document.createElement('div');
|
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"
|
container_light.id = miner["IP"] + "-light_container"
|
||||||
|
|
||||||
// create light button
|
// 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]}]
|
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.data.datasets = fan_2_data;
|
||||||
fan_2_graph.update();
|
fan_2_graph.update();
|
||||||
} else {
|
} else if (data.hasOwnProperty("text")) {
|
||||||
var miner_graphs = document.getElementById(data["IP"] + "-graphs")
|
var miner_graphs = document.getElementById(data["IP"] + "-graphs")
|
||||||
miner_graphs.hidden = true
|
miner_graphs.hidden = true
|
||||||
var miner_stdout = document.getElementById(data["IP"] + "-stdout_text")
|
var miner_stdout = document.getElementById(data["IP"] + "-stdout_text")
|
||||||
@@ -374,12 +375,14 @@ ws.onmessage = function(event) {
|
|||||||
};
|
};
|
||||||
if (data.hasOwnProperty("Light")) {
|
if (data.hasOwnProperty("Light")) {
|
||||||
light_box = document.getElementById(data["IP"] + "-light_container")
|
light_box = document.getElementById(data["IP"] + "-light_container")
|
||||||
|
console.log(data)
|
||||||
if (data["Light"] == "show") {
|
if (data["Light"] == "show") {
|
||||||
light_box.hidden = false
|
console.log(light_box)
|
||||||
} else {
|
light_box.style = "display: flex;"
|
||||||
light_box.hidden = true
|
} else if (data["Light"] == "hide") {
|
||||||
|
light_box.style = "display: none;"
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user