shepherd-core 2024.4.1__py3-none-any.whl → 2024.5.1__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.
Files changed (76) hide show
  1. shepherd_core/__init__.py +3 -3
  2. shepherd_core/calibration_hw_def.py +9 -1
  3. shepherd_core/commons.py +2 -0
  4. shepherd_core/data_models/__init__.py +11 -0
  5. shepherd_core/data_models/base/__init__.py +4 -1
  6. shepherd_core/data_models/base/cal_measurement.py +18 -6
  7. shepherd_core/data_models/base/calibration.py +39 -15
  8. shepherd_core/data_models/base/content.py +10 -2
  9. shepherd_core/data_models/base/shepherd.py +21 -12
  10. shepherd_core/data_models/base/timezone.py +5 -0
  11. shepherd_core/data_models/base/wrapper.py +3 -3
  12. shepherd_core/data_models/content/__init__.py +5 -4
  13. shepherd_core/data_models/content/_external_fixtures.yaml +410 -0
  14. shepherd_core/data_models/content/energy_environment.py +7 -5
  15. shepherd_core/data_models/content/energy_environment_fixture.yaml +53 -0
  16. shepherd_core/data_models/content/firmware.py +12 -5
  17. shepherd_core/data_models/content/firmware_datatype.py +7 -0
  18. shepherd_core/data_models/content/virtual_harvester.py +24 -19
  19. shepherd_core/data_models/content/virtual_harvester_fixture.yaml +160 -0
  20. shepherd_core/data_models/content/virtual_source.py +22 -10
  21. shepherd_core/data_models/content/virtual_source_fixture.yaml +230 -0
  22. shepherd_core/data_models/experiment/__init__.py +5 -4
  23. shepherd_core/data_models/experiment/experiment.py +7 -6
  24. shepherd_core/data_models/experiment/observer_features.py +14 -7
  25. shepherd_core/data_models/experiment/target_config.py +11 -7
  26. shepherd_core/data_models/readme.md +88 -0
  27. shepherd_core/data_models/task/__init__.py +10 -3
  28. shepherd_core/data_models/task/emulation.py +10 -7
  29. shepherd_core/data_models/task/firmware_mod.py +4 -2
  30. shepherd_core/data_models/task/harvest.py +5 -4
  31. shepherd_core/data_models/task/observer_tasks.py +3 -1
  32. shepherd_core/data_models/task/programming.py +3 -1
  33. shepherd_core/data_models/task/testbed_tasks.py +3 -1
  34. shepherd_core/data_models/testbed/__init__.py +5 -2
  35. shepherd_core/data_models/testbed/cape.py +7 -5
  36. shepherd_core/data_models/testbed/cape_fixture.yaml +94 -0
  37. shepherd_core/data_models/testbed/gpio.py +10 -8
  38. shepherd_core/data_models/testbed/gpio_fixture.yaml +166 -0
  39. shepherd_core/data_models/testbed/mcu.py +9 -9
  40. shepherd_core/data_models/testbed/mcu_fixture.yaml +19 -0
  41. shepherd_core/data_models/testbed/observer.py +9 -4
  42. shepherd_core/data_models/testbed/observer_fixture.yaml +221 -0
  43. shepherd_core/data_models/testbed/target.py +4 -2
  44. shepherd_core/data_models/testbed/target_fixture.yaml +137 -0
  45. shepherd_core/data_models/testbed/testbed.py +5 -2
  46. shepherd_core/data_models/testbed/testbed_fixture.yaml +25 -0
  47. shepherd_core/decoder_waveform/__init__.py +2 -0
  48. shepherd_core/decoder_waveform/uart.py +43 -25
  49. shepherd_core/fw_tools/__init__.py +2 -0
  50. shepherd_core/fw_tools/converter.py +20 -9
  51. shepherd_core/fw_tools/converter_elf.py +3 -0
  52. shepherd_core/fw_tools/patcher.py +17 -5
  53. shepherd_core/fw_tools/validation.py +27 -6
  54. shepherd_core/inventory/__init__.py +15 -5
  55. shepherd_core/inventory/python.py +4 -0
  56. shepherd_core/inventory/system.py +6 -2
  57. shepherd_core/inventory/target.py +4 -0
  58. shepherd_core/logger.py +5 -0
  59. shepherd_core/reader.py +38 -23
  60. shepherd_core/testbed_client/__init__.py +2 -0
  61. shepherd_core/testbed_client/cache_path.py +2 -0
  62. shepherd_core/testbed_client/client.py +15 -8
  63. shepherd_core/testbed_client/fixtures.py +27 -11
  64. shepherd_core/testbed_client/user_model.py +8 -3
  65. shepherd_core/vsource/__init__.py +2 -0
  66. shepherd_core/vsource/virtual_converter_model.py +10 -3
  67. shepherd_core/vsource/virtual_harvester_model.py +7 -1
  68. shepherd_core/vsource/virtual_source_model.py +9 -5
  69. shepherd_core/writer.py +26 -21
  70. {shepherd_core-2024.4.1.dist-info → shepherd_core-2024.5.1.dist-info}/METADATA +2 -1
  71. shepherd_core-2024.5.1.dist-info/RECORD +75 -0
  72. shepherd_core-2024.4.1.dist-info/RECORD +0 -64
  73. /shepherd_core/data_models/{doc_virtual_source.py → virtual_source_doc.txt} +0 -0
  74. {shepherd_core-2024.4.1.dist-info → shepherd_core-2024.5.1.dist-info}/WHEEL +0 -0
  75. {shepherd_core-2024.4.1.dist-info → shepherd_core-2024.5.1.dist-info}/top_level.txt +0 -0
  76. {shepherd_core-2024.4.1.dist-info → shepherd_core-2024.5.1.dist-info}/zip-safe +0 -0
