Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: order of drt discharge events #2926

Closed
wants to merge 1 commit into from
Closed

Conversation

sebhoerl
Copy link
Contributor

@sebhoerl sebhoerl commented Nov 10, 2023

Relatively simple fix for #2925: All discharging events are collected and only fired at the end of the simstep.

If somebody who is more familar with the edrt code could take over, that would be great :)

@@ -41,6 +41,7 @@ public void install() {
protected void configureQSim() {
this.bind(DriveDischargingHandler.class).in( Singleton.class );
addMobsimScopeEventHandlerBinding().to(DriveDischargingHandler.class);
addMobsimListenerBinding().to(DriveDischargingHandler.class);
Copy link
Member

@michalmac michalmac Nov 13, 2023

Choose a reason for hiding this comment

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

This line should be replaced with:
this.addQSimComponentBinding(EvModule.EV_COMPONENT).to(DriveDischargingHandler.class);

Right now I doubt there is any event processed. Maybe this is why so may tests failed.

@@ -104,6 +111,7 @@ public void handleEvent(VehicleLeavesTrafficEvent event) {
// (for instance, AUX discharging and battery charging modifies charge outside event handling
// (as MobsimAfterSimStepListeners)
//TODO In the long term, it will be safer to move the discharging procedure to a MobsimAfterSimStepListener
// -> has been implemented now as a hack /sebhoerl
Copy link
Member

Choose a reason for hiding this comment

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

While this change will definitely help with the order of events (which is good!), I was thinking about updating the SOC in the main thread (outside the event handling threads) to avoid race conditions (and also to have events deterministically ordered).

I will create a PR for moving the whole logic outside the event handling.

@sebhoerl sebhoerl closed this Nov 16, 2023
@sebhoerl sebhoerl deleted the fix/edrt-discharge-events branch November 21, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants