shepherd-core 2023.12.1__py3-none-any.whl → 2024.4.2__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 (116) hide show
  1. shepherd_core/__init__.py +5 -4
  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 +41 -16
  8. shepherd_core/data_models/base/content.py +20 -5
  9. shepherd_core/data_models/base/shepherd.py +23 -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 +32 -16
  14. shepherd_core/data_models/content/energy_environment.py +7 -5
  15. shepherd_core/data_models/content/energy_environment_fixture.yaml +3 -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 +25 -20
  19. shepherd_core/data_models/content/virtual_harvester_fixture.yaml +1 -0
  20. shepherd_core/data_models/content/virtual_source.py +40 -23
  21. shepherd_core/data_models/content/virtual_source_fixture.yaml +1 -0
  22. shepherd_core/data_models/experiment/__init__.py +5 -4
  23. shepherd_core/data_models/experiment/experiment.py +16 -15
  24. shepherd_core/data_models/experiment/observer_features.py +18 -12
  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 +9 -6
  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 +4 -2
  32. shepherd_core/data_models/task/programming.py +3 -1
  33. shepherd_core/data_models/task/testbed_tasks.py +10 -4
  34. shepherd_core/data_models/testbed/__init__.py +5 -2
  35. shepherd_core/data_models/testbed/cape.py +8 -6
  36. shepherd_core/data_models/testbed/gpio.py +11 -9
  37. shepherd_core/data_models/testbed/mcu.py +10 -10
  38. shepherd_core/data_models/testbed/observer.py +10 -5
  39. shepherd_core/data_models/testbed/observer_fixture.yaml +23 -22
  40. shepherd_core/data_models/testbed/target.py +5 -3
  41. shepherd_core/data_models/testbed/target_fixture.yaml +11 -11
  42. shepherd_core/data_models/testbed/testbed.py +6 -3
  43. shepherd_core/decoder_waveform/__init__.py +2 -0
  44. shepherd_core/decoder_waveform/uart.py +44 -25
  45. shepherd_core/fw_tools/__init__.py +2 -0
  46. shepherd_core/fw_tools/converter.py +20 -9
  47. shepherd_core/fw_tools/converter_elf.py +3 -0
  48. shepherd_core/fw_tools/patcher.py +16 -4
  49. shepherd_core/fw_tools/validation.py +25 -5
  50. shepherd_core/inventory/__init__.py +66 -6
  51. shepherd_core/inventory/python.py +4 -0
  52. shepherd_core/inventory/system.py +13 -1
  53. shepherd_core/inventory/target.py +4 -0
  54. shepherd_core/logger.py +5 -0
  55. shepherd_core/reader.py +44 -26
  56. shepherd_core/testbed_client/__init__.py +2 -0
  57. shepherd_core/testbed_client/cache_path.py +17 -0
  58. shepherd_core/testbed_client/client.py +14 -8
  59. shepherd_core/testbed_client/fixtures.py +30 -11
  60. shepherd_core/testbed_client/user_model.py +13 -6
  61. shepherd_core/vsource/__init__.py +2 -0
  62. shepherd_core/vsource/virtual_converter_model.py +11 -4
  63. shepherd_core/vsource/virtual_harvester_model.py +8 -1
  64. shepherd_core/vsource/virtual_source_model.py +10 -5
  65. shepherd_core/writer.py +28 -20
  66. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/METADATA +50 -34
  67. shepherd_core-2024.4.2.dist-info/RECORD +75 -0
  68. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/WHEEL +1 -1
  69. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/top_level.txt +0 -1
  70. shepherd_core-2023.12.1.dist-info/RECORD +0 -117
  71. tests/__init__.py +0 -0
  72. tests/conftest.py +0 -64
  73. tests/data_models/__init__.py +0 -0
  74. tests/data_models/conftest.py +0 -14
  75. tests/data_models/example_cal_data.yaml +0 -31
  76. tests/data_models/example_cal_data_faulty.yaml +0 -29
  77. tests/data_models/example_cal_meas.yaml +0 -178
  78. tests/data_models/example_cal_meas_faulty1.yaml +0 -142
  79. tests/data_models/example_cal_meas_faulty2.yaml +0 -136
  80. tests/data_models/example_config_emulator.yaml +0 -41
  81. tests/data_models/example_config_experiment.yaml +0 -16
  82. tests/data_models/example_config_experiment_alternative.yaml +0 -14
  83. tests/data_models/example_config_harvester.yaml +0 -15
  84. tests/data_models/example_config_testbed.yaml +0 -26
  85. tests/data_models/example_config_virtsource.yaml +0 -78
  86. tests/data_models/test_base_models.py +0 -205
  87. tests/data_models/test_content_fixtures.py +0 -41
  88. tests/data_models/test_content_models.py +0 -282
  89. tests/data_models/test_examples.py +0 -48
  90. tests/data_models/test_experiment_models.py +0 -277
  91. tests/data_models/test_task_generation.py +0 -52
  92. tests/data_models/test_task_models.py +0 -131
  93. tests/data_models/test_testbed_fixtures.py +0 -47
  94. tests/data_models/test_testbed_models.py +0 -187
  95. tests/decoder_waveform/__init__.py +0 -0
  96. tests/decoder_waveform/test_decoder.py +0 -34
  97. tests/fw_tools/__init__.py +0 -0
  98. tests/fw_tools/conftest.py +0 -5
  99. tests/fw_tools/test_converter.py +0 -76
  100. tests/fw_tools/test_patcher.py +0 -66
  101. tests/fw_tools/test_validation.py +0 -56
  102. tests/inventory/__init__.py +0 -0
  103. tests/inventory/test_inventory.py +0 -20
  104. tests/test_cal_hw.py +0 -34
  105. tests/test_examples.py +0 -40
  106. tests/test_logger.py +0 -15
  107. tests/test_reader.py +0 -283
  108. tests/test_writer.py +0 -169
  109. tests/testbed_client/__init__.py +0 -0
  110. tests/vsource/__init__.py +0 -0
  111. tests/vsource/conftest.py +0 -49
  112. tests/vsource/test_converter.py +0 -161
  113. tests/vsource/test_harvester.py +0 -73
  114. tests/vsource/test_z.py +0 -5
  115. /shepherd_core/data_models/{doc_virtual_source.py → virtual_source_doc.txt} +0 -0
  116. {shepherd_core-2023.12.1.dist-info → shepherd_core-2024.4.2.dist-info}/zip-safe +0 -0
