#%TITLE% PIXIUM.MAC
#%NAME%
# Macros for the Pixium flat panel detector
#
#%CATEGORY% Detection, Ccd
#
#%LOG%
#$Revision: 1.4 $
#$Log: pixium.mac,v $
#Revision 1.4 2008/07/17 15:06:36 rey
#documentation changes
#
#Revision 1.3 2008/04/15 11:50:11 claustre
#added new macros for external-trigger mode, gain setting, frequency setting ...
#
#Revision 1.1 2007/10/22 07:05:04 claustre
#Initial revision
#
#%END%
global PIXIUM_PAR
global PIXIUM_MODE_LIST
#%UU% <tango-device-name> <spec-ccd-num>
#%MDESC% setup the pixium connection
def pixiumsetup '{
global ESRF_ERR
if ($#!=2){
list_init PIXIUM_MODE_LIST
print "Usage: pixiumsetup <tango-device-name> <spec-ccd-num>"
exit
}
dev = "$1"
ESRF_ERR = -1
esrf_io(dev,"DevStatus")
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error importing the pixium TANGO device: "
tty_cntl("me")
print ESRF_ERR_MSG
PIXIUM_PAR["tango-dev"] = -1
exit
}
PIXIUM_PAR["tango-dev"] = dev
type = image_par($2,"controller")
if (type != "CCD_PC") {
print "Hoops, your CCD number "$2" is not of type CCD PC."
print "It is certainly not a Pixium Taco CCD device configured !!"
exit
}
dev = image_par($2, "device_id")
ESRF_ERR = -1
esrf_io(dev,"DevStatus")
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error importing the pixium Taco device: "
tty_cntl("me")
print ESRF_ERR_MSG
PIXIUM_PAR["taco-dev"] = -1
exit
}
PIXIUM_PAR["taco-dev"] = dev
PIXIUM_PAR["ccd_u"] = $2
tty_cntl("md"); print "Pixium detector ready to use !!"
tty_cntl("me")
}'
#%UU% [go ahead]
#%MDESC% Start a offset calibration, ask confirmation is no argument passed
def pixium_offset '{
local m trigger
if ($#!=1) {
if (!yesno("Are you sure your (safety) shutter is closed",0)) exit
}
# Check first the trigger mode is compatible with an offset calibration
trigger = esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Trigger","DevRead")
if (trigger==1) {
tty_cntl("md")
#print "Sorry you cannot make an offset calibration while the trigger mode is External"
print "You must provide a hardware trigger to calibrate the offset!"
tty_cntl("me") }
#Now calibrate the offset
esrf_io(PIXIUM_PAR["tango-dev"],"CalibrateOffset")
printf ("Pixium is calibrating the offset ...")
while ( esrf_io(PIXIUM_PAR["tango-dev"],"DevState")==2) {
printf("\b%s", substr("-\\|/", (m=++m%4)+1,1))
sleep(0.2)
}
p ""
}'
#%UU% [exposure-time] [go-ahead]
#%MDESC% change the exposure time and apply a offset calibration
def pixium_exposure '{
local exposure m
exposure = esrf_io(PIXIUM_PAR["taco-dev"],"DevCcdGetExposure")
if ($#!=2) {
exposure = getval("Enter the new exposure time",exposure)
} else exposure = $1
# First apply the new exposure time
ESRF_ERR = -1
esrf_io(PIXIUM_PAR["taco-dev"],"DevCcdSetExposure", exposure)
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error setting the exposure time: "
tty_cntl("me")
print ESRF_ERR_MSG
exit
}
# Inform SPEC too
image_par(PIXIUM_PAR["ccd_u"],"preset", exposure)
pixium_offset $2
}'
#%UU% [gain] [go-ahead]
#%MDESC% change the exposure time and apply a offset calibration
def pixium_gain '{
local gain m dev
gain = esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Gain","DevRead")
if ($#!=2) {
gain = getval("Enter the new gain",gain)
} else gain = $1
if (gain <0 || gain >7) {
print "wrong gain value, range is 0-7, 0 is the max. gain"
return
}
# First apply the new exposure time
ESRF_ERR = -1
esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Gain","DevWrite", gain)
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error setting the gain: "
tty_cntl("me")
print ESRF_ERR_MSG
exit
}
pixium_offset $2
}'
#%UU% [frequency] [go-ahead]
#%MDESC% change the frequency and apply an offset calibration
def pixium_frequency '{
local frequency m dev
frequency = esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Frequency","DevRead")/1000
if ($#!=2) {
gain = getval("Enter the new frequency",frequency)
} else frequency = $1
if (frequency <0 || frequency >60) {
print "wrong gain value, range is 0-60 Hz, 0 is the max. gain"
return
}
# First apply the new exposure time
ESRF_ERR = -1
esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Frequency","DevWrite", frequency*1000)
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error setting the frequency: "
tty_cntl("me")
print ESRF_ERR_MSG
exit
}
pixium_offset $2
}'
#%UU% [mode] [go-ahead]
#%MDESC% change trigger mode
def pixium_trigger '{
local trigger m dev
trigger = esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Trigger","DevRead")
if ($#!=2) {
trigger = getval("Enter the trigger mode (0-software,1-external).",trigger)
} else trigger = $1
if (trigger !=0 && trigger !=1) {
print "wrong trigger mode, (0-software,1-external)"
return
}
# First apply the new trigger mode
ESRF_ERR = -1
esrf_io(dev=PIXIUM_PAR["tango-dev"]"/Trigger","DevWrite", trigger)
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error setting the trigger mode: "
tty_cntl("me")
print ESRF_ERR_MSG
exit
}
}'
#%UU% [mode] [go-ahead]
#%MDESC% change auto-save mode 0-Off 1-On
def pixium_autosave '{
local mode m dev
mode = esrf_io(dev=PIXIUM_PAR["tango-dev"]"/SaveMode","DevRead")
if ($#!=2) {
mode = getval("Enter the Save mode (0-Off,1-On).",mode)
} else mode = $1
if (mode !=0 && mode !=1) {
print "wrong autosave mode, (0-Off,1-On)"
return
}
# First apply the new autosave mode
ESRF_ERR = -1
esrf_io(dev=PIXIUM_PAR["tango-dev"]"/SaveMode","DevWrite", mode)
if (ESRF_ERR!=0) {
tty_cntl("md")
print "Error setting the autosave mode: "
tty_cntl("me")
print ESRF_ERR_MSG
exit
}
}'
def pixium_startlive '{
esrf_io(PIXIUM_PAR["tango-dev"],"Live")
}'
def pixium_stoplive '{
esrf_io(PIXIUM_PAR["tango-dev"],"Stop")
}'
#%UU%
#%MDESC% Save all the taken frames to the disk
def pixium_saveall '{
ESRF_ERR = -1
printf ("Pixium is saving the frames ...")
esrf_io(PIXIUM_PAR["taco-dev"],"DevCcdWriteAll", 0)
if (ESRF_ERR==61) {
while(ESRF_ERR==61){
ESRF_ERR = -1
esrf_io(PIXIUM_PAR["taco-dev"],"DevState")
printf("\b%s", substr("-\\|/", (m=++m%4)+1,1))
sleep(.2)
}
} else if (ESRF_ERR!=0){
print ESRF_ERR_MSG
}
p ""
}'
#%UU%
#%MDESC% Save a the sum of all the taken frames to one file
def pixium_savesum '{
ESRF_ERR = -1
printf ("Pixium is summing and saving the frames ...")
esrf_io(PIXIUM_PAR["taco-dev"],"DevCcdWriteAll", 1)
if (ESRF_ERR==61) {
while(ESRF_ERR==61){
ESRF_ERR = -1
esrf_io(PIXIUM_PAR["taco-dev"],"DevState")
printf("\b%s", substr("-\\|/", (m=++m%4)+1,1))
sleep(.2)
}
} else if (ESRF_ERR!=0){
print ESRF_ERR_MSG
}
p ""
}'
#%UU%
#%MDESC% Change the logical mode of the pixium detector
def pixium_mode '{
local mode
mode=esrf_io(dev=PIXIUM_PAR["tango-dev"]"/LogicalMode","DevRead")
mode = getval("Enter the new mode (1-7)",mode)
if(mode <1 && mode > 7) {
print "Wrong mode value!"
exit
}
ESRF_ERR = -1
printf ("Pixium is change the mode ...")
esrf_io(dev=PIXIUM_PAR["tango-dev"]"/LogicalMode","DevWrite",mode)
if (ESRF_ERR==1101) {
while(ESRF_ERR==1101){
ESRF_ERR = -1
esrf_io(PIXIUM_PAR["tango-dev"],"DevState")
printf("\b%s", substr("-\\|/", (m=++m%4)+1,1))
sleep(.2)
}
} else if (ESRF_ERR!=0){
print ESRF_ERR_MSG
}
p ""
reconfig; image_data0[0]=image_data0[0]
}'
#%UU%
#%MDESC% Change the big-buffer mode, 0-normal, 1-stromboscopic
def pixium_bigbuffer '{
local mode
mode=esrf_io(dev=PIXIUM_PAR["tango-dev"]"/BigBufferMode","DevRead")
mode = getval("Enter the new mode (0:Normal , 1:Strombo)",mode)
if(mode <0 && mode > 1) {
print "Wrong bigbuffer mode value!"
exit
}
}'
#%UU%
#%MDESC% user macro
def pixiumct '{
local pix_maxexp nb_images ccd_u pars[]
if ($# < 1) { eprint "usage: marct time"; exit; }
if (0 < $1) {
pix_maxexp = esrf_io(PIXIUM_PAR["taco-dev"],"DevCcdGetExposure")
nb_images = int($1/pix_maxexp)+1
print "Will sum "nb_images" images of "pix_maxexp" sec."
waitmove;
if (esrf_io(SHUTTER["_CURRENT"],"DevState") != 4) { shopen; sleep(2); }
ccd_u = CCD_U
CCD_U = PIXIUM_PAR["ccd_u"]
count_em $*; mv shu 100;
ccdstart pix_maxexp nb_images
cdef("cleanup_once",sprintf("mv shu 0; shclose; user_handlecounts; \
ccdstop;CCD_U=%d;", ccd_u),"_PIXIUM_")
waitcount; mv shu 0; undef cleanup; get_counts; # shclose;
user_handlecounts; HEADING = sprintf("pixiumct %g",$1); pixhead;
}
waitacq; wait(0);
pixium_savesum
esrf_io(PIXIUM_PAR["taco-dev"],"DevCcdGetFilePar",pars)
print ccdfilename(pars[0],pars[1],pars[3],pars[2])
CCD_U=ccd_u
}'
#%IU%
#%MDESC%
def pixhead '{
local im_n, fnm, i, n
im_n = image_par(CCD_U,"file_inum");
fnm = sprintf("%s/%s%.3d%s",image_par(CCD_U,"file_dir"),image_par(CCD_U,"file_prefix"),im_n,image_par(CCD_U,"file_suffix"));
HEADING = sprintf("%s\n#PIXIUM IMAGE",fnm);
_cols = 0
PPRNT = VPRNT = ""; FPRNT = sprintf("%s ",_hkl_sym1); scan_head
PFMT = sprintf("%%s%%8.%df ",UP); VFMT = sprintf("%%s%%9.%df ",UP)
PPRNT = VPRNT = ""; FPRNT = sprintf("%s ",_hkl_val)
s = sprintf("%s%8.0f ",VPRNT,S[DET]); tty_cntl("resized?")
n = int((COLS - length(VPRNT) - length(Pout) - 24) / 9)
if (MON >= 0) { s = s sprintf("%8.0f ",S[MON]); n--; }
s = s sprintf("%10.6g ",S[sec]);
for (i = 0; i < COUNTERS && n > 0; i++) {
if (i != DET && i != MON && i != sec && is_using_counter(i)) {
s = s sprintf("%8.4g ", S[i]); n--
}
}
printf("%s%s\n",s,Pout)
ifp {
fprintf(PRINTER,"%s %8.6g ", _hkl_val11, S[sec])
if (MON >= 0) fprintf(PRINTER,"%8.0f ",S[MON])
fprintf(PRINTER,"%8.0f %s%s\n",S[DET],PPRNT,Pout)
}
if (DATAFILE != "") {
fprintf(DATAFILE,"%s%s%d",FPRNT,Fout,(TIME_END=time())-EPOCH)
for (i = 0; i < COUNTERS; i++)
if (i != MON && i != DET && is_using_counter(i))
fprintf(DATAFILE," %g",S[i])
if (MON >= 0) fprintf(DATAFILE," %g",S[MON])
fprintf(DATAFILE," %g\n",S[DET]);
}
}'
|