linx5o commited on
Commit
aee3a99
1 Parent(s): fe4b2cc

added experiment control to custom

Browse files
Files changed (1) hide show
  1. app.py +69 -2
app.py CHANGED
@@ -572,6 +572,43 @@ def change_experiment_default(ch_exp, 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:
@@ -797,10 +834,40 @@ with gr.Blocks() as demo:
797
  experiments_output = gr.Textbox(label="Experiments", interactive=False)
798
 
799
  get_status.click(
800
- fn=get_status_default,
801
- inputs=[experiment_input],
802
  outputs=[experiment_output, running_output, temp_output, rpm_output, led_output, experiments_output]
803
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
804
 
805
  with gr.Blocks():
806
  gr.Markdown("# Stirring")
 
572
  "reactor": PIOREACTOR,
573
  }
574
  client.publish(f"pioreactor/control", json.dumps(payload))
575
+
576
+ def new_experiment(new_exp, host, port, username, password, pioreactor, exp):
577
+ global client_custom
578
+ if client_custom is None:
579
+ custom_client(host, port, username, password)
580
+
581
+ payload = {
582
+ "command": "new_experiment",
583
+ "experiment": new_exp,
584
+ "reactor": pioreactor,
585
+ }
586
+ client_custom.publish(f"pioreactor/control", json.dumps(payload))
587
+
588
+ def remove_experiment(rem_exp, host, port, username, password, pioreactor, exp):
589
+ global client_custom
590
+ if client_custom is None:
591
+ custom_client(host, port, username, password)
592
+
593
+ payload = {
594
+ "command": "delete_experiment",
595
+ "experiment": rem_exp,
596
+ "reactor": pioreactor,
597
+ }
598
+ client_custom.publish(f"pioreactor/control", json.dumps(payload))
599
+
600
+ def change_experiment(ch_exp, host, port, username, password, pioreactor, exp):
601
+ global client_custom
602
+ if client_custom is None:
603
+ custom_client(host, port, username, password)
604
+
605
+ payload = {
606
+ "command": "change_experiment",
607
+ "experiment": exp,
608
+ "experiment_new": ch_exp,
609
+ "reactor": pioreactor,
610
+ }
611
+ client_custom.publish(f"pioreactor/control", json.dumps(payload))
612
 
613
  # Define the interface components
614
  with gr.Blocks() as demo:
 
834
  experiments_output = gr.Textbox(label="Experiments", interactive=False)
835
 
836
  get_status.click(
837
+ fn=get_status,
838
+ inputs=[host_input, port_input, username_input, password_input, pioreactor_input, experiment_input],
839
  outputs=[experiment_output, running_output, temp_output, rpm_output, led_output, experiments_output]
840
  )
841
+
842
+ with gr.Blocks():
843
+ gr.Markdown("# Experiments")
844
+
845
+ with gr.Row():
846
+ new_experiment = gr.Textbox(label="New Experiment")
847
+ new_experiment_button = gr.Button("Add Experiment")
848
+
849
+ with gr.Row():
850
+ remove_experiment = gr.Textbox(label="Remove Experiment")
851
+ remove_experiment_button = gr.Button("Remove Experiment")
852
+
853
+ with gr.Row():
854
+ change_experiment = gr.Textbox(label="Change Experiment")
855
+ change_experiment_button = gr.Button("Change Experiment")
856
+
857
+ new_experiment_button.click(
858
+ fn=new_experiment,
859
+ inputs=[new_experiment, host_input, port_input, username_input, password_input, pioreactor_input, experiment_input]
860
+ )
861
+
862
+ remove_experiment_button.click(
863
+ fn=remove_experiment,
864
+ inputs=[remove_experiment, host_input, port_input, username_input, password_input, pioreactor_input, experiment_input]
865
+ )
866
+
867
+ change_experiment_button.click(
868
+ fn=change_experiment,
869
+ inputs=[change_experiment, host_input, port_input, username_input, password_input, pioreactor_input, experiment_input]
870
+ )
871
 
872
  with gr.Blocks():
873
  gr.Markdown("# Stirring")