Skip to content

Commit

Permalink
Made tests run with AxesLocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
markmaker committed May 12, 2020
1 parent 4dd295d commit 3e72d57
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import javax.swing.Action;
Expand All @@ -33,12 +32,11 @@
import org.openpnp.machine.marek.MarekNozzle;
import org.openpnp.machine.neoden4.NeoDen4Driver;
import org.openpnp.machine.neoden4.Neoden4Camera;
import org.openpnp.machine.reference.axis.ReferenceCamCounterClockwiseAxis;
import org.openpnp.machine.reference.axis.ReferenceCamClockwiseAxis;
import org.openpnp.machine.reference.axis.ReferenceCamCounterClockwiseAxis;
import org.openpnp.machine.reference.axis.ReferenceControllerAxis;
import org.openpnp.machine.reference.axis.ReferenceLinearTransformAxis;
import org.openpnp.machine.reference.axis.ReferenceMappedAxis;
import org.openpnp.machine.reference.axis.wizards.ReferenceLinearTransformAxisConfigurationWizard;
import org.openpnp.machine.reference.camera.ImageCamera;
import org.openpnp.machine.reference.camera.OnvifIPCamera;
import org.openpnp.machine.reference.camera.OpenCvCamera;
Expand All @@ -52,9 +50,9 @@
import org.openpnp.machine.reference.feeder.BlindsFeeder;
import org.openpnp.machine.reference.feeder.ReferenceAutoFeeder;
import org.openpnp.machine.reference.feeder.ReferenceDragFeeder;
import org.openpnp.machine.reference.feeder.ReferencePushPullFeeder;
import org.openpnp.machine.reference.feeder.ReferenceLeverFeeder;
import org.openpnp.machine.reference.feeder.ReferenceLoosePartFeeder;
import org.openpnp.machine.reference.feeder.ReferencePushPullFeeder;
import org.openpnp.machine.reference.feeder.ReferenceRotatedTrayFeeder;
import org.openpnp.machine.reference.feeder.ReferenceSlotAutoFeeder;
import org.openpnp.machine.reference.feeder.ReferenceStripFeeder;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/openpnp/model/AxesLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -166,4 +167,22 @@ public boolean contains(Axis axis) {
}
return (location.containsKey(axis));
}

@Override
public String toString() {
StringBuilder str = new StringBuilder();
str.append("(");
int i = 0;
for (Entry<Axis, Double> entry : location.entrySet()) {
if (i++ > 0) {
str.append(", ");
}
str.append(entry.getKey().getName());
str.append(":");
str.append(String.format(Locale.US, "%f", entry.getValue()));
}
str.append(")");
return str.toString();
}

}
1 change: 0 additions & 1 deletion src/main/java/org/openpnp/spi/base/AbstractCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.openpnp.ConfigurationListener;
import org.openpnp.gui.MainFrame;
import org.openpnp.gui.support.Icons;
import org.openpnp.model.AbstractModelObject;
import org.openpnp.model.Configuration;
import org.openpnp.model.LengthUnit;
import org.openpnp.model.Location;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/openpnp/spi/base/AbstractHeadMountable.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public Length getEffectiveSafeZ() {
@Override
public void moveTo(Location location, double speed, MoveToOption... options) throws Exception {
Logger.debug("{}.moveTo({}, {})", getName(), location, speed);
location = toHeadLocation(location, getLocation());
getHead().moveTo(this, location, getHead().getMaxPartSpeed() * speed, options);
Location headLocation = toHeadLocation(location, getLocation());
getHead().moveTo(this, headLocation, getHead().getMaxPartSpeed() * speed, options);
}

@Override
Expand Down Expand Up @@ -240,7 +240,7 @@ public AxesLocation toRaw(Location location, LocationOption... options)

@Override
public Location getLocation() {
MappedAxes mappedAxes = getMappedAxes(getHead().getMachine());
MappedAxes mappedAxes = getMappedAxes(Configuration.get().getMachine());
Location location = toTransformed(mappedAxes.getLocation());
// From head to HeadMountable.
return toHeadMountableLocation(location);
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/BasicJobTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testSimpleJob() throws Exception {
Nozzle n2 = h1.getNozzle("N2");
Camera c1 = h1.getCamera("C1");

delegate.expectMove("Move N1 Nozzle Change Unload", n1,
delegate.expectMove("Move N1 Nozzle Change Load", n1,
new Location(LengthUnit.Millimeters, 40, 0, 0, 0), 1.0);
delegate.expectMove("Move N2 Nozzle Change Load", n2,
new Location(LengthUnit.Millimeters, 50, 0, 0, 0), 1.0);
Expand Down Expand Up @@ -220,8 +220,8 @@ class ExpectedMove extends ExpectedOp {
public ExpectedMove(String description, HeadMountable headMountable, Location location,
double speed) throws Exception {
this.headMountable = headMountable;
// The expected location is in raw coordinates.
location = headMountable.toHeadLocation(location);
// The expected location must be converted into raw coordinates but it is already a head location.
// DO NOT DO THIS: Location headLocation = headMountable.toHeadLocation(location);
this.location = headMountable.toRaw(location);
this.speed = speed;
this.description = description;
Expand Down

0 comments on commit 3e72d57

Please sign in to comment.