add for custom
Browse files
app.py
CHANGED
@@ -488,6 +488,34 @@ def cycle_media_default(cycle, experiment):
|
|
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")
|
@@ -509,6 +537,8 @@ def get_status_default(exp):
|
|
509 |
while experiment is None and (time.time() - start) < timeout:
|
510 |
time.sleep(0.1)
|
511 |
|
|
|
|
|
512 |
return experiment, running, temp_mqtt_auto, rpm_mqtt, led_mqtt, experiments
|
513 |
|
514 |
# Define the interface components
|
@@ -705,6 +735,25 @@ with gr.Blocks() as demo:
|
|
705 |
pioreactor_input.input(fn=void_client)
|
706 |
experiment_input.input(fn=void_client)
|
707 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
with gr.Blocks():
|
709 |
gr.Markdown("# Stirring")
|
710 |
rpm_input = gr.Slider(minimum=0, maximum=2000, step=50, label="RPM")
|
|
|
488 |
}
|
489 |
client.publish(f"pioreactor/control", json.dumps(payload))
|
490 |
|
491 |
+
def get_status(host, port, username, password, pioreactor, exp):
|
492 |
+
global client_custom
|
493 |
+
if client_custom is None:
|
494 |
+
custom_client(host, port, username, password)
|
495 |
+
|
496 |
+
client_custom.subscribe(f"pioreactor/{pioreactor}/worker")
|
497 |
+
client_custom.on_message = on_message_worker
|
498 |
+
global experiment
|
499 |
+
experiment = None
|
500 |
+
|
501 |
+
payload = {
|
502 |
+
"command": "get_worker",
|
503 |
+
"experiment": exp,
|
504 |
+
"reactor": pioreactor
|
505 |
+
}
|
506 |
+
|
507 |
+
client_custom.publish(f"pioreactor/control", json.dumps(payload))
|
508 |
+
|
509 |
+
timeout = 10
|
510 |
+
start = time.time()
|
511 |
+
|
512 |
+
while experiment is None and (time.time() - start) < timeout:
|
513 |
+
time.sleep(0.1)
|
514 |
+
|
515 |
+
client_custom.unsubscribe(f"pioreactor/{pioreactor}/worker")
|
516 |
+
|
517 |
+
return experiment, running, temp_mqtt_auto, rpm_mqtt, led_mqtt, experiments
|
518 |
+
|
519 |
def get_status_default(exp):
|
520 |
global client
|
521 |
client.subscribe(f"pioreactor/{PIOREACTOR}/worker")
|
|
|
537 |
while experiment is None and (time.time() - start) < timeout:
|
538 |
time.sleep(0.1)
|
539 |
|
540 |
+
client.unsubscribe(f"pioreactor/{PIOREACTOR}/worker")
|
541 |
+
|
542 |
return experiment, running, temp_mqtt_auto, rpm_mqtt, led_mqtt, experiments
|
543 |
|
544 |
# Define the interface components
|
|
|
735 |
pioreactor_input.input(fn=void_client)
|
736 |
experiment_input.input(fn=void_client)
|
737 |
|
738 |
+
with gr.Blocks():
|
739 |
+
gr.Markdown("# Status")
|
740 |
+
get_status = gr.Button("Get Status")
|
741 |
+
|
742 |
+
with gr.Row():
|
743 |
+
experiment_output = gr.Textbox(label="Experiment", interactive=False)
|
744 |
+
running_output = gr.Textbox(label="Running", interactive=False)
|
745 |
+
with gr.Row():
|
746 |
+
temp_output = gr.Textbox(label="Temperature Automation", interactive=False)
|
747 |
+
rpm_output = gr.Textbox(label="RPM", interactive=False)
|
748 |
+
led_output = gr.Textbox(label="LEDs", interactive=False)
|
749 |
+
experiments_output = gr.Textbox(label="Experiments", interactive=False)
|
750 |
+
|
751 |
+
get_status.click(
|
752 |
+
fn=get_status_default,
|
753 |
+
inputs=[experiment_input],
|
754 |
+
outputs=[experiment_output, running_output, temp_output, rpm_output, led_output, experiments_output]
|
755 |
+
)
|
756 |
+
|
757 |
with gr.Blocks():
|
758 |
gr.Markdown("# Stirring")
|
759 |
rpm_input = gr.Slider(minimum=0, maximum=2000, step=50, label="RPM")
|