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

Removing deprecated driver code, etc. #267

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
32b246d
Added a (failing) test to demonstrate dithering.
cbiffle Mar 9, 2012
cab13a4
Removed the excess-tracking code from the drivers.
cbiffle Mar 9, 2012
3cfb577
Fixed compilation errors in MachineLoaderTest.
cbiffle Mar 9, 2012
c01bd8d
Removed unused deprecated code in Sanguino3GDriver.
cbiffle Mar 9, 2012
45dc178
Fixed incorrect override that disabled stepper fan.
cbiffle Mar 9, 2012
f9db2bb
Removed overrides of deprecated API in MightyBoard.
cbiffle Mar 9, 2012
75c54f1
Improved code reuse in Makerbot4G*Driver.
cbiffle Mar 9, 2012
5ea1e1c
@Deprecated/@Override cleanup in Driver classes.
cbiffle Mar 9, 2012
ecc5d15
Cleaned up DriverBaseImplementation, mostly.
cbiffle Mar 9, 2012
3b6b3f6
Marked SerialDriver as abstract.
cbiffle Mar 9, 2012
17b477d
Cleaned up Sanguino3GDriver, mostly.
cbiffle Mar 9, 2012
1b37a7c
Cleaned up Makerbot4GDriver.
cbiffle Mar 9, 2012
8172560
Removed an unused variable from MB4GAD.
cbiffle Mar 9, 2012
ff84f72
Miscellaneous cleanups in driver package:
cbiffle Mar 10, 2012
77bf80a
Fixed infinite recursion in setMotorDirection.
cbiffle Mar 10, 2012
49bf43b
Added @Overrides in two virtual drivers.
cbiffle Mar 10, 2012
0b374df
Modernizing Driver's API.
cbiffle Mar 10, 2012
06a13f0
Modernized DriverQueryInterface.
cbiffle Mar 10, 2012
3202278
Removed old-style tool status methods from Driver.
cbiffle Mar 10, 2012
9901d17
Removed old-style methods for motor speed/dir from Driver.
cbiffle Mar 10, 2012
b1060b9
Removed old-style motor enable/disable methods from Driver.
cbiffle Mar 10, 2012
7d0291f
Removed old-style temperature control methods from Driver.
cbiffle Mar 10, 2012
102a0f7
Removed old-style fan control methods from Driver.
cbiffle Mar 10, 2012
4ecb79c
Removed old-style ABP method from Driver.
cbiffle Mar 10, 2012
9af8624
Removed old-style valve control methods from Driver.
cbiffle Mar 10, 2012
c54fd32
Removed old-style spindle methods from Driver.
cbiffle Mar 10, 2012
7af51aa
Valve G-Code commands are now multi-tool aware.
cbiffle Mar 10, 2012
5bd64ac
Spindle and temperature G-Codes are now multitool-aware.
cbiffle Mar 10, 2012
f3db5c8
Most (all?) commands now take explicit tool indices.
cbiffle Mar 10, 2012
0e207ef
Added driver name and stop info to DriverQueryInterface.
cbiffle Mar 10, 2012
7b9c9cb
Added code to defend against the negative tool hack.
cbiffle Mar 10, 2012
d6c7147
Fixed a typo introduced in 06a13f07.
cbiffle Mar 10, 2012
f2343b0
Cleaned up MCode parser to use 'tool' field.
cbiffle Mar 10, 2012
bf8c128
Fixed HBP control hack in ExtruderPanel.
cbiffle Mar 10, 2012
98c625e
Removed bogus NaN check in ExtruderPanel.
cbiffle Mar 10, 2012
e21879f
Merge branch 'master' of https://github.com/makerbot/ReplicatorG into…
cbiffle Mar 12, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/replicatorg/app/gcode/GCodeCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package replicatorg.app.gcode;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -113,13 +112,38 @@ public boolean hasCode(char searchCode) {
}

public double getCodeValue(char searchCode) {
return getCodeValue(searchCode, -1);
}