@@ -0,0 +1,410 @@
1
+ - datatype: EnergyEnvironment
2
+ created: 2024-02-25 12:45:58.488609+02:00
3
+ parameters:
4
+ id: 2639560972524229652
5
+ name: eenv_static_2000mV_10mA_3600s
6
+ description: Artificial static Energy Environment, 2000mV, 10mA, 3600s
7
+ comment: null
8
+ created: 2023-09-27 19:27:02.177941
9
+ updated_last: 2024-02-25 11:32:34.140144
10
+ owner: Ingmar
11
+ group: NES_Lab
12
+ visible2group: true
13
+ visible2all: true
14
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_2000mV_10mA_3600s.h5
15
+ data_type: ivsample
16
+ data_local: false
17
+ duration: 3600.0
18
+ energy_Ws: 72.00000003599966
19
+ valid: true
20
+ light_source: null
21
+ weather_conditions: null
22
+ indoor: true
23
+ location: Lab-VSrc
24
+ - datatype: EnergyEnvironment
25
+ created: 2024-02-25 12:45:58.497654+02:00
26
+ parameters:
27
+ id: 9823394105967169626
28
+ name: eenv_static_2000mV_1mA_3600s
29
+ description: Artificial static Energy Environment, 2000mV, 1mA, 3600s
30
+ comment: null
31
+ created: 2023-09-27 19:28:37.291941
32
+ updated_last: 2024-02-25 11:33:54.292910
33
+ owner: Ingmar
34
+ group: NES_Lab
35
+ visible2group: true
36
+ visible2all: true
37
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_2000mV_1mA_3600s.h5
38
+ data_type: ivsample
39
+ data_local: false
40
+ duration: 3600.0
41
+ energy_Ws: 7.200000003599944
42
+ valid: true
43
+ light_source: null
44
+ weather_conditions: null
45
+ indoor: true
46
+ location: Lab-VSrc
47
+ - datatype: EnergyEnvironment
48
+ created: 2024-02-25 12:45:58.506739+02:00
49
+ parameters:
50
+ id: 3900615675169501222
51
+ name: eenv_static_2000mV_50mA_3600s
52
+ description: Artificial static Energy Environment, 2000mV, 50mA, 3600s
53
+ comment: null
54
+ created: 2023-09-27 19:26:18.621440
55
+ updated_last: 2024-02-25 11:31:53.183281
56
+ owner: Ingmar
57
+ group: NES_Lab
58
+ visible2group: true
59
+ visible2all: true
60
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_2000mV_50mA_3600s.h5
61
+ data_type: ivsample
62
+ data_local: false
63
+ duration: 3600.0
64
+ energy_Ws: 360.00000018000185
65
+ valid: true
66
+ light_source: null
67
+ weather_conditions: null
68
+ indoor: true
69
+ location: Lab-VSrc
70
+ - datatype: EnergyEnvironment
71
+ created: 2024-02-25 12:45:58.515790+02:00
72
+ parameters:
73
+ id: 14796673729431137386
74
+ name: eenv_static_2000mV_5mA_3600s
75
+ description: Artificial static Energy Environment, 2000mV, 5mA, 3600s
76
+ comment: null
77
+ created: 2023-09-27 19:27:48.976440
78
+ updated_last: 2024-02-25 11:33:15.250555
79
+ owner: Ingmar
80
+ group: NES_Lab
81
+ visible2group: true
82
+ visible2all: true
83
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_2000mV_5mA_3600s.h5
84
+ data_type: ivsample
85
+ data_local: false
86
+ duration: 3600.0
87
+ energy_Ws: 36.00000001799983
88
+ valid: true
89
+ light_source: null
90
+ weather_conditions: null
91
+ indoor: true
92
+ location: Lab-VSrc
93
+ - datatype: EnergyEnvironment
94
+ created: 2024-02-25 12:45:58.524761+02:00
95
+ parameters:
96
+ id: 6648482606607441403
97
+ name: eenv_static_3000mV_10mA_3600s
98
+ description: Artificial static Energy Environment, 3000mV, 10mA, 3600s
99
+ comment: null
100
+ created: 2023-09-27 19:24:02.885439
101
+ updated_last: 2024-02-25 11:29:52.671833
102
+ owner: Ingmar
103
+ group: NES_Lab
104
+ visible2group: true
105
+ visible2all: true
106
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_3000mV_10mA_3600s.h5
107
+ data_type: ivsample
108
+ data_local: false
109
+ duration: 3600.0
110
+ energy_Ws: 107.999999999999
111
+ valid: true
112
+ light_source: null
113
+ weather_conditions: null
114
+ indoor: true
115
+ location: Lab-VSrc
116
+ - datatype: EnergyEnvironment
117
+ created: 2024-02-25 12:45:58.533513+02:00
118
+ parameters:
119
+ id: 13566000951043177991
120
+ name: eenv_static_3000mV_1mA_3600s
121
+ description: Artificial static Energy Environment, 3000mV, 1mA, 3600s
122
+ comment: null
123
+ created: 2023-09-27 19:25:32.729442
124
+ updated_last: 2024-02-25 11:31:12.003732
125
+ owner: Ingmar
126
+ group: NES_Lab
127
+ visible2group: true
128
+ visible2all: true
129
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_3000mV_1mA_3600s.h5
130
+ data_type: ivsample
131
+ data_local: false
132
+ duration: 3600.0
133
+ energy_Ws: 10.799999999999885
134
+ valid: true
135
+ light_source: null
136
+ weather_conditions: null
137
+ indoor: true
138
+ location: Lab-VSrc
139
+ - datatype: EnergyEnvironment
140
+ created: 2024-02-25 12:45:58.542278+02:00
141
+ parameters:
142
+ id: 7977778327156610158
143
+ name: eenv_static_3000mV_50mA_3600s
144
+ description: Artificial static Energy Environment, 3000mV, 50mA, 3600s
145
+ comment: null
146
+ created: 2023-09-27 19:23:18.980940
147
+ updated_last: 2024-02-25 11:29:12.185905
148
+ owner: Ingmar
149
+ group: NES_Lab
150
+ visible2group: true
151
+ visible2all: true
152
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_3000mV_50mA_3600s.h5
153
+ data_type: ivsample
154
+ data_local: false
155
+ duration: 3600.0
156
+ energy_Ws: 539.9999999999999
157
+ valid: true
158
+ light_source: null
159
+ weather_conditions: null
160
+ indoor: true
161
+ location: Lab-VSrc
162
+ - datatype: EnergyEnvironment
163
+ created: 2024-02-25 12:45:58.550974+02:00
164
+ parameters:
165
+ id: 4900162978999238419
166
+ name: eenv_static_3000mV_5mA_3600s
167
+ description: Artificial static Energy Environment, 3000mV, 5mA, 3600s
168
+ comment: null
169
+ created: 2023-09-27 19:24:47.092941
170
+ updated_last: 2024-02-25 11:30:33.170119
171
+ owner: Ingmar
172
+ group: NES_Lab
173
+ visible2group: true
174
+ visible2all: true
175
+ data_path: /var/shepherd/content/eenv/nes_lab/eenv_static_3000mV_5mA_3600s.h5
176
+ data_type: ivsample
177
+ data_local: false
178
+ duration: 3600.0
179
+ energy_Ws: 53.9999999999995
180
+ valid: true
181
+ light_source: null
182
+ weather_conditions: null
183
+ indoor: true
184
+ location: Lab-VSrc
185
+ - datatype: Firmware
186
+ created: 2024-02-25 12:45:58.568363+02:00
187
+ parameters:
188
+ id: 3000
189
+ name: msp430_deep_sleep
190
+ description: practically turned off MCU with the lowest possible consumption
191
+ comment: null
192
+ created: 2022-12-12 12:12:12
193
+ updated_last: 2024-02-25 11:45:58.563335
194
+ owner: Ingmar
195
+ group: NES_Lab
196
+ visible2group: true
197
+ visible2all: true
198
+ mcu:
199
+ id: 1002
200
+ name: MSP430FR
201
+ description: 16MHz Ultra-Low-Pwr MCU with 128 KB FRAM
202
+ comment: null
203
+ platform: MSP430
204
+ core: MSP430FR5962
205
+ prog_protocol: SBW
206
+ prog_voltage: 3.0
207
+ prog_datarate: 500000
208
+ fw_name_default: msp430_deep_sleep
209
+ data: /var/shepherd/content/fw/nes_lab/msp430_deep_sleep/build.elf
210
+ data_type: path_elf
211
+ data_hash: null
212
+ data_local: false
213
+ - datatype: Firmware
214
+ created: 2024-02-25 12:45:58.578594+02:00
215
+ parameters:
216
+ id: 3001
217
+ name: msp430_spi_fram
218
+ description: riotee implementation to use MSP as a flash storage
219
+ comment: null
220
+ created: 2022-12-12 12:12:12
221
+ updated_last: 2024-02-25 11:45:58.573327
222
+ owner: Ingmar
223
+ group: NES_Lab
224
+ visible2group: true
225
+ visible2all: true
226
+ mcu:
227
+ id: 1002
228
+ name: MSP430FR
229
+ description: 16MHz Ultra-Low-Pwr MCU with 128 KB FRAM
230
+ comment: null
231
+ platform: MSP430
232
+ core: MSP430FR5962
233
+ prog_protocol: SBW
234
+ prog_voltage: 3.0
235
+ prog_datarate: 500000
236
+ fw_name_default: msp430_deep_sleep
237
+ data: /var/shepherd/content/fw/nes_lab/msp430_spi_fram/build.elf
238
+ data_type: path_elf
239
+ data_hash: null
240
+ data_local: false
241
+ - datatype: Firmware
242
+ created: 2024-02-25 12:45:58.589223+02:00
243
+ parameters:
244
+ id: 3002
245
+ name: msp430_testable
246
+ description: switches on all shared gpio one by one (verification after assembly)
247
+ comment: null
248
+ created: 2022-12-12 12:12:12
249
+ updated_last: 2024-02-25 11:45:58.583701
250
+ owner: Ingmar
251
+ group: NES_Lab
252
+ visible2group: true
253
+ visible2all: true
254
+ mcu:
255
+ id: 1002
256
+ name: MSP430FR
257
+ description: 16MHz Ultra-Low-Pwr MCU with 128 KB FRAM
258
+ comment: null
259
+ platform: MSP430
260
+ core: MSP430FR5962
261
+ prog_protocol: SBW
262
+ prog_voltage: 3.0
263
+ prog_datarate: 500000
264
+ fw_name_default: msp430_deep_sleep
265
+ data: /var/shepherd/content/fw/nes_lab/msp430_testable/build.elf
266
+ data_type: path_elf
267
+ data_hash: null
268
+ data_local: false
269
+ - datatype: Firmware
270
+ created: 2024-02-25 12:45:58.599274+02:00
271
+ parameters:
272
+ id: 7163917825449888392
273
+ name: nrf52_deep_sleep
274
+ description: practically turned off MCU with the lowest possible consumption
275
+ comment: null
276
+ created: 2023-09-13 21:01:52.815691
277
+ updated_last: 2024-02-25 11:45:58.594236
278
+ owner: Ingmar
279
+ group: NES_Lab
280
+ visible2group: true
281
+ visible2all: true
282
+ mcu:
283
+ id: 1001
284
+ name: nRF52
285
+ description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
286
+ comment: null
287
+ platform: nRF52
288
+ core: nRF52840
289
+ prog_protocol: SWD
290
+ prog_voltage: 3.0
291
+ prog_datarate: 500000
292
+ fw_name_default: nrf52_demo_rf
293
+ data: /var/shepherd/content/fw/nes_lab/nrf52_deep_sleep/build.elf
294
+ data_type: path_elf
295
+ data_hash: null
296
+ data_local: false
297
+ - datatype: Firmware
298
+ created: 2024-02-25 12:45:58.609313+02:00
299
+ parameters:
300
+ id: 2000
301
+ name: nrf52_demo_rf
302
+ description: A simple demo that sends BLE packets when energy budget allows it
303
+ comment: null
304
+ created: 2022-12-12 12:12:12
305
+ updated_last: 2024-02-25 11:45:58.604324
306
+ owner: Ingmar
307
+ group: NES_Lab
308
+ visible2group: true
309
+ visible2all: true
310
+ mcu:
311
+ id: 1001
312
+ name: nRF52
313
+ description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
314
+ comment: null
315
+ platform: nRF52
316
+ core: nRF52840
317
+ prog_protocol: SWD
318
+ prog_voltage: 3.0
319
+ prog_datarate: 500000
320
+ fw_name_default: nrf52_demo_rf
321
+ data: /var/shepherd/content/fw/nes_lab/nrf52_demo_rf/build.elf
322
+ data_type: path_elf
323
+ data_hash: null
324
+ data_local: false
325
+ - datatype: Firmware
326
+ created: 2024-02-25 12:45:58.619155+02:00
327
+ parameters:
328
+ id: 3174430733058172825
329
+ name: nrf52_rf_survey
330
+ description: Link Matrix Generator - TX-Unit - sends packet with every possible
331
+ P_TX, loops until stopped
332
+ comment: null
333
+ created: 2023-09-13 21:01:53.308666
334
+ updated_last: 2024-02-25 11:45:58.614199
335
+ owner: Ingmar
336
+ group: NES_Lab
337
+ visible2group: true
338
+ visible2all: true
339
+ mcu:
340
+ id: 1001
341
+ name: nRF52
342
+ description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
343
+ comment: null
344
+ platform: nRF52
345
+ core: nRF52840
346
+ prog_protocol: SWD
347
+ prog_voltage: 3.0
348
+ prog_datarate: 500000
349
+ fw_name_default: nrf52_demo_rf
350
+ data: /var/shepherd/content/fw/nes_lab/nrf52_rf_survey/build.elf
351
+ data_type: path_elf
352
+ data_hash: null
353
+ data_local: false
354
+ - datatype: Firmware
355
+ created: 2024-02-25 12:45:58.628815+02:00
356
+ parameters:
357
+ id: 16381936580724580968
358
+ name: nrf52_rf_test
359
+ description: sends out 1 BLE-Packet per second (verify with an app like 'RaMBLE')
360
+ comment: null
361
+ created: 2023-09-13 21:01:53.575861
362
+ updated_last: 2024-02-25 11:45:58.623974
363
+ owner: Ingmar
364
+ group: NES_Lab
365
+ visible2group: true
366
+ visible2all: true
367
+ mcu:
368
+ id: 1001
369
+ name: nRF52
370
+ description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
371
+ comment: null
372
+ platform: nRF52
373
+ core: nRF52840
374
+ prog_protocol: SWD
375
+ prog_voltage: 3.0
376
+ prog_datarate: 500000
377
+ fw_name_default: nrf52_demo_rf
378
+ data: /var/shepherd/content/fw/nes_lab/nrf52_rf_test/build.elf
379
+ data_type: path_elf
380
+ data_hash: null
381
+ data_local: false
382
+ - datatype: Firmware
383
+ created: 2024-02-25 12:45:58.638812+02:00
384
+ parameters:
385
+ id: 2002
386
+ name: nrf52_testable
387
+ description: watches all gpio and reports with UART messages (verification after
388
+ assembly)
389
+ comment: null
390
+ created: 2022-12-12 12:12:12
391
+ updated_last: 2024-02-25 11:45:58.633957
392
+ owner: Ingmar
393
+ group: NES_Lab
394
+ visible2group: true
395
+ visible2all: true
396
+ mcu:
397
+ id: 1001
398
+ name: nRF52
399
+ description: Panasonic PAN1780, ENW-89854A1KF, Bluetooth 5 Low Energy Module
400
+ comment: null
401
+ platform: nRF52
402
+ core: nRF52840
403
+ prog_protocol: SWD
404
+ prog_voltage: 3.0
405
+ prog_datarate: 500000
406
+ fw_name_default: nrf52_demo_rf
407
+ data: /var/shepherd/content/fw/nes_lab/nrf52_testable/build.elf
408
+ data_type: path_elf
409
+ data_hash: null
410
+ data_local: false
@@ -1,3 +1,5 @@
1
+ """Data-model for recorded eEnvs."""
2
+
1
3
  from enum import Enum
