-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feature/add time sync logs #205
Changes from 2 commits
ddd71e2
fd21afb
10e9329
27a485b
f8ef74e
21cb0dc
e6c9bfe
f8cc7b1
8264517
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
|
||
package org.eclipse.mosaic.rti.time; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.mosaic.rti.MosaicComponentParameters; | ||
import org.eclipse.mosaic.rti.api.ComponentProvider; | ||
import org.eclipse.mosaic.rti.api.FederateAmbassador; | ||
|
@@ -31,6 +34,9 @@ public class SequentialTimeManagement extends AbstractTimeManagement { | |
|
||
private final int realtimeBrake; | ||
|
||
// Debugging & Logging | ||
HashMap<String, Long> logging_map = new HashMap<String, Long>(); | ||
|
||
/** | ||
* Creates a new instance of the sequential time management. | ||
* | ||
|
@@ -87,6 +93,18 @@ public void runSimulation() throws InternalFederateException, IllegalValueExcept | |
if (ambassador != null) { | ||
federation.getMonitor().onBeginActivity(event); | ||
long startTime = System.currentTimeMillis(); | ||
|
||
if (!logging_map.containsKey(event.getFederateId())) // first time printing, then directly save the last simulation time requested and print | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should all be avoidable by setting log level to info. All this should be inside an if for log level debug or trace and we may want to leave a comment to consider reworking this. What you really want is just data about when each federate progresses in time. This is probably not a long term solution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could even just make this whole block a method that takes in event and start time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed |
||
{ | ||
logging_map.put(event.getFederateId(), event.getRequestedTime()); | ||
this.logger.info("Simulation Time: {} where current system time is: {} and requested from id: {}", (int) (event.getRequestedTime()/1e6), startTime, event.getFederateId()); | ||
} // only print if last simulation time printed is different than new one | ||
else if (logging_map.containsKey(event.getFederateId()) && logging_map.get(event.getFederateId()) != event.getRequestedTime()) | ||
{ | ||
logging_map.put(event.getFederateId(), event.getRequestedTime()); | ||
this.logger.info("Simulation Time: {} where current system time is: {} and requested from id: {}", (int) (event.getRequestedTime()/1e6), startTime, event.getFederateId()); | ||
} | ||
|
||
ambassador.advanceTime(event.getRequestedTime()); | ||
federation.getMonitor().onEndActivity(event, System.currentTimeMillis() - startTime); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need both of these variables.
receivedSimulationStep
should be!firstTimePrintingTime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they are meant for different cases.
receivedSimulationStep
is flagged whencarla
returns with some handshake to sumoAmbassador. However, sumoAmbassador is called many times before that by MOSAIC.firstTimePrintingTime
is meant to track the first time ever sumoAmbassador is called to progressTime. And that is by design.In other words, we can't reuse the same variable, because if we pick
!receivedSimulationStep
, the log will still end up printing many times in almost like 1ms apart. ThisfirstTimePrintingTime
is meant to avoid such excessive logging.