Commit 40645fb8 authored by Andrey Filippov's avatar Andrey Filippov

Adding garbage collection before each goniometer scan step

parent cf2efd71
...@@ -251,43 +251,45 @@ horizontal axis: ...@@ -251,43 +251,45 @@ horizontal axis:
} }
startAxial=startStep-this.lastScanStep; startAxial=startStep-this.lastScanStep;
this.lastScanStep=startStep-1; this.lastScanStep=startStep-1;
Runtime runtime = Runtime.getRuntime();
for (int nTilt=startTilt;nTilt<numTiltSteps;nTilt++){ for (int nTilt=startTilt;nTilt<numTiltSteps;nTilt++){
double tilt=tilts[nTilt]; double tilt=tilts[nTilt];
tilt=0.1*Math.round(10*tilt); // is that needed? tilt=0.1*Math.round(10*tilt); // is that needed?
int tiltMotorPosition= (int) Math.round(tilt*this.goniometerParameters.goniometerMotors.stepsPerDegreeTilt); int tiltMotorPosition= (int) Math.round(tilt*this.goniometerParameters.goniometerMotors.stepsPerDegreeTilt);
status=IJ.d2s(1E-9*(System.nanoTime()-startTime),3)+": Tilt run "+(nTilt+1)+" (of "+numTiltSteps+"), tilt angle "+ status=IJ.d2s(1E-9*(System.nanoTime()-startTime),3)+": Tilt run "+(nTilt+1)+" (of "+numTiltSteps+"), tilt angle "+
IJ.d2s(tilt,2)+" degrees, motor steps: "+tiltMotorPosition; IJ.d2s(tilt,2)+" degrees, motor steps: "+tiltMotorPosition;
if (this.debugLevel>0) System.out.println(status); if (this.debugLevel>0) System.out.println(status);
if (updateStatus) IJ.showStatus(status); if (updateStatus) IJ.showStatus(status);
this.goniometerParameters.motorsSimultaneous=false; // not yet implemented this.goniometerParameters.motorsSimultaneous=false; // not yet implemented
// if (!this.goniometerParameters.motorsSimultaneous){ // if (!this.goniometerParameters.motorsSimultaneous){
OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(tiltMotor, tiltMotorPosition); OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(tiltMotor, tiltMotorPosition);
if (!OK) { if (!OK) {
String msg="Could not set motor "+(tiltMotor+1)+" to move to "+tiltMotorPosition+" - may be out of limit"; String msg="Could not set motor "+(tiltMotor+1)+" to move to "+tiltMotorPosition+" - may be out of limit";
System.out.println("Error: "+msg); System.out.println("Error: "+msg);
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
return false; return false;
} }
OK=this.goniometerParameters.goniometerMotors.waitMotor(tiltMotor); OK=this.goniometerParameters.goniometerMotors.waitMotor(tiltMotor);
if (!OK) { if (!OK) {
String msg="Motor "+(tiltMotor+1)+" failed to reach "+tiltMotorPosition+"."; String msg="Motor "+(tiltMotor+1)+" failed to reach "+tiltMotorPosition+".";
System.out.println("Error: "+msg); System.out.println("Error: "+msg);
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
return false; return false;
} }
// } // }
for (int nAxial=((nTilt==startTilt)?startAxial:0);nAxial<rots[nTilt].length;nAxial++){ for (int nAxial=((nTilt==startTilt)?startAxial:0);nAxial<rots[nTilt].length;nAxial++){
double axial=rots[nTilt][nAxial]; double axial=rots[nTilt][nAxial];
axial=0.1*Math.round(10*axial); axial=0.1*Math.round(10*axial);
int axialMotorPosition= (int) Math.round(axial*this.goniometerParameters.goniometerMotors.stepsPerDegreeAxial); int axialMotorPosition= (int) Math.round(axial*this.goniometerParameters.goniometerMotors.stepsPerDegreeAxial);
status=(this.lastScanStep+1)+"( last="+(numStops-1)+") "+IJ.d2s(1E-9*(System.nanoTime()-startTime),3)+" sec. tilt:"+(nTilt+1)+"/"+numTiltSteps+" , "+ status=(this.lastScanStep+1)+"( last="+(numStops-1)+") "+IJ.d2s(1E-9*(System.nanoTime()-startTime),3)+" sec. tilt:"+(nTilt+1)+"/"+numTiltSteps+" , "+
IJ.d2s(tilt,2)+" deg., axial:"+ IJ.d2s(tilt,2)+" deg., axial:"+
(nAxial+1)+"/"+rots[nTilt].length+" , "+IJ.d2s(axial,2)+" deg."; (nAxial+1)+"/"+rots[nTilt].length+" , "+IJ.d2s(axial,2)+" deg.";
if (this.debugLevel>0) System.out.println(status+", axial motor steps: "+axialMotorPosition); runtime.gc();
String memoryStatus="Free memory="+runtime.freeMemory()+" (of "+runtime.totalMemory()+")";
if (this.debugLevel>0) System.out.println(status+", axial motor steps: "+axialMotorPosition+" "+memoryStatus);
if (updateStatus) IJ.showStatus(status); if (updateStatus) IJ.showStatus(status);
OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(axialMotor, axialMotorPosition); OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(axialMotor, axialMotorPosition);
if (!OK) { if (!OK) {
String msg="Could not set motor "+(axialMotor+1)+" to move to "+axialMotorPosition+" - may be out of limit"; String msg="Could not set motor "+(axialMotor+1)+" to move to "+axialMotorPosition+" - may be out of limit";
...@@ -302,8 +304,8 @@ horizontal axis: ...@@ -302,8 +304,8 @@ horizontal axis:
IJ.showMessage("Error",msg); IJ.showMessage("Error",msg);
return false; return false;
} }
// update motor positions in the image properties, acquire and save images. // update motor positions in the image properties, acquire and save images.
// TODO: Make acquisition/decoding/laser identification multi-threaded // TODO: Make acquisition/decoding/laser identification multi-threaded
this.cameras.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions()); // Used target, not current to prevent minor variations this.cameras.setMotorsPosition(this.goniometerParameters.goniometerMotors.getTargetPositions()); // Used target, not current to prevent minor variations
this.cameras.reportTiming=debugTiming; this.cameras.reportTiming=debugTiming;
...@@ -327,12 +329,12 @@ horizontal axis: ...@@ -327,12 +329,12 @@ horizontal axis:
0, //tiltMotorPosition, 0, //tiltMotorPosition,
0, //axialMotorPosition, 0, //axialMotorPosition,
updateStatus); updateStatus);
return false; return false;
} }
} }
} }
} }
OK=motorsMove( OK=motorsMove(
tiltMotor, tiltMotor,
...@@ -343,7 +345,7 @@ horizontal axis: ...@@ -343,7 +345,7 @@ horizontal axis:
if (this.debugLevel>0) System.out.println("Scan finished in "+IJ.d2s(1E-9*(System.nanoTime()-startTime),3)+" seconds."); if (this.debugLevel>0) System.out.println("Scan finished in "+IJ.d2s(1E-9*(System.nanoTime()-startTime),3)+" seconds.");
return OK; return OK;
} }
public boolean motorsMove( public boolean motorsMove(
int tiltMotor, int tiltMotor,
......
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