Commit d2be09fb authored by Andrey Filippov's avatar Andrey Filippov
Browse files

optimizing goniometer moves

parent f54815de
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2610,6 +2610,15 @@ public class CalibrationHardwareInterface {
			return true;
        }
        
        public boolean [] checkGotTarget(){
    		updateMotorsPosition(0); // no wait here
    		boolean [] result=new boolean [this.curpos.length];
    		for (int motorNumber=0;motorNumber<result.length;motorNumber++){
    			result[motorNumber]=Math.abs(this.targetPosition[motorNumber]-this.curpos[motorNumber])<this.motorTolerance;
    		}
    		return result;
        }

        public boolean waitMotor(
        		int motorNumber,
        		AtomicInteger stopRequested, // or null
+11 −4
Original line number Diff line number Diff line
@@ -475,7 +475,9 @@ horizontal axis:
			int axialMotorPosition,
			AtomicInteger stopRequested, // or null
			boolean updateStatus){
		String status="Moving axial motor to "+axialMotorPosition+"...";
		String status;
		if (!this.goniometerParameters.goniometerMotors.checkGotTarget()[axialMotor]) {
			status="Moving axial motor to "+axialMotorPosition+"...";
			if (updateStatus) IJ.showStatus(status);
			boolean OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(axialMotor, axialMotorPosition);
			if (!OK) {
@@ -491,7 +493,11 @@ horizontal axis:
				IJ.showMessage("Error",msg);
				return false;
			}
			OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(tiltMotor, tiltMotorPosition);
		}
		if (!this.goniometerParameters.goniometerMotors.checkGotTarget()[tiltMotor]) {
			status="Moving tilt motor to "+tiltMotorPosition+"...";
			if (updateStatus) IJ.showStatus(status);
			boolean OK= this.goniometerParameters.goniometerMotors.moveMotorSetETA(tiltMotor, tiltMotorPosition);
			if (!OK) {
				String msg="Could not set motor "+(tiltMotor+1)+" to move to "+tiltMotorPosition+" - may be out of limit";
				System.out.println("Error: "+msg);
@@ -505,6 +511,7 @@ horizontal axis:
				IJ.showMessage("Error",msg);
				return false;
			}
		}
		return true;
	}