test of status
Browse files
app.py
CHANGED
@@ -13,6 +13,13 @@ PIOREACTOR = os.environ.get("pioreactor")
|
|
13 |
client = None
|
14 |
client_custom = None
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def on_connect(client, userdata, flags, rc):
|
18 |
print("Connected with result code "+str(rc))
|
@@ -481,6 +488,27 @@ def cycle_media_default(cycle, experiment):
|
|
481 |
}
|
482 |
client.publish(f"pioreactor/control", json.dumps(payload))
|
483 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
484 |
# Define the interface components
|
485 |
with gr.Blocks() as demo:
|
486 |
with gr.Tab("Default"):
|
@@ -489,6 +517,22 @@ with gr.Blocks() as demo:
|
|
489 |
|
490 |
client = create_client(HOST, PORT, USERNAME, PASSWORD)
|
491 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
with gr.Blocks():
|
493 |
gr.Markdown("# Stirring")
|
494 |
rpm = gr.Slider(minimum=0, maximum=2000, step=50, label="RPM")
|
|
|
13 |
client = None
|
14 |
client_custom = None
|
15 |
|
16 |
+
experiment = None
|
17 |
+
running = []
|
18 |
+
temp_mqtt_auto = None
|
19 |
+
rpm_mqtt = None
|
20 |
+
led_mqtt = None
|
21 |
+
experiments = []
|
22 |
+
|
23 |
|
24 |
def on_connect(client, userdata, flags, rc):
|
25 |
print("Connected with result code "+str(rc))
|
|
|
488 |
}
|
489 |
client.publish(f"pioreactor/control", json.dumps(payload))
|
490 |
|
491 |
+
def get_status_default(exp):
|
492 |
+
global client
|
493 |
+
client.subscribe(f"pioreactor/{PIOREACTOR}/worker")
|
494 |
+
client.on_message = on_message_worker
|
495 |
+
global experiment
|
496 |
+
experiment = None
|
497 |
+
|
498 |
+
payload = {
|
499 |
+
"command": "get_worker",
|
500 |
+
"experiment": exp,
|
501 |
+
"reactor": PIOREACTOR
|
502 |
+
}
|
503 |
+
|
504 |
+
client.publish(f"pioreactor/control", json.dumps(payload))
|
505 |
+
|
506 |
+
timeout = 10
|
507 |
+
start = time.time()
|
508 |
+
|
509 |
+
while experiment is None and (time.time() - start) < timeout:
|
510 |
+
time.sleep(0.1)
|
511 |
+
|
512 |
# Define the interface components
|
513 |
with gr.Blocks() as demo:
|
514 |
with gr.Tab("Default"):
|
|
|
517 |
|
518 |
client = create_client(HOST, PORT, USERNAME, PASSWORD)
|
519 |
|
520 |
+
with gr.Blocks():
|
521 |
+
gr.Markdown("# Status")
|
522 |
+
get_status = gr.Button("Get Status")
|
523 |
+
|
524 |
+
gr.Textbox(label="Experiment", value=experiment, readonly=True)
|
525 |
+
gr.Textbox(label="Running", value=running, readonly=True)
|
526 |
+
gr.Textbox(label="Temperature Automation", value=temp_mqtt_auto, readonly=True)
|
527 |
+
gr.Textbox(label="RPM", value=rpm_mqtt, readonly=True)
|
528 |
+
gr.Textbox(label="LEDs", value=led_mqtt, readonly=True)
|
529 |
+
gr.Textbox(label="Experiments", value=experiments, readonly=True)
|
530 |
+
|
531 |
+
get_status.click(
|
532 |
+
fn=get_status_default,
|
533 |
+
inputs=[experiment_input]
|
534 |
+
)
|
535 |
+
|
536 |
with gr.Blocks():
|
537 |
gr.Markdown("# Stirring")
|
538 |
rpm = gr.Slider(minimum=0, maximum=2000, step=50, label="RPM")
|