2
4
  from pathlib import Path
3
5
  from typing import Optional
@@ -10,15 +12,15 @@ from ..base.content import ContentModel
10
12
 
11
13
 
12
14
  class EnergyDType(str, Enum):
13
- ivsample = "ivsample"
14
- ivsamples = "ivsample"
15
- ivcurve = "ivcurve"
16
- ivcurves = "ivcurve" # a stream could also be called iv-surface
15
+ """Data-Type-Options for energy environments."""
16
+
17
+ ivsample = ivsamples = "ivsample"
18
+ ivcurve = ivcurves = ivsurface = "ivcurve"
17
19
  isc_voc = "isc_voc"
18
20
 
19
21
 
20
22
  class EnergyEnvironment(ContentModel):
21
- """Recording of meta-data representation of a testbed-component"""
23
+ """Recording of meta-data representation of a testbed-component."""
22
24
 
23
25
  # General Metadata & Ownership -> ContentModel
24
26
 
@@ -0,0 +1,53 @@
1
+ - datatype: EnergyEnvironment
2
+ parameters:
3
+ id: 1001
4
+ name: SolarSunny
5
+ description: MOCKUP! Sunny Day with 4 sq-cm Solar Cell
6
+ data_path: eenv/group/user/solar_4h_new.h5
7
+ data_type: ivsample
8
+ duration: 14400
9
+ energy_Ws: 0.5
10
+ valid: true
11
+
12
+ owner: Ingmar
13
+ group: NES Lab
14
+ visible2group: true
15
+ visible2all: true
16
+ created: 2022-12-12 12:12:12
17
+ updated_last: 2022-12-12 12:12:12
18
+
19
+ - datatype: EnergyEnvironment
20
+ parameters:
21
+ id: 1002
22
+ name: ThermoelectricWashingMachine
23
+ description: MOCKUP! Energy harvested from side of machine during washing & tumbling
24
+ data_path: eenv/group/user/thermoelectric_1h_wash.h5
25
+ data_type: ivcurve
26
+ duration: 3600
27
+ energy_Ws: 0.1
28
+ valid: true
29
+
30
+ owner: Ingmar
31
+ group: NES Lab
32
+ visible2group: true
33
+ visible2all: true
34
+ created: 2022-12-12 12:12:12
35
+ updated_last: 2022-12-12 12:12:12
36
+
37
+ - datatype: EnergyEnvironment
38
+ parameters:
39
+ id: 666
40
+ name: nuclear
41
+ description: MOCKUP! Energy harvested
42
+ data_path: eenv/group/user/thermoelectric_1h_wash.h5
43
+ data_type: ivcurve
44
+ duration: 3600
45
+ energy_Ws: 0.1
46
+ valid: false
47
+
48
+ owner: Ingmar
49
+ group: NES Lab
50
+ visible2group: true
51
+ visible2all: true
52
+ created: 2022-12-12 12:12:12
53
+ updated_last: 2022-12-12 12:12:12
@@ -1,3 +1,8 @@
1
+ """Handling firmware for targets.
2
+
3
+ TODO: should be more generalized - currently only supports msp & nRF
4
+ """
5
+
1
6
  from pathlib import Path
