Skip to content

Commit 6bf1787

Browse files
authored
Add ABC Actions and jog settings. (winder#1515)
1 parent 245af90 commit 6bf1787

File tree

37 files changed

+1551
-111
lines changed

37 files changed

+1551
-111
lines changed

run_classic.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
#!/usr/bin/env bash
12
mvn install
23
mvn exec:java -Dexec.mainClass="com.willwinder.universalgcodesender.MainWindow" -pl ugs-core

run_platform.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
#!/usr/bin/env bash
12
mvn install -DskipTests=true && \
23
mvn nbm:run-platform -pl ugs-platform/application

ugs-core/src/com/willwinder/universalgcodesender/IController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2015-2020 Will Winder
2+
Copyright 2015-2021 Will Winder
33
44
This file is part of Universal Gcode Sender (UGS).
55

ugs-core/src/com/willwinder/universalgcodesender/model/GUIBackend.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2015-2018 Will Winder
2+
Copyright 2015-2021 Will Winder
33
44
This file is part of Universal Gcode Sender (UGS).
55

ugs-core/src/com/willwinder/universalgcodesender/model/PartialPosition.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1-
package com.willwinder.universalgcodesender.model;
1+
/*
2+
Copyright 2019-2021 Will Winder
3+
4+
This file is part of Universal Gcode Sender (UGS).
5+
6+
UGS is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
210
11+
UGS is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with UGS. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
package com.willwinder.universalgcodesender.model;
320

421
import com.google.common.collect.ImmutableMap;
522
import com.willwinder.universalgcodesender.Utils;
@@ -208,6 +225,7 @@ public double getAxis(Axis axis) {
208225
}
209226

210227
public PartialPosition getPositionIn(UnitUtils.Units units) {
228+
if (units == this.units) return this;
211229
double scale = UnitUtils.scaleUnits(this.units, units);
212230
Builder builder = builder();
213231
for (Map.Entry<Axis, Double> axis : getAll().entrySet()) {

ugs-core/src/com/willwinder/universalgcodesender/services/JogService.java

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016-2018 Will Winder
2+
Copyright 2016-2021 Will Winder
33
44
This file is part of Universal Gcode Sender (UGS).
55
@@ -116,6 +116,15 @@ public void decreaseZStepSize() {
116116
setStepSizeZ(decreaseSize(getStepSizeZ()));
117117
}
118118

119+
public void increaseABCStepSize() {
120+
setStepSizeABC(increaseSize(getStepSizeABC()));
121+
}
122+
123+
public void decreaseABCStepSize() {
124+
setStepSizeABC(decreaseSize(getStepSizeABC()));
125+
}
126+
127+
119128
public void divideXYStepSize() {
120129
setStepSizeXY(divideSize(getStepSizeXY()));
121130
}
@@ -124,6 +133,10 @@ public void divideZStepSize() {
124133
setStepSizeZ(divideSize(getStepSizeZ()));
125134
}
126135

136+
public void divideABCStepSize() {
137+
setStepSizeABC(divideSize(getStepSizeZ()));
138+
}
139+
127140
public void multiplyXYStepSize() {
128141
setStepSizeXY(multiplySize(getStepSizeXY()));
129142
}
@@ -132,6 +145,10 @@ public void multiplyZStepSize() {
132145
setStepSizeZ(multiplySize(getStepSizeZ()));
133146
}
134147

148+
public void multiplyABCStepSize() {
149+
setStepSizeABC(multiplySize(getStepSizeZ()));
150+
}
151+
135152
public void multiplyFeedRate() {
136153
setFeedRate(multiplySize(getFeedRate()));
137154
}
@@ -148,16 +165,21 @@ public void decreaseFeedRate() {
148165
setFeedRate(decreaseSize(getFeedRate()));
149166
}
150167

151-
public void setStepSizeXY(double size) {
152-
getSettings().setManualModeStepSize(size);
153-
}
154168

155169
private Settings getSettings() {
156170
return backend.getSettings();
157171
}
158172

173+
public void setStepSizeXY(double size) {
174+
getSettings().setManualModeStepSize(size);
175+
}
176+
159177
public void setStepSizeZ(double size) {
160-
getSettings().setzJogStepSize(size);
178+
getSettings().setZJogStepSize(size);
179+
}
180+
181+
public void setStepSizeABC(double size) {
182+
getSettings().setABCJogStepSize(size);
161183
}
162184

163185
public void setFeedRate(double rate) {
@@ -189,7 +211,7 @@ public void adjustManualLocation(PartialPosition distance) {
189211
try {
190212
double feedRate = getSettings().getJogFeedRate();
191213
Units units = getSettings().getPreferredUnits();
192-
backend.adjustManualLocation(distance, feedRate);
214+
backend.adjustManualLocation(distance.getPositionIn(units), feedRate);
193215
} catch (Exception e) {
194216
// Not much we can do
195217
}
@@ -218,6 +240,10 @@ public boolean useStepSizeZ() {
218240
return getSettings().useZStepSize();
219241
}
220242

243+
public boolean showABCStepSize() {
244+
return getSettings().showABCStepSize();
245+
}
246+
221247
/**
222248
* Adjusts the XY axis location.
223249
* @param x direction.
@@ -228,33 +254,34 @@ public void adjustManualLocationXY(int x, int y) {
228254
double feedRate = getFeedRate();
229255
double stepSize = getStepSizeXY();
230256
Units preferredUnits = getUnits();
231-
backend.adjustManualLocation(new PartialPosition(x * stepSize, y * stepSize, null, preferredUnits), feedRate);
257+
Double dx = x == 0 ? null : x * stepSize;
258+
Double dy = y == 0 ? null : y * stepSize;
259+
backend.adjustManualLocation(new PartialPosition(dx, dy, null, preferredUnits), feedRate);
232260
} catch (Exception e) {
233261
//NotifyDescriptor nd = new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
234262
//DialogDisplayer.getDefault().notify(nd);
235263
}
236264
}
237265

238266
/**
239-
* Adjusts the axis location.
267+
* Adjusts the rotation axis location.
240268
* @param a direction.
241269
* @param b direction.
242270
* @param c direction.
243271
*/
244272
public void adjustManualLocationABC(int a, int b, int c) {
245-
// TODO: ABC Axis
246-
throw new UnsupportedOperationException("This has not been implemented yet.");
247-
/*
248273
try {
249274
double feedRate = getFeedRate();
250-
double stepSize = getStepSizeXY();
275+
double stepSize = getStepSizeABC();
251276
Units preferredUnits = getUnits();
252-
backend.adjustManualLocation(new PartialPosition(x * stepSize, y * stepSize, 0.0, preferredUnits), feedRate);
277+
Double da = a == 0 ? null : a * stepSize;
278+
Double db = b == 0 ? null : b * stepSize;
279+
Double dc = c == 0 ? null : c * stepSize;
280+
backend.adjustManualLocation(new PartialPosition(null, null, null, da, db, dc, preferredUnits), feedRate);
253281
} catch (Exception e) {
254282
//NotifyDescriptor nd = new NotifyDescriptor.Message(e.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
255283
//DialogDisplayer.getDefault().notify(nd);
256284
}
257-
*/
258285
}
259286

260287
public boolean canJog() {
@@ -268,7 +295,11 @@ public double getStepSizeXY() {
268295
}
269296

270297
public double getStepSizeZ() {
271-
return getSettings().getzJogStepSize();
298+
return getSettings().getZJogStepSize();
299+
}
300+
301+
public double getStepSizeABC() {
302+
return getSettings().getABCJogStepSize();
272303
}
273304

274305
public void cancelJog() {

ugs-core/src/com/willwinder/universalgcodesender/uielements/jog/JogPanel.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void UGSEvent(UGSEvent evt) {
144144
private void syncWithJogService() {
145145
Settings s = backend.getSettings();
146146
xyStepSizeSpinner.setValue(s.getManualModeStepSize());
147-
zStepSizeSpinner.setValue(s.getzJogStepSize());
147+
zStepSizeSpinner.setValue(s.getZJogStepSize());
148148
feedRateSpinner.setValue(s.getJogFeedRate());
149149
}
150150

@@ -187,22 +187,22 @@ private void updateUnitButton() {
187187

188188
public void increaseStepActionPerformed() {
189189
jogService.increaseXYStepSize();
190-
xyStepSizeSpinner.setValue(getxyStepSize());
190+
xyStepSizeSpinner.setValue(getXYStepSize());
191191
}
192192

193193
public void decreaseStepActionPerformed() {
194194
jogService.decreaseXYStepSize();
195-
xyStepSizeSpinner.setValue(getxyStepSize());
195+
xyStepSizeSpinner.setValue(getXYStepSize());
196196
}
197197

198198
public void multiplyStepActionPerformed() {
199199
jogService.multiplyXYStepSize();
200-
xyStepSizeSpinner.setValue(getxyStepSize());
200+
xyStepSizeSpinner.setValue(getXYStepSize());
201201
}
202202

203203
public void divideStepActionPerformed() {
204204
jogService.divideXYStepSize();
205-
xyStepSizeSpinner.setValue(getxyStepSize());
205+
xyStepSizeSpinner.setValue(getXYStepSize());
206206
}
207207

208208
@Override
@@ -260,15 +260,15 @@ private Units getUnits() {
260260
return jogService.getUnits();
261261
}
262262

263-
private double getxyStepSize() {
263+
private double getXYStepSize() {
264264
double stepSize = xyStepSizeSpinner.getValue();
265265
backend.getSettings().setManualModeStepSize(stepSize);
266266
return stepSize;
267267
}
268268

269-
private double getzStepSize() {
269+
private double getZStepSize() {
270270
double stepSize = zStepSizeSpinner.getValue();
271-
backend.getSettings().setzJogStepSize(stepSize);
271+
backend.getSettings().setZJogStepSize(stepSize);
272272
return stepSize;
273273
}
274274

ugs-core/src/com/willwinder/universalgcodesender/utils/ContinuousJogWorker.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2020 Will Winder
2+
Copyright 2020-2021 Will Winder
33
44
This file is part of Universal Gcode Sender (UGS).
55
@@ -72,7 +72,9 @@ public ContinuousJogWorker(BackendAPI backendAPI, JogService jogService) {
7272
*/
7373
public void destroy() {
7474
isRunning = false;
75-
future.cancel(false);
75+
if (future != null) {
76+
future.cancel(false);
77+
}
7678
backendAPI.removeControllerListener(this);
7779
}
7880

@@ -183,7 +185,9 @@ public void commandComplete(GcodeCommand command) {
183185
isWaitingForCommandComplete = false;
184186
if (command.isError()) {
185187
stop();
186-
future.cancel(false);
188+
if (future != null) {
189+
future.cancel(false);
190+
}
187191
}
188192
}
189193

ugs-core/src/com/willwinder/universalgcodesender/utils/Settings.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2014-2019 Will Winder
2+
Copyright 2014-2021 Will Winder
33
44
This file is part of Universal Gcode Sender (UGS).
55
@@ -56,7 +56,9 @@ public class Settings {
5656
private boolean manualModeEnabled = false;
5757
private double manualModeStepSize = 1;
5858
private boolean useZStepSize = true;
59+
private boolean showABCStepSize = true;
5960
private double zJogStepSize = 1;
61+
private double abcJogStepSize = 1;
6062
private double jogFeedRate = 10;
6163
private boolean scrollWindowEnabled = true;
6264
private boolean verboseOutputEnabled = false;
@@ -247,15 +249,33 @@ public void setUseZStepSize(boolean useZStepSize) {
247249
changed();
248250
}
249251

250-
public double getzJogStepSize() {
252+
public boolean showABCStepSize() {
253+
return this.showABCStepSize;
254+
}
255+
256+
public void setShowABCStepSize(boolean showABCStepSize) {
257+
this.showABCStepSize = showABCStepSize;
258+
changed();
259+
}
260+
261+
public double getZJogStepSize() {
251262
return zJogStepSize;
252263
}
253264

254-
public void setzJogStepSize(double zJogStepSize) {
265+
public void setZJogStepSize(double zJogStepSize) {
255266
this.zJogStepSize = zJogStepSize;
256267
changed();
257268
}
258269

270+
public double getABCJogStepSize() {
271+
return abcJogStepSize;
272+
}
273+
274+
public void setABCJogStepSize(double abcJogStepSize) {
275+
this.abcJogStepSize = abcJogStepSize;
276+
changed();
277+
}
278+
259279
public double getJogFeedRate() {
260280
return jogFeedRate;
261281
}
@@ -349,7 +369,7 @@ public void setPreferredUnits(Units units) {
349369

350370
// Change
351371
setManualModeStepSize(manualModeStepSize * scaleUnits);
352-
setzJogStepSize(zJogStepSize * scaleUnits);
372+
setZJogStepSize(zJogStepSize * scaleUnits);
353373
setJogFeedRate(Math.round(jogFeedRate * scaleUnits));
354374
}
355375
}

ugs-core/src/resources/MessagesBundle_en_US.properties

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ mainWindow.swing.resetCoordinatesButton = Reset Zero
9595
action.resetXCoordinatesButton = Reset X Zero
9696
action.resetYCoordinatesButton = Reset Y Zero
9797
action.resetZCoordinatesButton = Reset Z Zero
98+
action.resetACoordinatesButton = Reset A Zero
99+
action.resetBCoordinatesButton = Reset B Zero
100+
action.resetCCoordinatesButton = Reset C Zero
98101
mainWindow.swing.returnToZeroButton = Return to Zero
99102
mainWindow.swing.homeMachine = Home Machine
100103
mainWindow.swing.rowsLabel = Rows In File\:
@@ -246,6 +249,12 @@ jogging.xPlus.yMinus = Jog: X+ Y-
246249
jogging.xPlus.yPlus = Jog: X+ Y+
247250
jogging.xMinus.yPlus = Jog: X- Y+
248251
jogging.xMinus.yMinus = Jog: X- Y-
252+
jogging.aPlus = Jog: A+
253+
jogging.aMinus = Jog: A-
254+
jogging.bPlus = Jog: B+
255+
jogging.bMinus = Jog: B-
256+
jogging.cPlus = Jog: C+
257+
jogging.cMinus = Jog: C-
249258
jogging.divide = Jog: Divide XY Step Size by 10
250259
jogging.multiply = Jog: Multiply XY Step Size by 10
251260
jogging.increase = Jog: Increase XY Step Size
@@ -254,6 +263,10 @@ jogging.divide.z = Jog: Divide Z Step Size by 10
254263
jogging.multiply.z = Jog: Multiply Z Step Size by 10
255264
jogging.increase.z = Jog: Increase Z Step Size
256265
jogging.decrease.z = Jog: Decrease Z Step Size
266+
jogging.divide.abc = Jog: Divide ABC Step Size by 10
267+
jogging.multiply.abc = Jog: Multiply ABC Step Size by 10
268+
jogging.increase.abc = Jog: Increase ABC Step Size
269+
jogging.decrease.abc = Jog: Decrease ABC Step Size
257270
jogging.increase.feed = Jog: Increase Feed Rate
258271
jogging.decrease.feed = Jog: Decrease Feed Rate
259272
jogging.multiply.feed = Jog: Multiply Feed Rate by 10
@@ -559,10 +572,12 @@ platform.visualizer.popup.presets.top = Top
559572
platform.visualizer.popup.presets.left = Left
560573
platform.visualizer.popup.presets.front = Front
561574
platform.plugin.jog.useSeparateStepSize = Use separate step sizes for Z and XY
575+
platform.plugin.jog.showABCStepSize = Show ABC step size
562576
platform.plugin.jog.feedRate = Feed rate
563577
platform.plugin.jog.stepSize = Step size
564578
platform.plugin.jog.stepSizeZ = Step size Z
565579
platform.plugin.jog.stepSizeXY = Step size XY
580+
platform.plugin.jog.stepSizeABC = Step size ABC
566581
platform.plugin.jog.stepLarger = Larger
567582
platform.plugin.jog.stepSmaller = Smaller
568583
platform.plugin.jog.stealKeyboardFocus = Making sure that keyboard controls are active

0 commit comments

Comments
 (0)