use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class AutoLevelerSettingsPanel method save.
@Override
public void save() {
Settings.AutoLevelSettings values = new Settings.AutoLevelSettings();
values.autoLevelProbeZeroHeight = (double) this.zHeightSpinner.getValue();
values.probeSpeed = (double) this.probeFeedRate.getValue();
values.autoLevelArcSliceLength = (double) this.arcSegmentLengthSpinner.getValue();
values.autoLevelProbeOffset = new Position((double) this.xOffsetSpinner.getValue(), (double) this.yOffsetSpinner.getValue(), (double) this.zOffsetSpinner.getValue(), Units.UNKNOWN);
settings.setAutoLevelSettings(values);
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method useLoadedFileActionPerformed.
// GEN-LAST:event_settingsButtonActionPerformed
private void useLoadedFileActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_useLoadedFileActionPerformed
if (backend.getProcessedGcodeFile() == null) {
return;
}
FileStats fs = backend.getSettings().getFileStats();
Units u = this.unitMM.isSelected() ? Units.MM : Units.INCH;
Position min = fs.minCoordinate.getPositionIn(u);
Position max = fs.maxCoordinate.getPositionIn(u);
this.xMin.setValue(min.x);
this.yMin.setValue(min.y);
this.zMin.setValue(min.z);
this.xMax.setValue(max.x);
this.yMax.setValue(max.y);
this.zMax.setValue(max.z);
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method updateScanner.
private AutoLevelSettings updateScanner(Units units) {
Settings.AutoLevelSettings autoLevelerSettings = this.settings.getAutoLevelSettings();
double xOff = autoLevelerSettings.autoLevelProbeOffset.x;
double yOff = autoLevelerSettings.autoLevelProbeOffset.y;
Position corner1 = new Position(getValue(xMin) + xOff, getValue(yMin) + yOff, getValue(zMin), units);
Position corner2 = new Position(getValue(xMax) + xOff, getValue(yMax) + yOff, getValue(zMax), units);
autoLevelerSettings.stepResolution = getValue(this.stepResolution);
autoLevelerSettings.zSurface = getValue(this.zSurface);
scanner.update(corner1, corner2, autoLevelerSettings.stepResolution);
if (r != null) {
r.updateSettings(scanner.getProbeStartPositions(), scanner.getUnits(), scanner.getProbePositionGrid(), scanner.getMaxXYZ(), scanner.getMinXYZ());
}
return autoLevelerSettings;
}
use of com.willwinder.universalgcodesender.model.Position in project Universal-G-Code-Sender by winder.
the class GcodeTilerTopComponent method generateOneTile.
private void generateOneTile(double offsetX, double offsetY, PrintWriter output) {
String gcodeFile = backend.getGcodeFile().getAbsolutePath();
UnitUtils.Units u = selectedUnit(this.units.getSelectedIndex());
GcodeParser parser = new GcodeParser();
parser.addCommandProcessor(new Translator(new Position(offsetX, offsetY, 0.0, u)));
parser.addCommandProcessor(new M30Processor());
output.println(GcodeUtils.unitCommand(u) + "G90");
output.println("G0X" + offsetX + "Y" + offsetY);
try {
File file = new File(gcodeFile);
try {
try (GcodeStreamReader gsr = new GcodeStreamReader(file)) {
while (gsr.getNumRowsRemaining() > 0) {
GcodeCommand next = gsr.getNextCommand();
applyTranslation(next.getCommandString(), parser, output);
}
}
} catch (GcodeStreamReader.NotGcodeStreamFile e) {
try (FileInputStream fstream = new FileInputStream(file);
DataInputStream dis = new DataInputStream(fstream);
BufferedReader fileStream = new BufferedReader(new InputStreamReader(dis))) {
String line;
while ((line = fileStream.readLine()) != null) {
applyTranslation(line, parser, output);
}
}
}
} catch (GcodeParserException | IOException ex) {
Exceptions.printStackTrace(ex);
}
}
use of com.willwinder.universalgcodesender.model.Position 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