added partial fault light functionality and fixed stdout output direction
This commit is contained in:
@@ -21,6 +21,14 @@ class testbenchMiner:
|
|||||||
def __init__(self, host: ip_address):
|
def __init__(self, host: ip_address):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.state = START
|
self.state = START
|
||||||
|
self.light = False
|
||||||
|
|
||||||
|
async def fault_light(self):
|
||||||
|
miner = await MinerFactory().get_miner(self.host)
|
||||||
|
if self.light:
|
||||||
|
await miner.fault_light_off()
|
||||||
|
else:
|
||||||
|
await miner.fault_light_on()
|
||||||
|
|
||||||
async def add_to_output(self, message):
|
async def add_to_output(self, message):
|
||||||
await ConnectionManager().broadcast_json(
|
await ConnectionManager().broadcast_json(
|
||||||
@@ -194,9 +202,11 @@ class testbenchMiner:
|
|||||||
return
|
return
|
||||||
|
|
||||||
async def install_done(self):
|
async def install_done(self):
|
||||||
|
await self.add_to_output("Waiting for disconnect...")
|
||||||
while await ping_miner(self.host) and self.state == DONE:
|
while await ping_miner(self.host) and self.state == DONE:
|
||||||
print(await self.get_web_data())
|
await ConnectionManager().broadcast_json(await self.get_web_data())
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
self.state = START
|
||||||
|
|
||||||
async def install_loop(self):
|
async def install_loop(self):
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
@@ -101,12 +101,14 @@ def start_monitor():
|
|||||||
|
|
||||||
|
|
||||||
async def monitor():
|
async def monitor():
|
||||||
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
await ConnectionManager().broadcast_json(
|
await ConnectionManager().broadcast_json(
|
||||||
{"IP": "192.168.1.11", "text": "hello\n"}
|
{"IP": "192.168.1.11", "text": f"hello - {i}\n"}
|
||||||
)
|
)
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
await ConnectionManager().broadcast_json(miner_data)
|
await ConnectionManager().broadcast_json(miner_data)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -216,6 +216,28 @@ var ws = new WebSocket("ws://{{request.url.hostname}}:{% if request.url.port %}{
|
|||||||
miner_graphs.append(row_fan)
|
miner_graphs.append(row_fan)
|
||||||
column.append(miner_graphs)
|
column.append(miner_graphs)
|
||||||
|
|
||||||
|
|
||||||
|
// create light button container
|
||||||
|
var container_light = document.createElement('div');
|
||||||
|
container_light.className = "form-check form-switch d-flex justify-content-evenly"
|
||||||
|
|
||||||
|
// create light button
|
||||||
|
var light_switch = document.createElement('input');
|
||||||
|
light_switch.type = "checkbox"
|
||||||
|
light_switch.id = miner + "-light"
|
||||||
|
light_switch.className = "form-check-input"
|
||||||
|
|
||||||
|
// add a light label to the button
|
||||||
|
var label_light = document.createElement("label");
|
||||||
|
label_light.setAttribute("for", "light_" + miner.IP);
|
||||||
|
label_light.innerHTML = "Light";
|
||||||
|
|
||||||
|
// add the button and label to the container
|
||||||
|
container_light.append(label_light)
|
||||||
|
container_light.append(light_switch)
|
||||||
|
|
||||||
|
column.append(container_light)
|
||||||
|
|
||||||
container_all.append(column)
|
container_all.append(column)
|
||||||
|
|
||||||
var chart_hr = new Chart(hr_canvas, {
|
var chart_hr = new Chart(hr_canvas, {
|
||||||
@@ -321,7 +343,6 @@ var ws = new WebSocket("ws://{{request.url.hostname}}:{% if request.url.port %}{
|
|||||||
var fan_2_rpm = data["Fans"]["fan_1"]["RPM"]
|
var fan_2_rpm = data["Fans"]["fan_1"]["RPM"]
|
||||||
var fan_2_title = document.getElementById(data["IP"] + "-fan_r");
|
var fan_2_title = document.getElementById(data["IP"] + "-fan_r");
|
||||||
fan_2_title.innerHTML = "Fan R: " + fan_2_rpm + " RPM";
|
fan_2_title.innerHTML = "Fan R: " + fan_2_rpm + " RPM";
|
||||||
console.log(fan_2_rpm);
|
|
||||||
if (fan_2_rpm == 0){
|
if (fan_2_rpm == 0){
|
||||||
var secondary_col_2 = "rgba(97, 4, 4, 1)"
|
var secondary_col_2 = "rgba(97, 4, 4, 1)"
|
||||||
} else {
|
} else {
|
||||||
@@ -335,9 +356,18 @@ var ws = new WebSocket("ws://{{request.url.hostname}}:{% if request.url.port %}{
|
|||||||
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")
|
||||||
miner_stdout.hidden = false
|
miner_stdout.hidden = false
|
||||||
miner_stdout.innerHTML += data["text"]
|
miner_stdout.innerHTML = data["text"] + miner_stdout.innerHTML
|
||||||
}
|
};
|
||||||
|
if (data.hasOwnProperty("Light")) {
|
||||||
|
if (data["Light"] == "show") {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user