makerbot/ReplicatorG — Issue #238: RepG fails when asking a single headed machine to do stuff with a non-existent second head
Author: tedbrandston
Created: 2011-10-13 17:24:04+00:00
State: open

When running gcode that asks the machine to set the temperature for T1 RepG says "Cannot select non-existant tool (#1)." and recovers. This is fine (aside from the [spelling error][1]).
However, when running code that waits for the extruder to heat up RepG spits out that message twice, then one about being unable to "get" the tool, and my java console displays two exceptions, with the following trace:
```
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
at java.util.Vector.get(Unknown Source)
at replicatorg.machine.model.MachineModel.getTool(MachineModel.java:457)
at replicatorg.drivers.gen3.Sanguino3GDriver.requestToolChange(Sanguino3GDriver.java:721)
at replicatorg.drivers.commands.RequestToolChange.run(RequestToolChange.java:17)
at replicatorg.machine.builder.Direct.runNext(Direct.java:158)
at replicatorg.machine.MachineThread.run(MachineThread.java:483)
Exception in thread "Machine Thread" java.lang.NullPointerException
at replicatorg.drivers.gen3.Sanguino3GDriver.requestToolChange(Sanguino3GDriver.java:721)
at replicatorg.drivers.commands.RequestToolChange.run(RequestToolChange.java:17)
at replicatorg.machine.builder.Direct.runNext(Direct.java:158)
at replicatorg.machine.MachineThread.run(MachineThread.java:483)
Oct 13, 2011 1:19:30 PM replicatorg.app.ui.MainWindow$40 run
```

ReplicatorG then cannot stop the build or start a new one. There should be a better failure mode.

[1]: http://en.wiktionary.org/wiki/existant#English