Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
447a735d
Commit
447a735d
authored
Sep 24, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding heater/fan control for thermal focal distance measurements
parent
d3195f8c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
242 additions
and
23 deletions
+242
-23
Aberration_Calibration.java
src/main/java/Aberration_Calibration.java
+95
-14
CalibrationHardwareInterface.java
src/main/java/CalibrationHardwareInterface.java
+91
-4
LensAdjustment.java
src/main/java/LensAdjustment.java
+56
-5
No files found.
src/main/java/Aberration_Calibration.java
View file @
447a735d
...
@@ -519,6 +519,7 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
...
@@ -519,6 +519,7 @@ public static MatchSimulatedPattern.DistortionParameters DISTORTION =new MatchSi
public float [][] SIM_ARRAY=null; // first index - 0 - main, 1 - shifted by 0.5 pixel diagonally (to extract checker greens)
public float [][] SIM_ARRAY=null; // first index - 0 - main, 1 - shifted by 0.5 pixel diagonally (to extract checker greens)
public static CalibrationHardwareInterface.LaserPointers LASERS=new CalibrationHardwareInterface.LaserPointers(LASER_POINTERS);
public static CalibrationHardwareInterface.LaserPointers LASERS=new CalibrationHardwareInterface.LaserPointers(LASER_POINTERS);
public static CalibrationHardwareInterface.PowerControl POWER_CONTROL=new CalibrationHardwareInterface.PowerControl();
public static CalibrationHardwareInterface.CamerasInterface CAMERAS=new CalibrationHardwareInterface.CamerasInterface(26,LASERS);
public static CalibrationHardwareInterface.CamerasInterface CAMERAS=new CalibrationHardwareInterface.CamerasInterface(26,LASERS);
public static CalibrationHardwareInterface.FocusingMotors MOTORS=new CalibrationHardwareInterface.FocusingMotors();
public static CalibrationHardwareInterface.FocusingMotors MOTORS=new CalibrationHardwareInterface.FocusingMotors();
...
@@ -781,6 +782,7 @@ if (MORE_BUTTONS) {
...
@@ -781,6 +782,7 @@ if (MORE_BUTTONS) {
addButton("Auto Focus/Tilt",panelFocusing,color_process);
addButton("Auto Focus/Tilt",panelFocusing,color_process);
// addButton("List Pre-focus",panelFocusing);
// addButton("List Pre-focus",panelFocusing);
addButton("Focus Average",panelFocusing,color_report);
addButton("Focus Average",panelFocusing,color_report);
addButton("Power Control",panelFocusing,color_configure);
addButton("Temp. Scan",panelFocusing,color_process);
addButton("Temp. Scan",panelFocusing,color_process);
//
//
addButton("List History",panelFocusing,color_report);
addButton("List History",panelFocusing,color_report);
...
@@ -3766,6 +3768,7 @@ if (MORE_BUTTONS) {
...
@@ -3766,6 +3768,7 @@ if (MORE_BUTTONS) {
// Use rotation from head lasers
// Use rotation from head lasers
if (FOCUS_MEASUREMENT_PARAMETERS.useHeadLasers){
if (FOCUS_MEASUREMENT_PARAMETERS.useHeadLasers){
psi=-headPointersTilt; // "-" - correction, instead of the target tilt
psi=-headPointersTilt; // "-" - correction, instead of the target tilt
FOCUS_MEASUREMENT_PARAMETERS.result_PSI=psi; // Was not here, using relative to the pattern (w/o head lasers)
}
}
double diffY=12*Math.sin(Math.PI/180.0*psi);
double diffY=12*Math.sin(Math.PI/180.0*psi);
...
@@ -5069,7 +5072,8 @@ if (MORE_BUTTONS) {
...
@@ -5069,7 +5072,8 @@ if (MORE_BUTTONS) {
Matcher matcher=fileNameFormat.matcher(fileList[i].getName());
Matcher matcher=fileNameFormat.matcher(fileList[i].getName());
if (matcher.find()){
if (matcher.find()){
if ((matcher.group(1)!=null) && multiLensPerSFE) lens= Integer.parseInt(matcher.group(1));
if ((matcher.group(1)!=null) && multiLensPerSFE) lens= Integer.parseInt(matcher.group(1));
if ((matcher.group(2)!=null) && stageResults && multiLensPerSFE) manState=Integer.parseInt(matcher.group(2));
// if ((matcher.group(2)!=null) && stageResults && multiLensPerSFE) manState=Integer.parseInt(matcher.group(2));
if ((matcher.group(2)!=null) && stageResults) manState=Integer.parseInt(matcher.group(2));
} else {
} else {
matcher=fileNameFormat0.matcher(fileList[i].getName());
matcher=fileNameFormat0.matcher(fileList[i].getName());
if (matcher.find()){
if (matcher.find()){
...
@@ -5085,6 +5089,7 @@ if (MORE_BUTTONS) {
...
@@ -5085,6 +5089,7 @@ if (MORE_BUTTONS) {
ts=Double.parseDouble(sts);
ts=Double.parseDouble(sts);
} else {
} else {
System.out.println("Failed to find timestamp in "+fileList[i].getName()+", lens="+lens+" manState="+manState);
System.out.println("Failed to find timestamp in "+fileList[i].getName()+", lens="+lens+" manState="+manState);
continue;
}
}
if (DEBUG_LEVEL>1){
if (DEBUG_LEVEL>1){
System.out.println (i+": "+fileList[i].getName()+ " lens="+lens+" manState="+manState+" timestamp="+ts);
System.out.println (i+": "+fileList[i].getName()+ " lens="+lens+" manState="+manState+" timestamp="+ts);
...
@@ -5187,8 +5192,8 @@ if (MORE_BUTTONS) {
...
@@ -5187,8 +5192,8 @@ if (MORE_BUTTONS) {
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_B50,3));
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_B50,3));
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_RC50,3));
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_RC50,3));
// if (iState==0) { // to visually separate different lenses
// if (iState==0) { // to visually separate different lenses
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_PX0-0.5*sensorDimensions[iSFE][0],3));
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_PX0-0.5*sensorDimensions[iSFE][0]
-sfeParameters[iSFE][iLens][iState].centerDeltaX
,3));
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_PY0-0.5*sensorDimensions[iSFE][1],3));
sb.append("\t"+IJ.d2s(sfeParameters[iSFE][iLens][iState].result_PY0-0.5*sensorDimensions[iSFE][1]
-sfeParameters[iSFE][iLens][iState].centerDeltaY
,3));
// } else {
// } else {
// sb.append("\t\t");
// sb.append("\t\t");
// }
// }
...
@@ -5267,6 +5272,14 @@ if (MORE_BUTTONS) {
...
@@ -5267,6 +5272,14 @@ if (MORE_BUTTONS) {
DISTORTION.loop_debug_level);
DISTORTION.loop_debug_level);
return;
return;
}
}
/* ======================================================================== */
//"Power Control"
if (label.equals("Power Control")) {
DEBUG_LEVEL=MASTER_DEBUG_LEVEL;
POWER_CONTROL.setDebugLevel(DEBUG_LEVEL);
POWER_CONTROL.showDialog("Configure power control", true);
return;
}
/* ======================================================================== */
/* ======================================================================== */
if (label.equals("Temp. Scan") || label.equals("Focus Average")) {
if (label.equals("Temp. Scan") || label.equals("Focus Average")) {
checkSerialAndRestore(); // returns true if did not change or was restored
checkSerialAndRestore(); // returns true if did not change or was restored
...
@@ -5286,16 +5299,27 @@ if (MORE_BUTTONS) {
...
@@ -5286,16 +5299,27 @@ if (MORE_BUTTONS) {
gd.addMessage("Temperature has to be varied separately.");
gd.addMessage("Temperature has to be varied separately.");
gd.addMessage("Use \"List History\" to see the results.");
gd.addMessage("Use \"List History\" to see the results.");
gd.addCheckbox("Turn lasers off to protect from overheating",true);
gd.addCheckbox("Turn lasers off to protect from overheating",true);
if (!POWER_CONTROL.isPowerControlEnabled()){
gd.addMessage("Power control hardware is disabled, use \"Power Control\" command to enable it before proceeding");
}
}
}
gd.addCheckbox("Erase previous measurement history",modeAverage);
gd.addCheckbox("Erase previous measurement history",modeAverage);
gd.addCheckbox("Allow tilt scan when looking for the best fit",!noTiltScan);
gd.addCheckbox("Allow tilt scan when looking for the best fit",!noTiltScan);
gd.addCheckbox ("Use lens aberration model (if available) for focal distance and tilts", FOCUS_MEASUREMENT_PARAMETERS.useLMAMetrics);
gd.addCheckbox ("Use lens aberration model (if available) for focal distance and tilts", FOCUS_MEASUREMENT_PARAMETERS.useLMAMetrics);
// gd.addCheckbox("Use LMA calculations for focus/tilt",useLMA);
// gd.addCheckbox("Use LMA calculations for focus/tilt",useLMA);
double scanMinutes=modeAverage?2.0:30.0;
double scanMinutes=modeAverage?2.0:30.0;
if (modeAverage) {
gd.addNumericField("Measure for ", scanMinutes , 1,5," minutes");
gd.addNumericField("Measure for ", scanMinutes , 1,5," minutes");
} else {
gd.addCheckbox ("Enable power control for heater and fan", FOCUS_MEASUREMENT_PARAMETERS.powerControlEnable);
gd.addNumericField("Maximal allowed temperature", FOCUS_MEASUREMENT_PARAMETERS.powerControlMaximalTemperature, 3,5,"C");
gd.addNumericField("Heater ON time", FOCUS_MEASUREMENT_PARAMETERS.powerControlHeaterOnMinutes, 1,5,"min");
gd.addNumericField("Both heater and fan OFF time", FOCUS_MEASUREMENT_PARAMETERS.powerControlNeitherOnMinutes, 1,5,"min");
gd.addNumericField("Fan ON time", FOCUS_MEASUREMENT_PARAMETERS.powerControlFanOnMinutes, 1,5,"min");
}
gd.showDialog();
gd.showDialog();
if (gd.wasCanceled()) return;
if (gd.wasCanceled()) return;
if (!modeAverage && gd.getNextBoolean()){
if (!modeAverage && gd.getNextBoolean()){
// was only asked in thermal scan mode
UV_LED_LASERS.debugLevel=DEBUG_LEVEL;
UV_LED_LASERS.debugLevel=DEBUG_LEVEL;
UV_LED_LASERS.lasersOff(FOCUS_MEASUREMENT_PARAMETERS);
UV_LED_LASERS.lasersOff(FOCUS_MEASUREMENT_PARAMETERS);
if (MASTER_DEBUG_LEVEL>0) System.out.println ("Turned laser pointers off to protect from overheating");
if (MASTER_DEBUG_LEVEL>0) System.out.println ("Turned laser pointers off to protect from overheating");
...
@@ -5312,9 +5336,19 @@ if (MORE_BUTTONS) {
...
@@ -5312,9 +5336,19 @@ if (MORE_BUTTONS) {
FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL);
FOCUSING_FIELD.setDebugLevel(DEBUG_LEVEL);
}
}
boolean useLMA=FOCUS_MEASUREMENT_PARAMETERS.useLMAMetrics && (FOCUSING_FIELD!=null);
boolean useLMA=FOCUS_MEASUREMENT_PARAMETERS.useLMAMetrics && (FOCUSING_FIELD!=null);
if (modeAverage) {
// int startHistPos=MOTORS.historySize();
scanMinutes=gd.getNextNumber();
scanMinutes=gd.getNextNumber();
} else {
FOCUS_MEASUREMENT_PARAMETERS.powerControlEnable=gd.getNextBoolean();
FOCUS_MEASUREMENT_PARAMETERS.powerControlMaximalTemperature=gd.getNextNumber();
FOCUS_MEASUREMENT_PARAMETERS.powerControlHeaterOnMinutes=gd.getNextNumber();
FOCUS_MEASUREMENT_PARAMETERS.powerControlNeitherOnMinutes=gd.getNextNumber();
FOCUS_MEASUREMENT_PARAMETERS.powerControlFanOnMinutes=gd.getNextNumber();
scanMinutes=FOCUS_MEASUREMENT_PARAMETERS.powerControlMaximalTemperature+
FOCUS_MEASUREMENT_PARAMETERS.powerControlHeaterOnMinutes+
FOCUS_MEASUREMENT_PARAMETERS.powerControlNeitherOnMinutes+
FOCUS_MEASUREMENT_PARAMETERS.powerControlFanOnMinutes;
}
long startTime=System.nanoTime();
long startTime=System.nanoTime();
long endTime=startTime+(long) (6E10*scanMinutes);
long endTime=startTime+(long) (6E10*scanMinutes);
if (MASTER_DEBUG_LEVEL>0) System.out.println(" startTime= "+startTime+", endTime="+endTime);
if (MASTER_DEBUG_LEVEL>0) System.out.println(" startTime= "+startTime+", endTime="+endTime);
...
@@ -5342,6 +5376,13 @@ if (MORE_BUTTONS) {
...
@@ -5342,6 +5376,13 @@ if (MORE_BUTTONS) {
System.out.println("Optimal Ty="+FOCUSING_FIELD.qualBOptimizationResults[2]);
System.out.println("Optimal Ty="+FOCUSING_FIELD.qualBOptimizationResults[2]);
}
}
}
}
long stateEndTime=endTime;
if (!modeAverage) {
POWER_CONTROL.setPower("fan","off");
POWER_CONTROL.setPower("heater","on");
stateEndTime=startTime+(long) (6E10*FOCUS_MEASUREMENT_PARAMETERS.powerControlHeaterOnMinutes);
}
int scanState=(!modeAverage && FOCUS_MEASUREMENT_PARAMETERS.powerControlEnable)?1:-1;
while (System.nanoTime()<endTime){
while (System.nanoTime()<endTime){
moveAndMaybeProbe(
moveAndMaybeProbe(
true, // just move, not probe
true, // just move, not probe
...
@@ -5363,15 +5404,48 @@ if (MORE_BUTTONS) {
...
@@ -5363,15 +5404,48 @@ if (MORE_BUTTONS) {
MASTER_DEBUG_LEVEL,
MASTER_DEBUG_LEVEL,
DISTORTION.loop_debug_level);
DISTORTION.loop_debug_level);
runs++;
runs++;
long secondsLeft=(long) (0.000000001*(endTime-System.nanoTime()));
if (secondsLeft<0) secondsLeft=0;
if (MASTER_DEBUG_LEVEL>0) System.out.println(" Measured "+runs+", "+secondsLeft+" seconds left");
if (this.SYNC_COMMAND.stopRequested.get()>0) {
if (this.SYNC_COMMAND.stopRequested.get()>0) {
System.out.println("User requested stop");
System.out.println("User requested stop");
break;
break;
}
}
// Temperature within limits?
if (FOCUS_MEASUREMENT_PARAMETERS.sensorTemperature>=FOCUS_MEASUREMENT_PARAMETERS.powerControlMaximalTemperature){
POWER_CONTROL.setPower("heater","off");
}
// long secondsLeft=(long) (0.000000001*(endTime-System.nanoTime()));
long secondsLeft=(long) (0.000000001*(endTime-System.nanoTime()));
if (secondsLeft<0) secondsLeft=0;
long secondsLeftState=(long) (0.000000001*(stateEndTime-System.nanoTime()));
if (secondsLeftState<0) secondsLeftState=0;
if (MASTER_DEBUG_LEVEL>0) System.out.println(" Measured "+runs+", "+secondsLeftState+" seconds left ("+secondsLeft+")");
boolean timerOver=(System.nanoTime()>=stateEndTime) ||
((scanState==1) && (FOCUS_MEASUREMENT_PARAMETERS.sensorTemperature>=FOCUS_MEASUREMENT_PARAMETERS.powerControlMaximalTemperature));
if ((scanState>0) && timerOver) {
scanState++;
switch (scanState) {
case 2:
POWER_CONTROL.setPower("heater","off");
POWER_CONTROL.setPower("fan","off");
stateEndTime=System.nanoTime()+(long) (6E10*FOCUS_MEASUREMENT_PARAMETERS.powerControlNeitherOnMinutes);
break;
case 3:
POWER_CONTROL.setPower("heater","off");
POWER_CONTROL.setPower("fan","on");
stateEndTime=System.nanoTime()+(long) (6E10*FOCUS_MEASUREMENT_PARAMETERS.powerControlFanOnMinutes);
break;
}
}
// nothing specific is needed for case 4 - it will end anyway
}
}
if (!modeAverage) {
if (DEBUG_LEVEL>0) System.out.println("Turning both heater and fan off");
POWER_CONTROL.setPower("fan","off");
POWER_CONTROL.setPower("heater","off");
}
// LMA version
// LMA version
FocusingField ff= null;
FocusingField ff= null;
if (useLMA){
if (useLMA){
...
@@ -5475,7 +5549,7 @@ if (MORE_BUTTONS) {
...
@@ -5475,7 +5549,7 @@ if (MORE_BUTTONS) {
// Calculate and show average distances and tilts for measured history
// Calculate and show average distances and tilts for measured history
if (!modeAverage) {
if (!modeAverage) {
remoteNotifyComplete();
double [] lastKT=MOTORS.focusingHistory.temperatureLinearApproximation(
double [] lastKT=MOTORS.focusingHistory.temperatureLinearApproximation(
useLMA,
useLMA,
runs, // number of last samples from history to use, 0 - use all
runs, // number of last samples from history to use, 0 - use all
...
@@ -13820,6 +13894,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
...
@@ -13820,6 +13894,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
boolean select_GONIOMETER_PARAMETERS=!select;
boolean select_GONIOMETER_PARAMETERS=!select;
boolean select_ABERRATIONS_PARAMETERS=!select;
boolean select_ABERRATIONS_PARAMETERS=!select;
boolean select_FOCUSING_FIELD=!select;
boolean select_FOCUSING_FIELD=!select;
boolean select_POWER_CONTROL=!select;
if (select) {
if (select) {
GenericDialog gd = new GenericDialog("Select parameters to save");
GenericDialog gd = new GenericDialog("Select parameters to save");
gd.addMessage("===== Individual parameters ======");
gd.addMessage("===== Individual parameters ======");
...
@@ -13859,6 +13934,8 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
...
@@ -13859,6 +13934,8 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
gd.addCheckbox("GONIOMETER_PARAMETERS",select_GONIOMETER_PARAMETERS);
gd.addCheckbox("GONIOMETER_PARAMETERS",select_GONIOMETER_PARAMETERS);
gd.addCheckbox("ABERRATIONS_PARAMETERS",select_ABERRATIONS_PARAMETERS);
gd.addCheckbox("ABERRATIONS_PARAMETERS",select_ABERRATIONS_PARAMETERS);
gd.addCheckbox("FOCUSING_FIELD",select_FOCUSING_FIELD);
gd.addCheckbox("FOCUSING_FIELD",select_FOCUSING_FIELD);
gd.addCheckbox("POWER_CONTROL",select_POWER_CONTROL);
WindowTools.addScrollBars(gd);
WindowTools.addScrollBars(gd);
gd.showDialog();
gd.showDialog();
if (gd.wasCanceled()) return;
if (gd.wasCanceled()) return;
...
@@ -13898,6 +13975,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
...
@@ -13898,6 +13975,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
select_GONIOMETER_PARAMETERS=gd.getNextBoolean();
select_GONIOMETER_PARAMETERS=gd.getNextBoolean();
select_ABERRATIONS_PARAMETERS=gd.getNextBoolean();
select_ABERRATIONS_PARAMETERS=gd.getNextBoolean();
select_FOCUSING_FIELD=gd.getNextBoolean();
select_FOCUSING_FIELD=gd.getNextBoolean();
select_POWER_CONTROL=gd.getNextBoolean();
}
}
if (select_MASTER_DEBUG_LEVEL) properties.setProperty("MASTER_DEBUG_LEVEL", MASTER_DEBUG_LEVEL+"");
if (select_MASTER_DEBUG_LEVEL) properties.setProperty("MASTER_DEBUG_LEVEL", MASTER_DEBUG_LEVEL+"");
...
@@ -13936,6 +14014,8 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
...
@@ -13936,6 +14014,8 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
if (select_GONIOMETER_PARAMETERS) GONIOMETER_PARAMETERS.setProperties("GONIOMETER_PARAMETERS.", properties);
if (select_GONIOMETER_PARAMETERS) GONIOMETER_PARAMETERS.setProperties("GONIOMETER_PARAMETERS.", properties);
if (select_ABERRATIONS_PARAMETERS) ABERRATIONS_PARAMETERS.setProperties("ABERRATIONS_PARAMETERS.", properties);
if (select_ABERRATIONS_PARAMETERS) ABERRATIONS_PARAMETERS.setProperties("ABERRATIONS_PARAMETERS.", properties);
if ((select_FOCUSING_FIELD) && (FOCUSING_FIELD!=null)) FOCUSING_FIELD.setProperties("FOCUSING_FIELD.", properties);
if ((select_FOCUSING_FIELD) && (FOCUSING_FIELD!=null)) FOCUSING_FIELD.setProperties("FOCUSING_FIELD.", properties);
if (select_POWER_CONTROL) POWER_CONTROL.setProperties("POWER_CONTROL.", properties);
if (select) properties.remove("selected");
if (select) properties.remove("selected");
}
}
/* ======================================================================== */
/* ======================================================================== */
...
@@ -13976,6 +14056,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
...
@@ -13976,6 +14056,7 @@ private double [][] jacobianByJacobian(double [][] jacobian, boolean [] mask) {
GONIOMETER_PARAMETERS.getProperties("GONIOMETER_PARAMETERS.", properties);
GONIOMETER_PARAMETERS.getProperties("GONIOMETER_PARAMETERS.", properties);
ABERRATIONS_PARAMETERS.getProperties("ABERRATIONS_PARAMETERS.", properties);
ABERRATIONS_PARAMETERS.getProperties("ABERRATIONS_PARAMETERS.", properties);
if (FOCUSING_FIELD!=null) FOCUSING_FIELD.getProperties("FOCUSING_FIELD.", properties,false); // false -> overwrite distortions center
if (FOCUSING_FIELD!=null) FOCUSING_FIELD.getProperties("FOCUSING_FIELD.", properties,false); // false -> overwrite distortions center
POWER_CONTROL.getProperties("POWER_CONTROL.", properties);
}
}
private String selectSourceDirectory(String defaultPath) {
private String selectSourceDirectory(String defaultPath) {
...
...
src/main/java/CalibrationHardwareInterface.java
View file @
447a735d
...
@@ -1797,12 +1797,99 @@ public class CalibrationHardwareInterface {
...
@@ -1797,12 +1797,99 @@ public class CalibrationHardwareInterface {
throw
new
RuntimeException
(
ie
);
throw
new
RuntimeException
(
ie
);
}
}
}
}
}
public
static
class
PowerControl
{
public
int
debugLevel
=
1
;
private
String
powerIP
=
"192.168.0.80"
;
private
final
String
urlFormat
=
"http://%s/insteon/index.php?cmd=%s&group=%s"
;
private
final
String
rootElement
=
"Document"
;
public
boolean
powerConrtolEnabled
=
false
;
public
void
setProperties
(
String
prefix
,
Properties
properties
){
properties
.
setProperty
(
prefix
+
"powerIP"
,
this
.
powerIP
+
""
);
properties
.
setProperty
(
prefix
+
"powerConrtolEnabled"
,
this
.
powerConrtolEnabled
+
""
);
}
//Integer.decode(string)
public
void
getProperties
(
String
prefix
,
Properties
properties
){
if
(
properties
.
getProperty
(
prefix
+
"powerIP"
)!=
null
)
this
.
powerIP
=
properties
.
getProperty
(
prefix
+
"powerIP"
);
if
(
properties
.
getProperty
(
prefix
+
"powerConrtolEnabled"
)!=
null
)
this
.
powerConrtolEnabled
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"powerConrtolEnabled"
));
}
}
public
boolean
setPower
(
String
group
,
String
state
){
if
(!
powerConrtolEnabled
)
{
System
.
out
.
println
(
"=== Power control is disabled ==="
);
return
false
;
}
String
url
=
String
.
format
(
urlFormat
,
this
.
powerIP
,
state
,
group
);
if
(
this
.
debugLevel
>
2
)
System
.
out
.
println
(
"setPower: "
+
url
);
Document
dom
=
null
;
try
{
DocumentBuilderFactory
dbf
=
DocumentBuilderFactory
.
newInstance
();
DocumentBuilder
db
=
dbf
.
newDocumentBuilder
();
dom
=
db
.
parse
(
url
);
if
(!
dom
.
getDocumentElement
().
getNodeName
().
equals
(
rootElement
))
{
System
.
out
.
println
(
"Root element: expected \""
+
rootElement
+
"\", got \""
+
dom
.
getDocumentElement
().
getNodeName
()+
"\""
);
IJ
.
showMessage
(
"Error"
,
"Root element: expected \""
+
rootElement
+
"\", got \""
+
dom
.
getDocumentElement
().
getNodeName
()+
"\""
);
return
false
;
}
// boolean responceError= (dom.getDocumentElement().getElementsByTagName("error").getLength()!=0);
// if (responceError) {
// System.out.println("ERROR: register write ("+url+") FAILED" );
// IJ.showMessage("Error","register write ("+url+") FAILED");
// return false;
// }
}
catch
(
MalformedURLException
e
){
System
.
out
.
println
(
"Please check the URL:"
+
e
.
toString
()
);
return
false
;
}
catch
(
IOException
e1
){
IJ
.
showStatus
(
""
);
String
error
=
e1
.
getMessage
();
if
(
error
==
null
||
error
.
equals
(
""
))
error
=
""
+
e1
;
IJ
.
showMessage
(
"setPower ERROR"
,
""
+
error
);
return
false
;
}
catch
(
ParserConfigurationException
pce
)
{
pce
.
printStackTrace
();
return
false
;
}
catch
(
SAXException
se
)
{
se
.
printStackTrace
();
return
false
;
}
return
true
;
}
public
boolean
showDialog
(
String
title
,
boolean
control
)
{
GenericDialog
gd
=
new
GenericDialog
(
title
);
boolean
heaterOn
=
false
,
fanOn
=
false
;
gd
.
addCheckbox
(
"Enable power control (heater, fan) "
,
this
.
powerConrtolEnabled
);
gd
.
addStringField
(
"IP address of the power control"
,
this
.
powerIP
,
15
);
if
(
control
){
gd
.
addCheckbox
(
"Heater On"
,
heaterOn
);
gd
.
addCheckbox
(
"Fan On"
,
fanOn
);
}
WindowTools
.
addScrollBars
(
gd
);
if
(
control
)
gd
.
enableYesNoCancel
(
"OK"
,
"Control Power"
);
gd
.
showDialog
();
if
(
gd
.
wasCanceled
())
return
false
;
this
.
powerConrtolEnabled
=
gd
.
getNextBoolean
();
this
.
powerIP
=
gd
.
getNextString
();
if
(
control
){
heaterOn
=
gd
.
getNextBoolean
();
fanOn
=
gd
.
getNextBoolean
();
if
(!
gd
.
wasOKed
())
{
setPower
(
"heater"
,
heaterOn
?
"on"
:
"off"
);
setPower
(
"fan"
,
fanOn
?
"on"
:
"off"
);
}
}
return
true
;
}
public
boolean
isPowerControlEnabled
(){
return
this
.
powerConrtolEnabled
;
}
public
void
setDebugLevel
(
int
debugLevel
){
this
.
debugLevel
=
debugLevel
;
}
}
public
static
class
LaserPointers
{
public
static
class
LaserPointers
{
public
int
debugLevel
=
1
;
public
int
debugLevel
=
1
;
...
...
src/main/java/LensAdjustment.java
View file @
447a735d
...
@@ -330,6 +330,12 @@ public class LensAdjustment {
...
@@ -330,6 +330,12 @@ public class LensAdjustment {
public
boolean
lensDistanceShowResults
=
true
;
// show results window from foca
public
boolean
lensDistanceShowResults
=
true
;
// show results window from foca
public
boolean
lensDistanceMoveToGoal
=
true
;
// Move to targetMicrons
public
boolean
lensDistanceMoveToGoal
=
true
;
// Move to targetMicrons
public
boolean
powerControlEnable
=
true
;
public
double
powerControlMaximalTemperature
=
60.0
;
public
double
powerControlHeaterOnMinutes
=
10.0
;
public
double
powerControlNeitherOnMinutes
=
5.0
;
public
double
powerControlFanOnMinutes
=
15.0
;
public
String
uvLasersIP
=
"192.168.0.236"
;
// IP address of the camera with UV LEDs and aiming lasers are connected
public
String
uvLasersIP
=
"192.168.0.236"
;
// IP address of the camera with UV LEDs and aiming lasers are connected
public
int
uvLasersBus
=
0
;
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
public
int
uvLasersBus
=
0
;
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
public
double
[]
uvLasersCurrents
={
40.0
,
40.0
,
40.0
,
40.0
};
// default LED on currents (mA)
public
double
[]
uvLasersCurrents
={
40.0
,
40.0
,
40.0
,
40.0
};
// default LED on currents (mA)
...
@@ -546,6 +552,11 @@ public class LensAdjustment {
...
@@ -546,6 +552,11 @@ public class LensAdjustment {
boolean
lensDistanceInteractive
,
// Open dialog when calibrating focal distance
boolean
lensDistanceInteractive
,
// Open dialog when calibrating focal distance
boolean
lensDistanceShowResults
,
// show results window from foca
boolean
lensDistanceShowResults
,
// show results window from foca
boolean
lensDistanceMoveToGoal
,
// Move to targetMicrons
boolean
lensDistanceMoveToGoal
,
// Move to targetMicrons
boolean
powerControlEnable
,
double
powerControlMaximalTemperature
,
double
powerControlHeaterOnMinutes
,
double
powerControlNeitherOnMinutes
,
double
powerControlFanOnMinutes
,
String
uvLasersIP
,
// IP address of the camera with UV LEDs and aiming lasers are connected
String
uvLasersIP
,
// IP address of the camera with UV LEDs and aiming lasers are connected
int
uvLasersBus
,
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
int
uvLasersBus
,
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
double
[]
uvLasersCurrents
,
// default LED on currents (mA)
double
[]
uvLasersCurrents
,
// default LED on currents (mA)
...
@@ -692,6 +703,11 @@ public class LensAdjustment {
...
@@ -692,6 +703,11 @@ public class LensAdjustment {
this
.
lensDistanceInteractive
=
lensDistanceInteractive
;
// Open dialog when calibrating focal distance
this
.
lensDistanceInteractive
=
lensDistanceInteractive
;
// Open dialog when calibrating focal distance
this
.
lensDistanceShowResults
=
lensDistanceShowResults
;
// show results window from foca
this
.
lensDistanceShowResults
=
lensDistanceShowResults
;
// show results window from foca
this
.
lensDistanceMoveToGoal
=
lensDistanceMoveToGoal
;
// Move to targetMicrons
this
.
lensDistanceMoveToGoal
=
lensDistanceMoveToGoal
;
// Move to targetMicrons
this
.
powerControlEnable
=
powerControlEnable
;
this
.
powerControlMaximalTemperature
=
powerControlMaximalTemperature
;
this
.
powerControlHeaterOnMinutes
=
powerControlHeaterOnMinutes
;
this
.
powerControlNeitherOnMinutes
=
powerControlNeitherOnMinutes
;
this
.
powerControlFanOnMinutes
=
powerControlFanOnMinutes
;
this
.
uvLasersIP
=
new
String
(
uvLasersIP
);
// IP address of the camera with UV LEDs and aiming lasers are connected
this
.
uvLasersIP
=
new
String
(
uvLasersIP
);
// IP address of the camera with UV LEDs and aiming lasers are connected
this
.
uvLasersBus
=
uvLasersBus
;
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
this
.
uvLasersBus
=
uvLasersBus
;
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
this
.
uvLasersCurrents
=
uvLasersCurrents
.
clone
();
// default LED on currents (mA)
this
.
uvLasersCurrents
=
uvLasersCurrents
.
clone
();
// default LED on currents (mA)
...
@@ -840,6 +856,11 @@ public class LensAdjustment {
...
@@ -840,6 +856,11 @@ public class LensAdjustment {
this
.
lensDistanceInteractive
,
// Open dialog when calibrating focal distance
this
.
lensDistanceInteractive
,
// Open dialog when calibrating focal distance
this
.
lensDistanceShowResults
,
// show results window from foca
this
.
lensDistanceShowResults
,
// show results window from foca
this
.
lensDistanceMoveToGoal
,
// Move to targetMicrons
this
.
lensDistanceMoveToGoal
,
// Move to targetMicrons
this
.
powerControlEnable
,
this
.
powerControlMaximalTemperature
,
this
.
powerControlHeaterOnMinutes
,
this
.
powerControlNeitherOnMinutes
,
this
.
powerControlFanOnMinutes
,
this
.
uvLasersIP
,
// IP address of the camera with UV LEDs and aiming lasers are connected
this
.
uvLasersIP
,
// IP address of the camera with UV LEDs and aiming lasers are connected
this
.
uvLasersBus
,
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
this
.
uvLasersBus
,
// 0 if 103641 board is connected to the sensor port (through 10-359), 1 - to 10369
this
.
uvLasersCurrents
,
// default LED on currents (mA)
this
.
uvLasersCurrents
,
// default LED on currents (mA)
...
@@ -993,6 +1014,12 @@ public class LensAdjustment {
...
@@ -993,6 +1014,12 @@ public class LensAdjustment {
properties
.
setProperty
(
prefix
+
"lensDistanceShowResults"
,
this
.
lensDistanceShowResults
+
""
);
properties
.
setProperty
(
prefix
+
"lensDistanceShowResults"
,
this
.
lensDistanceShowResults
+
""
);
properties
.
setProperty
(
prefix
+
"lensDistanceMoveToGoal"
,
this
.
lensDistanceMoveToGoal
+
""
);
properties
.
setProperty
(
prefix
+
"lensDistanceMoveToGoal"
,
this
.
lensDistanceMoveToGoal
+
""
);
properties
.
setProperty
(
prefix
+
"powerControlEnable"
,
this
.
powerControlEnable
+
""
);
properties
.
setProperty
(
prefix
+
"powerControlMaximalTemperature"
,
this
.
powerControlMaximalTemperature
+
""
);
properties
.
setProperty
(
prefix
+
"powerControlHeaterOnMinutes"
,
this
.
powerControlHeaterOnMinutes
+
""
);
properties
.
setProperty
(
prefix
+
"powerControlNeitherOnMinutes"
,
this
.
powerControlNeitherOnMinutes
+
""
);
properties
.
setProperty
(
prefix
+
"powerControlFanOnMinutes"
,
this
.
powerControlFanOnMinutes
+
""
);
properties
.
setProperty
(
prefix
+
"uvLasersIP"
,
this
.
uvLasersIP
);
properties
.
setProperty
(
prefix
+
"uvLasersIP"
,
this
.
uvLasersIP
);
properties
.
setProperty
(
prefix
+
"uvLasersBus"
,
this
.
uvLasersBus
+
""
);
properties
.
setProperty
(
prefix
+
"uvLasersBus"
,
this
.
uvLasersBus
+
""
);
properties
.
setProperty
(
prefix
+
"uvLasersCurrents_0"
,
this
.
uvLasersCurrents
[
0
]+
""
);
properties
.
setProperty
(
prefix
+
"uvLasersCurrents_0"
,
this
.
uvLasersCurrents
[
0
]+
""
);
...
@@ -1276,6 +1303,18 @@ public class LensAdjustment {
...
@@ -1276,6 +1303,18 @@ public class LensAdjustment {
if
(
properties
.
getProperty
(
prefix
+
"lensDistanceMoveToGoal"
)!=
null
)
if
(
properties
.
getProperty
(
prefix
+
"lensDistanceMoveToGoal"
)!=
null
)
this
.
lensDistanceMoveToGoal
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"lensDistanceMoveToGoal"
));
this
.
lensDistanceMoveToGoal
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"lensDistanceMoveToGoal"
));
if
(
properties
.
getProperty
(
prefix
+
"powerControlEnable"
)!=
null
)
this
.
powerControlEnable
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"powerControlEnable"
));
if
(
properties
.
getProperty
(
prefix
+
"powerControlMaximalTemperature"
)!=
null
)
this
.
powerControlMaximalTemperature
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"powerControlMaximalTemperature"
));
if
(
properties
.
getProperty
(
prefix
+
"powerControlHeaterOnMinutes"
)!=
null
)
this
.
powerControlHeaterOnMinutes
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"powerControlHeaterOnMinutes"
));
if
(
properties
.
getProperty
(
prefix
+
"powerControlNeitherOnMinutes"
)!=
null
)
this
.
powerControlNeitherOnMinutes
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"powerControlNeitherOnMinutes"
));
if
(
properties
.
getProperty
(
prefix
+
"powerControlFanOnMinutes"
)!=
null
)
this
.
powerControlFanOnMinutes
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"powerControlFanOnMinutes"
));
if
(
properties
.
getProperty
(
prefix
+
"uvLasersIP"
)!=
null
)
if
(
properties
.
getProperty
(
prefix
+
"uvLasersIP"
)!=
null
)
this
.
uvLasersIP
=
properties
.
getProperty
(
prefix
+
"uvLasersIP"
);
this
.
uvLasersIP
=
properties
.
getProperty
(
prefix
+
"uvLasersIP"
);
if
(
properties
.
getProperty
(
prefix
+
"uvLasersBus"
)!=
null
)
if
(
properties
.
getProperty
(
prefix
+
"uvLasersBus"
)!=
null
)
...
@@ -1528,6 +1567,12 @@ public class LensAdjustment {
...
@@ -1528,6 +1567,12 @@ public class LensAdjustment {
gd
.
addCheckbox
(
"Show results window from focal distance calibration"
,
this
.
lensDistanceShowResults
);
gd
.
addCheckbox
(
"Show results window from focal distance calibration"
,
this
.
lensDistanceShowResults
);
gd
.
addCheckbox
(
"Move motors together to the requested microns from the \"best focus\""
,
this
.
lensDistanceMoveToGoal
);
gd
.
addCheckbox
(
"Move motors together to the requested microns from the \"best focus\""
,
this
.
lensDistanceMoveToGoal
);
gd
.
addCheckbox
(
"Enable power control for heater and fan"
,
this
.
powerControlEnable
);
gd
.
addNumericField
(
"Maximal allowed temperature"
,
this
.
powerControlMaximalTemperature
,
3
,
5
,
"C"
);
gd
.
addNumericField
(
"Heater ON time"
,
this
.
powerControlHeaterOnMinutes
,
1
,
5
,
"min"
);
gd
.
addNumericField
(
"Both heater and fan OFF time"
,
this
.
powerControlNeitherOnMinutes
,
1
,
5
,
"min"
);
gd
.
addNumericField
(
"Fan ON time"
,
this
.
powerControlFanOnMinutes
,
1
,
5
,
"min"
);
gd
.
addStringField
(
"IP address of the camera with 103641 board (UV LEDs and lasers) are attached"
,
this
.
uvLasersIP
,
40
);
gd
.
addStringField
(
"IP address of the camera with 103641 board (UV LEDs and lasers) are attached"
,
this
.
uvLasersIP
,
40
);
gd
.
addNumericField
(
"I2C bus where LED/laser board is attached (0 - through 10359, 1 - through 10369)"
,
this
.
uvLasersBus
,
0
);
gd
.
addNumericField
(
"I2C bus where LED/laser board is attached (0 - through 10359, 1 - through 10369)"
,
this
.
uvLasersBus
,
0
);
gd
.
addNumericField
(
"UV LED1 \"on\" current (left/near when looking from the target)"
,
this
.
uvLasersCurrents
[
0
],
3
,
5
,
"mA"
);
gd
.
addNumericField
(
"UV LED1 \"on\" current (left/near when looking from the target)"
,
this
.
uvLasersCurrents
[
0
],
3
,
5
,
"mA"
);
...
@@ -1701,6 +1746,12 @@ public class LensAdjustment {
...
@@ -1701,6 +1746,12 @@ public class LensAdjustment {
this
.
lensDistanceShowResults
=
gd
.
getNextBoolean
();
this
.
lensDistanceShowResults
=
gd
.
getNextBoolean
();
this
.
lensDistanceMoveToGoal
=
gd
.
getNextBoolean
();
this
.
lensDistanceMoveToGoal
=
gd
.
getNextBoolean
();
this
.
powerControlEnable
=
gd
.
getNextBoolean
();
this
.
powerControlMaximalTemperature
=
gd
.
getNextNumber
();
this
.
powerControlHeaterOnMinutes
=
gd
.
getNextNumber
();
this
.
powerControlNeitherOnMinutes
=
gd
.
getNextNumber
();
this
.
powerControlFanOnMinutes
=
gd
.
getNextNumber
();
this
.
uvLasersIP
=
gd
.
getNextString
();
this
.
uvLasersIP
=
gd
.
getNextString
();
this
.
uvLasersBus
=
(
int
)
gd
.
getNextNumber
();
this
.
uvLasersBus
=
(
int
)
gd
.
getNextNumber
();
this
.
uvLasersCurrents
[
0
]=
gd
.
getNextNumber
();
this
.
uvLasersCurrents
[
0
]=
gd
.
getNextNumber
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment