Spaces:
Sleeping
Sleeping
terrible solution to bad problem
Browse files
app.py
CHANGED
|
@@ -25,11 +25,11 @@ temp_mqtt_auto = None
|
|
| 25 |
rpm_mqtt = None
|
| 26 |
led_mqtt = None
|
| 27 |
|
| 28 |
-
if st.session_state.get("channels", None) is not None:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
REQUEST_INTERVAL = 60
|
| 35 |
|
|
@@ -190,7 +190,12 @@ def get_running_jobs(client, reactor):
|
|
| 190 |
print(rpm_mqtt)
|
| 191 |
st.session_state["stirring_speed"] = rpm_mqtt
|
| 192 |
|
| 193 |
-
st.session_state["channels"] = led_mqtt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
async def get_graph(placeholder):
|
| 196 |
try:
|
|
@@ -943,28 +948,34 @@ if st.session_state["experiment"] is not None:
|
|
| 943 |
with cols[0]:
|
| 944 |
st.write("Channel A")
|
| 945 |
with st.form("led_form_a"):
|
| 946 |
-
|
| 947 |
channel_a_submit = st.form_submit_button("Update Channel A")
|
| 948 |
|
| 949 |
with cols[1]:
|
| 950 |
st.write("Channel B")
|
| 951 |
with st.form("led_form_b"):
|
| 952 |
-
|
| 953 |
channel_b_submit = st.form_submit_button("Update Channel B")
|
| 954 |
|
| 955 |
with cols[2]:
|
| 956 |
st.write("Channel C")
|
| 957 |
with st.form("led_form_c"):
|
| 958 |
-
|
| 959 |
channel_c_submit = st.form_submit_button("Update Channel C")
|
| 960 |
|
| 961 |
with cols[3]:
|
| 962 |
st.write("Channel D")
|
| 963 |
with st.form("led_form_d"):
|
| 964 |
-
|
| 965 |
channel_d_submit = st.form_submit_button("Update Channel D")
|
| 966 |
|
| 967 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 968 |
if channel_a_submit:
|
| 969 |
pass
|
| 970 |
|
|
@@ -985,6 +996,11 @@ if st.session_state["experiment"] is not None:
|
|
| 985 |
|
| 986 |
time.sleep(1)
|
| 987 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 988 |
# Check if the LED automation job is running
|
| 989 |
get_running_jobs(st.session_state["client"], reactor)
|
| 990 |
|
|
@@ -1021,6 +1037,12 @@ if st.session_state["experiment"] is not None:
|
|
| 1021 |
|
| 1022 |
time.sleep(1)
|
| 1023 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1024 |
# Check if the LED automation job is running
|
| 1025 |
get_running_jobs(st.session_state["client"], reactor)
|
| 1026 |
|
|
@@ -1057,6 +1079,12 @@ if st.session_state["experiment"] is not None:
|
|
| 1057 |
|
| 1058 |
time.sleep(1)
|
| 1059 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1060 |
# Check if the LED automation job is running
|
| 1061 |
get_running_jobs(st.session_state["client"], reactor)
|
| 1062 |
|
|
|
|
| 25 |
rpm_mqtt = None
|
| 26 |
led_mqtt = None
|
| 27 |
|
| 28 |
+
# if st.session_state.get("channels", None) is not None:
|
| 29 |
+
# st.session_state["channel_a"] = int(st.session_state["channels"].get("A", 0))
|
| 30 |
+
# st.session_state["channel_b"] = int(st.session_state["channels"].get("B", 0))
|
| 31 |
+
# st.session_state["channel_c"] = int(st.session_state["channels"].get("C", 0))
|
| 32 |
+
# st.session_state["channel_d"] = int(st.session_state["channels"].get("D", 0))
|
| 33 |
|
| 34 |
REQUEST_INTERVAL = 60
|
| 35 |
|
|
|
|
| 190 |
print(rpm_mqtt)
|
| 191 |
st.session_state["stirring_speed"] = rpm_mqtt
|
| 192 |
|
| 193 |
+
# st.session_state["channels"] = led_mqtt
|
| 194 |
+
|
| 195 |
+
st.session_state["channel_a"] = int(led_mqtt.get("A", 0))
|
| 196 |
+
st.session_state["channel_b"] = int(led_mqtt.get("B", 0))
|
| 197 |
+
st.session_state["channel_c"] = int(led_mqtt.get("C", 0))
|
| 198 |
+
st.session_state["channel_d"] = int(led_mqtt.get("D", 0))
|
| 199 |
|
| 200 |
async def get_graph(placeholder):
|
| 201 |
try:
|
|
|
|
| 948 |
with cols[0]:
|
| 949 |
st.write("Channel A")
|
| 950 |
with st.form("led_form_a"):
|
| 951 |
+
channel_a_placeholder = st.empty()
|
| 952 |
channel_a_submit = st.form_submit_button("Update Channel A")
|
| 953 |
|
| 954 |
with cols[1]:
|
| 955 |
st.write("Channel B")
|
| 956 |
with st.form("led_form_b"):
|
| 957 |
+
channel_b_placeholder = st.empty()
|
| 958 |
channel_b_submit = st.form_submit_button("Update Channel B")
|
| 959 |
|
| 960 |
with cols[2]:
|
| 961 |
st.write("Channel C")
|
| 962 |
with st.form("led_form_c"):
|
| 963 |
+
channel_c_placeholder = st.empty()
|
| 964 |
channel_c_submit = st.form_submit_button("Update Channel C")
|
| 965 |
|
| 966 |
with cols[3]:
|
| 967 |
st.write("Channel D")
|
| 968 |
with st.form("led_form_d"):
|
| 969 |
+
channel_d_placeholder = st.empty()
|
| 970 |
channel_d_submit = st.form_submit_button("Update Channel D")
|
| 971 |
|
| 972 |
|
| 973 |
+
channel_a = channel_a_placeholder.number_input("Channel A", min_value=0, max_value=100, step=1, value=st.session_state.get("channel_a", 0))
|
| 974 |
+
channel_b = channel_b_placeholder.number_input("Channel B", min_value=0, max_value=100, step=1, value=st.session_state.get("channel_b", 0))
|
| 975 |
+
channel_c = channel_c_placeholder.number_input("Channel C", min_value=0, max_value=100, step=1, value=st.session_state.get("channel_c", 0))
|
| 976 |
+
channel_d = channel_d_placeholder.number_input("Channel D", min_value=0, max_value=100, step=1, value=st.session_state.get("channel_d", 0))
|
| 977 |
+
|
| 978 |
+
|
| 979 |
if channel_a_submit:
|
| 980 |
pass
|
| 981 |
|
|
|
|
| 996 |
|
| 997 |
time.sleep(1)
|
| 998 |
|
| 999 |
+
channel_a_placeholder.empty()
|
| 1000 |
+
channel_b_placeholder.empty()
|
| 1001 |
+
channel_c_placeholder.empty()
|
| 1002 |
+
channel_d_placeholder.empty()
|
| 1003 |
+
|
| 1004 |
# Check if the LED automation job is running
|
| 1005 |
get_running_jobs(st.session_state["client"], reactor)
|
| 1006 |
|
|
|
|
| 1037 |
|
| 1038 |
time.sleep(1)
|
| 1039 |
|
| 1040 |
+
|
| 1041 |
+
channel_a_placeholder.empty()
|
| 1042 |
+
channel_b_placeholder.empty()
|
| 1043 |
+
channel_c_placeholder.empty()
|
| 1044 |
+
channel_d_placeholder.empty()
|
| 1045 |
+
|
| 1046 |
# Check if the LED automation job is running
|
| 1047 |
get_running_jobs(st.session_state["client"], reactor)
|
| 1048 |
|
|
|
|
| 1079 |
|
| 1080 |
time.sleep(1)
|
| 1081 |
|
| 1082 |
+
|
| 1083 |
+
channel_a_placeholder.empty()
|
| 1084 |
+
channel_b_placeholder.empty()
|
| 1085 |
+
channel_c_placeholder.empty()
|
| 1086 |
+
channel_d_placeholder.empty()
|
| 1087 |
+
|
| 1088 |
# Check if the LED automation job is running
|
| 1089 |
get_running_jobs(st.session_state["client"], reactor)
|
| 1090 |
|