public double getCodeValue(char searchCode, double fallback) {
for (gCodeParameter parameter : parameters) {
if (parameter.code == searchCode) {
return parameter.value;
}
}

return -1; // TODO: What do we return if there is no code?
return fallback;
}

public int getCodeValueInt(char searchCode, int fallback) {
return (int) getCodeValue(searchCode, fallback);
}

/*
* Note: unlike getCodeValue(char) above, this has no magic default
* return value. If used on a nonexistent code, it throws to indicate
* a programming error (in RepG, not the GCode).
*/
public int getCodeValueInt(char searchCode) {
for (gCodeParameter parameter : parameters) {
if (parameter.code == searchCode) {
return parameter.value.intValue();
}
}

throw new IllegalStateException(
"getCodeValueInt called for nonexistent code " + searchCode
+ "; caller should have checked hasCode first!");
}

// public Double removeCode(Character searchCode) {
Expand Down
74 changes: 41 additions & 33 deletions src/replicatorg/app/gcode/GCodeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Queue< DriverCommand > drawArc(Point5d center, Point5d endpoint, boolean clockwi
double feedrate = 0.0;

// current selected tool
protected int tool = ToolheadAlias.SINGLE.number;
private int tool = ToolheadAlias.SINGLE.number;

// unit variables.
public static int UNITS_MM = 0;
Expand Down Expand Up @@ -283,8 +283,8 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
// you may wish to avoid using M6.
if (gcode.hasCode('T') && driver instanceof MultiTool && ((MultiTool)driver).supportsSimultaneousTools())
{
commands.add(new replicatorg.drivers.commands.SelectTool((int) gcode.getCodeValue('T')));
tool = (int) gcode.getCodeValue('T');
commands.add(new replicatorg.drivers.commands.SelectTool(tool));
}

// handle unrecognised GCode
Expand Down Expand Up @@ -317,17 +317,17 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
break;
// spindle on, CW
case M3:
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(DriverCommand.AxialDirection.CLOCKWISE));
commands.add(new replicatorg.drivers.commands.EnableSpindle());
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(DriverCommand.AxialDirection.CLOCKWISE, tool));
commands.add(new replicatorg.drivers.commands.EnableSpindle(tool));
break;
// spindle on, CCW
case M4:
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(DriverCommand.AxialDirection.COUNTERCLOCKWISE));
commands.add(new replicatorg.drivers.commands.EnableSpindle());
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(DriverCommand.AxialDirection.COUNTERCLOCKWISE, tool));
commands.add(new replicatorg.drivers.commands.EnableSpindle(tool));
break;
// spindle off
case M5:
commands.add(new replicatorg.drivers.commands.DisableSpindle());
commands.add(new replicatorg.drivers.commands.DisableSpindle(tool));
break;
// tool change.
case M6:
Expand All @@ -336,7 +336,7 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
timeout = (int)gcode.getCodeValue('P');
}
if (gcode.hasCode('T')) {
commands.add(new replicatorg.drivers.commands.RequestToolChange((int) gcode.getCodeValue('T'), timeout));
commands.add(new replicatorg.drivers.commands.RequestToolChange(gcode.getCodeValueInt('T'), timeout));
}
else {
throw new GCodeException("The T parameter is required for tool changes. (M6)");
Expand Down Expand Up @@ -373,14 +373,18 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
break;
// spindle CW and coolant A on
case M13:
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(DriverCommand.AxialDirection.CLOCKWISE));
commands.add(new replicatorg.drivers.commands.EnableSpindle());
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(
DriverCommand.AxialDirection.CLOCKWISE,
tool));
commands.add(new replicatorg.drivers.commands.EnableSpindle(tool));
commands.add(new replicatorg.drivers.commands.EnableFloodCoolant());
break;
// spindle CCW and coolant A on
case M14:
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(DriverCommand.AxialDirection.COUNTERCLOCKWISE));
commands.add(new replicatorg.drivers.commands.EnableSpindle());
commands.add(new replicatorg.drivers.commands.SetSpindleDirection(
DriverCommand.AxialDirection.COUNTERCLOCKWISE,
tool));
commands.add(new replicatorg.drivers.commands.EnableSpindle(tool));
commands.add(new replicatorg.drivers.commands.EnableFloodCoolant());
break;
// enable drives
Expand Down Expand Up @@ -438,7 +442,7 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
break;
// read spindle speed
case M50:
driver.getSpindleRPM();
driver.getSpindleRPM(tool);
break;
// turn extruder on, forward
case M70:
Expand Down Expand Up @@ -469,22 +473,25 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
commands.add(new replicatorg.drivers.commands.SetBuildPercent(gcode.getCodeValue('P'), gcode.getComment() ) );
break;
case M101:
commands.add(new replicatorg.drivers.commands.SetMotorDirection(DriverCommand.AxialDirection.CLOCKWISE));
commands.add(new replicatorg.drivers.commands.EnableExtruderMotor());
commands.add(new replicatorg.drivers.commands.SetMotorDirection(DriverCommand.AxialDirection.CLOCKWISE, tool));
commands.add(new replicatorg.drivers.commands.EnableExtruderMotor(tool));
break;
// turn extruder on, reverse
case M102:
commands.add(new replicatorg.drivers.commands.SetMotorDirection(DriverCommand.AxialDirection.COUNTERCLOCKWISE));
commands.add(new replicatorg.drivers.commands.EnableExtruderMotor());
commands.add(new replicatorg.drivers.commands.SetMotorDirection(DriverCommand.AxialDirection.COUNTERCLOCKWISE, tool));
commands.add(new replicatorg.drivers.commands.EnableExtruderMotor(tool));
break;
// turn extruder off
case M103:
commands.add(new replicatorg.drivers.commands.DisableMotor());
commands.add(new replicatorg.drivers.commands.DisableMotor(tool));
break;
// custom code for temperature control
case M104:
if (gcode.hasCode('S'))
commands.add(new replicatorg.drivers.commands.SetTemperature(gcode.getCodeValue('S')));
if (gcode.hasCode('S')) {
commands.add(new replicatorg.drivers.commands.SetTemperature(
gcode.getCodeValue('S'),
tool));
}
break;
// custom code for temperature reading
// TODO: This command seems like a hack, it would be better for the driver to poll temperature rather than
Expand All @@ -494,42 +501,42 @@ private void buildMCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
break;
// turn AutomatedBuildPlatform on
case M106:
if(driver.hasAutomatedBuildPlatform())
commands.add(new replicatorg.drivers.commands.ToggleAutomatedBuildPlatform(true));
if(driver.hasAutomatedBuildPlatform(tool))
commands.add(new replicatorg.drivers.commands.ToggleAutomatedBuildPlatform(true, tool));
else
commands.add(new replicatorg.drivers.commands.EnableFan());
commands.add(new replicatorg.drivers.commands.EnableFan(tool));
break;
// turn AutomatedBuildPlatform off
case M107:
if(driver.hasAutomatedBuildPlatform())
commands.add(new replicatorg.drivers.commands.ToggleAutomatedBuildPlatform(false));
if(driver.hasAutomatedBuildPlatform(tool))
commands.add(new replicatorg.drivers.commands.ToggleAutomatedBuildPlatform(false, tool));
else
commands.add(new replicatorg.drivers.commands.DisableFan());
commands.add(new replicatorg.drivers.commands.DisableFan(tool));
break;
// set max extruder speed, RPM
case M108:
if (gcode.hasCode('S'))
commands.add(new replicatorg.drivers.commands.SetMotorSpeedPWM((int)gcode.getCodeValue('S')));
commands.add(new replicatorg.drivers.commands.SetMotorSpeedPWM((int)gcode.getCodeValue('S'), tool));
else if (gcode.hasCode('R'))
commands.add(new replicatorg.drivers.commands.SetMotorSpeedRPM(gcode.getCodeValue('R')));
commands.add(new replicatorg.drivers.commands.SetMotorSpeedRPM(gcode.getCodeValue('R'), tool));
break;
// set build platform temperature
case M109:
case M140: // skeinforge chamber code for HBP
if (gcode.hasCode('S'))
commands.add(new replicatorg.drivers.commands.SetPlatformTemperature(gcode.getCodeValue('S')));
commands.add(new replicatorg.drivers.commands.SetPlatformTemperature(gcode.getCodeValue('S'), tool));
break;
// set build chamber temperature
case M110:
commands.add(new replicatorg.drivers.commands.SetChamberTemperature(gcode.getCodeValue('S')));
break;
// valve open
case M126:
commands.add(new replicatorg.drivers.commands.OpenValve());
commands.add(new replicatorg.drivers.commands.OpenValve(tool));
break;
// valve close
case M127:
commands.add(new replicatorg.drivers.commands.CloseValve());
commands.add(new replicatorg.drivers.commands.CloseValve(tool));
break;
// where are we?
case M128:
Expand Down Expand Up @@ -613,7 +620,6 @@ private void buildGCodes(GCodeCommand gcode, Queue< DriverCommand > commands) th
double qVal = convertToMM(gcode.getCodeValue('Q'), units); // / feed
// increment for
// G83
double rVal = convertToMM(gcode.getCodeValue('R'), units); // / arc radius
double xVal = convertToMM(gcode.getCodeValue('X'), units); // / X units
double yVal = convertToMM(gcode.getCodeValue('Y'), units); // / Y units
double zVal = convertToMM(gcode.getCodeValue('Z'), units); // / Z units
Expand Down Expand Up @@ -885,7 +891,9 @@ else if (gcode.hasCode('R')) {
// break;
// spindle speed rate
case G97:
commands.add(new replicatorg.drivers.commands.SetSpindleRPM(gcode.getCodeValue('S')));
commands.add(new replicatorg.drivers.commands.SetSpindleRPM(
gcode.getCodeValue('S'),
gcode.getCodeValueInt('T', driver.getCurrentToolIndex())));
break;
case G130:
/// TODO: axis ids should not be hard coded
Expand Down
26 changes: 14 additions & 12 deletions src/replicatorg/app/ui/controlpanel/ExtruderPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void actionPerformed(ActionEvent e) {
}
}
}, "handleTextField", "motor-speed-pwm", 5, Base.getLocalFormat());
field.setValue(machine.getDriverQueryInterface().getMotorSpeedPWM());
field.setValue(machine.getDriverQueryInterface().getMotorSpeedPWM(tool.getIndex()));
panel.add(label);
panel.add(field,"wrap");
}
Expand Down Expand Up @@ -748,16 +748,18 @@ private void handleChangedTextField(JFormattedTextField source)
{
String name = source.getName();
int toolhead;
boolean platform = false;
double newValue = Double.NaN;

// tools position may not match index
if(source == t0TargetTemperatureField)
toolhead = tool0.getIndex();
else if(source == t1TargetTemperatureField)
toolhead = tool1.getIndex();
else if(source == pTargetTemperatureField)
toolhead = -1; // -1 means autodetect
else {
else if(source == pTargetTemperatureField) {
toolhead = tool0.getIndex();
platform = true;
} else {
Base.logger.warning("Unhandled text field: "+name);
return;
}
Expand All @@ -767,7 +769,7 @@ else if(source == pTargetTemperatureField)
newValue = ((Number)source.getValue()).doubleValue();

// if we have a toolhead temperature
if(toolhead != -1) {
if (!platform) {
newValue = confirmTemperature(newValue,"temperature.acceptedLimit",260.0);
if (newValue == Double.MIN_VALUE) {
return;
Expand All @@ -781,7 +783,7 @@ else if(source == pTargetTemperatureField)
machine.runCommand(new replicatorg.drivers.commands.SetPlatformTemperature(newValue, toolhead));
}
}
if(newValue != Double.NaN) {
if(!Double.isNaN(newValue)) {
if(source == t0TargetTemperatureField)
t0TargetTemperature = newValue;
else if(source == t1TargetTemperatureField)
Expand All @@ -801,14 +803,14 @@ private void handleChangedItem(ItemEvent e, ToolModel tool) {
machine.runCommand(new replicatorg.drivers.commands.SetMotorDirection(AxialDirection.CLOCKWISE,toolhead));
// TODO: Hack to support RepRap/Ultimaker- always re-send RPM
if (tool.motorHasEncoder() || tool.motorIsStepper()) {
machine.runCommand(new replicatorg.drivers.commands.SetMotorSpeedRPM(machine.getDriver().getMotorRPM(),toolhead));
machine.runCommand(new replicatorg.drivers.commands.SetMotorSpeedRPM(machine.getDriverQueryInterface().getMotorRPM(toolhead), toolhead));
}
machine.runCommand(new replicatorg.drivers.commands.EnableExtruderMotor(toolhead));
} else if (name.equals("motor-reverse")) {
machine.runCommand(new replicatorg.drivers.commands.SetMotorDirection(AxialDirection.COUNTERCLOCKWISE,toolhead));
// TODO: Hack to support RepRap/Ultimaker- always re-send RPM
if (tool.motorHasEncoder() || tool.motorIsStepper()) {
machine.runCommand(new replicatorg.drivers.commands.SetMotorSpeedRPM(machine.getDriver().getMotorRPM(),toolhead));
machine.runCommand(new replicatorg.drivers.commands.SetMotorSpeedRPM(machine.getDriverQueryInterface().getMotorRPM(toolhead), toolhead));
}
machine.runCommand(new replicatorg.drivers.commands.EnableExtruderMotor(toolhead));
} else if (name.equals("motor-stop")) {
Expand Down Expand Up @@ -845,29 +847,29 @@ private void handleMotorAction(ActionEvent e, ToolModel tool) {
if (tool.getMotorStepperAxisName() != "") {
machine.runCommand(new replicatorg.drivers.commands.SetMotorDirection(AxialDirection.CLOCKWISE,toolhead));
// Reverted to one single command for RepRap5D driver
if (machine.getDriver().getDriverName().equals("RepRap5D")) {
if (machine.getDriverQueryInterface().getDriverName().equals("RepRap5D")) {
machine.runCommand(new replicatorg.drivers.commands.EnableExtruderMotor(extrudeTime*1000,toolhead));
} else {
// See Note (***) Below:
machine.runCommand(new replicatorg.drivers.commands.SelectTool(toolhead));

machine.runCommand(new replicatorg.drivers.commands.EnableExtruderMotor(toolhead));
machine.runCommand(new replicatorg.drivers.commands.Delay(extrudeTime*1000,toolhead));
machine.runCommand(new replicatorg.drivers.commands.Delay(extrudeTime*1000));
machine.runCommand(new replicatorg.drivers.commands.DisableMotor(toolhead));
}
}
} else if (actionName.equals("reverse")) {
if (tool.getMotorStepperAxisName() != "") {
machine.runCommand(new replicatorg.drivers.commands.SetMotorDirection(AxialDirection.COUNTERCLOCKWISE,toolhead));
// Reverted to one single command for RepRap5D driver
if (machine.getDriver().getDriverName().equals("RepRap5D")) {
if (machine.getDriverQueryInterface().getDriverName().equals("RepRap5D")) {
machine.runCommand(new replicatorg.drivers.commands.EnableExtruderMotor(extrudeTime*1000,toolhead));
} else {
// See Note (***) Below:
machine.runCommand(new replicatorg.drivers.commands.SelectTool(toolhead));

machine.runCommand(new replicatorg.drivers.commands.EnableExtruderMotor(toolhead));
machine.runCommand(new replicatorg.drivers.commands.Delay(extrudeTime*1000,toolhead));
machine.runCommand(new replicatorg.drivers.commands.Delay(extrudeTime*1000));
machine.runCommand(new replicatorg.drivers.commands.DisableMotor(toolhead));
}
}
Expand Down
Loading