Skip to content

Commit

Permalink
Fix XY stage movement after homing
Browse files Browse the repository at this point in the history
Peter Gabriel Pitrone pointed out that after homing the 4D stage,
pressing the "+" button on the x position would reset the y position to
the one *before* homing.

The culprit is that redundant information is held in too many places
(here: the MM core *and* the GenericXYStage wrapper) and such
information is prone to become inconsistent, even for the best
programmers amongst us.

While the workaround introduced by this commit is far from perfect, it
allows Peter to use the software, at least, while HongKee is working on
cleaning up the software design.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed May 12, 2015
1 parent a190b1b commit 89ef59c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/java/spim/setup/GenericXYStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Device manufacture(CMMCore core, String label) {

public GenericXYStage() {
stageX = stageY = null;
destX = destY = 0;
destX = destY = -1;
}

public class SubStage extends Stage {
Expand All @@ -47,20 +47,17 @@ public SubStage(CMMCore core, String label, boolean isX) {
super(core, label);

iAmX = isX;

if (isX)
GenericXYStage.this.destX = getPosition();
else
GenericXYStage.this.destY = getPosition();
}

@Override
public void setPosition(double pos) {
try {
if (iAmX) {
if (destY < 0) destY = core.getYPosition(label);
core.setXYPosition(label, pos, GenericXYStage.this.destY);
GenericXYStage.this.destX = pos;
} else {
if (destX < 0) destX = core.getXPosition(label);
core.setXYPosition(label, GenericXYStage.this.destX, pos);
GenericXYStage.this.destY = pos;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/spim/setup/PicardXYStage.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public void setVelocity(double velocity) throws IllegalArgumentException {
public void home() {
try {
core.home(label);
if (iAmX)
destX = -1;
else
destY = -1;
} catch (Exception e) {
ReportingUtils.logError(e, "Could not home X/Y stage.");
}
Expand Down

0 comments on commit 89ef59c

Please sign in to comment.