use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class ProbeService method UGSEvent.
@Override
public void UGSEvent(UGSEvent evt) {
if (this.currentOperation == ProbeOperation.NONE)
return;
if (evt instanceof ControllerStateEvent) {
ControllerStateEvent controllerStateEvent = (ControllerStateEvent) evt;
ControllerState state = controllerStateEvent.getState();
if (state == ControllerState.DISCONNECTED) {
resetProbe();
} else if (state == ControllerState.IDLE) {
// Finalize
if (this.currentOperation.getNumProbes() <= this.probePositions.size()) {
try {
continuation.execute();
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception finalizing " + this.currentOperation + " probe operation.", e);
} finally {
params.endPosition = this.backend.getMachinePosition();
this.resetProbe();
}
}
}
} else if (evt instanceof ProbeEvent) {
this.probePositions.add(((ProbeEvent) evt).getProbePosition());
try {
continuation.execute();
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception during " + this.currentOperation + " probe operation.", e);
resetProbe();
}
}
}
use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class AnalogJogActionTest method setValueShouldSetThePercentageToUse.
@Test
public void setValueShouldSetThePercentageToUse() {
ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
// Simulate the controller in running state
action.setValue(0.6f);
action.UGSEvent(new ControllerStateEvent(ControllerState.JOG, ControllerState.IDLE));
action.actionPerformed(null);
assertTrue(action.isEnabled());
verify(worker, times(1)).setDirection(eq(Axis.Y), eq(0.6f));
}
use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class AnalogJogActionTest method actionPerformedShouldNotGenerateJogCommandsWhenStateIsRunning.
@Test
public void actionPerformedShouldNotGenerateJogCommandsWhenStateIsRunning() {
ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
// Simulate the controller in running state
action.UGSEvent(new ControllerStateEvent(ControllerState.RUN, ControllerState.IDLE));
action.actionPerformed(null);
assertFalse(action.isEnabled());
verifyNoInteractions(worker);
}
Aggregations