feat(simulation): Allow to set simulation data via channel#3313
feat(simulation): Allow to set simulation data via channel#3313parapluplu wants to merge 1 commit intoOpenEMS:developfrom
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (3.45%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #3313 +/- ##
=============================================
- Coverage 59.83% 59.82% -0.01%
Complexity 112 112
=============================================
Files 2786 2788 +2
Lines 120836 120864 +28
Branches 9011 9011
=============================================
- Hits 72296 72290 -6
- Misses 45849 45879 +30
- Partials 2691 2695 +4 🚀 New features to boost your workflow:
|
5f029ed to
d3a228d
Compare
There was a problem hiding this comment.
@parapluplu
Nice. This is fine with me.
Please just update the one description.
Reminder: We should also rename AbstractCsvDatasource to just AbstractDatasource.
io.openems.edge.simulator/src/io/openems/edge/simulator/datasource/single/channel/Config.java
Show resolved
Hide resolved
d3a228d to
ba7ddff
Compare
For testing it's helpful to set production/consumption data externally
via channel updates. This controller adds this feature
Testing:
```
> curl -d '{"value":6000000}' http://admin:admin@localhost:8084/rest/channel/simulateConsumption/Data
{}
> curl http://admin:admin@localhost:8084/rest/channel/_sum/ConsumptionActivePower
{"address":"_sum/ConsumptionActivePower","type":"INTEGER","accessMode":"RO","text":"","unit":"W","value":6000000}
> curl -d '{"value":1}' http://admin:admin@localhost:8084/rest/channel/simulateConsumption/Data
{}
> curl http://admin:admin@localhost:8084/rest/channel/_sum/ConsumptionActivePower
{"address":"_sum/ConsumptionActivePower","type":"INTEGER","accessMode":"RO","text":"","unit":"W","value":1}
```
ba7ddff to
131531a
Compare
| @Override | ||
| protected DataContainer getData() throws NumberFormatException, IOException { | ||
| if (this.containerIsEmpty) { | ||
| // fill with default value 0 if container is empty and no value set via channel yet | ||
| this.container.addRecord(new Float[] { 0f }); | ||
| this.containerIsEmpty = false; | ||
| } | ||
| return this.container; | ||
| } |
There was a problem hiding this comment.
@parapluplu Could you also add a unit test for getData() to verify that this behavior is correctly applied?
|
Hi @parapluplu, |
Currently not. I'm planning to pick it up once I've some time. Likely this will happen mid of December, but I don't know for sure. I'm not mad if somebody else finishes this :D But yeah, eventually I'll pick it up. |
|
@da-Kai i will provide a Updated PR soon ! |
|
closing this, as it's continued here: |
For testing it's helpful to set production/consumption data externally via channel updates. This controller adds this feature
Testing: