Skip to content

Commit 06a13f0

Browse files
committed
Modernized DriverQueryInterface.
While the Driver interface grew new methods to support multiple tools, DriverQueryInterface was left behind. Fortunately, it's a much less popular type, so fixing this is a relatively small change. Because classes tend to implement both Driver and DriverQueryInterface, and Driver already had the methods in question, I was able to simply remove the old-style methods from DriverQueryInterface. As a side effect, a few G-Code commands are now multi-tool aware -- specifically, the commands for setting spindle speed.
1 parent 0b374df commit 06a13f0

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

src/replicatorg/app/gcode/GCodeParser.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,11 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
438438
break;
439439
// read spindle speed
440440
case M50:
441-
driver.getSpindleRPM();
441+
if (gcode.hasCode('T')) {
442+
driver.getSpindleRPM((int) gcode.getCodeValue('P'));
443+
} else {
444+
driver.getSpindleRPM(driver.getCurrentToolIndex());
445+
}
442446
break;
443447
// turn extruder on, forward
444448
case M70:
@@ -493,19 +497,23 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
493497
commands.add(new replicatorg.drivers.commands.ReadTemperature());
494498
break;
495499
// turn AutomatedBuildPlatform on
496-
case M106:
497-
if(driver.hasAutomatedBuildPlatform())
500+
case M106: {
501+
int toolIndex = gcode.hasCode('T') ? (int) gcode.getCodeValue('T') : driver.getCurrentToolIndex();
502+
if(driver.hasAutomatedBuildPlatform(toolIndex))
498503
commands.add(new replicatorg.drivers.commands.ToggleAutomatedBuildPlatform(true));
499504
else
500505
commands.add(new replicatorg.drivers.commands.EnableFan());
501506
break;
507+
}
502508
// turn AutomatedBuildPlatform off
503-
case M107:
504-
if(driver.hasAutomatedBuildPlatform())
509+
case M107: {
510+
int toolIndex = gcode.hasCode('T') ? (int) gcode.getCodeValue('T') : driver.getCurrentToolIndex();
511+
if(driver.hasAutomatedBuildPlatform(toolIndex))
505512
commands.add(new replicatorg.drivers.commands.ToggleAutomatedBuildPlatform(false));
506513
else
507514
commands.add(new replicatorg.drivers.commands.DisableFan());
508515
break;
516+
}
509517
// set max extruder speed, RPM
510518
case M108:
511519
if (gcode.hasCode('S'))

src/replicatorg/app/ui/controlpanel/ExtruderPanel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void actionPerformed(ActionEvent e) {
274274
}
275275
}
276276
}, "handleTextField", "motor-speed-pwm", 5, Base.getLocalFormat());
277-
field.setValue(machine.getDriverQueryInterface().getMotorSpeedPWM());
277+
field.setValue(machine.getDriverQueryInterface().getMotorSpeedPWM(tool.getIndex()));
278278
panel.add(label);
279279
panel.add(field,"wrap");
280280
}

src/replicatorg/drivers/DriverBaseImplementation.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,10 @@ protected Point5d getDelta(Point5d p) {
398398
@Override public void selectTool(int toolIndex) throws RetryException {
399399
machine.selectTool(toolIndex);
400400
}
401+
402+
@Override public int getCurrentToolIndex() {
403+
return machine.currentTool().getIndex();
404+
}
401405

402406
/***************************************************************************
403407
* pause function
@@ -797,12 +801,7 @@ public void setAutomatedBuildPlatformRunning(boolean state, int toolhead)
797801
}
798802

799803

800-
@Override public boolean hasAutomatedBuildPlatform()
801-
{
802-
return hasAutomatedBuildPlatform(-1);
803-
}
804-
805-
private boolean hasAutomatedBuildPlatform(int toolhead)
804+
@Override public boolean hasAutomatedBuildPlatform(int toolhead)
806805
{
807806
/// toolhead -1 indicate auto-detect.Fast hack to get software out..
808807
if(toolhead == -1 ) toolhead = machine.currentTool().getIndex();

src/replicatorg/drivers/DriverQueryInterface.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,26 @@
1111
* @author matt.mets
1212
*/
1313
public interface DriverQueryInterface {
14+
public int getCurrentToolIndex();
15+
1416
public Point3d getOffset(int i);
1517

1618
public Point5d getMaximumFeedrates();
1719

18-
public double getSpindleRPM();
20+
public double getSpindleRPM(int toolhead);
1921

20-
public double getMotorRPM();
22+
public double getMotorRPM(int toolhead);
2123

22-
public int getMotorSpeedPWM();
23-
24-
/** relies on timing to have the 'right selected toolhead', deprecated */
25-
@Deprecated
26-
public double getTemperature();
24+
public int getMotorSpeedPWM(int toolhead);
2725

2826
public double getTemperature(int toolhead);
2927

30-
public double getTemperatureSetting();
28+
public double getTemperatureSetting(int toolhead);
3129

32-
public boolean hasAutomatedBuildPlatform();
30+
public boolean hasAutomatedBuildPlatform(int toolhead);
3331

34-
/** relies on timing to have the 'right selected toolhead', deprecated */
35-
@Deprecated
36-
public double getPlatformTemperature();
3732
public double getPlatformTemperature(int toolhead);
38-
public double getPlatformTemperatureSetting();
33+
public double getPlatformTemperatureSetting(int toolhead);
3934

4035
public Point5d getCurrentPosition(boolean b);
4136

0 commit comments

Comments
 (0)