Spaces:
Runtime error
Runtime error
added experiment controls
Browse files
app.py
CHANGED
|
@@ -541,6 +541,38 @@ def get_status_default(exp):
|
|
| 541 |
|
| 542 |
return experiment, running, temp_mqtt_auto, rpm_mqtt, led_mqtt, experiments
|
| 543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
# Define the interface components
|
| 545 |
with gr.Blocks() as demo:
|
| 546 |
with gr.Tab("Default"):
|
|
@@ -569,18 +601,34 @@ with gr.Blocks() as demo:
|
|
| 569 |
)
|
| 570 |
|
| 571 |
with gr.Blocks():
|
| 572 |
-
gr.Markdown("#
|
| 573 |
-
|
|
|
|
|
|
|
|
|
|
| 574 |
|
| 575 |
with gr.Row():
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
st = gr.Button("Send Command")
|
| 579 |
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 583 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
|
| 585 |
with gr.Blocks():
|
| 586 |
gr.Markdown("# Temperature Automation")
|
|
|
|
| 541 |
|
| 542 |
return experiment, running, temp_mqtt_auto, rpm_mqtt, led_mqtt, experiments
|
| 543 |
|
| 544 |
+
|
| 545 |
+
def new_experiment_default(new_exp, exp):
|
| 546 |
+
global client
|
| 547 |
+
|
| 548 |
+
payload = {
|
| 549 |
+
"command": "new_experiment",
|
| 550 |
+
"experiment": new_exp,
|
| 551 |
+
"reactor": PIOREACTOR,
|
| 552 |
+
}
|
| 553 |
+
client.publish(f"pioreactor/control", json.dumps(payload))
|
| 554 |
+
|
| 555 |
+
def remove_experiment_default(rem_exp, exp):
|
| 556 |
+
global client
|
| 557 |
+
|
| 558 |
+
payload = {
|
| 559 |
+
"command": "delete_experiment",
|
| 560 |
+
"experiment": rem_exp,
|
| 561 |
+
"reactor": PIOREACTOR,
|
| 562 |
+
}
|
| 563 |
+
client.publish(f"pioreactor/control", json.dumps(payload))
|
| 564 |
+
|
| 565 |
+
def change_experiment_default(ch_exp, exp):
|
| 566 |
+
global client
|
| 567 |
+
|
| 568 |
+
payload = {
|
| 569 |
+
"command": "change_experiment",
|
| 570 |
+
"experiment": exp,
|
| 571 |
+
"experiment_new": ch_exp,
|
| 572 |
+
"reactor": PIOREACTOR,
|
| 573 |
+
}
|
| 574 |
+
client.publish(f"pioreactor/control", json.dumps(payload))
|
| 575 |
+
|
| 576 |
# Define the interface components
|
| 577 |
with gr.Blocks() as demo:
|
| 578 |
with gr.Tab("Default"):
|
|
|
|
| 601 |
)
|
| 602 |
|
| 603 |
with gr.Blocks():
|
| 604 |
+
gr.Markdown("# Experiments")
|
| 605 |
+
|
| 606 |
+
with gr.Row():
|
| 607 |
+
new_experiment = gr.Textbox(label="New Experiment")
|
| 608 |
+
new_experiment_button = gr.Button("Add Experiment")
|
| 609 |
|
| 610 |
with gr.Row():
|
| 611 |
+
remove_experiment = gr.Textbox(label="Remove Experiment")
|
| 612 |
+
remove_experiment_button = gr.Button("Remove Experiment")
|
|
|
|
| 613 |
|
| 614 |
+
with gr.Row():
|
| 615 |
+
change_experiment = gr.Textbox(label="Change Experiment")
|
| 616 |
+
change_experiment_button = gr.Button("Change Experiment")
|
| 617 |
+
|
| 618 |
+
new_experiment_button.click(
|
| 619 |
+
fn=new_experiment_default,
|
| 620 |
+
inputs=[new_experiment, experiment_input]
|
| 621 |
+
)
|
| 622 |
+
|
| 623 |
+
remove_experiment_button.click(
|
| 624 |
+
fn=remove_experiment_default,
|
| 625 |
+
inputs=[remove_experiment, experiment_input]
|
| 626 |
)
|
| 627 |
+
|
| 628 |
+
change_experiment_button.click(
|
| 629 |
+
fn=change_experiment_default,
|
| 630 |
+
inputs=[change_experiment, experiment_input]
|
| 631 |
+
)
|
| 632 |
|
| 633 |
with gr.Blocks():
|
| 634 |
gr.Markdown("# Temperature Automation")
|