@@ -1,11 +1,12 @@
1
1
  - datatype: EnergyEnvironment
2
- created: 2023-09-27 19:51:44.779899
2
+ created: 2024-02-25 12:45:58.488609+02:00
3
3
  parameters:
4
4
  id: 2639560972524229652
5
5
  name: eenv_static_2000mV_10mA_3600s
6
6
  description: Artificial static Energy Environment, 2000mV, 10mA, 3600s
7
7
  comment: null
8
8
  created: 2023-09-27 19:27:02.177941
9
+ updated_last: 2024-02-25 11:32:34.140144
9
10
  owner: Ingmar
10
11
  group: NES_Lab
11
12
  visible2group: true
@@ -21,13 +22,14 @@
21
22
  indoor: true
22
23
  location: Lab-VSrc
23
24
  - datatype: EnergyEnvironment
24
- created: 2023-09-27 19:51:44.783398
25
+ created: 2024-02-25 12:45:58.497654+02:00
25
26
  parameters:
26
27
  id: 9823394105967169626
27
28
  name: eenv_static_2000mV_1mA_3600s
28
29
  description: Artificial static Energy Environment, 2000mV, 1mA, 3600s
29
30
  comment: null
30
31
  created: 2023-09-27 19:28:37.291941
32
+ updated_last: 2024-02-25 11:33:54.292910
31
33
  owner: Ingmar
32
34
  group: NES_Lab
33
35
  visible2group: true
@@ -43,13 +45,14 @@
43
45
  indoor: true
44
46
  location: Lab-VSrc
45
47
  - datatype: EnergyEnvironment
46
- created: 2023-09-27 19:51:44.786899
48
+ created: 2024-02-25 12:45:58.506739+02:00
47
49
  parameters:
48
50
  id: 3900615675169501222
49
51
  name: eenv_static_2000mV_50mA_3600s
50
52
  description: Artificial static Energy Environment, 2000mV, 50mA, 3600s
51
53
  comment: null
52
54
  created: 2023-09-27 19:26:18.621440
55
+ updated_last: 2024-02-25 11:31:53.183281
53
56
  owner: Ingmar
54
57
  group: NES_Lab
55
58
  visible2group: true
@@ -65,13 +68,14 @@
65
68
  indoor: true
66
69
  location: Lab-VSrc
67
70
  - datatype: EnergyEnvironment
68
- created: 2023-09-27 19:51:44.790399
71
+ created: 2024-02-25 12:45:58.515790+02:00
69
72
  parameters:
