Stopped to Starting

This commit is contained in:
phact 2020-04-06 12:33:34 -04:00
parent f650d2e9be
commit 03e7021b3a
2 changed files with 26 additions and 8 deletions

View File

@ -48,6 +48,7 @@ public enum RunState {
default: default:
return false; return false;
case Uninitialized: // A motor was just created. This is its initial state. case Uninitialized: // A motor was just created. This is its initial state.
case Stopped:
switch (to) { switch (to) {
case Starting: // a motor has been reserved for an execution command case Starting: // a motor has been reserved for an execution command
return true; return true;
@ -76,14 +77,7 @@ public enum RunState {
return true; return true;
default: default:
return false; return false;
} }// A motor was restarted after being stopped
case Stopped:
switch (to) {
case Running: // A motor was restarted after being stopped
return true;
default:
return false;
}
case Finished: case Finished:
switch (to) { switch (to) {
case Running: // A motor was restarted? case Running: // A motor was restarted?

View File

@ -38,6 +38,30 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ActivityExecutorTest { public class ActivityExecutorTest {
private static final Logger logger = LoggerFactory.getLogger(ActivityExecutorTest.class); private static final Logger logger = LoggerFactory.getLogger(ActivityExecutorTest.class);
@Test
public void testRestart() {
ActivityDef ad = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;initdelay=5000;");
Optional<ActivityType> activityType = ActivityType.FINDER.get(ad.getActivityType());
Activity a = new DelayedInitActivity(ad);
InputDispenser idisp = new CoreInputDispenser(a);
ActionDispenser adisp = new CoreActionDispenser(a);
OutputDispenser tdisp = CoreServices.getOutputDispenser(a).orElse(null);
MotorDispenser<?> mdisp = new CoreMotorDispenser(a, idisp, adisp, tdisp);
a.setActionDispenserDelegate(adisp);
a.setOutputDispenserDelegate(tdisp);
a.setInputDispenserDelegate(idisp);
a.setMotorDispenserDelegate(mdisp);
ActivityExecutor ae = new ActivityExecutor(a);
ad.setThreads(1);
ae.startActivity();
ae.stopActivity();
ae.startActivity();
ae.awaitCompletion(15000);
assertThat(idisp.getInput(10).getInputSegment(3)).isNull();
}
@Test @Test
public void testDelayedStartSanity() { public void testDelayedStartSanity() {
ActivityDef ad = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;initdelay=5000;"); ActivityDef ad = ActivityDef.parseActivityDef("driver=diag;alias=test;cycles=1000;initdelay=5000;");