Skip to content

Commit

Permalink
Fixed incorrect override that disabled stepper fan.
Browse files Browse the repository at this point in the history
I've added @OverRide annotations to all overrides.  This revealed
a bug: the enableMotor/disableMotor, despite being documented as
overrides, weren't.  As a result, the Sanguino3GDriver behavior
was being invoked, generating DC motor control messages even when
the axis has been hijacked for a stepper extruder.  Because this
driver reuses the same motor control channel for the stepper fan,
this meant the fan turned on...until the first motion.  Then it
started toggling on and off with the stepper motor.

That's kind of silly, so with this change it obeys the flag passed
to enableStepperExtruderFan(boolean).
  • Loading branch information
cbiffle committed Mar 9, 2012
1 parent c01bd8d commit 45dc178
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/replicatorg/drivers/gen3/Makerbot4GAlternateDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class Makerbot4GAlternateDriver extends Makerbot4GDriver {

private boolean stepperExtruderFanEnabled = false;

public String getDriverName() {
@Override public String getDriverName() {
return "Makerbot4GAlternate";
}

public void reset() {
@Override public void reset() {
// We should poll the machine for it's state here, but it is more important to have the
// fan on than off.
stepperExtruderFanEnabled = false;
Expand All @@ -35,7 +35,7 @@ public void reset() {
/**
* Overloaded to manage a hijacked axis and run this axis in relative mode instead of the extruder DC motor
*/
public void queuePoint(Point5d p) throws RetryException {
@Override public void queuePoint(Point5d p) throws RetryException {
// If we don't know our current position, make this move an old-style move, ignoring any hijacked axes.
if (positionLost()) {
Base.logger.fine("Position invalid, reverting to default speed for next motion");
Expand Down Expand Up @@ -112,7 +112,7 @@ public void queuePoint(Point5d p) throws RetryException {
* In legacy use, delayed while a DC motor ran. For compatiblity, this function
* creates a Point5D to do 'extrude while sitting still'.
*/
public void delay(long millis) throws RetryException {
@Override public void delay(long millis) throws RetryException {
Base.logger.finer("Delaying " + millis + " millis.");

Point5d steps = pointsFromHijackedAxes( machine.currentTool(), millis / 60000d);
Expand Down Expand Up @@ -223,7 +223,7 @@ private Point5d pointsFromHijackedAxes(ToolModel curTool, double minutes) {
return steps;
}

public void stop(boolean abort) {
@Override public void stop(boolean abort) {
// Record the toolstate as off, so we don't excite the extruder motor in future moves.
machine.currentTool().disableMotor();

Expand Down Expand Up @@ -264,38 +264,41 @@ protected void queueNewPoint(Point5d steps, long us, int relative) throws RetryE
/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void enableMotor() throws RetryException {
machine.currentTool().enableMotor();
@Override public void enableMotor(int toolhead) throws RetryException {
if (toolhead == -1 ) toolhead = machine.currentTool().getIndex();
machine.getTool(toolhead).enableMotor();
}

/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void disableMotor() throws RetryException {
machine.currentTool().disableMotor();
@Override public void disableMotor(int toolhead) throws RetryException {
if (toolhead == -1 ) toolhead = machine.currentTool().getIndex();

machine.getTool(toolhead).disableMotor();
}

/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void setMotorSpeedPWM(int pwm) throws RetryException {
@Override public void setMotorSpeedPWM(int pwm) throws RetryException {
machine.currentTool().setMotorSpeedPWM(pwm);
}

/**
* Overridden to not talk to the DC motor driver. This driver is reused for the stepper motor fan
*/
public void setMotorRPM(double rpm, int toolhead) throws RetryException {
@Override public void setMotorRPM(double rpm, int toolhead) throws RetryException {
machine.currentTool().setMotorSpeedRPM(rpm);
}

public void enableDrives() throws RetryException {
@Override public void enableDrives() throws RetryException {
enableStepperExtruderFan(true);

super.enableDrives();
}

public void disableDrives() throws RetryException {
@Override public void disableDrives() throws RetryException {
enableStepperExtruderFan(false);

super.disableDrives();
Expand All @@ -305,7 +308,7 @@ public void disableDrives() throws RetryException {
* Will turn on/off the stepper extruder fan if it's not already in the correct state.
*
*/
public void enableStepperExtruderFan(boolean enabled) throws RetryException {
@Override public void enableStepperExtruderFan(boolean enabled) throws RetryException {

// Always re-enable the fan when
if (this.stepperExtruderFanEnabled == enabled) return;
Expand Down Expand Up @@ -342,11 +345,10 @@ public void enableStepperExtruderFan(boolean enabled) throws RetryException {
/// This is a list of which axis are hijacked for extruder use.
EnumMap<AxisId,ToolModel> extruderHijackedMap = new EnumMap<AxisId,ToolModel>(AxisId.class);

@Override
/**
* When the machine is set for this driver, some toolheads may poach the an extrusion axis.
*/
public void setMachine(MachineModel m) {
@Override public void setMachine(MachineModel m) {
super.setMachine(m);
for (ToolModel tm : m.getTools()) {
Element e = (Element)tm.getXml();
Expand All @@ -370,12 +372,11 @@ public void setMachine(MachineModel m) {
}
}

@Override
/**
* Overridden to not ask the board for the RPM as it would report the RPM from the extruder
* controller, which doesn't know about it in this case.
*/
public double getMotorRPM() {
@Override public double getMotorRPM() {
double rpm = machine.currentTool().getMotorSpeedRPM();
machine.currentTool().setMotorSpeedReadingRPM(rpm);
return rpm;
Expand Down

0 comments on commit 45dc178

Please sign in to comment.