"""IMU放置于人体模型后的motion capture分析,包括离线、在线。读入或在线接入数据进行波形绘制、数据分析及分析结果的人体模型渲染和结果图表""" import streamlit as st import os from datetime import datetime from db import subject from db import test from components.remove_style import hide_footer from device.peripheral.manager import get_serial_ports import page_utils def _create_test(conn, subjects): with st.form("test_form"): st.write("创建训练") position = st.selectbox("训练部位", ['右手', '左手']) hand_com = st.selectbox("气动手COM口", get_serial_ports()) finger_model_names = st.multiselect("气动手手势", list(page_utils.fingermodel_trans.keys())) owner_name = st.selectbox("用户", subjects.name.to_list()) model_path = page_utils.file_selector(os.path.join(f'./static/models/{owner_name}')) submitted = st.form_submit_button("开始训练") if submitted: start_time = datetime.strptime(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), "%Y-%m-%d %H:%M:%S") test_new = {"position": position, "finger_model": ','.join([page_utils.fingermodel_trans[f] for f in finger_model_names]), "start_time": start_time, "owner_name": owner_name, "model_path": model_path} test.create_test(conn, test_new) # TODO: run a psychopy process return owner_name def render(): st.set_page_config( page_title="自由手势训练", page_icon=":chart_with_upwards_trend:" ) hide_footer() st.markdown("# 自由手势训练") st.sidebar.success("训练") conn = st.connection("sql_app", type="sql") test.create_table(conn) subjects = subject.get_subjects(conn) sub_name = _create_test(conn, subjects) if sub_name: tests = test.get_tests(conn, sub_name) st.write("# 训练列表") st.dataframe(tests) render()