diff --git a/tcl/lof.tcl b/tcl/lof.tcl new file mode 100644 index 00000000..fd6cc93d --- /dev/null +++ b/tcl/lof.tcl @@ -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 +} diff --git a/tcl/phytron.tcl b/tcl/phytron.tcl index 17b40289..8759fdf5 100644 --- a/tcl/phytron.tcl +++ b/tcl/phytron.tcl @@ -201,9 +201,9 @@ proc phytron::make {name axis controller lowlim upperlim} { $name makescriptfunc refrun "phytron::refrun $name $controller $axis $lowlim" user - $name makescriptfunc setpos "phytron::defpos $controller $axis" user - hfactory /sics/${name}/setpos/value plain user float + $name makescriptfunc sethardpos "phytron::defpos $controller $axis" user + 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 }