70
73
  id: 14796673729431137386
71
74
  name: eenv_static_2000mV_5mA_3600s
72
75
  description: Artificial static Energy Environment, 2000mV, 5mA, 3600s
73
76
  comment: null
74
77
  created: 2023-09-27 19:27:48.976440
78
+ updated_last: 2024-02-25 11:33:15.250555
75
79
  owner: Ingmar
76
80
  group: NES_Lab
77
81
  visible2group: true
@@ -87,13 +91,14 @@
87
91
  indoor: true
88
92
  location: Lab-VSrc
89
93
  - datatype: EnergyEnvironment
90
- created: 2023-09-27 19:51:44.793899
94
+ created: 2024-02-25 12:45:58.524761+02:00
91
95
  parameters:
92
96
  id: 6648482606607441403
93
97
  name: eenv_static_3000mV_10mA_3600s
94
98
  description: Artificial static Energy Environment, 3000mV, 10mA, 3600s
95
99
  comment: null
96
100
  created: 2023-09-27 19:24:02.885439
101
+ updated_last: 2024-02-25 11:29:52.671833
97
102
  owner: Ingmar
98
103
  group: NES_Lab
99
104
  visible2group: true
@@ -109,13 +114,14 @@
109
114
  indoor: true
110
115
  location: Lab-VSrc
111
116
  - datatype: EnergyEnvironment
112
- created: 2023-09-27 19:51:44.796898
117
+ created: 2024-02-25 12:45:58.533513+02:00
113
118
  parameters:
114
119
  id: 13566000951043177991
115
120
  name: eenv_static_3000mV_1mA_3600s
116
121
  description: Artificial static Energy Environment, 3000mV, 1mA, 3600s
117
122
  comment: null
118
123
  created: 2023-09-27 19:25:32.729442
124
+ updated_last: 2024-02-25 11:31:12.003732
119
125
  owner: Ingmar
120
126
  group: NES_Lab
121
127
  visible2group: true
@@ -131,13 +137,14 @@
131
137
  indoor: true
132
138
  location: Lab-VSrc
133
139
  - datatype: EnergyEnvironment
134
- created: 2023-09-27 19:51:44.800400
140
+ created: 2024-02-25 12:45:58.542278+02:00
135
141
  parameters:
136
142
  id: 7977778327156610158
137
143
  name: eenv_static_3000mV_50mA_3600s
138
144
  description: Artificial static Energy Environment, 3000mV, 50mA, 3600s
139
145
  comment: null
140
146
  created: 2023-09-27 19:23:18.980940
147
+ updated_last: 2024-02-25 11:29:12.185905
141
148
  owner: Ingmar
142
149
  group: NES_Lab
143
150
  visible2group: true
@@ -153,13 +160,14 @@
153
160
  indoor: true
154
161
  location: Lab-VSrc
155
162
  - datatype: EnergyEnvironment
156
- created: 2023-09-27 19:51:44.803899
163
+ created: 2024-02-25 12:45:58.550974+02:00
157
164
  parameters:
158
165
  id: 4900162978999238419
159
166
  name: eenv_static_3000mV_5mA_3600s
160
167
  description: Artificial static Energy Environment, 3000mV, 5mA, 3600s
161
168
  comment: null
162
169
  created: 2023-09-27 19:24:47.092941
170
+ updated_last: 2024-02-25 11:30:33.170119
163
171
  owner: Ingmar
164
172
  group: NES_Lab
165
173
  visible2group: true
@@ -175,13 +183,14 @@
175
183
  indoor: true
176
184
  location: Lab-VSrc
177
185
  - datatype: Firmware
178
- created: 2023-09-27 19:51:44.816899
186
+ created: 2024-02-25 12:45:58.568363+02:00
179
187
  parameters:
180
188
  id: 3000
181
189
  name: msp430_deep_sleep
182
190
  description: practically turned off MCU with the lowest possible consumption
183
191
  comment: null
184
192
  created: 2022-12-12 12:12:12
193
+ updated_last: 2024-02-25 11:45:58.563335
185
194
  owner: Ingmar
186
195
  group: NES_Lab
187
196
  visible2group: true
@@ -202,13 +211,14 @@
202
211
  data_hash: null
203
212
  data_local: false
204
213
  - datatype: Firmware
205
- created: 2023-09-27 19:51:44.820399
214
+ created: 2024-02-25 12:45:58.578594+02:00
206
215
  parameters:
207
216
  id: 3001
