Closedown

This commit is contained in:
gac-x04sa
2019-07-31 17:42:55 +02:00
parent f451644a94
commit 4a9cf08623

View File

@@ -55,21 +55,15 @@ def auto_init():
global COUNT_TIME, RETRY_COUNT
global AUTO_LEVEL
global AUTO_RETRY_MAX
global AUTO_COUNT_TIME
global AUTO_EXP_LO, AUTO_EXP_HI
global AUTO_THRESH1, AUTO_THRESH2, AUTO_THRESH3, AUTO_THRESH4
global AUTO_THRESH1_COUNT, AUTO_THRESH2_COUNT
global AUTO_THRESH3_COUNT, AUTO_THRESH4_COUNT
AUTO_LEVEL = 0; AUTO_RETRY_MAX = 20; RETRY_COUNT=0
AUTO_COUNT_TIME = 0
AUTO_EXP_LO = 1; AUTO_EXP_HI = 10
# for safety, set the thresh values gigantically high to start with
AUTO_THRESH1=1e8; AUTO_THRESH2=1e9; AUTO_THRESH3=1e10; AUTO_THRESH4=1e11
pixel.threshold1=1e8; pixel.threshold2=1e9; pixel.threshold3=1e10; pixel.threshold4=1e11
# for safety, set the thresh values gigantically high to start with
AUTO_THRESH1_COUNT=100; AUTO_THRESH2_COUNT=100; AUTO_THRESH3_COUNT=100
AUTO_THRESH4_COUNT=100
image.thresh1_count=100; image.thresh2_count=100; image.thresh3_count=100; image.thresh4_count=100
COUNT_TIME = AUTO_EXP_LO
auto_init()
@@ -97,7 +91,7 @@ def auto_set_exposure(short_exp, long_exp):
where <short> is the shorter and <long>
the longer exposure time in seconds [s].
"""
global AUTO_EXP_LO, AUTO_EXP_HI, AUTO_THRESH1, AUTO_THRESH2, AUTO_THRESH3, AUTO_THRESH4
global AUTO_EXP_LO, AUTO_EXP_HI
AUTO_EXP_LO = short_exp
AUTO_EXP_HI = long_exp
@@ -107,7 +101,7 @@ def auto_set_exposure(short_exp, long_exp):
print "Invalid auto_set_exposure values - set to default values <<"
auto_show_exposure()
# set AUTO_TRESH2 1.5 times higher than ratio of counting times to avoid oscillations
AUTO_THRESH2 = AUTO_THRESH1 * (AUTO_EXP_HI/AUTO_EXP_LO) * 1.5
pixel.threshold2 = pixel.threshold1 * (AUTO_EXP_HI/AUTO_EXP_LO) * 1.5
def auto_show():
@@ -172,11 +166,8 @@ def auto_adjust():
global COUNT_TIME
global AUTO_LEVEL
global AUTO_RETRY_MAX
global AUTO_COUNT_TIME
global AUTO_EXP_LO, AUTO_EXP_HI
global AUTO_THRESH1, AUTO_THRESH2, AUTO_THRESH3, AUTO_THRESH4
global AUTO_THRESH1_COUNT, AUTO_THRESH2_COUNT
global AUTO_THRESH3_COUNT, AUTO_THRESH4_COUNT
if (AUTO_LEVEL < 1):
return(0) # do nothing when auto-level is zero
@@ -192,7 +183,7 @@ def auto_adjust():
autoTransmVal = transm.getPosition()
# try to set filters and exposure time
if (AUTO_THRESH4_COUNT > 2):
if (image.thresh2_count > 2):
# intensity too high -> reduce exposure time or filter transmission
if ((AUTO_LEVEL >= 2) and (autoExposure > AUTO_EXP_LO)):
autoExposure = AUTO_EXP_LO
@@ -203,7 +194,7 @@ def auto_adjust():
print("Intensity too high, reducing transmission to %.3e\n" % transm.getPosition())
autoAdjusted = 1
if (AUTO_THRESH2_COUNT < 1):
if (image.thresh2_count < 1):
# intensity too low -> take out filter or increase exposure time
if (autoTransmVal < 1.0):
# take out filter
@@ -211,7 +202,7 @@ def auto_adjust():
autoTransmVal = transm.getPosition()
autoTransmVal *= 10.0
if (AUTO_THRESH1_COUNT < 1) :
if (image.thresh1_count < 1) :
autoTransmVal *= 5.0
# readjust transmission-soll if it is > 1 now.
@@ -224,12 +215,12 @@ def auto_adjust():
# increase exposure time?
if ((AUTO_LEVEL >= 2) and (autoExposure < AUTO_EXP_HI)):
# check for long exposure-time
if (AUTO_THRESH1_COUNT < 1):
if (image.thresh1_count < 1):
autoExposure = AUTO_EXP_HI
autoAdjusted = 1
print("Intensity too low - setting exposure to %d sec\n"% autoExposure)
if ((AUTO_THRESH3_COUNT < 1) and (AUTO_THRESH2_COUNT > 1)):
if ((image.thresh3_count < 1) and (image.thresh2_count > 1)):
# decrease exptime?
if ((AUTO_LEVEL >= 2) and (autoExposure > AUTO_EXP_LO)):
autoExposure = AUTO_EXP_LO
@@ -252,7 +243,7 @@ def auto_adjust():
print("Intensity too low, increasing transmission to %.3e\n" % transm.getPosition())
autoAdjusted = 1
if ((AUTO_THRESH4_COUNT < 1) and (AUTO_THRESH3_COUNT > 1)):
if ((image.thresh4_count < 1) and (image.thresh3_count > 1)):
# decrease exptime?
if ((AUTO_LEVEL >= 2) and (autoExposure > AUTO_EXP_LO)):
autoExposure = AUTO_EXP_LO
@@ -261,9 +252,8 @@ def auto_adjust():
autoAdjusted = 1
if (AUTO_LEVEL == 2):
AUTO_COUNT_TIME = autoExposure
COUNT_TIME = AUTO_COUNT_TIME
_ctime = AUTO_COUNT_TIME # set the counting time for a scan to
COUNT_TIME = autoExposure
set_count_time(COUNT_TIME)
return autoAdjusted
###################################################################################################