Skip to content

feat(simulation): Allow to set simulation data via channel#3313

Closed
parapluplu wants to merge 1 commit intoOpenEMS:developfrom
parapluplu:felix/simulate_channel
Closed

feat(simulation): Allow to set simulation data via channel#3313
parapluplu wants to merge 1 commit intoOpenEMS:developfrom
parapluplu:felix/simulate_channel

Conversation

@parapluplu
Copy link
Contributor

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}

@codecov
Copy link

codecov bot commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 3.44828% with 28 lines in your changes missing coverage. Please review.

❌ 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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@da-Kai da-Kai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parapluplu
Nice. This is fine with me.

Please just update the one description.

Reminder: We should also rename AbstractCsvDatasource to just AbstractDatasource.

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}
```
@parapluplu parapluplu force-pushed the felix/simulate_channel branch from ba7ddff to 131531a Compare October 6, 2025 14:19
Comment on lines +73 to +81
@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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parapluplu Could you also add a unit test for getData() to verify that this behavior is correctly applied?

@da-Kai
Copy link
Contributor

da-Kai commented Nov 27, 2025

Hi @parapluplu,
are you still working on this?

@parapluplu
Copy link
Contributor Author

Hi @parapluplu, are you still working on this?

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.

@Sn0w3y
Copy link
Collaborator

Sn0w3y commented Nov 27, 2025

@da-Kai i will provide a Updated PR soon !

@parapluplu
Copy link
Contributor Author

closing this, as it's continued here:
#3448

@parapluplu parapluplu closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants