Commit e4ac0da9 authored by Andrey Filippov's avatar Andrey Filippov

more on adjustment

parent 2ed1f2f7
...@@ -4388,6 +4388,7 @@ if (MORE_BUTTONS) { ...@@ -4388,6 +4388,7 @@ if (MORE_BUTTONS) {
"",//); //String defaultPath); // AtomicInteger stopRequested "",//); //String defaultPath); // AtomicInteger stopRequested
this.SYNC_COMMAND.stopRequested); this.SYNC_COMMAND.stopRequested);
FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL); FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL);
FOCUSING_FIELD.setAdjustMode(false);
if (PROPERTIES!=null) FOCUSING_FIELD.getProperties("FOCUSING_FIELD.", PROPERTIES); if (PROPERTIES!=null) FOCUSING_FIELD.getProperties("FOCUSING_FIELD.", PROPERTIES);
System.out.println("Loaded FocusingField"); System.out.println("Loaded FocusingField");
if (!FOCUSING_FIELD.configureDataVector("Configure curvature - TODO: fix many settings restored from properties",true,true)) return; if (!FOCUSING_FIELD.configureDataVector("Configure curvature - TODO: fix many settings restored from properties",true,true)) return;
...@@ -4415,6 +4416,7 @@ if (MORE_BUTTONS) { ...@@ -4415,6 +4416,7 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (FOCUSING_FIELD==null) return; if (FOCUSING_FIELD==null) return;
FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL); FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL);
FOCUSING_FIELD.setAdjustMode(false);
if (!FOCUSING_FIELD.configureDataVector("Re-configure curvature parameters",false,true)) return; if (!FOCUSING_FIELD.configureDataVector("Re-configure curvature parameters",false,true)) return;
FOCUSING_FIELD.setDataVector( FOCUSING_FIELD.setDataVector(
true, // calibrate mode true, // calibrate mode
...@@ -4454,10 +4456,11 @@ if (MORE_BUTTONS) { ...@@ -4454,10 +4456,11 @@ if (MORE_BUTTONS) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL; DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
if (FOCUSING_FIELD==null) return; if (FOCUSING_FIELD==null) return;
FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL); FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL);
FOCUSING_FIELD.setAdjustMode(false);
FOCUSING_FIELD.LevenbergMarquardt( FOCUSING_FIELD.LevenbergMarquardt(
null, // measurement null, // measurement
true, // open dialog true, // open dialog
false, // filterZ // false, // filterZ
DEBUG_LEVEL); //boolean openDialog, int debugLevel){ DEBUG_LEVEL); //boolean openDialog, int debugLevel){
return; return;
} }
...@@ -9719,7 +9722,44 @@ if (MORE_BUTTONS) { ...@@ -9719,7 +9722,44 @@ if (MORE_BUTTONS) {
} }
if (!allOK) break; // failed if (!allOK) break; // failed
} }
if (focusMeasurementParameters.scanTiltReverse) {
if (debugLevel>0) System.out.println("Starting reverse scanning tilt in X direction, number of stops="+ focusMeasurementParameters.scanTiltStepsX+
", step size="+IJ.d2s(scanStepX,0));
for (int numStep=0;numStep<focusMeasurementParameters.scanTiltStepsX;numStep++){
int delta=(int) Math.round(focusMeasurementParameters.scanTiltRangeX*
(1.0*numStep/(focusMeasurementParameters.scanTiltStepsX-1) -0.5));
scanPos[0]=centerMotorPos[0]+delta;
scanPos[1]=centerMotorPos[1]+delta;
scanPos[2]=centerMotorPos[2]-delta;
if (debugLevel>0) System.out.println("Reverse scanning tilt in X direction, step#"+(numStep+1)+" (of "+
focusMeasurementParameters.scanTiltStepsX+") at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
allOK &=moveAndMaybeProbe(
true,
scanPos, // null OK
focusingMotors,
camerasInterface,
lensDistortionParameters,
matchSimulatedPattern, // should not bee null
focusMeasurementParameters,
patternDetectParameters,
distortionParameters,
simulParameters,
colorComponents,
otfFilterParameters,
psfParameters,
threadsMax,
updateStatus,
debugLevel,
loopDebugLevel);
if (this.SYNC_COMMAND.stopRequested.get()>0){
aborted=true;
allOK=false;
System.out.println("Stop requested, command aborted, returning motors to initial position");
break;
}
if (!allOK) break; // failed
}
}
} }
if (allOK && (focusMeasurementParameters.scanTiltStepsY >1 )) { // 0 or 1 STOPS - do not scan if (allOK && (focusMeasurementParameters.scanTiltStepsY >1 )) { // 0 or 1 STOPS - do not scan
double scanStepY=1.0*focusMeasurementParameters.scanTiltRangeY/(focusMeasurementParameters.scanTiltStepsY-1); double scanStepY=1.0*focusMeasurementParameters.scanTiltRangeY/(focusMeasurementParameters.scanTiltStepsY-1);
...@@ -9759,9 +9799,45 @@ if (MORE_BUTTONS) { ...@@ -9759,9 +9799,45 @@ if (MORE_BUTTONS) {
} }
if (!allOK) break; // failed if (!allOK) break; // failed
} }
if (focusMeasurementParameters.scanTiltReverse) {
if (debugLevel>0) System.out.println("Starting reverse scanning tilt in Y direction, number of stops="+ focusMeasurementParameters.scanTiltStepsY+
", step size="+IJ.d2s(scanStepY,0));
for (int numStep=0;numStep<focusMeasurementParameters.scanTiltStepsY;numStep++){
int delta=(int) Math.round(focusMeasurementParameters.scanTiltRangeY*
(1.0*numStep/(focusMeasurementParameters.scanTiltStepsY-1) -0.5));
scanPos[0]=centerMotorPos[0]+delta;
scanPos[1]=centerMotorPos[1]-delta;
scanPos[2]=centerMotorPos[2]+0;
if (debugLevel>0) System.out.println("Reverse scanning tilt in Y direction, step#"+(numStep+1)+" (of "+
focusMeasurementParameters.scanTiltStepsY+") at "+ IJ.d2s(0.000000001*(System.nanoTime()-startTime),3));
allOK &=moveAndMaybeProbe(
true,
scanPos, // null OK
focusingMotors,
camerasInterface,
lensDistortionParameters,
matchSimulatedPattern, // should not bee null
focusMeasurementParameters,
patternDetectParameters,
distortionParameters,
simulParameters,
colorComponents,
otfFilterParameters,
psfParameters,
threadsMax,
updateStatus,
debugLevel,
loopDebugLevel);
if (this.SYNC_COMMAND.stopRequested.get()>0){
aborted=true;
allOK=false;
System.out.println("Stop requested, command aborted, returning motors to initial position");
break;
}
if (!allOK) break; // failed
}
}
} }
} }
if (allOK && focusMeasurementParameters.scanHysteresis && (scanPosLast!=null)){ if (allOK && focusMeasurementParameters.scanHysteresis && (scanPosLast!=null)){
......
This diff is collapsed.
...@@ -304,6 +304,7 @@ public class LensAdjustment { ...@@ -304,6 +304,7 @@ public class LensAdjustment {
public int scanHysteresisNumber=5; // number of test points for the Hysteresis measurement public int scanHysteresisNumber=5; // number of test points for the Hysteresis measurement
public boolean scanTiltEnable=true; // enable scanning tilt public boolean scanTiltEnable=true; // enable scanning tilt
public boolean scanTiltReverse=false; // enable scanning tilt in both directions
public int scanTiltRangeX=14336; // 4 periods public int scanTiltRangeX=14336; // 4 periods
public int scanTiltRangeY=14336; // 4 periods public int scanTiltRangeY=14336; // 4 periods
public int scanTiltStepsX=24; public int scanTiltStepsX=24;
...@@ -518,6 +519,7 @@ public class LensAdjustment { ...@@ -518,6 +519,7 @@ public class LensAdjustment {
int scanHysteresisNumber, // number of test points for the Hysteresis measurement int scanHysteresisNumber, // number of test points for the Hysteresis measurement
boolean scanTiltEnable, //=true; // enable scanning tilt boolean scanTiltEnable, //=true; // enable scanning tilt
boolean scanTiltReverse,
int scanTiltRangeX, //=14336; // 4 periods int scanTiltRangeX, //=14336; // 4 periods
int scanTiltRangeY, //=14336; // 4 periods int scanTiltRangeY, //=14336; // 4 periods
int scanTiltStepsX, //=24; int scanTiltStepsX, //=24;
...@@ -660,6 +662,7 @@ public class LensAdjustment { ...@@ -660,6 +662,7 @@ public class LensAdjustment {
this.scanHysteresisNumber=scanHysteresisNumber; // number of test points for the Hysteresis measurement this.scanHysteresisNumber=scanHysteresisNumber; // number of test points for the Hysteresis measurement
this.scanTiltEnable=scanTiltEnable; //=true; // enable scanning tilt this.scanTiltEnable=scanTiltEnable; //=true; // enable scanning tilt
this.scanTiltReverse=scanTiltReverse;
this.scanTiltRangeX=scanTiltRangeX; //, //=14336; // 4 periods this.scanTiltRangeX=scanTiltRangeX; //, //=14336; // 4 periods
this.scanTiltRangeY=scanTiltRangeY; //, //=14336; // 4 periods this.scanTiltRangeY=scanTiltRangeY; //, //=14336; // 4 periods
this.scanTiltStepsX=scanTiltStepsX; //=24; this.scanTiltStepsX=scanTiltStepsX; //=24;
...@@ -803,6 +806,7 @@ public class LensAdjustment { ...@@ -803,6 +806,7 @@ public class LensAdjustment {
this.scanHysteresisNumber, // number of test points for the Hysteresis measurement this.scanHysteresisNumber, // number of test points for the Hysteresis measurement
this.scanTiltEnable, // enable scanning tilt this.scanTiltEnable, // enable scanning tilt
this.scanTiltReverse,
this.scanTiltRangeX, // 4 periods this.scanTiltRangeX, // 4 periods
this.scanTiltRangeY, // 4 periods this.scanTiltRangeY, // 4 periods
this.scanTiltStepsX, this.scanTiltStepsX,
...@@ -953,6 +957,8 @@ public class LensAdjustment { ...@@ -953,6 +957,8 @@ public class LensAdjustment {
properties.setProperty(prefix+"scanHysteresisNumber",this.scanHysteresisNumber+""); properties.setProperty(prefix+"scanHysteresisNumber",this.scanHysteresisNumber+"");
properties.setProperty(prefix+"scanTiltEnable",this.scanTiltEnable+""); // enable scanning tilt properties.setProperty(prefix+"scanTiltEnable",this.scanTiltEnable+""); // enable scanning tilt
properties.setProperty(prefix+"scanTiltReverse",this.scanTiltReverse+"");
properties.setProperty(prefix+"scanTiltRangeX",this.scanTiltRangeX+""); // 4 periods properties.setProperty(prefix+"scanTiltRangeX",this.scanTiltRangeX+""); // 4 periods
properties.setProperty(prefix+"scanTiltRangeY",this.scanTiltRangeY+""); // 4 periods properties.setProperty(prefix+"scanTiltRangeY",this.scanTiltRangeY+""); // 4 periods
properties.setProperty(prefix+"scanTiltStepsX",this.scanTiltStepsX+""); properties.setProperty(prefix+"scanTiltStepsX",this.scanTiltStepsX+"");
...@@ -1207,6 +1213,10 @@ public class LensAdjustment { ...@@ -1207,6 +1213,10 @@ public class LensAdjustment {
if (properties.getProperty(prefix+"scanTiltEnable")!=null) if (properties.getProperty(prefix+"scanTiltEnable")!=null)
this.scanTiltEnable=Boolean.parseBoolean(properties.getProperty(prefix+"scanTiltEnable")); this.scanTiltEnable=Boolean.parseBoolean(properties.getProperty(prefix+"scanTiltEnable"));
if (properties.getProperty(prefix+"scanTiltReverse")!=null)
this.scanTiltReverse=Boolean.parseBoolean(properties.getProperty(prefix+"scanTiltReverse"));
if (properties.getProperty(prefix+"scanTiltRangeX")!=null) if (properties.getProperty(prefix+"scanTiltRangeX")!=null)
this.scanTiltRangeX=Integer.parseInt(properties.getProperty(prefix+"scanTiltRangeX")); this.scanTiltRangeX=Integer.parseInt(properties.getProperty(prefix+"scanTiltRangeX"));
if (properties.getProperty(prefix+"scanTiltRangeY")!=null) if (properties.getProperty(prefix+"scanTiltRangeY")!=null)
...@@ -1353,6 +1363,9 @@ public class LensAdjustment { ...@@ -1353,6 +1363,9 @@ public class LensAdjustment {
gd.addNumericField("Number of scan steps during hysteresis (play) measurement", this.scanHysteresisNumber, 0); gd.addNumericField("Number of scan steps during hysteresis (play) measurement", this.scanHysteresisNumber, 0);
gd.addCheckbox ("Scan for tilt measurement (approximately preserving center)", this.scanTiltEnable); gd.addCheckbox ("Scan for tilt measurement (approximately preserving center)", this.scanTiltEnable);
gd.addCheckbox ("Scan for tilt measurement in both directions", this.scanTiltReverse);
gd.addNumericField("Full range of scanning motors tilting in X-direction", this.scanTiltRangeX, 0,7,"motors steps"); gd.addNumericField("Full range of scanning motors tilting in X-direction", this.scanTiltRangeX, 0,7,"motors steps");
gd.addNumericField("Full range of scanning motors tilting in Y-direction", this.scanTiltRangeY, 0,7,"motors steps"); gd.addNumericField("Full range of scanning motors tilting in Y-direction", this.scanTiltRangeY, 0,7,"motors steps");
gd.addNumericField("Number of stops measurements when tilting in X-deirection", this.scanTiltStepsX, 0); gd.addNumericField("Number of stops measurements when tilting in X-deirection", this.scanTiltStepsX, 0);
...@@ -1372,6 +1385,7 @@ public class LensAdjustment { ...@@ -1372,6 +1385,7 @@ public class LensAdjustment {
this.scanHysteresisNumber= (int) gd.getNextNumber(); this.scanHysteresisNumber= (int) gd.getNextNumber();
this.scanTiltEnable= gd.getNextBoolean(); this.scanTiltEnable= gd.getNextBoolean();
this.scanTiltReverse= gd.getNextBoolean();
this.scanTiltRangeX= (int) gd.getNextNumber(); this.scanTiltRangeX= (int) gd.getNextNumber();
this.scanTiltRangeY= (int) gd.getNextNumber(); this.scanTiltRangeY= (int) gd.getNextNumber();
this.scanTiltStepsX= (int) gd.getNextNumber(); this.scanTiltStepsX= (int) gd.getNextNumber();
...@@ -1503,6 +1517,8 @@ public class LensAdjustment { ...@@ -1503,6 +1517,8 @@ public class LensAdjustment {
gd.addNumericField("Number of scan steps during hysteresis (play) measurement", this.scanHysteresisNumber, 0); gd.addNumericField("Number of scan steps during hysteresis (play) measurement", this.scanHysteresisNumber, 0);
gd.addCheckbox ("Scan for tilt measurement (approximately preserving center)", this.scanTiltEnable); gd.addCheckbox ("Scan for tilt measurement (approximately preserving center)", this.scanTiltEnable);
gd.addCheckbox ("Scan for tilt measurement in both directions", this.scanTiltReverse);
gd.addNumericField("Full range of scanning motors tilting in X-direction", this.scanTiltRangeX, 0,7,"motors steps"); gd.addNumericField("Full range of scanning motors tilting in X-direction", this.scanTiltRangeX, 0,7,"motors steps");
gd.addNumericField("Full range of scanning motors tilting in Y-direction", this.scanTiltRangeY, 0,7,"motors steps"); gd.addNumericField("Full range of scanning motors tilting in Y-direction", this.scanTiltRangeY, 0,7,"motors steps");
gd.addNumericField("Number of stops measurements when tilting in X-deirection", this.scanTiltStepsX, 0); gd.addNumericField("Number of stops measurements when tilting in X-deirection", this.scanTiltStepsX, 0);
...@@ -1667,6 +1683,7 @@ public class LensAdjustment { ...@@ -1667,6 +1683,7 @@ public class LensAdjustment {
this.scanHysteresisNumber= (int) gd.getNextNumber(); this.scanHysteresisNumber= (int) gd.getNextNumber();
this.scanTiltEnable= gd.getNextBoolean(); this.scanTiltEnable= gd.getNextBoolean();
this.scanTiltReverse= gd.getNextBoolean();
this.scanTiltRangeX= (int) gd.getNextNumber(); this.scanTiltRangeX= (int) gd.getNextNumber();
this.scanTiltRangeY= (int) gd.getNextNumber(); this.scanTiltRangeY= (int) gd.getNextNumber();
this.scanTiltStepsX= (int) gd.getNextNumber(); this.scanTiltStepsX= (int) gd.getNextNumber();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment