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

goToTime should work multiple times #2017

Open
cric96 opened this issue Feb 21, 2023 · 1 comment
Open

goToTime should work multiple times #2017

cric96 opened this issue Feb 21, 2023 · 1 comment

Comments

@cric96
Copy link
Contributor

cric96 commented Feb 21, 2023

The goToTime method in the Simulation should allow users to move the simulation to a specific point in the future and pause it. However, after testing this method, I discovered that there is a flaw in its implementation.

When the goToTime method is first called, the Simulation correctly jumps to the specified time using the DoubleTime parameter:

val simulation = ...
simulation.goToTime(DoubleTime(10.0)
simulation.play()
// run simulation into another thread
executor. submit { simulation. run() }
simulation.waitFor(Stautus.PAUSED, 1, TimeUnit.SECONDS)
// here simulation.getTime is greater than 10.0

The issue arises when the goToTime method is called a second time to jump to a new time, as the simulation does not progress past the previous paused time. This problem occurs because the OutputMonitor is not removed after the first time the simulation is paused, which causes the monitor to trigger again and pause the simulation at the previous time.

Upon examining the source code, it is clear that the issue is caused by the OutputMonitor not being removed after its initial use. I have created a test that demonstrates this error, which can be found here.

@DanySK
Copy link
Member

DanySK commented Feb 21, 2023

The solution looks relatively easy: upon satisfaction of the condition, the output monitor should deregister itself. Can you open a PR with the regression test?

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

No branches or pull requests

2 participants