pydae 0.56.3__py3-none-any.whl → 0.56.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pydae/__init__.py +1 -1
- pydae/bmapu/bmapu_builder.py +49 -14
- pydae/bmapu/miscellaneous/banks.hjson +8 -0
- pydae/bmapu/miscellaneous/banks.py +79 -0
- pydae/bmapu/miscellaneous/pll.py +1 -0
- pydae/bmapu/miscellaneous/temp.py +27 -25
- pydae/bmapu/miscellaneous/temp_cffi.c +1115 -1662
- pydae/bmapu/miscellaneous/temp_xy_0.json +1 -7
- pydae/bmapu/miscellaneous/xy_0.json +1 -7
- pydae/bmapu/pvs/pv_string.py +647 -0
- pydae/bmapu/pvs/pvs.py +3 -0
- pydae/build_v2.py +29 -18
- pydae/etools/pv_designer.py +325 -0
- pydae/models/pendulum/api_test.http +106 -0
- pydae/models/pendulum/dae_api.py +107 -0
- pydae/models/pendulum/dashboard.py +211 -0
- pydae/models/pendulum/temp.py +1882 -0
- pydae/models/pendulum/temp_ini_cffi.c +1247 -0
- pydae/models/pendulum/temp_run_cffi.c +1247 -0
- pydae/models/pendulum/temp_trap_cffi.c +950 -0
- pydae/svg_tools/bmapu_tooltips.ipynb +119 -0
- pydae/svg_tools/svg_tools.py +11 -4
- pydae/temp.py +1 -1
- pydae/temp_ini_cffi.c +4 -0
- pydae/temp_run_cffi.c +4 -0
- pydae/temp_trap_cffi.c +4 -0
- pydae/templates/class_dae_template_api.py +1857 -0
- pydae/tools.py +22 -11
- pydae/urisi/fcs/sofc_dcdcac_gf.py +13 -9
- pydae/utils/svg2pdf.py +56 -0
- {pydae-0.56.3.dist-info → pydae-0.56.5.dist-info}/METADATA +4 -2
- {pydae-0.56.3.dist-info → pydae-0.56.5.dist-info}/RECORD +35 -21
- {pydae-0.56.3.dist-info → pydae-0.56.5.dist-info}/WHEEL +1 -1
- {pydae-0.56.3.dist-info → pydae-0.56.5.dist-info/licenses}/COPYING +0 -0
- {pydae-0.56.3.dist-info → pydae-0.56.5.dist-info/licenses}/LICENSE +0 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import panel as pn
|
|
2
|
+
import datetime
|
|
3
|
+
import param
|
|
4
|
+
import asyncio
|
|
5
|
+
import re
|
|
6
|
+
from pydae.svg_tools import svg
|
|
7
|
+
import requests
|
|
8
|
+
import json
|
|
9
|
+
import time
|
|
10
|
+
import matplotlib.pyplot as plt
|
|
11
|
+
import numpy as np
|
|
12
|
+
pn.extension('katex','matplotlib')
|
|
13
|
+
|
|
14
|
+
t_0 = time.time()
|
|
15
|
+
plot_pane = pn.pane.Matplotlib(sizing_mode='stretch_width')
|
|
16
|
+
|
|
17
|
+
# A function to generate a new plot
|
|
18
|
+
|
|
19
|
+
# with open('cuerva_emec_db.svg', 'r') as fobj:
|
|
20
|
+
# svg_file_content = fobj.read()
|
|
21
|
+
|
|
22
|
+
# Generate the new SVG
|
|
23
|
+
#s = svg('cuerva_emec_db.svg')
|
|
24
|
+
# s.set_tspan('U_SS1', f"{meas_dict['V_SS1']:5.3f} pu")
|
|
25
|
+
# s.set_tspan('U_SS2', f"{meas_dict['V_SS2']:5.3f} pu")
|
|
26
|
+
# s.set_tspan('U_POI', f"{slider_val:5.3f} pu")
|
|
27
|
+
# s.set_title('GRID_title', f"V = {meas_dict['V_GRID']:5.3f} pu\nP = {meas_dict['p_line_POIHV_GRID'] / 1e6:5.3f} MW\nQ = {meas_dict['q_line_POIHV_GRID'] / 1e6:5.3f} Mvar")
|
|
28
|
+
# s.set_tspan('P_POI', f"{meas_dict['p_line_POI_POIHV'] / 1e6:5.1f} MW")
|
|
29
|
+
# s.set_tspan('Q_POI', f"{meas_dict['q_line_POI_POIHV'] / 1e6:5.1f} Mvar")
|
|
30
|
+
|
|
31
|
+
# html_code = """
|
|
32
|
+
# <div>
|
|
33
|
+
# <svg width="200" height="200" xmlns="http://www.w3.org/2000/svg">
|
|
34
|
+
# <circle id="interactive_circle" cx="100" cy="100" r="50" fill="skyblue">
|
|
35
|
+
# <title>This is a circle\nHola</title>
|
|
36
|
+
# </circle>
|
|
37
|
+
# <text id="time_label" x="50" y="50" font-family="Arial" font-size="24" text-anchor="middle" fill="#333">
|
|
38
|
+
# Time: 00:00:00
|
|
39
|
+
# </text>
|
|
40
|
+
# </svg>
|
|
41
|
+
# </div>
|
|
42
|
+
# """
|
|
43
|
+
|
|
44
|
+
N_t = 300
|
|
45
|
+
charts_data = {'Times':np.zeros(N_t),
|
|
46
|
+
'theta':np.zeros(N_t),
|
|
47
|
+
'f_x':np.zeros(N_t),
|
|
48
|
+
'k':0, 'N_t':N_t, 't_0':t_0
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# html_code = f"""
|
|
52
|
+
# <div>
|
|
53
|
+
# {s.tostring()}
|
|
54
|
+
# </div>
|
|
55
|
+
# """
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
#svg_pane = pn.pane.HTML(html_code, width=200, height=200)
|
|
59
|
+
# panel.servable()
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Create other widgets
|
|
63
|
+
button1 = pn.widgets.Button(name='Set to Red', button_type='success')
|
|
64
|
+
button2 = pn.widgets.Button(name='Set to Green', button_type='primary')
|
|
65
|
+
slider1 = pn.widgets.IntSlider(name='Circle Radius', start=20, end=100, value=80)
|
|
66
|
+
color_picker = pn.widgets.ColorPicker(name='Circle Color', value='#FF0000')
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
sld_f_x_label = pn.pane.LaTeX(r'$\mathsf {f_{x}}$ (Nm):', width=80)
|
|
70
|
+
sld_f_x = pn.widgets.FloatSlider(start=-200.0, end=200.0, value=0.0, step=0.01)
|
|
71
|
+
|
|
72
|
+
# Crear pestañas con Panel
|
|
73
|
+
tabs_monitor = pn.Tabs(
|
|
74
|
+
# ('Plant', svg_pane),
|
|
75
|
+
('Charts', plot_pane)
|
|
76
|
+
)
|
|
77
|
+
tabs_ctrl = pn.Tabs(
|
|
78
|
+
('Enviroment', pn.Column(
|
|
79
|
+
sld_f_x_label,sld_f_x))
|
|
80
|
+
# ('POI', pn.widgets.Button(name='Set to 2', button_type='success')),
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
# # A reusable function to update the SVG (for buttons and sliders)
|
|
84
|
+
# def update_svg(event=None):
|
|
85
|
+
# current_svg = svg_pane.object
|
|
86
|
+
|
|
87
|
+
# new_radius = slider1.value
|
|
88
|
+
# new_color = color_picker.value
|
|
89
|
+
|
|
90
|
+
# if event and event.obj is button1:
|
|
91
|
+
# new_color = '#FF0000'
|
|
92
|
+
# elif event and event.obj is button2:
|
|
93
|
+
# new_color = '#00FF00'
|
|
94
|
+
|
|
95
|
+
# # Use regular expressions for more reliable attribute updates
|
|
96
|
+
# updated_svg = re.sub(
|
|
97
|
+
# r'(<circle id="interactive_circle".*?)\sfill=".*?"',
|
|
98
|
+
# r'\1 fill="{}"'.format(new_color),
|
|
99
|
+
# current_svg
|
|
100
|
+
# )
|
|
101
|
+
# updated_svg = re.sub(
|
|
102
|
+
# r'(<circle id="interactive_circle".*?)\sr=".*?"',
|
|
103
|
+
# r'\1 r="{}"'.format(new_radius),
|
|
104
|
+
# updated_svg
|
|
105
|
+
# )
|
|
106
|
+
|
|
107
|
+
# # s.set_tspan('U_SS1', f"{meas_dict['V_SS1']:5.3f} pu")
|
|
108
|
+
# # s.set_tspan('U_SS2', f"{meas_dict['V_SS2']:5.3f} pu")
|
|
109
|
+
# # s.set_tspan('U_POI', f"{slider_val:5.3f} pu")
|
|
110
|
+
# # s.set_title('GRID_title', f"V = {meas_dict['V_GRID']:5.3f} pu\nP = {meas_dict['p_line_POIHV_GRID'] / 1e6:5.3f} MW\nQ = {meas_dict['q_line_POIHV_GRID'] / 1e6:5.3f} Mvar")
|
|
111
|
+
# # s.set_tspan('P_POI', f"{meas_dict['p_line_POI_POIHV'] / 1e6:5.1f} MW")
|
|
112
|
+
# # s.set_tspan('Q_POI', f"{meas_dict['q_line_POI_POIHV'] / 1e6:5.1f} Mvar")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
# svg_pane.object = updated_svg
|
|
116
|
+
|
|
117
|
+
# The asynchronous function to be called periodically
|
|
118
|
+
async def update_time_label():
|
|
119
|
+
"""
|
|
120
|
+
Asynchronously updates the time label in the SVG.
|
|
121
|
+
"""
|
|
122
|
+
current_time = datetime.datetime.now().strftime("%H:%M:%S")
|
|
123
|
+
# current_svg = svg_pane.object
|
|
124
|
+
|
|
125
|
+
# # Use a regular expression to update the content of the text element
|
|
126
|
+
# new_svg = re.sub(
|
|
127
|
+
# r'(<tspan id="P_POI".*?>)(.*?)(</tspan>)',
|
|
128
|
+
# r'\1Time: {}\3'.format(current_time),
|
|
129
|
+
# current_svg,
|
|
130
|
+
# flags=re.DOTALL
|
|
131
|
+
# )
|
|
132
|
+
|
|
133
|
+
url = "http://localhost:8000/measurements"
|
|
134
|
+
|
|
135
|
+
ppc_ip = '10.30.0.4'
|
|
136
|
+
|
|
137
|
+
# http://10.30.0.4:5500/ppc_measurements
|
|
138
|
+
|
|
139
|
+
##############################################################################
|
|
140
|
+
url = "http://localhost:8000/measurements"
|
|
141
|
+
#url = f"http://{ppc_ip}:5500/ppc_measurements"
|
|
142
|
+
response = requests.get(url, headers={"Content-Type": "application/json"}, timeout=0.5) # Added a timeout
|
|
143
|
+
response.raise_for_status()
|
|
144
|
+
meas_dict = response.json()
|
|
145
|
+
time.sleep(0.05)
|
|
146
|
+
|
|
147
|
+
###############################################################################
|
|
148
|
+
url = "http://localhost:8000/setpoints"
|
|
149
|
+
#url = f"http://{ppc_ip}:5500/ppc_setpoints"
|
|
150
|
+
headers = {"Content-Type": "application/json"}
|
|
151
|
+
data = {
|
|
152
|
+
"f_x":float(sld_f_x.value)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
response = requests.post(url, headers=headers, data=json.dumps(data))
|
|
156
|
+
|
|
157
|
+
# # This is the line that's failing
|
|
158
|
+
# response.raise_for_status()
|
|
159
|
+
|
|
160
|
+
#response = requests.post(url, headers=headers, data=json.dumps(data))
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# time.sleep(1.0)
|
|
165
|
+
|
|
166
|
+
# # Generate the new SVG
|
|
167
|
+
# s = svg('cuerva_emec_db.svg')
|
|
168
|
+
# s.set_tspan('U_SS1', f"{meas_dict['U_SS1']/20e3:5.3f} pu")
|
|
169
|
+
# s.set_tspan('U_SS2', f"{meas_dict['U_SS2']/20e3:5.3f} pu")
|
|
170
|
+
# s.set_tspan('U_POI', f"{meas_dict['U_POI']/20e3:5.3f} pu")
|
|
171
|
+
# #s.set_title('GRID_title', f"V = {meas_dict['V_GRID']:5.3f} pu\nP = {meas_dict['p_line_POIHV_GRID'] / 1e6:5.3f} MW\nQ = {meas_dict['q_line_POIHV_GRID'] / 1e6:5.3f} Mvar")
|
|
172
|
+
# s.set_tspan('P_POI', f"{meas_dict['p_line_POI_POIHV'] / 1e6:5.2f} MW")
|
|
173
|
+
# s.set_tspan('Q_POI', f"{meas_dict['q_line_POI_POIHV'] / 1e6:5.2f} Mvar")
|
|
174
|
+
|
|
175
|
+
charts_data['Times'][-1] = time.time() - t_0
|
|
176
|
+
charts_data['theta'][-1] = meas_dict['theta']
|
|
177
|
+
charts_data['f_x'][-1] = meas_dict['f_x']
|
|
178
|
+
|
|
179
|
+
charts_data['Times'][0:-1] = charts_data['Times'][1:]
|
|
180
|
+
charts_data['theta'][0:-1] = charts_data['theta'][1:]
|
|
181
|
+
charts_data['f_x'][0:-1] = charts_data['f_x'][1:]
|
|
182
|
+
|
|
183
|
+
charts_data['k'] += 1
|
|
184
|
+
|
|
185
|
+
plt.close('all') # Clear previous plot
|
|
186
|
+
fig, ax = plt.subplots(figsize=(6, 4))
|
|
187
|
+
ax.plot(charts_data['Times'], charts_data['theta'], color='blue') # Plot new random data
|
|
188
|
+
ax.plot(charts_data['Times'], charts_data['f_x'], color='red') # Plot new random data
|
|
189
|
+
|
|
190
|
+
plot_pane.object = fig # Assign the new figure to the pane
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
# # Link widgets to the update function
|
|
194
|
+
# button1.on_click(update_svg)
|
|
195
|
+
# button2.on_click(update_svg)
|
|
196
|
+
# slider1.param.watch(update_svg, 'value')
|
|
197
|
+
# color_picker.param.watch(update_svg, 'value')
|
|
198
|
+
|
|
199
|
+
# Combine all components into a Panel layout
|
|
200
|
+
dashboard = pn.Column(
|
|
201
|
+
tabs_monitor,
|
|
202
|
+
tabs_ctrl
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# Use pn.io.periodic_async to run the update_time_label function every 1000ms (1 second)
|
|
206
|
+
# The `dashboard.servable()` is required to use periodic functions in a standalone app.
|
|
207
|
+
# In a Jupyter notebook, `dashboard` will automatically display the periodic updates.
|
|
208
|
+
pn.state.add_periodic_callback(update_time_label, period=100)
|
|
209
|
+
|
|
210
|
+
# Display the dashboard
|
|
211
|
+
dashboard.show()
|