2
7
  from typing import Optional
3
8
  from typing import TypedDict
@@ -45,7 +50,7 @@ FirmwareStr = Annotated[str, StringConstraints(min_length=3, max_length=8_000_00
45
50
 
46
51
 
47
52
  class Firmware(ContentModel, title="Firmware of Target"):
48
- """meta-data representation of a data-component"""
53
+ """meta-data representation of a data-component."""
49
54
 
50
55
  # General Metadata & Ownership -> ContentModel
51
56
 
@@ -91,9 +96,10 @@ class Firmware(ContentModel, title="Firmware of Target"):
91
96
  embed: bool = True,
92
97
  **kwargs: Unpack[TypedDict],
93
98
  ) -> Self:
94
- """Embeds firmware and tries to fill parameters
99
+ """Embeds firmware and tries to fill parameters.
100
+
95
101
  ELF -> mcu und data_type are deducted
96
- HEX -> must supply mcu manually
102
+ HEX -> must supply mcu manually.
97
103
  """
98
104
  # TODO: use new determine_type() & determine_arch() and also allow to not embed
99
105
  kwargs["data_hash"] = fw_tools.file_to_hash(file)
@@ -113,7 +119,7 @@ class Firmware(ContentModel, title="Firmware of Target"):
113
119
  elif fw_tools.is_hex_nrf52(file):
114
120
  arch = "nrf52"
115
121
  else:
116
- raise ValueError("File is not a HEX for the Testbed")
122
+ raise ValueError("File is not a suitable HEX for the Testbed")
117
123
  if "mcu" not in kwargs:
118
124
  kwargs["mcu"] = arch_to_mcu[arch]
119
125
 
@@ -150,7 +156,8 @@ class Firmware(ContentModel, title="Firmware of Target"):
150
156
 
151
157
  @validate_call
152
158
  def extract_firmware(self, file: Path) -> Path:
153
- """Stores embedded data in file
159
+ """Store embedded fw-data in file.
160
+
154
161
  - file-suffix is derived from data-type and adapted
155
162
  - if provided path is a directory, the firmware-name is used
156
163
  """
@@ -1,7 +1,14 @@
1
+ """Separated data-type.
2
+
3
+ Done due to cyclic inheritance.
4
+ """
5
+
1
6
  from enum import Enum
2
7
 
3
8
 
4
9
  class FirmwareDType(str, Enum):
10
+ """Options for firmware-types."""
11
+
5
12
  base64_hex = "hex"
6
13
  base64_elf = "elf"
7
14
  path_hex = "path_hex"
@@ -1,3 +1,5 @@
1
+ """Generalized energy harvester data models."""
2
+
1
3
  from enum import Enum
2
4
  from typing import Optional
3
5
  from typing import Tuple
@@ -17,22 +19,22 @@ from .energy_environment import EnergyDType
17
19
 
18
20
 
19
21
  class AlgorithmDType(str, Enum):
22
+ """Options for choosing a harvesting algorithm."""
23
+
20
24
  isc_voc = "isc_voc"
21
- ivcurve = ("ivcurve",)
22
- ivcurves = ("ivcurve",)
23
- cv = "cv"
24
- constant = "cv"
25
+ ivcurve = ivcurves = ("ivcurve",)
26
+ constant = cv = "cv"
25
27
  # ci .. constant current -> is this desired?
26
28
  mppt_voc = "mppt_voc"
27
- mppt_po = "mppt_po"
28
- perturb_observe = "mppt_po"
29
- mppt_opt = "mppt_opt"
30
- optimal = "mppt_opt"
29
+ mppt_po = perturb_observe = "mppt_po"
30
+ mppt_opt = optimal = "mppt_opt"
31
31
 
32
32
 
33
33
  class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
34
- """A Harvester is needed when the file-based energy environment
35
- of the virtual source is not already supplied as ivsample
34
+ """A vHrv makes a source-characterization (i.e. ivcurve) usable for the vSrc.
35
+
36
+ Mostly used when the file-based energy environment of the virtual source
37
+ is not already supplied as pre-harvested ivsample-stream.
36
38
  """
37
39
 
38
40
  # General Metadata & Ownership -> ContentModel
@@ -110,19 +112,21 @@ class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
110
112
  def calc_algorithm_num(self, *, for_emu: bool) -> int:
111
113
  num = algo_to_num.get(self.algorithm)
112
114
  if for_emu and self.get_datatype() != EnergyDType.ivsample:
113
- raise ValueError(
115
+ msg = (
114
116
  f"[{self.name}] Select valid harvest-algorithm for emulator, "
115
- f"current usage = {self.algorithm}",
117
+ f"current usage = {self.algorithm}"
116
118
  )
119
+ raise ValueError(msg)
117
120
  if num < algo_to_num["isc_voc"]:
118
- raise ValueError(
121
+ msg = (
119
122
  f"[{self.name}] Select valid harvest-algorithm for harvester, "
120
- f"current usage = {self.algorithm}",
123
+ f"current usage = {self.algorithm}"
121
124
  )
125
+ raise ValueError(msg)
122
126
  return num
123
127
 
124
128
  def calc_timings_ms(self, *, for_emu: bool) -> Tuple[float, float]:
125
- """factor-in model-internal timing-constraints"""
129
+ """factor-in model-internal timing-constraints."""
126
130
  window_length = self.samples_n * (1 + self.wait_cycles)
127
131
  time_min_ms = (1 + self.wait_cycles) * 1_000 / samplerate_sps_default
128
132
  if for_emu:
@@ -155,7 +159,7 @@ class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
155
159
  if dtype_in == EnergyDType.ivsample:
156
160
  return 0
157
161
  # isc_voc: 2 * (1 + wait_cycles), noqa
158
- raise ValueError("Not Implemented")
162
+ raise NotImplementedError
159
163
 
160
164
  # only used by ivcurve algo (in ADC-Mode)
161
165
  return self.samples_n
@@ -191,11 +195,12 @@ algo_to_dtype = {
191
195
 
192
196
 
193
197
  class HarvesterPRUConfig(ShpModel):
194
- """Map settings-list to internal state-vars struct HarvesterConfig
198
+ """Map settings-list to internal state-vars struct HarvesterConfig for PRU.
199
+
195
200
  NOTE:
196
201
  - yaml is based on si-units like nA, mV, ms, uF
197
202
  - c-code and py-copy is using nA, uV, ns, nF, fW, raw
198
- - ordering is intentional and in sync with shepherd/commons.h
203
+ - ordering is intentional and in sync with shepherd/commons.h.
199
204
  """
200
205
 
201
206
  algorithm: u32
@@ -228,7 +233,7 @@ class HarvesterPRUConfig(ShpModel):
228
233
  if isinstance(dtype_in, str):
229
234
  dtype_in = EnergyDType[dtype_in]
230
235
  if for_emu and dtype_in not in {EnergyDType.ivsample, EnergyDType.ivcurve}:
231
- raise ValueError("Not Implemented")
236
+ raise NotImplementedError
232
237
  # TODO: use dtype properly in shepherd
233
238
  interval_ms, duration_ms = data.calc_timings_ms(for_emu=for_emu)
234
239
  return cls(