cvs diff -u -rRELEASE-1_2-MERGEPOINT -rHEAD <filepath> and found no modifications on the trunk between the release 1.2 mergepoint and cvs HEAD r1946 | ffr | 2007-05-08 15:01:16 +1000 (Tue, 08 May 2007) | 4 lines
302 lines
10 KiB
Tcl
302 lines
10 KiB
Tcl
# TODO Return filename from nxcreatefile and call nxreopen nxclose etc
|
|
# TODO Make an nxscript namespace for all this.
|
|
|
|
# dictalias is a global hash which records the alias which the value of
|
|
# a sics object (eg motors) is written to. The has is indexed by the
|
|
# objects name. It is useful for making links to datasets.
|
|
# dim0 = vertical axis on detector
|
|
# dim1 = horizontal axis on detector
|
|
|
|
set tmpstr [string map {"$" ""} {$Name: not supported by cvs2svn $}]
|
|
set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
|
set tmpstr [string map {"$" ""} {$Revision: 1.24 $}]
|
|
set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
|
|
|
MakeNXScript
|
|
sicsdatafactory new nxscript_data
|
|
|
|
proc getVal {msg} {
|
|
return [string trim [lindex [split $msg =] 1 ] ]
|
|
}
|
|
|
|
proc newFileName {} {
|
|
sicsdatanumber incr;
|
|
set idNum [SplitReply [sicsdatanumber]];
|
|
set dataPath [SplitReply [sicsdatapath]];
|
|
set prefix [SplitReply [sicsdataprefix]];
|
|
set postfix [SplitReply [sicsdatapostfix]];
|
|
set date_time_arr [split [sicstime] " "]
|
|
set isodate [lindex $date_time_arr 0];
|
|
set isotime [string map {: -} [lindex $date_time_arr 1]];
|
|
return [format "%s/%s_%sT%s_%05d%s" $dataPath $prefix $isodate $isotime $idNum $postfix];
|
|
}
|
|
|
|
proc nxcreatefile {nxdic {type nx.hdf}} {
|
|
global nxFileOpen cfPath nexusdic;
|
|
SicsDataPostFix .$type;
|
|
|
|
set nexusdic $nxdic
|
|
array set nxmode [list nx.hdf create5 h5 create5 nx5 create5 xml createxml];
|
|
dataFileName [newFileName]
|
|
nxscript $nxmode($type) [SplitReply [dataFileName]] $cfPath(nexus)/$nexusdic;
|
|
set nxFileOpen true
|
|
}
|
|
|
|
|
|
proc nxreopenfile {} {
|
|
global nxFileOpen cfPath nexusdic;
|
|
nxscript reopen [SplitReply [dataFileName]] $cfPath(nexus)/$nexusdic;
|
|
set nxFileOpen true;
|
|
}
|
|
|
|
proc nxclosefile {} {
|
|
global nxFileOpen;
|
|
if {$nxFileOpen == true} {
|
|
nxscript close;
|
|
set nxFileOpen false;
|
|
set flist [split [SplitReply [dataFileName]] "/"];
|
|
set fname [lindex $flist [expr [llength $flist] - 1] ];
|
|
clientput "$fname updated" "event";
|
|
}
|
|
}
|
|
|
|
set dradius 1.25
|
|
set ndect 128
|
|
set tubedia 0.0254
|
|
set pi 3.1415926
|
|
set angsep 1.25
|
|
# stthmin = (180 - (1.25*127))/2
|
|
|
|
proc hmm_save {nxobj entryname point} {
|
|
global dradius ndect angsep dictalias;
|
|
set dictalias(hmm) hmcounts
|
|
# dim0 is vertical and dim1 is horizontal
|
|
set dim0 [SplitReply [hmm configure dim0]];
|
|
set dim1 [SplitReply [hmm configure dim1]];
|
|
putcommon $nxobj $entryname $point;
|
|
putcrystal $nxobj;
|
|
putmonitor $nxobj $point;
|
|
putsample $nxobj;
|
|
|
|
$nxobj putattribute program_name hmm_mode [SplitReply [hmm_mode]]
|
|
$nxobj putfloat detangle_degrees [SplitReply [detector_angle_deg]]
|
|
$nxobj putfloat dheight [SplitReply [detector_active_height_mm]]
|
|
put_det_haxis_arr $nxobj $dim1;
|
|
put_det_vaxis_arr $nxobj $dim0;
|
|
$nxobj puttext dtype [SplitReply [detector_type]]
|
|
$nxobj puttext ddesc [SplitReply [detector_description]]
|
|
$nxobj putfloat dradius [SplitReply [detector_radius_mm]]
|
|
$nxobj puttext dlayout [SplitReply [detector_layout]]
|
|
set histo_length [SplitReply [hmm_length]]
|
|
$nxobj updatedictvar padim0 $dim0
|
|
$nxobj updatedictvar padim1 $dim1
|
|
$nxobj putslab $dictalias(hmm) [list $point 0 0] [list 1 $dim0 $dim1 ] hmm [SplitReply [hmm_start]] $histo_length [SplitReply [hmm_bank]]
|
|
put_polar_angle $nxobj $point $dim0 $dim1;
|
|
#TODO replace scandata with generic name
|
|
$nxobj makelink scandata hmcounts
|
|
$nxobj makelink scanhoraxis [SplitReply [_hmm_hor_axis_alias]]
|
|
$nxobj makelink scanvertaxis [SplitReply [_hmm_vert_axis_alias]]
|
|
$nxobj putattribute [SplitReply [_hmm_vert_axis_alias]] axis 2;
|
|
$nxobj putattribute [SplitReply [_hmm_hor_axis_alias]] axis 3;
|
|
}
|
|
|
|
proc hmm_addnxscanentry {nxobj entryname point scanVariable scanVarPos scanVarStep start_time} {
|
|
global dictalias;
|
|
set hor_axis [SplitReply [_hmm_hor_axis]]
|
|
set vert_axis [SplitReply [_hmm_vert_axis]]
|
|
|
|
$nxobj puttext estart $start_time;
|
|
$nxobj putattribute program_name run_mode hmscan
|
|
nxscript_data clear;
|
|
nxscript_data putint 0 $point;
|
|
$nxobj putslab erun [list $point] [list 1] nxscript_data;
|
|
hmm_save $nxobj $entryname $point;
|
|
fillPath $nxobj $scanVariable;
|
|
$nxobj makelink scanvar $dictalias($scanVariable);
|
|
$nxobj putattribute $dictalias($scanVariable) axis 1;
|
|
$nxobj putattribute hmcounts signal 1;
|
|
$nxobj putattribute hmcounts axes $scanVariable:$vert_axis:$hor_axis;
|
|
$nxobj puttext eend [sicstime];
|
|
}
|
|
|
|
proc bm_save {nxobj entryname point} {
|
|
global dradius ndect angsep;
|
|
# $nxobj updatedictvar scan_variable $scanVariable;
|
|
putcommon $nxobj $entryname $point
|
|
putcrystal $nxobj
|
|
putmonitor $nxobj $point
|
|
putsample $nxobj
|
|
$nxobj puttext dlayout point
|
|
#TODO replace scandata with generic name
|
|
$nxobj makelink scandata bmcounts
|
|
}
|
|
|
|
proc bm_addnxscanentry {nxobj entryname point scanVariable scanVarPos scanVarStep start_time} {
|
|
global dictalias;
|
|
|
|
$nxobj puttext estart $start_time;
|
|
$nxobj putattribute program_name run_mode bmonscan
|
|
nxscript_data clear;
|
|
nxscript_data putint 0 $point;
|
|
$nxobj putslab erun [list $point] [list 1] nxscript_data;
|
|
bm_save $nxobj $entryname $point;
|
|
fillPath $nxobj $scanVariable;
|
|
$nxobj makelink scanvar $dictalias($scanVariable);
|
|
$nxobj putattribute $dictalias($scanVariable) axis 1;
|
|
$nxobj putattribute bmcounts signal 1;
|
|
$nxobj putattribute bmcounts axes $scanVariable;
|
|
#TODO add dtype ddesc
|
|
$nxobj puttext eend [sicstime];
|
|
}
|
|
|
|
proc putmonitor {nxobj point} {
|
|
$nxobj puttext mmode [string trim [lindex [split [bm getmode] =] 1]]
|
|
$nxobj putfloat mpreset [string trim [lindex [split [bm getpreset] =] 1]]
|
|
# $nxobj putint mdata [string trim [lindex [split [bm getcounts] =] 1]]
|
|
nxscript_data clear
|
|
nxscript_data putfloat 0 [SplitReply [bm getcounts]]
|
|
$nxobj putslab bmcounts [list $point] [list 1] nxscript_data
|
|
$nxobj putfloat mdistance [SplitReply [bmon_distance]]
|
|
}
|
|
|
|
proc put_det_haxis_arr {nxobj dim1} {
|
|
set det_radius_mm [SplitReply [detector_radius_mm]]
|
|
set det_angle_rad [SplitReply [detector_angle_rad]]
|
|
set angsep [expr $det_angle_rad / ($dim1-1)]
|
|
|
|
for {set i 0} {$i < $dim1} {incr i} {
|
|
set col_index($i) [expr int($i)]
|
|
set xpixel_offset($i) [expr $i*$angsep*$det_radius_mm]
|
|
}
|
|
$nxobj putarray dhaxis xpixel_offset $dim1;
|
|
$nxobj updatedictvar column_index_name [SplitReply [_hmm_hor_channel_name]]
|
|
$nxobj putintarray dcolindex col_index $dim1;
|
|
}
|
|
|
|
proc put_det_vaxis_arr {nxobj dim0} {
|
|
set det_active_height_mm [SplitReply [detector_active_height_mm]]
|
|
set hsep [expr $det_active_height_mm/($dim0-1)]
|
|
set det_zero_row [SplitReply [detector_zero_row] ]
|
|
set det_last_vert_pixel [SplitReply [detector_last_vert_pixel]]
|
|
set row_zero [expr ($dim0 - 1.0)*$det_zero_row/$det_last_vert_pixel]
|
|
|
|
for {set i 0} {$i < $dim0} {incr i} {
|
|
set row_index($i) [expr int($i)]
|
|
set ypixel [expr $det_active_height_mm - ($i+$row_zero)*$hsep]
|
|
set det_ypixel_offset($i) $ypixel
|
|
}
|
|
|
|
$nxobj putarray dvaxis det_ypixel_offset $dim0
|
|
$nxobj updatedictvar row_index_name vertical_channel_number
|
|
$nxobj putintarray drowindex row_index $dim0;
|
|
}
|
|
|
|
proc putsample {nxobj} {
|
|
$nxobj puttext saname [getVal [Sample]]
|
|
}
|
|
proc putcrystal {nxobj} {
|
|
$nxobj puttext ctype [SplitReply [crystal_type]]
|
|
$nxobj putfloat clambda [SplitReply [crystal_wavelength_A]]
|
|
}
|
|
proc putcommon {nxobj entryName point} {
|
|
global nx_content_release_tag nx_content_revision_num;
|
|
$nxobj updatedictvar entryName $entryName
|
|
$nxobj puttext program_name SICS
|
|
$nxobj putattribute program_name sics_release [SplitReply [sics_release]]
|
|
$nxobj putattribute program_name sics_revision [SplitReply [sics_revision_num]]
|
|
$nxobj putattribute program_name nx_content_release $nx_content_release_tag
|
|
$nxobj putattribute program_name nx_content_revision $nx_content_revision_num
|
|
$nxobj puttext etitle [getVal [Title]]
|
|
$nxobj puttext iname [getVal [Instrument]]
|
|
$nxobj puttext username [SplitReply [user]]
|
|
$nxobj puttext useremail [SplitReply [email]]
|
|
$nxobj puttext userphone [SplitReply [phone]]
|
|
|
|
# NXsource
|
|
$nxobj puttext sname OPAL
|
|
$nxobj puttext stype Reactor Neutron Source
|
|
$nxobj puttext sprobe Neutron
|
|
putsamplemotors $nxobj $point
|
|
putslitmotors $nxobj $point
|
|
putmonomotors $nxobj $point
|
|
}
|
|
|
|
# This should be called before making a link to a dataset
|
|
# via a value in the dictalias hash.
|
|
proc fillPath {nxobj sobj} {
|
|
set otype [SplitReply [sicslist $sobj type]];
|
|
if {$otype == "Motor"} {
|
|
fillMotPath $nxobj $sobj;
|
|
}
|
|
}
|
|
|
|
proc fillMotPath {nxobj motor} {
|
|
$nxobj updatedictvar mot_name $motor;
|
|
$nxobj updatedictvar mot_long_name [SplitReply [$motor long_name]];
|
|
$nxobj updatedictvar mot_units [SplitReply [$motor units]];
|
|
}
|
|
|
|
proc putsamplemotors {nxobj point} {
|
|
global dictalias;
|
|
|
|
foreach motor { som schi sphi sx sy stth } {
|
|
fillMotPath $nxobj $motor;
|
|
set dictalias($motor) nxsample_mot
|
|
nxscript_data clear;
|
|
nxscript_data putfloat 0 [getVal [$motor] ];
|
|
$nxobj putslab $dictalias($motor) [list $point] [list 1] nxscript_data;
|
|
}
|
|
# sth is a virtual motor
|
|
nxscript_data clear
|
|
nxscript_data putfloat 0 [getVal [sth ]]
|
|
set dictalias(sth) sth
|
|
$nxobj putslab $dictalias(sth) [list $point] [list 1] nxscript_data;
|
|
}
|
|
|
|
proc putmonomotors {nxobj point} {
|
|
global dictalias;
|
|
|
|
set instrument [SplitReply [instrument]]
|
|
|
|
if {$instrument == "echidna"} {
|
|
set extra_mots [list pcx pcr]
|
|
} elseif {$instrument == "wombat"} {
|
|
set extra_mots [list oct mf2]
|
|
}
|
|
foreach motor " mom mchi mphi mx my mtth $extra_mots" {
|
|
fillMotPath $nxobj $motor;
|
|
set dictalias($motor) nxcrystal_mot
|
|
nxscript_data clear
|
|
nxscript_data putfloat 0 [getVal [$motor] ]
|
|
$nxobj putslab $dictalias($motor) [list $point] [list 1] nxscript_data;
|
|
}
|
|
# mth is a virtual motor
|
|
nxscript_data clear
|
|
nxscript_data putfloat 0 [getVal [mth ]]
|
|
set dictalias(mth) mth
|
|
$nxobj putslab $dictalias(mth) [list $point] [list 1] nxscript_data;
|
|
}
|
|
|
|
proc putslitmotors {nxobj point} {
|
|
global dictalias;
|
|
|
|
foreach motor {ss1u ss1d ss1l ss1r ss2u ss2d ss2l ss2r } {
|
|
fillMotPath $nxobj $motor;
|
|
set dictalias($motor) nxfilter_mot
|
|
nxscript_data clear
|
|
nxscript_data putfloat 0 [getVal [$motor] ]
|
|
$nxobj putslab $dictalias($motor) [list $point] [list 1] nxscript_data;
|
|
}
|
|
foreach motor {ss1vg ss1vo ss1hg ss1ho ss2vg ss2vo ss2hg ss2ho } {
|
|
set dictalias($motor) $motor
|
|
nxscript_data clear
|
|
nxscript_data putfloat 0 [getVal [$motor] ]
|
|
$nxobj putslab $dictalias($motor) [list $point] [list 1] nxscript_data;
|
|
}
|
|
}
|
|
|
|
publish nxcreatefile user
|
|
publish addnxscanentry user
|
|
publish bm_addnxscanentry user
|
|
|