208
217
  name: msp430_spi_fram
209
218
  description: riotee implementation to use MSP as a flash storage
210
219
  comment: null
211
220
  created: 2022-12-12 12:12:12
221
+ updated_last: 2024-02-25 11:45:58.573327
212
222
  owner: Ingmar
213
223
  group: NES_Lab
214
224
  visible2group: true
@@ -229,13 +239,14 @@
229
239
  data_hash: null
230
240
  data_local: false
231
241
  - datatype: Firmware
232
- created: 2023-09-27 19:51:44.823899
242
+ created: 2024-02-25 12:45:58.589223+02:00
233
243
  parameters:
234
244
  id: 3002
235
245
  name: msp430_testable
236
246
  description: switches on all shared gpio one by one (verification after assembly)
237
247
  comment: null
238
248
  created: 2022-12-12 12:12:12
249
+ updated_last: 2024-02-25 11:45:58.583701
239
250
  owner: Ingmar
240
251
  group: NES_Lab
241
252
  visible2group: true
@@ -256,13 +267,14 @@
256
267
  data_hash: null
257
268
  data_local: false
258
269
  - datatype: Firmware
259
- created: 2023-09-27 19:51:44.827399
270
+ created: 2024-02-25 12:45:58.599274+02:00
260
271
  parameters:
261
272
  id: 7163917825449888392
262
273
  name: nrf52_deep_sleep
263
274
  description: practically turned off MCU with the lowest possible consumption
264
275
  comment: null
265
276
  created: 2023-09-13 21:01:52.815691
277
+ updated_last: 2024-02-25 11:45:58.594236
266
278
  owner: Ingmar
267
279
  group: NES_Lab
268
280
  visible2group: true
@@ -283,13 +295,14 @@
283
295
  data_hash: null
284
296
  data_local: false
285
297
  - datatype: Firmware
286
- created: 2023-09-27 19:51:44.831400
298
+ created: 2024-02-25 12:45:58.609313+02:00
287
299
  parameters:
288
300
  id: 2000
289
301
  name: nrf52_demo_rf
290
302
  description: A simple demo that sends BLE packets when energy budget allows it
291
303
  comment: null
292
304
  created: 2022-12-12 12:12:12
305
+ updated_last: 2024-02-25 11:45:58.604324
293
306
  owner: Ingmar
294
307
  group: NES_Lab
295
308
  visible2group: true
@@ -310,7 +323,7 @@
310
323
  data_hash: null
311
324
  data_local: false
312
325
  - datatype: Firmware
313
- created: 2023-09-27 19:51:44.834899
326
+ created: 2024-02-25 12:45:58.619155+02:00
314
327
  parameters:
315
328
  id: 3174430733058172825
316
329
  name: nrf52_rf_survey
@@ -318,6 +331,7 @@
318
331
  P_TX, loops until stopped
319
332
  comment: null
320
333
  created: 2023-09-13 21:01:53.308666
334
+ updated_last: 2024-02-25 11:45:58.614199
321
335
  owner: Ingmar
322
336
  group: NES_Lab
323
337
  visible2group: true
@@ -338,13 +352,14 @@
338
352
  data_hash: null
339
353
  data_local: false
340
354
  - datatype: Firmware
341
- created: 2023-09-27 19:51:44.838398
355
+ created: 2024-02-25 12:45:58.628815+02:00
342
356
  parameters:
343
357
  id: 16381936580724580968
344
358
  name: nrf52_rf_test
345
359
  description: sends out 1 BLE-Packet per second (verify with an app like 'RaMBLE')
346
360
  comment: null
347
361
  created: 2023-09-13 21:01:53.575861
362
+ updated_last: 2024-02-25 11:45:58.623974
348
363
  owner: Ingmar
349
364
  group: NES_Lab
350
365
  visible2group: true
@@ -365,7 +380,7 @@
365
380
  data_hash: null
366
381
  data_local: false
367
382
  - datatype: Firmware
368
- created: 2023-09-27 19:51:44.841899
383
+ created: 2024-02-25 12:45:58.638812+02:00
369
384
  parameters:
370
385
  id: 2002
371
386
  name: nrf52_testable
@@ -373,6 +388,7 @@
373
388
  assembly)
374
389
  comment: null
375
390
  created: 2022-12-12 12:12:12
391
+ updated_last: 2024-02-25 11:45:58.633957
376
392
  owner: Ingmar
377
393
  group: NES_Lab
378
394
  visible2group: true
