Search in sources :

Example 56 with Position

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);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) AbstractUGSSettings(com.willwinder.universalgcodesender.uielements.helpers.AbstractUGSSettings) Settings(com.willwinder.universalgcodesender.utils.Settings)

Example 57 with Position

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);
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) FileStats(com.willwinder.universalgcodesender.utils.Settings.FileStats) Units(com.willwinder.universalgcodesender.model.UnitUtils.Units)

Example 58 with Position

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;
}
Also used : Position(com.willwinder.universalgcodesender.model.Position) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) AutoLevelSettings(com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings) Settings(com.willwinder.universalgcodesender.utils.Settings)

Example 59 with Position

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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Position(com.willwinder.universalgcodesender.model.Position) GcodeParser(com.willwinder.universalgcodesender.gcode.GcodeParser) GcodeCommand(com.willwinder.universalgcodesender.types.GcodeCommand) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream) UnitUtils(com.willwinder.universalgcodesender.model.UnitUtils) Translator(com.willwinder.universalgcodesender.gcode.processors.Translator) BufferedReader(java.io.BufferedReader) GcodeStreamReader(com.willwinder.universalgcodesender.utils.GcodeStreamReader) M30Processor(com.willwinder.universalgcodesender.gcode.processors.M30Processor) GcodeParserException(com.willwinder.universalgcodesender.gcode.util.GcodeParserException) File(java.io.File)

Example 60 with Position

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));
    }
}
Also used : InOrder(org.mockito.InOrder) Position(com.willwinder.universalgcodesender.model.Position) UGSEvent(com.willwinder.universalgcodesender.model.UGSEvent)

Aggregations

Position (com.willwinder.universalgcodesender.model.Position)66 Test (org.junit.Test)33 GcodeState (com.willwinder.universalgcodesender.gcode.GcodeState)15 GcodeMeta (com.willwinder.universalgcodesender.gcode.GcodeParser.GcodeMeta)7 ControllerStatus (com.willwinder.universalgcodesender.listeners.ControllerStatus)6 UnitUtils (com.willwinder.universalgcodesender.model.UnitUtils)6 GcodeParserException (com.willwinder.universalgcodesender.gcode.util.GcodeParserException)5 Units (com.willwinder.universalgcodesender.model.UnitUtils.Units)5 GcodeCommand (com.willwinder.universalgcodesender.types.GcodeCommand)4 Settings (com.willwinder.universalgcodesender.utils.Settings)4 ArrayList (java.util.ArrayList)4 ProbeParameters (com.willwinder.ugs.platform.probe.ProbeService.ProbeParameters)3 GcodeParser (com.willwinder.universalgcodesender.gcode.GcodeParser)3 PlaneFormatter (com.willwinder.universalgcodesender.gcode.util.PlaneFormatter)3 UGSEvent (com.willwinder.universalgcodesender.model.UGSEvent)3 AutoLevelSettings (com.willwinder.universalgcodesender.utils.Settings.AutoLevelSettings)3 SplitCommand (com.willwinder.universalgcodesender.gcode.GcodePreprocessorUtils.SplitCommand)2 CommentProcessor (com.willwinder.universalgcodesender.gcode.processors.CommentProcessor)2 Code (com.willwinder.universalgcodesender.gcode.util.Code)2 PointSegment (com.willwinder.universalgcodesender.types.PointSegment)2