| 
1 |  | -"""This is the panel that will use the logic."""  | 
 | 1 | +"""Streamlit application script for displaying values using nipanel package."""  | 
2 | 2 | 
 
  | 
3 | 3 | import streamlit as st  | 
4 |  | -import streamlit.components.v1 as components  | 
5 | 4 | from streamlit_echarts import st_echarts  | 
6 | 5 | 
 
  | 
7 | 6 | import nipanel  | 
8 | 7 | 
 
  | 
9 | 8 | panel = nipanel.StreamlitPanelValueAccessor(panel_id="nidaqmx_continuous_analog_input_panel")  | 
10 | 9 | 
 
  | 
11 |  | -add_refresh_component = components.declare_component(  | 
12 |  | -    "panelRefreshComponent",  | 
13 |  | -    url=f"http://localhost:42001/panels/refresh/{panel.panel_id}",  | 
14 |  | -)  | 
15 |  | -add_refresh_component()  | 
 | 10 | +panel = nipanel.initialize_panel()  | 
16 | 11 | 
 
  | 
17 | 12 | 
 
  | 
18 | 13 | st.title("Analog Input - Voltage and Thermocouple in a Single Task")  | 
 | 
30 | 25 | )  | 
31 | 26 | 
 
  | 
32 | 27 | 
 
  | 
33 |  | -list_of_therm_amp = panel.get_value("amplitude")  | 
34 |  | -list_of_voltage_amp = panel.get_value("Volts")  | 
35 |  | - | 
36 |  | -if "therm_history" not in st.session_state:  | 
37 |  | -    st.session_state.therm_history = []  | 
38 |  | -if "volts_history" not in st.session_state:  | 
39 |  | -    st.session_state.volts_history = []  | 
 | 28 | +list_of_therm_amp = panel.get_value("thermocouple_data", [0.0])  | 
 | 29 | +list_of_voltage_amp = panel.get_value("voltage_data", [0.0])  | 
40 | 30 | 
 
  | 
41 |  | -for therm_amp in list_of_therm_amp:  | 
42 |  | -    st.session_state.therm_history.append(therm_amp)  | 
43 |  | -for voltage_amp in list_of_voltage_amp:  | 
44 |  | -    st.session_state.volts_history.append(voltage_amp)  | 
45 |  | - | 
46 |  | -therm_amp_graph = {  | 
47 |  | -    "tooltip": {"trigger": "axis"},  | 
48 |  | -    "legend": {"data": ["thermocouple_amplitude"]},  | 
49 |  | -    "xAxis": {  | 
50 |  | -        "type": "category",  | 
51 |  | -        "data": list(range(len(st.session_state.therm_history))),  | 
52 |  | -        "name": "Time",  | 
53 |  | -    },  | 
54 |  | -    "yAxis": {"type": "value", "name": "Thermocouple Amplitude"},  | 
55 |  | -    "series": [  | 
56 |  | -        {  | 
57 |  | -            "name": "thermocouple_amplitude",  | 
58 |  | -            "type": "line",  | 
59 |  | -            "data": st.session_state.therm_history,  | 
60 |  | -            "color": "red",  | 
61 |  | -        },  | 
62 |  | -    ],  | 
63 |  | -}  | 
64 |  | -st_echarts(options=therm_amp_graph, height="400px")  | 
65 |  | - | 
66 |  | -voltage_amp_graph = {  | 
67 |  | -    "tooltip": {"trigger": "axis"},  | 
68 |  | -    "legend": {"data": ["voltage_amplitude"]},  | 
69 |  | -    "xAxis": {  | 
70 |  | -        "type": "category",  | 
71 |  | -        "data": list(range(len(st.session_state.volts_history))),  | 
72 |  | -        "name": "Time",  | 
73 |  | -    },  | 
74 |  | -    "yAxis": {"type": "value", "name": "Voltage Amplitude"},  | 
75 |  | -    "series": [  | 
76 |  | -        {  | 
77 |  | -            "name": "voltage_amplitude",  | 
78 |  | -            "type": "line",  | 
79 |  | -            "data": st.session_state.volts_history,  | 
80 |  | -        },  | 
81 |  | -    ],  | 
82 |  | -}  | 
83 |  | -st_echarts(options=voltage_amp_graph, height="400px")  | 
84 | 31 | 
 
  | 
85 | 32 | st.header("Voltage & Thermocouple")  | 
86 | 33 | voltage_therm_graph = {  | 
87 | 34 |     "tooltip": {"trigger": "axis"},  | 
88 | 35 |     "legend": {"data": ["voltage_amplitude", "thermocouple_amplitude"]},  | 
89 | 36 |     "xAxis": {  | 
90 | 37 |         "type": "category",  | 
91 |  | -        "data": list(range(len(st.session_state.volts_history))),  | 
 | 38 | +        "data": list(range(len(list_of_voltage_amp))),   | 
92 | 39 |         "name": "Time",  | 
93 | 40 |     },  | 
94 | 41 |     "yAxis": {"type": "value", "name": "Voltage and Thermocouple Amplitude"},  | 
95 | 42 |     "series": [  | 
96 | 43 |         {  | 
97 | 44 |             "name": "voltage_amplitude",  | 
98 | 45 |             "type": "line",  | 
99 |  | -            "data": st.session_state.volts_history,  | 
 | 46 | +            "data": list_of_voltage_amp,  | 
100 | 47 |             "emphasis": {"focus": "series"},  | 
101 | 48 |             "smooth": True,  | 
102 | 49 |             "seriesLayoutBy": "row",  | 
103 | 50 |         },  | 
104 | 51 |         {  | 
105 | 52 |             "name": "thermocouple_amplitude",  | 
106 | 53 |             "type": "line",  | 
107 |  | -            "data": st.session_state.therm_history,  | 
 | 54 | +            "data": list_of_therm_amp,  | 
108 | 55 |             "color": "red",  | 
109 | 56 |             "emphasis": {"focus": "series"},  | 
110 | 57 |             "smooth": True,  | 
 | 
0 commit comments