use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class SourceMultiviewElement method UGSEvent.
@Override
public void UGSEvent(UGSEvent ugsEvent) {
// Disable the editor if not idle or disconnected
if (ugsEvent instanceof ControllerStateEvent) {
ControllerState state = backend.getControllerState();
getEditorPane().setEditable(state == ControllerState.IDLE || state == ControllerState.DISCONNECTED);
}
}
use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class AnalogJogActionTest method actionPerformedShouldGenerateJogCommandsWhenStateIsIdle.
@Test
public void actionPerformedShouldGenerateJogCommandsWhenStateIsIdle() {
ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
// Simulate the controller in running state
action.UGSEvent(new ControllerStateEvent(ControllerState.IDLE, ControllerState.IDLE));
action.actionPerformed(null);
assertTrue(action.isEnabled());
verify(worker, times(1)).setDirection(eq(Axis.Y), anyFloat());
}
use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class AnalogJogActionTest method actionPerformedShouldNotGenerateJogCommandsWhenStateIsDoor.
@Test
public void actionPerformedShouldNotGenerateJogCommandsWhenStateIsDoor() {
ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
// Simulate the controller in running state
action.UGSEvent(new ControllerStateEvent(ControllerState.DOOR, ControllerState.IDLE));
action.actionPerformed(null);
assertFalse(action.isEnabled());
verifyNoInteractions(worker);
}
use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class AnalogJogActionTest method actionPerformedShouldGenerateJogCommandsWhenStateIsJog.
@Test
public void actionPerformedShouldGenerateJogCommandsWhenStateIsJog() {
ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
// Simulate the controller in running state
action.UGSEvent(new ControllerStateEvent(ControllerState.JOG, ControllerState.IDLE));
action.actionPerformed(null);
assertTrue(action.isEnabled());
verify(worker, times(1)).setDirection(eq(Axis.Y), anyFloat());
}
use of com.willwinder.universalgcodesender.model.events.ControllerStateEvent in project Universal-G-Code-Sender by winder.
the class AnalogJogAction method UGSEvent.
@Override
public void UGSEvent(UGSEvent evt) {
if (evt instanceof ControllerStateEvent) {
ControllerState state = ((ControllerStateEvent) evt).getState();
setEnabled(state == ControllerState.IDLE || state == ControllerState.JOG);
}
}
Aggregations