- Added driver for phytron motor controller

- Added the lof command
This commit is contained in:
koennecke
2009-08-13 07:32:00 +00:00
parent f8b2ebcfb0
commit 9eddd6fd7c
2 changed files with 93 additions and 3 deletions

90
tcl/lof.tcl Normal file
View File

@ -0,0 +1,90 @@
#------------------------------------------------------------
# Last openened files. Lists the last n old files, giving
# a summary of each.
#
# copyright: see file COPYRIGHT
#
# Mark Koennecke, July 2009
#------------------------------------------------------------
namespace eval lof {}
set lof::instrument focus
set lof::table(Title) /entry1/title
set lof::table(Finished) /entry1/end_time
set lof::table(Monitor) /entry1/FOCUS/counter/monitor
set lof::table(Sample) /entry1/sample/name
set lof::table(Temperature) /entry1/sample/temperature
set lof::table(Lambda) /entry1/FOCUS/monochromator/lambda
proc lof::getyear {} {
return [clock format [clock seconds] -format "%Y"]
}
#------------------------------------------------------------
proc lof::makefilename {num} {
global simMode lof::instrument datahome
set hun [expr $num / 1000]
set y [lof::getyear]
if {$simMode == 0} {
set filename [format "%s/%3.3d/%s%4.4dn%6.6d.hdf" $datahome $hun $lof::instrument $y $num]
} else {
set filename [format "/afs/psi.ch/project/sinqdata/%s/%s/%3.3d/%s%4.4dn%6.6d.hdf" \
$y $lof::instrument $hun $lof::instrument $y $num]
}
return $filename
}
#------------------------------------------------------------
proc lof::getcurrentnumor {} {
global simMode lof::instrument
if {$simMode == 0} {
set txt [sicsdatanumber]
set l [split $txt =]
return [string trim [lindex $l 1]]
} else {
set y [getyear]
set filnam [format "/afs/psi.ch/project/sinqdata/%s/%s/DataNumber" \
$y $instrument]
set in [open $filnam r]
gets $in line
close $in
return [string trim $line]
}
}
#-----------------------------------------------------------
proc lof::readfiledata {num} {
global lof::table NXACC_READ NX_CHAR
set hdffile [lof::makefilename $num]
set nxfile [nx_open $hdffile $NXACC_READ]
set names [array names lof::table]
append result [file tail $hdffile] \n
append result "=======================================================================\n"
foreach name $names {
set status [catch {nx_openpath $nxfile $lof::table($name)} msg]
if {$status == 0} {
set data [nx_getdata $nxfile]
set type [get_nxds_type $data]
if {[string compare $type $NX_CHAR] == 0} {
set value [get_nxds_text $data]
} else {
set value [get_nxds_value $data 0]
}
append result [format "%-20s:%50s" $name $value] \n
}
}
nx_close $nxfile
return $result
}
#-----------------------------------------------------------
proc lof::lof {{num 5}} {
set numor [getcurrentnumor]
for {set n [expr $numor - $num] } {$n < $numor} {incr n} {
append result [readfiledata $n]
append result " \n"
}
return $result
}

View File

@ -201,9 +201,9 @@ proc phytron::make {name axis controller lowlim upperlim} {
$name makescriptfunc refrun "phytron::refrun $name $controller $axis $lowlim" user $name makescriptfunc refrun "phytron::refrun $name $controller $axis $lowlim" user
$name makescriptfunc setpos "phytron::defpos $controller $axis" user $name makescriptfunc sethardpos "phytron::defpos $controller $axis" user
hfactory /sics/${name}/setpos/value plain user float hfactory /sics/${name}/sethardpos/value plain user float
hupdate /sics/{$name}/status idle hupdate /sics/${name}/status idle
$controller queue /sics/${name}/hardposition progress read $controller queue /sics/${name}/hardposition progress read
} }