diff --git a/build.properties b/build.properties index 73efe8d..efc24be 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -strongback.version=1.2.0-Beta2 +strongback.version=1.2.0-Beta3 # # The build will download a specific version of the WPILib given by the following URL # and install it into the 'libs/wpilib' folder. To use a different version of WPILib, diff --git a/strongback/src/org/strongback/Strongback.java b/strongback/src/org/strongback/Strongback.java index 86b499a..b64fb9f 100644 --- a/strongback/src/org/strongback/Strongback.java +++ b/strongback/src/org/strongback/Strongback.java @@ -1258,10 +1258,12 @@ public String toString() { return true; } - private CommandListener createCommandListener() { - if (recordCommands) { + private CommandListener createCommandListener(EventRecorder recorder, boolean recordCommands) { + if (recordCommands && recorder != null) { return (command, state) -> { - eventRecorder.record(command.getClass().getName(), state.ordinal()); + if (command != null) { + recorder.record(command.getClass().getName(), state.ordinal()); + } }; } return null; @@ -1287,13 +1289,23 @@ protected boolean doStart() { try { executorDelayCounter.set(0); + // Create the event recorder if needed ... + boolean listenToCommands = false; + if (eventWriter != null) { + eventRecorder = new AsyncEventRecorder(eventWriter, clock); + eventRecorder.execute(CLOCK.currentTimeInMillis()); + listenToCommands = recordCommands; + } + // Create the scheduler that runs commands ... - scheduler = new Scheduler(logger, createCommandListener()); + scheduler = new Scheduler(logger, createCommandListener(eventRecorder,listenToCommands)); + scheduler.execute(CLOCK.currentTimeInMillis()); executables.register(scheduler, SCHEDULER_PRIORITY); if (useSwitchReactor) { // Register the switch reactor ... executables.register(switchReactor, SWITCH_REACTOR_PRIORITY); + switchReactor.execute(CLOCK.currentTimeInMillis()); } // Create the data recorder if needed ... @@ -1301,12 +1313,11 @@ protected boolean doStart() { if (dataWriterFactorySupplier != null) { dataRecorderDriver = new DataRecorderDriver(dataRecorderChannels, dataWriterFactorySupplier.get()); dataRecorderDriver.start(); + dataRecorderDriver.execute(CLOCK.currentTimeInMillis()); executables.register(dataRecorderDriver, DATA_RECORDER_PRIORITY); } - // Create the event recorder if needed ... - if (eventWriter != null) { - eventRecorder = new AsyncEventRecorder(eventWriter, clock); + if (eventRecorder != null) { executables.register(eventRecorder, EVENT_RECORDER_PRIORITY); }