@@ -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"
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
 
@@ -14,6 +14,7 @@
14
14
  visible2group: true
15
15
  visible2all: true
16
16
  created: 2022-12-12 12:12:12
17
+ updated_last: 2022-12-12 12:12:12
17
18
 
18
19
  - datatype: EnergyEnvironment
19
20
  parameters:
@@ -31,6 +32,7 @@
31
32
  visible2group: true
32
33
  visible2all: true
33
34
  created: 2022-12-12 12:12:12
35
+ updated_last: 2022-12-12 12:12:12
34
36
 
35
37
  - datatype: EnergyEnvironment
36
38
  parameters:
@@ -48,3 +50,4 @@
48
50
  visible2group: true
49
51
  visible2all: true
50
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
@@ -76,7 +78,7 @@ class VirtualHarvesterConfig(ContentModel, title="Config for the Harvester"):
76
78
  logger.debug("VHrv-Inheritances: %s", chain)
77
79
 
78
80
  # post corrections -> should be in separate validator
79
- cal = CalibrationHarvester() # todo: as argument?
81
+ cal = CalibrationHarvester() # TODO: as argument?
80
82
  c_limit = values.get("current_limit_uA", 50_000) # cls.current_limit_uA)
81
83
  values["current_limit_uA"] = max(10**6 * cal.adc_C_Hrv.raw_to_si(4), c_limit)
82
84
 
