linx5o commited on
Commit
ba55472
·
1 Parent(s): c2dccf3

dosing actions

Browse files
Files changed (1) hide show
  1. app.py +135 -0
app.py CHANGED
@@ -1228,6 +1228,141 @@ if st.session_state["experiment"] is not None:
1228
 
1229
  st.divider()
1230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1231
  st.header("Graphs")
1232
 
1233
 
 
1228
 
1229
  st.divider()
1230
 
1231
+ st.header("Dosing")
1232
+
1233
+ cols = st.columns(3)
1234
+
1235
+ with cols[0]:
1236
+ st.subheader("Add Media")
1237
+ with st.form("media_form"):
1238
+ media_ml = st.number_input("Media (mL)", min_value=0, step=1, value=0)
1239
+ media_submit = st.form_submit_button("Add Media")
1240
+
1241
+ with cols[1]:
1242
+ st.subheader("Remove Waste")
1243
+ with st.form("waste_form"):
1244
+ waste_ml = st.number_input("Waste (mL)", min_value=0, step=1, value=0)
1245
+ waste_submit = st.form_submit_button("Remove Waste")
1246
+
1247
+ with cols[2]:
1248
+ st.subheader("Cycle Media")
1249
+ with st.form("cycle_form"):
1250
+ cycle_s = st.number_input("Cycle (s)", min_value=0, step=1, value=0)
1251
+ cycle_submit = st.form_submit_button("Cycle Media")
1252
+
1253
+ if media_submit:
1254
+ payload = {
1255
+ "command": "pump_add_media",
1256
+ "reactor": reactor,
1257
+ "experiment": st.session_state["experiment"],
1258
+ "volume": media_ml
1259
+ }
1260
+
1261
+ payload_str = json.dumps(payload)
1262
+
1263
+ st.session_state["client"].loop_start()
1264
+
1265
+ st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
1266
+
1267
+ time.sleep(1)
1268
+
1269
+ # Check if the dosing job is running
1270
+ # get_running_jobs(st.session_state["client"], reactor)
1271
+
1272
+ # st.session_state["client"].loop_stop()
1273
+
1274
+ # if "dosing" in running:
1275
+ # st.success("Media added successfully!")
1276
+ # else:
1277
+ # st.error("Failed to add media.")
1278
+ # st.session_state["experiment"] = None
1279
+
1280
+ # for run in running:
1281
+ # st.session_state["jobs"][run] = True
1282
+
1283
+ # st.session_state["experiment"] = experiment
1284
+
1285
+ st.success("Media added successfully!")
1286
+
1287
+ time.sleep(3)
1288
+ st.rerun()
1289
+
1290
+ if waste_submit:
1291
+ payload = {
1292
+ "command": "pump_remove_waste",
1293
+ "reactor": reactor,
1294
+ "experiment": st.session_state["experiment"],
1295
+ "volume": waste_ml
1296
+ }
1297
+
1298
+ payload_str = json.dumps(payload)
1299
+
1300
+ st.session_state["client"].loop_start()
1301
+
1302
+ st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
1303
+
1304
+ time.sleep(1)
1305
+
1306
+ # Check if the dosing job is running
1307
+ # get_running_jobs(st.session_state["client"], reactor)
1308
+
1309
+ # st.session_state["client"].loop_stop()
1310
+
1311
+ # if "dosing" in running:
1312
+ # st.success("Waste removed successfully!")
1313
+ # else:
1314
+ # st.error("Failed to remove waste.")
1315
+ # st.session_state["experiment"] = None
1316
+
1317
+ # for run in running:
1318
+ # st.session_state["jobs"][run] = True
1319
+
1320
+ # st.session_state["experiment"] = experiment
1321
+
1322
+ st.success("Waste removed successfully!")
1323
+
1324
+ time.sleep(3)
1325
+ st.rerun()
1326
+
1327
+ if cycle_submit:
1328
+ payload = {
1329
+ "command": "pump_cycle_media",
1330
+ "reactor": reactor,
1331
+ "experiment": st.session_state["experiment"],
1332
+ "duration": cycle_s
1333
+ }
1334
+
1335
+ payload_str = json.dumps(payload)
1336
+
1337
+ st.session_state["client"].loop_start()
1338
+
1339
+ st.session_state["client"].publish("pioreactor/control", payload_str, qos=1)
1340
+
1341
+ time.sleep(1)
1342
+
1343
+ # Check if the dosing job is running
1344
+ # get_running_jobs(st.session_state["client"], reactor)
1345
+
1346
+ # st.session_state["client"].loop_stop()
1347
+
1348
+ # if "dosing" in running:
1349
+ # st.success("Media cycled successfully!")
1350
+ # else:
1351
+ # st.error("Failed to cycle media.")
1352
+ # st.session_state["experiment"] = None
1353
+
1354
+ # for run in running:
1355
+ # st.session_state["jobs"][run] = True
1356
+
1357
+ # st.session_state["experiment"] = experiment
1358
+
1359
+ st.success("Media cycled successfully!")
1360
+
1361
+ time.sleep(3)
1362
+ st.rerun()
1363
+
1364
+ st.divider()
1365
+
1366
  st.header("Graphs")
1367
 
1368