use of com.willwinder.universalgcodesender.model.UGSEvent in project Universal-G-Code-Sender by winder.
the class ProbeServiceTest method testProbeServiceOutside.
@Test
public void testProbeServiceOutside() throws Exception {
doReturn(true).when(backend).isIdle();
ProbeService ps = new ProbeService(backend);
ProbeParameters pc = new ProbeParameters(1, new Position(5, 5, 5, Units.MM), 10, 10, 0., 1, 1, 1, 100, 25, 5, Units.MM, G55);
ps.performOutsideCornerProbe(pc);
Position probeY = new Position(2.0, 2.0, 0, Units.MM);
Position probeX = new Position(1.0, 1.0, 0, Units.MM);
// Events to transition between states.
ps.UGSEvent(new UGSEvent(probeY));
ps.UGSEvent(new UGSEvent(probeY));
ps.UGSEvent(new UGSEvent(probeX));
ps.UGSEvent(new UGSEvent(probeX));
ps.UGSEvent(new UGSEvent(UGSEvent.ControlState.COMM_IDLE));
InOrder order = inOrder(backend);
order.verify(backend, times(1)).sendGcodeCommand(true, "G10 L20 P2 X0.0Y0.0");
// probe Y axis
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X" + pc.xSpacing);
order.verify(backend, times(1)).probe("Y", pc.feedRate, pc.ySpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G91 G21 G0 Y" + retractDistance(pc.ySpacing));
order.verify(backend, times(1)).probe("Y", pc.feedRateSlow, pc.ySpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Y0.0");
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X0.0");
// probe X axis
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Y" + pc.ySpacing);
order.verify(backend, times(1)).probe("X", pc.feedRate, pc.xSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G91 G21 G0 X" + retractDistance(pc.ySpacing));
order.verify(backend, times(1)).probe("X", pc.feedRateSlow, pc.xSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X0.0");
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Y0.0");
// Verify the correct offset
double radius = pc.probeDiameter / 2;
double xDir = ((pc.xSpacing > 0) ? -1 : 1);
double yDir = ((pc.ySpacing > 0) ? -1 : 1);
double xProbeOffset = pc.startPosition.x - probeX.x + xDir * (radius + Math.abs(pc.xOffset));
double yProbeOffset = pc.startPosition.y - probeY.y + yDir * (radius + Math.abs(pc.yOffset));
order.verify(backend, times(1)).sendGcodeCommand(true, "G10 L20 P2 X" + xProbeOffset + "Y" + yProbeOffset);
}
use of com.willwinder.universalgcodesender.model.UGSEvent in project Universal-G-Code-Sender by winder.
the class ProbeServiceTest method testProbeServiceXYZ.
@Test
public void testProbeServiceXYZ() throws Exception {
doReturn(true).when(backend).isIdle();
ProbeService ps = new ProbeService(backend);
ProbeParameters pc = new ProbeParameters(1, new Position(5, 5, 5, Units.MM), 10, 10, 0., 1, 1, 1, 100, 25, 5, Units.MM, G55);
ps.performXYZProbe(pc);
Position probeY = new Position(2.0, 2.0, 0, Units.MM);
Position probeX = new Position(1.0, 1.0, 0, Units.MM);
Position probeZ = new Position(0., 0., 3.0, Units.MM);
// Events to transition between states.
ps.UGSEvent(new UGSEvent(probeZ));
ps.UGSEvent(new UGSEvent(probeZ));
ps.UGSEvent(new UGSEvent(probeX));
ps.UGSEvent(new UGSEvent(probeX));
ps.UGSEvent(new UGSEvent(probeY));
ps.UGSEvent(new UGSEvent(probeY));
ps.UGSEvent(new UGSEvent(UGSEvent.ControlState.COMM_IDLE));
InOrder order = inOrder(backend);
order.verify(backend, times(1)).sendGcodeCommand(true, "G10 L20 P2 X0.0Y0.0Z0.0");
// Probe Z axis
order.verify(backend, times(1)).probe("Z", pc.feedRate, pc.zSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G91 G21 G0 Z" + retractDistance(pc.zSpacing));
order.verify(backend, times(1)).probe("Z", pc.feedRateSlow, pc.zSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Z0.0");
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X" + -pc.xSpacing);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Z" + pc.zSpacing);
// probe X axis
order.verify(backend, times(1)).probe("X", pc.feedRate, pc.xSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G91 G21 G0 X" + retractDistance(pc.ySpacing));
order.verify(backend, times(1)).probe("X", pc.feedRateSlow, pc.xSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X" + -pc.xSpacing);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Y" + -pc.ySpacing);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X" + pc.xSpacing);
// probe Y axis
order.verify(backend, times(1)).probe("Y", pc.feedRate, pc.ySpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G91 G21 G0 Y" + retractDistance(pc.ySpacing));
order.verify(backend, times(1)).probe("Y", pc.feedRateSlow, pc.ySpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 Z0.0");
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G21 G0 X0.0 Y0.0");
// Verify the correct offset
double radius = pc.probeDiameter / 2;
double xDir = ((pc.xSpacing > 0) ? -1 : 1);
double yDir = ((pc.ySpacing > 0) ? -1 : 1);
double xProbeOffset = pc.startPosition.x - probeX.x + xDir * (radius + Math.abs(pc.xOffset));
double yProbeOffset = pc.startPosition.y - probeY.y + yDir * (radius + Math.abs(pc.yOffset));
double zProbeOffset = pc.startPosition.z - probeZ.z;
order.verify(backend, times(1)).sendGcodeCommand(true, "G10 L20 P2 X" + xProbeOffset + "Y" + yProbeOffset + "Z" + zProbeOffset);
}
use of com.willwinder.universalgcodesender.model.UGSEvent in project Universal-G-Code-Sender by winder.
the class ProbeServiceTest method testZProbe.
private void testZProbe(ProbeParameters pc, boolean finalRetract) throws Exception {
ProbeService ps = new ProbeService(backend);
ps.performZProbe(pc);
Position probeZ = new Position(5, 5, 3, Units.MM);
ps.UGSEvent(new UGSEvent(probeZ));
ps.UGSEvent(new UGSEvent(probeZ));
ps.UGSEvent(new UGSEvent(UGSEvent.ControlState.COMM_IDLE));
InOrder order = inOrder(backend);
order.verify(backend, times(1)).probe("Z", pc.feedRate, pc.zSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G91 G20 G0 Z" + retractDistance(pc.zSpacing));
order.verify(backend, times(1)).probe("Z", pc.feedRateSlow, pc.zSpacing, pc.units);
order.verify(backend, times(1)).sendGcodeCommand(true, "G10 L20 P1 Z1.0");
if (finalRetract) {
order.verify(backend, times(1)).sendGcodeCommand(true, "G90 G20 G0 Z" + (pc.retractHeight + pc.zOffset));
}
}
Aggregations