@@ -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(
@@ -12,6 +12,7 @@
12
12
  visible2group: true
13
13
  visible2all: true
14
14
  created: 2022-12-12 12:12:12
15
+ updated_last: 2022-12-12 12:12:12
15
16
 
16
17
  - datatype: VirtualHarvesterConfig
17
18
  parameters:
@@ -1,3 +1,5 @@
1
+ """Generalized virtual source data models."""
2
+
1
3
  from typing import List
2
4
 
3
5
  from pydantic import Field
@@ -8,8 +10,8 @@ from typing_extensions import Self
8
10
  from ...commons import samplerate_sps_default
9
11
  from ...logger import logger
10
12
  from ...testbed_client import tb_client
11
- from .. import ShpModel
12
13
  from ..base.content import ContentModel
14
+ from ..base.shepherd import ShpModel
13
15
  from .virtual_harvester import HarvesterPRUConfig
14
16
  from .virtual_harvester import VirtualHarvesterConfig
15
17
 
@@ -21,16 +23,19 @@ LUT2D = Annotated[List[LUT1D], Field(min_length=LUT_SIZE, max_length=LUT_SIZE)]
21
23
 
22
24
 
23
25
  class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
24
- """The virtual Source uses the energy environment (file)
25
- for supplying the Target Node during the experiment.
26
- If not already done, the energy will be harvested and then converted.
26
+ """The vSrc uses the energy environment (file) for supplying the Target Node.
27
+
28
+ If not already done, the energy will be harvested and
29
+ then converted during the experiment.
30
+
27
31
  The converter-stage is software defined and offers:
28
- buck-boost-combinations,
29
- a simple diode + resistor and
30
- an intermediate buffer capacitor.
31
- TODO: I,V,R should be in regular unit (V, A, Ohm)
32
+ - buck-boost-combinations,
33
+ - a simple diode + resistor and
34
+ - an intermediate buffer capacitor.
32
35
  """
33
36
 
37
+ # TODO: I,V,R should be in regular unit (V, A, Ohm)
38
+
34
39
  # General Metadata & Ownership -> ContentModel
35
40
 
36
41
  enable_boost: bool = False
@@ -116,21 +121,30 @@ class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
116
121
  return self
117
122
 
118
123
  def calc_internal_states(self) -> dict:
119
- """Compensate for (hard to detect) current-surge of real capacitors
120
- when converter gets turned on -> this can be const value, because
121
- the converter always turns on with "V_storage_enable_threshold_uV"
124
+ """Update the model-states for the capacitor and other elements.
125
+
126
+ This also compensates for current-surge of real capacitors
127
+ when the converter gets turned on:
128
+
129
+ - surges are hard to detect & record
130
+ - this can be const value, because
131
+ - the converter always turns on with "V_storage_enable_threshold_uV".
132
+
122
133
  TODO: currently neglecting delay after disabling converter, boost
123
134
  only has simpler formula, second enabling when V_Cap >= V_out
124
135
 
125
136
  Math behind this calculation:
126
- Energy-Change Storage Cap -> E_new = E_old - E_output
127
- with Energy of a Cap -> E_x = C_x * V_x^2 / 2
128
- combine formulas ->
129
- C_store * V_store_new^2 / 2 = C_store * V_store_old^2 / 2 - C_out * V_out^2 / 2
130
- convert formula to V_new -> V_store_new^2 = V_store_old^2 - (C_out / C_store) * V_out^2
131
- convert into dV -> dV = V_store_new - V_store_old
132
- in case of V_cap = V_out -> dV = V_store_old * (sqrt(1 - C_out / C_store) - 1)
133
- -> dV values will be reversed (negated), because dV is always negative (Voltage drop)
137
+
138
+ - Energy-Change Storage Cap -> E_new = E_old - E_output
139
+ - with Energy of a Cap -> E_x = C_x * V_x^2 / 2
140
+ - combine formulas -> C_store * V_store_new^2 / 2 =
141
+ C_store * V_store_old^2 / 2 - C_out * V_out^2 / 2
142
+ - convert formula to V_new -> V_store_new^2 =
143
+ V_store_old^2 - (C_out / C_store) * V_out^2
144
+ - convert into dV -> dV = V_store_new - V_store_old
145
+ - in case of V_cap = V_out -> dV = V_store_old * (sqrt(1 - C_out / C_store) - 1)
146
+
147
+ Note: dV values will be reversed (negated), because dV is always negative (Voltage drop)
134
148
  """
135
149
  values = {}
136
150
  if self.C_intermediate_uF > 0 and self.C_output_uF > 0:
@@ -185,9 +199,10 @@ class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
185
199
  return values
186
200
 
187
201
  def calc_converter_mode(self, *, log_intermediate_node: bool) -> int:
188
- """Assembles bitmask from discrete values
202
+ """Assembles bitmask from discrete values.
203
+
189
204
  log_intermediate_node: record / log virtual intermediate (cap-)voltage and
190
- -current (out) instead of output-voltage and -current
205
+ -current (out) instead of output-voltage and -current
191
206
  """
192
207
  enable_storage = self.C_intermediate_uF > 0
193
208
  enable_boost = self.enable_boost and enable_storage
@@ -199,7 +214,8 @@ class VirtualSourceConfig(ContentModel, title="Config for the virtual Source"):
199
214
  )
200
215
 
201
216
  def calc_cap_constant_us_per_nF_n28(self) -> int:
202
- """Calc constant to convert capacitor-current to Voltage-delta
217
+ """Calc constant to convert capacitor-current to Voltage-delta.
218
+
203
219
  dV[uV] = constant[us/nF] * current[nA] = constant[us*V/nAs] * current[nA]
204
220
  """
205
221
  C_cap_uF = max(self.C_intermediate_uF, 0.001)
@@ -219,7 +235,8 @@ lut_o = Annotated[List[u32], Field(min_length=LUT_SIZE, max_length=LUT_SIZE)]
219
235
 
220
236
 
221
237
  class ConverterPRUConfig(ShpModel):
222
- """Map settings-list to internal state-vars struct ConverterConfig
238
+ """Map settings-list to internal state-vars struct ConverterConfig.
239
+
223
240
  NOTE:
224
241
  - yaml is based on si-units like nA, mV, ms, uF
225
242
  - c-code and py-copy is using nA, uV, ns, nF, fW, raw
@@ -72,6 +72,7 @@
72
72
  visible2group: true
73
73
  visible2all: true
74
74
  created: 2022-12-12 12:12:12
75
+ updated_last: 2022-12-12 12:12:12
75
76
 
76
77
  - datatype: VirtualSourceConfig
77
78
  parameters:
@@ -1,4 +1,8 @@
1
- from ..testbed.cape import TargetPort
1
+ """Module for experiment related data-models.
2
+
3
+ These models import externally from: /base, /content, /testbed.
4
+ """
5
+
2
6
  from .experiment import Experiment
3
7
  from .observer_features import GpioActuation
4
8
  from .observer_features import GpioEvent
@@ -8,8 +12,6 @@ from .observer_features import PowerTracing
8
12
  from .observer_features import SystemLogging
9
13
  from .target_config import TargetConfig
10
14
 
11
- # these models import externally from: /base, /content, /testbed
12
-
13
15
  __all__ = [
14
16
  "Experiment",
15
17
  "TargetConfig",
@@ -21,5 +23,4 @@ __all__ = [
21
23
  "SystemLogging",
22
24
  # Enums
23
25
  "GpioLevel",
24
- "TargetPort",
25
26
  ]