Spaces:
Sleeping
Sleeping
not working led automation
Browse files
app.py
CHANGED
|
@@ -734,9 +734,161 @@ if st.session_state["experiment"] is not None:
|
|
| 734 |
# Display the temperature graph
|
| 735 |
# Using asyncio to run the loop in the background and periodically update the graph
|
| 736 |
|
|
|
|
| 737 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 738 |
|
|
|
|
|
|
|
| 739 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 740 |
|
| 741 |
st.header("Graphs")
|
| 742 |
|
|
|
|
| 734 |
# Display the temperature graph
|
| 735 |
# Using asyncio to run the loop in the background and periodically update the graph
|
| 736 |
|
| 737 |
+
# st.header("LED Automation")
|
| 738 |
|
| 739 |
+
# with st.form("led_form"):
|
| 740 |
+
# channel_a = st.slider("Channel A", min_value=0, max_value=100, step=1, value=0)
|
| 741 |
+
# channel_a_submit = st.form_submit_button("Update Channel A")
|
| 742 |
+
|
| 743 |
+
# if channel_a_submit:
|
| 744 |
+
# payload = {
|
| 745 |
+
# "command": "set_led_intensity",
|
| 746 |
+
# "reactor": reactor,
|
| 747 |
+
# "experiment": st.session_state["experiment"],
|
| 748 |
+
# "brightness": channel_a,
|
| 749 |
+
# "led": "A"
|
| 750 |
+
# }
|
| 751 |
+
# payload_str = json.dumps(payload)
|
| 752 |
+
|
| 753 |
+
# st.session_state["client"].loop_start()
|
| 754 |
+
# st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
|
| 755 |
+
|
| 756 |
+
# time.sleep(1)
|
| 757 |
+
|
| 758 |
+
# # Check if the LED automation job is running
|
| 759 |
+
# get_running_jobs(st.session_state["client"], reactor)
|
| 760 |
+
|
| 761 |
+
# st.session_state["client"].loop_stop()
|
| 762 |
+
|
| 763 |
+
# if "led_automation" in running:
|
| 764 |
+
# st.success("LED Automation updated!")
|
| 765 |
+
# else:
|
| 766 |
+
# st.error("Failed to update LED Automation.")
|
| 767 |
+
# st.session_state["experiment"] = None
|
| 768 |
+
|
| 769 |
+
# for run in running:
|
| 770 |
+
# st.session_state["jobs"][run] = True
|
| 771 |
+
|
| 772 |
+
# st.session_state["experiment"] = experiment
|
| 773 |
+
|
| 774 |
+
# time.sleep(3)
|
| 775 |
+
# st.rerun()
|
| 776 |
+
|
| 777 |
+
# with st.form("led_form_b"):
|
| 778 |
+
# channel_b = st.slider("Channel B", min_value=0, max_value=100, step=1, value=0)
|
| 779 |
+
# channel_b_submit = st.form_submit_button("Update Channel B")
|
| 780 |
+
|
| 781 |
+
# if channel_b_submit:
|
| 782 |
+
# payload = {
|
| 783 |
+
# "command": "set_led_intensity",
|
| 784 |
+
# "reactor": reactor,
|
| 785 |
+
# "experiment": st.session_state["experiment"],
|
| 786 |
+
# "brightness": channel_b,
|
| 787 |
+
# "led": "B"
|
| 788 |
+
# }
|
| 789 |
+
# payload_str = json.dumps(payload)
|
| 790 |
+
|
| 791 |
+
# st.session_state["client"].loop_start()
|
| 792 |
+
# st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
|
| 793 |
+
|
| 794 |
+
# time.sleep(1)
|
| 795 |
+
|
| 796 |
+
# # Check if the LED automation job is running
|
| 797 |
+
# get_running_jobs(st.session_state["client"], reactor)
|
| 798 |
+
|
| 799 |
+
# st.session_state["client"].loop_stop()
|
| 800 |
+
|
| 801 |
+
# if "led_automation" in running:
|
| 802 |
+
# st.success("LED Automation updated!")
|
| 803 |
+
# else:
|
| 804 |
+
# st.error("Failed to update LED Automation.")
|
| 805 |
+
# st.session_state["experiment"] = None
|
| 806 |
+
|
| 807 |
+
# for run in running:
|
| 808 |
+
# st.session_state["jobs"][run] = True
|
| 809 |
+
|
| 810 |
+
# st.session_state["experiment"] = experiment
|
| 811 |
+
|
| 812 |
+
# time.sleep(3)
|
| 813 |
+
# st.rerun()
|
| 814 |
+
|
| 815 |
+
# with st.form("led_form_c"):
|
| 816 |
+
# channel_c = st.slider("Channel C", min_value=0, max_value=100, step=1, value=0)
|
| 817 |
+
# channel_c_submit = st.form_submit_button("Update Channel C")
|
| 818 |
+
|
| 819 |
+
# if channel_c_submit:
|
| 820 |
+
# payload = {
|
| 821 |
+
# "command": "set_led_intensity",
|
| 822 |
+
# "reactor": reactor,
|
| 823 |
+
# "experiment": st.session_state["experiment"],
|
| 824 |
+
# "brightness": channel_c,
|
| 825 |
+
# "led": "C"
|
| 826 |
+
# }
|
| 827 |
+
# payload_str = json.dumps(payload)
|
| 828 |
+
|
| 829 |
+
# st.session_state["client"].loop_start()
|
| 830 |
+
# st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
|
| 831 |
+
|
| 832 |
+
# time.sleep(1)
|
| 833 |
+
|
| 834 |
+
# # Check if the LED automation job is running
|
| 835 |
+
# get_running_jobs(st.session_state["client"], reactor)
|
| 836 |
+
|
| 837 |
+
# st.session_state["client"].loop_stop()
|
| 838 |
+
|
| 839 |
+
# if "led_automation" in running:
|
| 840 |
+
# st.success("LED Automation updated!")
|
| 841 |
+
# else:
|
| 842 |
+
# st.error("Failed to update LED Automation.")
|
| 843 |
+
# st.session_state["experiment"] = None
|
| 844 |
+
|
| 845 |
+
# for run in running:
|
| 846 |
+
# st.session_state["jobs"][run] = True
|
| 847 |
+
|
| 848 |
+
# st.session_state["experiment"] = experiment
|
| 849 |
|
| 850 |
+
# time.sleep(3)
|
| 851 |
+
# st.rerun()
|
| 852 |
|
| 853 |
+
# with st.form("led_form_d"):
|
| 854 |
+
# channel_d = st.slider("Channel D", min_value=0, max_value=100, step=1, value=0)
|
| 855 |
+
# channel_d_submit = st.form_submit_button("Update Channel D")
|
| 856 |
+
|
| 857 |
+
# if channel_d_submit:
|
| 858 |
+
# payload = {
|
| 859 |
+
# "command": "set_led_intensity",
|
| 860 |
+
# "reactor": reactor,
|
| 861 |
+
# "experiment": st.session_state["experiment"],
|
| 862 |
+
# "brightness": channel_d,
|
| 863 |
+
# "led": "D"
|
| 864 |
+
# }
|
| 865 |
+
# payload_str = json.dumps(payload)
|
| 866 |
+
|
| 867 |
+
# st.session_state["client"].loop_start()
|
| 868 |
+
# st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
|
| 869 |
+
|
| 870 |
+
# time.sleep(1)
|
| 871 |
+
|
| 872 |
+
# # Check if the LED automation job is running
|
| 873 |
+
# get_running_jobs(st.session_state["client"], reactor)
|
| 874 |
+
|
| 875 |
+
# st.session_state["client"].loop_stop()
|
| 876 |
+
|
| 877 |
+
# if "led_automation" in running:
|
| 878 |
+
# st.success("LED Automation updated!")
|
| 879 |
+
# else:
|
| 880 |
+
# st.error("Failed to update LED Automation.")
|
| 881 |
+
# st.session_state["experiment"] = None
|
| 882 |
+
|
| 883 |
+
# for run in running:
|
| 884 |
+
# st.session_state["jobs"][run] = True
|
| 885 |
+
|
| 886 |
+
# st.session_state["experiment"] = experiment
|
| 887 |
+
|
| 888 |
+
# time.sleep(3)
|
| 889 |
+
# st.rerun()
|
| 890 |
+
|
| 891 |
+
# st.divider()
|
| 892 |
|
| 893 |
st.header("Graphs")
|
| 894 |
|