Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to probe UI #2280

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions ugs-core/src/resources/MessagesBundle_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ mainWindow.status.hold = Hold
mainWindow.status.queue = Queue
mainWindow.status.run = Run
platform.menu.runFrom = Run From...
platform.menu.toggleUnit = Toggle units
platform.menu.toggleUnit.tooltip = Toggles the preferred units in the application
mainWindow.error.openingFile = Problem opening file
mainWindow.error.processingFile = Unknown IOException while processing file
mainWindow.error.pauseResume = Error while trying to pause/resume
Expand Down Expand Up @@ -505,14 +507,20 @@ probe.find-rate = Fast find rate
probe.measure-rate = Slow measure rate
probe.x-distance = Probe X Distance
probe.y-distance = Probe Y Distance
probe.z-distance = Probe Z Distance
probe.retract-height = Retract height
probe.retract-amount = Retract amount
probe.hole-diameter = Approximate hole diameter
probe.hole-center-hint = Move probe to approximate center
probe.measure.hole-center = Measure hole center
probe.measure.outside-corner = Measure outside corner
probe.measure.inside-corner = Measure inside corner
probe.work-coordinates = Work Coordinates
probe.action.z = Probe and zero Z
probe.action.z.confirmation = Are you sure you want to probe Z with current settings?
probe.action.xy = Probe and zero XY
probe.action.xy.confirmation = Are you sure you want to probe XY with current settings?
probe.action.xyz = Probe and zero XYZ
probe.action.xyz.confirmation = Are you sure you want to probe XYZ with current settings?
probe.action.hole-center = Probe and zero hole center
probe.action.hole-center.confirmation = Are you sure you want to probe the hole with current settings?
probe.action.tooltip.disabled = Machine needs to be connected and idle to be able to use probing
probe.action.tooltip.enabled = Press to start probing
probe.visualizer.corner-preview = Corner probe preview
probe.visualizer.hole-center-preview = Hole center probe preview
probe.visualizer.z-preview = Z probe preview
Expand Down
5 changes: 5 additions & 0 deletions ugs-platform/ProbeModule/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<version>${project.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ugs-platform-ugscore</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ugs-platform-visualizer</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2023 Will Winder

This file is part of Universal Gcode Sender (UGS).

UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.ugs.platform.probe;

import com.willwinder.universalgcodesender.model.Position;
import com.willwinder.universalgcodesender.model.UnitUtils;
import com.willwinder.universalgcodesender.model.WorkCoordinateSystem;

/**
* Parameters passed into the probe operations.
*/
public class ProbeParameters {
public final double probeDiameter;
public final double xSpacing;
public final double ySpacing;
public final double zSpacing;
public final double xOffset;
public final double yOffset;
public final double zOffset;
public final double holeDiameter;
public final double feedRate;
public final double feedRateSlow;
public final double retractAmount;
public final WorkCoordinateSystem wcsToUpdate;
public final UnitUtils.Units units;

// Results
public final Position startPosition;
public Position endPosition;

public ProbeParameters(double diameter, Position start,
double xSpacing, double ySpacing, double zSpacing,
double xOffset, double yOffset, double zOffset,
double holeDiameter,
double feedRate, double feedRateSlow, double retractAmount,
UnitUtils.Units u, WorkCoordinateSystem wcs) {
this.endPosition = null;
this.probeDiameter = diameter;
this.startPosition = start;
this.xSpacing = xSpacing;
this.ySpacing = ySpacing;
this.zSpacing = zSpacing;
this.xOffset = xOffset;
this.yOffset = yOffset;
this.zOffset = zOffset;
this.holeDiameter = holeDiameter;
this.feedRate = feedRate;
this.feedRateSlow = feedRateSlow;
this.retractAmount = retractAmount;
this.units = u;
this.wcsToUpdate = wcs;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2017-2018 Will Winder
Copyright 2017-2023 Will Winder

This file is part of Universal Gcode Sender (UGS).

Expand All @@ -19,6 +19,8 @@ This file is part of Universal Gcode Sender (UGS).
package com.willwinder.ugs.platform.probe;

import com.google.common.base.Preconditions;
import com.willwinder.ugs.nbp.lib.lookup.CentralLookup;
import com.willwinder.ugs.platform.probe.renderable.ProbePreviewManager;
import com.willwinder.universalgcodesender.Utils;
import com.willwinder.universalgcodesender.gcode.util.GcodeUtils;
import com.willwinder.universalgcodesender.listeners.ControllerState;
Expand All @@ -30,6 +32,8 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.universalgcodesender.model.WorkCoordinateSystem;
import com.willwinder.universalgcodesender.model.events.ControllerStateEvent;
import com.willwinder.universalgcodesender.model.events.ProbeEvent;
import org.openide.util.Lookup;
import org.openide.util.lookup.ServiceProvider;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -41,6 +45,7 @@ This file is part of Universal Gcode Sender (UGS).
*
* @author wwinder
*/
@ServiceProvider(service = ProbeService.class)
public class ProbeService implements UGSEventListener {
private static final Logger logger = Logger.getLogger(ProbeService.class.getName());
private static final String WCS_PATTERN = "G10 L20 P%d %s";
Expand Down Expand Up @@ -79,59 +84,15 @@ public int getNumProbes() {
}
}

/**
* Parameters passed into the probe operations.
*/
public static class ProbeParameters {
public String errorMessage;
public UGSEvent event;
public final double probeDiameter;
public final double xSpacing;
public final double ySpacing;
public final double zSpacing;
public final double xOffset;
public final double yOffset;
public final double zOffset;
public final double holeDiameter;
public final double feedRate;
public final double feedRateSlow;
public final double retractAmount;
public final WorkCoordinateSystem wcsToUpdate;
public final Units units;

// Results
public final Position startPosition;
public Position endPosition;

public ProbeParameters(double diameter, Position start,
double xSpacing, double ySpacing, double zSpacing,
double xOffset, double yOffset, double zOffset,
double holeDiameter,
double feedRate, double feedRateSlow, double retractAmount,
Units u, WorkCoordinateSystem wcs) {
this.endPosition = null;
this.probeDiameter = diameter;
this.startPosition = start;
this.xSpacing = xSpacing;
this.ySpacing = ySpacing;
this.zSpacing = zSpacing;
this.xOffset = xOffset;
this.yOffset = yOffset;
this.zOffset = zOffset;
this.holeDiameter = holeDiameter;
this.feedRate = feedRate;
this.feedRateSlow = feedRateSlow;
this.retractAmount = retractAmount;
this.units = u;
this.wcsToUpdate = wcs;
}
}

public ProbeService(BackendAPI backend) {
this.backend = backend;
this.backend.addUGSEventListener(this);
}

public ProbeService() {
this(CentralLookup.getDefault().lookup(BackendAPI.class));
}

protected static double retractDistance(double spacing, double retractAmount) {
return (spacing < 0) ? retractAmount : -1 * retractAmount;
}
Expand All @@ -153,7 +114,7 @@ private void validateState() {
}
}

void performZProbe(ProbeParameters params) throws IllegalStateException {
public void performZProbe(ProbeParameters params) throws IllegalStateException {
validateState();
currentOperation = ProbeOperation.Z;
this.params = params;
Expand All @@ -175,6 +136,7 @@ private void performZProbeInternal(int stepNumber) throws IllegalStateException
}
case 1: {
gcode("G91 " + unit + " G0 Z" + retractDistance(params.zSpacing, params.retractAmount));
// TODO If probing a large distance this could cause soft limit alarm here, use the retract amount on the second probe
probe('Z', params.feedRateSlow, params.zSpacing, params.units);
break;
}
Expand Down Expand Up @@ -208,7 +170,7 @@ private void performZProbeInternal(int stepNumber) throws IllegalStateException
}
}

void performOutsideCornerProbe(ProbeParameters params) throws IllegalStateException {
public void performOutsideCornerProbe(ProbeParameters params) throws IllegalStateException {
validateState();
currentOperation = ProbeOperation.OUTSIDE_XY;
this.params = params;
Expand Down Expand Up @@ -284,7 +246,7 @@ private void performOutsideCornerProbeInternal(int stepNumber) throws IllegalSta
}
}

void performXYZProbe(ProbeParameters params) throws IllegalStateException {
public void performXYZProbe(ProbeParameters params) throws IllegalStateException {
validateState();
currentOperation = ProbeOperation.OUTSIDE_XYZ;
this.params = params;
Expand Down Expand Up @@ -381,7 +343,7 @@ private void performXYZProbeInternal(int stepNumber) throws IllegalStateExceptio
}
}

void performHoleCenterProbe(ProbeParameters params) throws IllegalStateException {
public void performHoleCenterProbe(ProbeParameters params) throws IllegalStateException {
validateState();
currentOperation = ProbeOperation.INSIDE_CIRCLE;
this.params = params;
Expand Down