Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN committed Mar 21, 2024
1 parent 27a485b commit f8ef74e
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ public class SequentialTimeManagement extends AbstractTimeManagement {
// Debugging & Logging
HashMap<String, Long> loggingMap = new HashMap<>();

/**
* Prints log for time synchronization monitor script. Only meant to be printed for debugging purposes.
* Please see https://github.com/usdot-fhwa-stol/carma-analytics-fotda/pull/43
*
* @param event FederateEvent requested by one of the ambassadaor
* @param startTime current system time when the event request was received
*/

private void printTimeSyncDebugLogs(FederateEvent event, long startTime){
if (!loggingMap.containsKey(event.getFederateId()) ||
(loggingMap.containsKey(event.getFederateId()) && loggingMap.get(event.getFederateId()) != event.getRequestedTime()))
{
loggingMap.put(event.getFederateId(), event.getRequestedTime());
this.logger.debug("Simulation Time: {} where current system time is: {} and requested from id: {}", (int) (event.getRequestedTime()/1e6), startTime, event.getFederateId());
}
}

/**
* Creates a new instance of the sequential time management.
*
Expand Down Expand Up @@ -99,12 +116,7 @@ public void runSimulation() throws InternalFederateException, IllegalValueExcept
// https://github.com/usdot-fhwa-stol/carma-analytics-fotda/pull/43
if (this.logger.isDebugEnabled())
{
if (!loggingMap.containsKey(event.getFederateId()) ||
(loggingMap.containsKey(event.getFederateId()) && loggingMap.get(event.getFederateId()) != event.getRequestedTime()))
{
loggingMap.put(event.getFederateId(), event.getRequestedTime());
this.logger.debug("Simulation Time: {} where current system time is: {} and requested from id: {}", (int) (event.getRequestedTime()/1e6), startTime, event.getFederateId());
}
printTimeSyncDebugLogs(event, startTime);
}

ambassador.advanceTime(event.getRequestedTime());
Expand Down

0 comments on commit f8ef74e

Please sign in to comment.