Search in sources :

Example 6 with PartialPosition

use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.

the class G2CoreControllerTest method jogMachineTo.

@Test
public void jogMachineTo() throws Exception {
    // Given
    when(communicator.isConnected()).thenReturn(true);
    // Simulate that the machine is running in mm
    controller.getCurrentGcodeState().units = Code.G21;
    // When
    InOrder orderVerifier = inOrder(communicator);
    controller.jogMachineTo(new PartialPosition(1.0, 2.0, 3.0, UnitUtils.Units.MM), 1000);
    // Then
    orderVerifier.verify(communicator, times(1)).queueCommand(any(GcodeCommand.class));
    orderVerifier.verify(communicator).streamCommands();
    GcodeCommand command = queueCommandArgumentCaptor.getAllValues().get(0);
    assertEquals("G21G90G1X1Y2Z3F1000", command.getCommandString());
    assertTrue(command.isGenerated());
    assertTrue(command.isTemporaryParserModalChange());
}
Also used : InOrder(org.mockito.InOrder) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test)

Example 7 with PartialPosition

use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.

the class G2CoreControllerTest method jogMachineShouldTurnSwitchOfIsJoggingWhenComplete.

@Test
public void jogMachineShouldTurnSwitchOfIsJoggingWhenComplete() throws Exception {
    // Given
    when(communicator.isConnected()).thenReturn(true);
    controller.jogMachine(new PartialPosition(1.0, 2.0, 3.0, UnitUtils.Units.MM), 1000d);
    // receive IDLE
    controller.rawResponseHandler("{\"sr\":{\"stat\": 1}}");
    // When
    controller.sendCommandImmediately(new GcodeCommand("G0 X1"));
    // receive RUN
    controller.rawResponseHandler("{\"sr\":{\"stat\": 5}}");
    // Then
    assertEquals("Should now consider send commands as a normal run state", ControllerState.RUN, controller.getControllerStatus().getState());
}
Also used : PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test)

Example 8 with PartialPosition

use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.

the class G2CoreControllerTest method jogMachine.

@Test
public void jogMachine() throws Exception {
    // Given
    when(communicator.isConnected()).thenReturn(true);
    // Simulate that the machine is running in inches
    controller.getCurrentGcodeState().units = Code.G21;
    // When
    InOrder orderVerifier = inOrder(communicator);
    controller.jogMachine(new PartialPosition(100., 100., 100., UnitUtils.Units.MM), 1000);
    // Then
    orderVerifier.verify(communicator, times(1)).queueCommand(any(GcodeCommand.class));
    orderVerifier.verify(communicator).streamCommands();
    GcodeCommand command = queueCommandArgumentCaptor.getAllValues().get(0);
    assertEquals("G21G91G1X100Y100Z100F1000", command.getCommandString());
    assertTrue(command.isGenerated());
    assertTrue(command.isTemporaryParserModalChange());
}
Also used : InOrder(org.mockito.InOrder) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test)

Example 9 with PartialPosition

use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.

the class G2CoreControllerTest method jogMachineWhenUsingInchesShouldConvertCoordinates.

@Test
public void jogMachineWhenUsingInchesShouldConvertCoordinates() throws Exception {
    // Given
    when(communicator.isConnected()).thenReturn(true);
    // Simulate that the machine is running in inches
    controller.getCurrentGcodeState().units = Code.G20;
    // When
    InOrder orderVerifier = inOrder(communicator);
    controller.jogMachine(new PartialPosition(100., 100., 100., UnitUtils.Units.MM), 1000);
    // Then
    orderVerifier.verify(communicator, times(1)).queueCommand(any(GcodeCommand.class));
    orderVerifier.verify(communicator).streamCommands();
    GcodeCommand command = queueCommandArgumentCaptor.getAllValues().get(0);
    assertEquals("G20G91G1X3.937Y3.937Z3.937F39.37", command.getCommandString());
    assertTrue(command.isGenerated());
    assertTrue(command.isTemporaryParserModalChange());
}
Also used : InOrder(org.mockito.InOrder) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test)

Example 10 with PartialPosition

use of com.willwinder.universalgcodesender.model.PartialPosition in project Universal-G-Code-Sender by winder.

the class TinyGControllerTest method jogMachine.

@Test
public void jogMachine() throws Exception {
    // Given
    when(communicator.isConnected()).thenReturn(true);
    // Simulate that the machine is running in inches
    controller.getCurrentGcodeState().units = Code.G21;
    // When
    InOrder orderVerifier = inOrder(communicator);
    controller.jogMachine(new PartialPosition(100., 100., 100., UnitUtils.Units.MM), 1000);
    // Then
    orderVerifier.verify(communicator, times(1)).queueCommand(any(GcodeCommand.class));
    orderVerifier.verify(communicator).streamCommands();
    GcodeCommand command = queueCommandArgumentCaptor.getAllValues().get(0);
    assertEquals("G21G91G1X100Y100Z100F1000", command.getCommandString());
    assertTrue(command.isGenerated());
    assertTrue(command.isTemporaryParserModalChange());
}
Also used : InOrder(org.mockito.InOrder) PartialPosition(com.willwinder.universalgcodesender.model.PartialPosition) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) Test(org.junit.Test)

Aggregations

PartialPosition (com.willwinder.universalgcodesender.model.PartialPosition)36 Test (org.junit.Test)19 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)10 List (java.util.List)8 InOrder (org.mockito.InOrder)8 Position (com.willwinder.universalgcodesender.model.Position)7 Collectors (java.util.stream.Collectors)6 CentralLookup (com.willwinder.ugs.nbp.lib.lookup.CentralLookup)4 GcodeParserException (com.willwinder.universalgcodesender.gcode.util.GcodeParserException)4 UGSEventListener (com.willwinder.universalgcodesender.listeners.UGSEventListener)4 BackendAPI (com.willwinder.universalgcodesender.model.BackendAPI)4 UGSEvent (com.willwinder.universalgcodesender.model.UGSEvent)4 UnitUtils (com.willwinder.universalgcodesender.model.UnitUtils)4 ControllerStateEvent (com.willwinder.universalgcodesender.model.events.ControllerStateEvent)4 FileStateEvent (com.willwinder.universalgcodesender.model.events.FileStateEvent)4 LoaderDialogHelper (com.willwinder.universalgcodesender.uielements.helpers.LoaderDialogHelper)4 com.willwinder.universalgcodesender.utils (com.willwinder.universalgcodesender.utils)4 GcodeViewParse (com.willwinder.universalgcodesender.visualizer.GcodeViewParse)4 LineSegment (com.willwinder.universalgcodesender.visualizer.LineSegment)4 VisualizerUtils (com.willwinder.universalgcodesender.visualizer.VisualizerUtils)4