use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class GcodeTilerTopComponent method loadDimensions.
private boolean loadDimensions() {
if (backend.getProcessedGcodeFile() == null) {
GUIHelpers.displayErrorDialog("Must load gcode file first.");
return false;
}
Settings.FileStats fs = backend.getSettings().getFileStats();
UnitUtils.Units u = selectedUnit(this.units.getSelectedIndex());
Position min = fs.minCoordinate.getPositionIn(u);
Position max = fs.maxCoordinate.getPositionIn(u);
GcodeTilerTopComponent.xWidth = max.x - min.x;
GcodeTilerTopComponent.yWidth = max.y - min.y;
return true;
}
use of com.willwinder.universalgcodesender.model.Position 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.Position 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.Position in project Universal-G-Code-Sender by winder.
the class RendererInputHandler method updateBounds.
/**
* Pass new bounds (after interpolating arcs) in case of weird arcs.
*/
private void updateBounds(Point3d min, Point3d max) {
// Update bounds.
FileStats fs = settings.getFileStats();
fs.minCoordinate = new Position(min.x, min.y, min.z, Units.MM);
fs.maxCoordinate = new Position(max.x, max.y, max.z, Units.MM);
settings.setFileStats(fs);
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method dataViewerActionPerformed.
// GEN-LAST:event_scanSurfaceButtonActionPerformed
private void dataViewerActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_dataViewerActionPerformed
List<Map<String, Double>> probeData = new ArrayList<>();
// Collect data from grid.
if (scanner != null && scanner.getProbePositionGrid() != null) {
for (Position[] row : scanner.getProbePositionGrid()) {
for (Position p : row) {
if (p != null) {
probeData.add(ImmutableMap.of("x", p.x, "y", p.y, "z", p.z));
}
}
}
}
JTextArea ta = new JTextArea(15, 30);
ta.setText(GSON.toJson(probeData));
JOptionPane.showMessageDialog(null, new JScrollPane(ta));
}
Aggregations