// Convert the Location to millimeters, since that's the unit that
// this driver works in natively.
location = location.convertToUnits(LengthUnit.Millimeters);
// Get the current location of the Head that we'll move
Location hl = getHeadLocation(hm.getHead());
String movable;
if (hm.toString().equals("N1")) {
movable = "Nozzle1";
}
else if (hm.toString().equals("N2")) {
movable = "Nozzle2";
}
else if (hm.toString().contains("Camera")) {
movable = "Camera";
}
else if (hm.toString().equals("A1")) {
movable = "Actuator";
}
else {
throw new Exception("Don't know what " + hm.toString() + " is.");
}
send(String.format("m,%s,%f,%f,%f,%f", movable, location.getX(), location.getY(), location.getZ(), location.getRotation()));
// Now that movement is complete, update the stored Location to the new
// Location, unless the incoming Location specified an axis with a value
// of NaN. NaN is interpreted to mean "Don't move this axis" so we don't
// update the value, either.
hl = hl.derive(
Double.isNaN(location.getX()) ? null : location.getX(),
Double.isNaN(location.getY()) ? null : location.getY(),
Double.isNaN(location.getZ()) ? null : location.getZ(),
Double.isNaN(location.getRotation()) ? null : location.getRotation());