#%TITLE% SONY.MAC
#%NAME% SONY.MAC - Macros to access the Sony Camera via the Meteor2 frame
# grabber card from spec.
#
#%DESCRIPTION%
# The Meteor2 device server can be accessed via SPEC as a standart CCD
# camera. All standart functionality is implemented. On the Sony camera
# several extra features are available which are accessible via this
# set of macros.
# The main features are:
#%UL%
#%LI% Counters on calculated beam parameters (spot center, size, ...)
#%LI% Manual and automatic image intensity calibration
#%LI% Live mode for monitoring
#%LI% Intensity threshold on image
#%XUL%
#
#%EXAMPLE%
#%DL%
#%DT% sony_setup ID13/meteor2/sony %DD%
# It will declare the camera device so that it is known
# by the macros.
#
#%DT% sony_show %DD%
# Shows all readable parameters for the camera with their index
# and actual values. The actual SONY camera set-up is:
#%DL%
#%DD% [index] : description : value
#%DD% -----------------------------------------
#%DD% [0] : Exposure time : 0.000000
#%DD% [1] : Threshold : 0
#%DD% [9] : Live mode : 0
#%DD% [30] : Auto calibration mode : 0
#%DD% [2] : Calibrated max. Intensity : 0
#%DD%
#%DD% [3] : Full image siz X : 0
#%DD% [4] : Full image siz Y : 0
#%DD%
#%DD% [5] : ROI start X : 0
#%DD% [6] : ROI start Y : 0
#%DD% [7] : ROI end X : 0
#%DD% [8] : ROI end Y : 0
#%DD%
#%DD% [10] : Number of beam spots : 0
#%DD% [11] : Beam intensity : 0
#%DD% [29] : Nomalized beam intensity : 0
#%DD% : (Beam intensity/Exposure time)
#%DD%
#%DD% [12] : Beam center X : 0.00
#%DD% [13] : Beam center Y : 0.00
#%DD% [14] : Beam size FWHM X : 0
#%DD% [15] : Beam size FWHM Y : 0
#%DD% [16] : Beam size full X : 0
#%DD% [17] : Beam size full Y : 0
#%DD%
#%DD% [18] : Max. pixel value : 0
#%DD% [19] : Max. pixel X : 0
#%DD% [20] : Max. pixel Y : 0
#%DD%
#%DD% [21] : Beam spot start X : 0
#%DD% [22] : Beam spot start Y : 0
#%DD% [23] : Beam spot end X : 0
#%DD% [24] : Beam spot end Y : 0
#%DD% [25] : Beam spot FWHM start X : 0
#%DD% [26] : Beam spot FWHM start Y : 0
#%DD% [27] : Beam spot FWHM end X : 0
#%DD% [28] : Beam spot FWHM end Y : 0
#%DD%
#%DT% sony_counter_add inten 11 %DD%
# Configures the counter inten with the beam intensity value (index = 11)
#
#%DT% sony_counter_add cenx 12 %DD%
# Configures the counter cenx with the beam center X value (index = 12)
#
#%DT% sony_counter_add ceny 13 %DD%
# Configures the counter ceny with the beam center Y value (index = 13)
#
#%DT% sony_on %DD%
# Switches on the configured counters during ct and scans.
#
#%XDL%
#
#%END%
#
#
global SONY_DEVICE
global SONY_CT_LIST
global SONY_ON
list_test SONY_CT_LIST
#%UU% [ device_name ]
#%MDESC%
# It will declare the camera device so that it is known
# by the macros.
#
def sony_setup '{
if ($# == 1) {
SONY_DEVICE = "$1"
} else {
printf(" Usage: ");
tty_cntl("md");print "sony_setup device_name";tty_cntl("me")
exit
}
cdef ("user_getcounts", "sony_ct_read\n", "beamct", 0x10)
}'
#%UU%
#%MDESC%
# Cleans-up the camera and counter set-up.
#
def sony_unsetup '{
print "Deleting the sony beam parameter counters!"
cdef ("","","beamct","delete")
}'
#%UU%
#%MDESC%
# Switches on the configured counters during ct and scans.
#
def sony_on '{
SONY_ON = 1
}'
#%UU%
#%MDESC%
# Disables the configured counters during ct and scans.
#
def sony_off '{
local _mne
local _ct_num
local _counters
SONY_ON = 0
_counters = list_n (SONY_CT_LIST)
for (i=1; i <= _counters; i++) {
_ct_num = cnt_num (_mne = list_item (SONY_CT_LIST, i))
S[_ct_num] = 0
}
}'
#%UU% [ counter_mnemonic value_index ]
#%MDESC%
# Adds the counter with the given mnemonic which reads the camera value
# specified by the index. The index can be found executing "sony_show"!
#
def sony_counter_add '{
if ($# == 2) {
sony_ct_add ("$1", $2)
} else {
printf(" Usage: ");
tty_cntl("md");print "sony_counter_add counter_mnemonic signal_index";tty_cntl("me")
exit
}
}'
#%UU% [ counter_mnemonic ]
#%MDESC%
# Removes the counter with the given mnemonic.
#
def sony_counter_remove '{
if ($# == 1) {
sony_ct_remove ("$1")
} else {
printf(" Usage: ");
tty_cntl("md");print "sony_counter_remove counter_mnemonic";tty_cntl("me")
exit
}
}'
#%IU% (counter_mnemonic value_index)
#%MDESC%
# Adds the counter with the given mnemonic which reads the camera value
# specified by the index. The index can be found executing "sony_show"!
#
def sony_ct_add (counter_mnemonic, signal_index) '{
list_add (SONY_CT_LIST, counter_mnemonic)
list_setpar(SONY_CT_LIST, counter_mnemonic, "index", signal_index)
}'
#%IU% (counter_mnemonic)
#%MDESC%
# Removes the counter with the given mnemonic.
#
def sony_ct_remove (counter_mnemonic) '{
local _ct_num
list_remove(SONY_CT_LIST, counter_mnemonic)
_ct_num = cnt_num (counter_mnemonic)
S[_ct_num] = 0
}'
#%IU%
#%MDESC%
# Reads all counters specified for the camera if the reading was eanabled
# by "sony_on"!
#
def sony_ct_read '{
local _val
local _mne
local _index
local _ct_num
local _counters
if (SONY_ON == 1){
esrf_io (SONY_DEVICE, "DevReadSigValues", _val)
_counters = list_n (SONY_CT_LIST)
for (i=1; i <= _counters; i++) {
_ct_num = cnt_num (_mne = list_item (SONY_CT_LIST, i))
_index = list_getpar (SONY_CT_LIST, _mne, "index")
S[_ct_num] = _val[_index]
}
}
}'
#%UU% (threshold)
#%MDESC%
# Sets the intensity threshold for the camera.
#
def sony_set_threshold (threshold) '{
esrf_io (SONY_DEVICE, "DevCcdSetThreshold", threshold)
return
}'
#%UU% ()
#%MDESC%
# Returns the intensity threshold for the camera.
#
def sony_get_threshold () '{
local _th
_th = esrf_io (SONY_DEVICE, "DevCcdGetThreshold")
return _th
}'
#%UU% (exposure_time)
#%MDESC%
# Sets the exposure time for the camera.
#
def sony_set_exposure (exp_time) '{
esrf_io (SONY_DEVICE, "DevCcdSetExposure", exp_time)
return
}'
#%UU% ()
#%MDESC%
# Returns the actual exposure time off the camera.
#
def sony_get_exposure () '{
local _exp
_exp = esrf_io (SONY_DEVICE, "DevCcdGetExposure")
return _exp
}'
#%UU% (max_exposure_time)
#%MDESC%
# Sets the maximum exposure time for the camera.
#
def sony_set_max_exposure (exp_time) '{
esrf_io (SONY_DEVICE, "DevCcdSetMaxExposure", exp_time)
return
}'
#%UU% ()
#%MDESC%
# Returns the maximum exposure time off the camera.
#
def sony_get_max_exposure () '{
local _exp
_exp = esrf_io (SONY_DEVICE, "DevCcdGetMaxExposure")
return _exp
}'
#%UU% ()
#%MDESC%
# Sets the camera to live mode
#
def sony_live_on () '{
esrf_io (SONY_DEVICE, "DevCcdSetLive", 1)
return
}'
#%UU% ()
#%MDESC%
# Stops the camera live mode
#
def sony_live_off () '{
esrf_io (SONY_DEVICE, "DevCcdSetLive", 0)
return
}'
#%UU% (min_intensity, max_intensity)
#%MDESC%
# Switch on the intensity calibration for every image aquired.
# The camera calibrates the image intensity to the specified range
# before taking an image by changing the exposure time.
#
def sony_autocal_on (min_intensity, max_intensity) '{
local argin
argin[0] = 1
argin[1] = min_intensity
argin[2] = max_intensity
esrf_io (SONY_DEVICE, "DevCalibration", argin)
}'
#%UU% ()
#%MDESC%
# Switch off the intensity calibration for every image aquired.
#
def sony_autocal_off () '{
local argin
argin[0] = 0
esrf_io(SONY_DEVICE, "DevCalibration", argin)
}'
#%UU% (min_intensity, max_intensity)
#%MDESC%
# The camera calibrates the image intensity to the specified range
# by changing the exposure time.
#
def sony_calibrate_intensity (min_intensity, max_intensity) '{
local argin
local state
local calib_values
#
# I know its dirty to put the device name here!
#
calib_values[0] = -1.0
calib_values[1] = -1.0
argin[0] = min_intensity
argin[1] = max_intensity
esrf_io (SONY_DEVICE,"DevSetCalib", argin)
state = esrf_io (SONY_DEVICE,"DevState")
# state == DevCcdTaking
while ( state == 202899458 ) {
sleep(0.3)
state = esrf_io (SONY_DEVICE,"DevState")
}
# state == DevCcdReady
if ( state == 202899457 ) {
esrf_io(SONY_DEVICE, "DevGetCalib", calib_values)
} else {
p "Calibration did not finish correctly!"
p esrf_io(METEOR_DEVICE, "DevCcdGetLstErrMsg")
}
return calib_values
}'
#%UU%
#%MDESC%
# Shows all readable parameters for the camera with their index
# and actual values.
#
def sony_show '{
local _val
esrf_io (SONY_DEVICE, "DevReadSigValues", _val)
printf ("The actual SONY camera set-up is:\n\n")
printf ("[index] : description : value\n")
printf ("[0] : Exposure time : %f\n", _val[0])
printf ("[1] : Threshold : %3.0f\n", _val[1])
printf ("[9] : Live mode : %1.0f\n", _val[9])
printf ("[30] : Auto calibration mode : %1.0f\n", _val[30])
printf ("[2] : Calibrated max. Intensity : %3.0f\n", _val[2])
printf ("\n")
printf ("[3] : Full image siz X : %4.0f\n", _val[3])
printf ("[4] : Full image siz Y : %4.0f\n", _val[4])
printf ("\n")
printf ("[5] : ROI start X : %4.0f\n", _val[5])
printf ("[6] : ROI start Y : %4.0f\n", _val[6])
printf ("[7] : ROI end X : %4.0f\n", _val[7])
printf ("[8] : ROI end Y : %4.0f\n", _val[8])
printf ("\n")
printf ("[10] : Number of beam spots : %1.0f\n", _val[10])
printf ("[11] : Beam intensity : %g\n", _val[11])
printf ("[29] : Nomalized beam intensity : %g\n", _val[29])
printf (" : (Beam intensity/Exposure time)\n")
printf ("\n")
printf ("[12] : Beam center X : %6.2f\n", _val[12])
printf ("[13] : Beam center Y : %6.2f\n", _val[13])
printf ("[14] : Beam size FWHM X : %4.0f\n", _val[14])
printf ("[15] : Beam size FWHM Y : %4.0f\n", _val[15])
printf ("[16] : Beam size full X : %4.0f\n", _val[16])
printf ("[17] : Beam size full Y : %4.0f\n", _val[17])
printf ("\n")
printf ("[18] : Max. pixel value : %3.0f\n", _val[18])
printf ("[19] : Max. pixel X : %4.0f\n", _val[19])
printf ("[20] : Max. pixel Y : %4.0f\n", _val[20])
printf ("\n")
printf ("[21] : Beam spot start X : %4.0f\n", _val[21])
printf ("[22] : Beam spot start Y : %4.0f\n", _val[22])
printf ("[23] : Beam spot end X : %4.0f\n", _val[23])
printf ("[24] : Beam spot end Y : %4.0f\n", _val[24])
printf ("[25] : Beam spot FWHM start X : %4.0f\n", _val[21])
printf ("[26] : Beam spot FWHM start Y : %4.0f\n", _val[22])
printf ("[27] : Beam spot FWHM end X : %4.0f\n", _val[23])
printf ("[28] : Beam spot FWHM end Y : %4.0f\n", _val[24])
printf ("\n")
}'
#%MACROS%
#%IMACROS%
#%AUTHOR% J. MEYER / BLISS / ESRF 2002
#%TOC%
|