Available commands below can be combined with virtually any Perl-code. (actual path to Hrpt-library is /afs/psi.ch/user/p/pomjakushin/perl/lib/Hrpt/) can be used from `hix' (sics interactive client) or from xbu-scrips run by hxbu command. #---------------------- # # top level commands to be used mainly in # xbu-scripts # #---------------------- # English-like commands. See the description of # the original short commands below. # sub sample_changer {hs_sch @_ } sub lambda {hs_lambda @_} sub resolution {hs_resol @_} sub sample_rotation {hsarot @_ } sub time_per_sweep {psweep @_ } sub sinq_current {psinq @_ } sub set_sweep_range {hs_sweep @_} sub hrpt_count {hcount @_ } sub beam_reduction_info {br_info @_ } sub beam_reduction_horizontal {brhoriz @_ } sub beam_reduction_vertical {brvert @_ } sub beam_reduction_top {brtop @_ } sub beam_reduction_bottom {brbot @_ } sub beam_reduction_vertical_slit {brv_slit @_} sub hs_sch; # select sample changer 'rt', 'lt', or 'lt5' and optinally second arg that overrides # p1 for the given sch. # drives stx, sty to the defaults for given sch and set the globals $Stx,y sub hsarot; # 'on'/'off' Sample rotation. sub hd_stxy; # drives both to arg1,arg2 of and set them to default globals $Stx $Sty # or drives to default if no args given... sub hs_lambda; # drive lambda to arg in Angstrems # possible choices (in quotes): '1p15' '1p49' '1p89' '2p45d' # or just numbers, like 0.8 1.0 1.15 1.5 1.9 2.5 # e.g hs_lambda '1p89' # or equivalent hs_lambda 1.9 # or equivalent hs_lambda 1.89 # use it witout agrs to see allposible choices sub hs_resol; # drive resolution to arg # possible choice: HI MR sub hcount; # main count command can have up to five arguments # one can jump to the example section below instead of reading the # explanations... # arguments are: $Stats, $Titsam, $Sample_no, $Tem, $Twait # 1. $Stats # -> no. of sweeps. It can be negative and fractional, see below. # Sweep represents several measurements at the same experimental conditions, but with # slightly different starting 2theta position of the detector. Time of one sweep is # 1/2 hour by default and can be tuned by psweep and psinq commands described below.* # 2. $Titsam = (shift or 'title_not_set'); # title and optional sample if there are spaces. The last word goes to # sample name # for example 'title_bla' will set title to title_bla, sample name will be # set automatically # 'title,bla blah H2O' will set title to 'title,bla_blah_H2O', # sample to 'H2O' # The meaning of the next arguments depends on context. # 3. $Sample_no # only in case is the changer was set by hs_sch # command, otherwise it is assumed to be # temperature. See below. # 4. $Tem # 5. $Twait # 4th arg is temperature, which can be # 100 '100 K' '100 C' or '100C' or any string # if NO sample changer is set, it is assumed that $Sample_no (3rd arg) # is temperature. If this arg cannot be interpreted as the above temperature, # (e.g. 'blah') T is not set, but title string will have T=blah # $Twait can be 120: waits 120s after temperature is in default tolerance or # '120 2': in addition overrides tolerance to 2 # "negative" statistics e.g. -10 # should start count immediately and finish either when $Tem is reached in tolerance # given in this command or after $Stat sweeps. # # -------------------------------------------- # Examples: # hcount 2,"NAC6_in_ILL3"; # will count 2 sweeps, T not set # one standard sweep is 1/2 hour, but can be changed by # psweep command explained below # hcount 10,"NAC6_in_ILL3",2; # will count 10 sweeps, at T=2K with default tolerance # hcount 10,"NAC6_in_ILL3",'2C'; # will count 10 sweeps, at T=2C with default tolerance # hcount 10,"NAC6_in_ILL3",'200K','600 5'; # will count 10 sweeps, after T=200K is reached within # tolerance 5K and waiting for 600 seconds # hcount 10,"NAC6_in_ILL3",'RT'; # will count 10 sweeps,T not set, but title string will have T=RT # if sample changer is set. For instance as: hs_sch 'lt5'; # hcount 10,"NAC6_in_ORI4",2; # will count 10 sweeps, sample number 2, T not set # hcount 10,"NAC6",2,100; # will count 10 sweeps, sample number 2, at T=100K # hcount 10,"TmMnO3", 3, 200,'600 5'; # drives to sample no.3, drives T to 200K within # tolerance 5K, waits 600 seconds and # count 10 sweeps # hcount 0,0,2; # drives to sample no.2 and returns without counting # # -------------------------------------------- # * Technical info about Neutron Monitor Preset logics: # Neutron monitor for the swep is taken from $Presets{$Lambda . $Resol} # if lambda & resolution are set, so the variables $Lambda & $Resol are defined # the $Preset will be ovewritten by the global hash $Presets{$Lambda . $Resol} # provided that it is non-empty. Simplest way to have non-standard different preset # (though this is not recommended) is # $Presets{'1p89HI'}=7200; # explicitly or # $Presets{$Lambda . $Resol}=7200; # for the current mode whatever it is... sub use_new_psweep; # since 26 Oct 2018: a new logic of the # psinq, psweep, hs_sweep # much better when all three commands are used in different order. sub psinq; # recalculate presets for NM # to the SINQ current $arg # from the values in Tables @ 1480 uA # so each sweep is == 1/2h # e.g. psinq 1520; # will renormalise presets for all modes defined in Tables.pm # to new current 1520uA, so all sweeps -> 1/2h sub round_presets; # will round all neunron monitor presets to have # two zeros at the end sub psweep; # set sweep duration in hours # in new logic acceps argument in h[ours] # m[[in]utes] and s[[ec]onds] d[ays] # For example: # psinq 1520; # all sweeps 1/2 hour for I=1520uA # psweep 2; # all sweeps 2 hours # psweep '30m' # psweep '2hours' # psweep '1day' # psweep; # just print info about presets, etc. # psinq; # just print info # psinq 1300; # all sweeps 1/2 hour for I=1300uA sub hs_sweep; # restores A4_? for sweep if no args # or set the new values # step, A4_1, A4_2 # e.g. hs_sweep (0.15, 3.95, 5.01); # will count at => (3.95, 4.1, 4.25, 4.4, 4.55, 4.7, 4.85, 5) # sweep is: for (my $a4 = $A4_1; $a4 < $A4_2; $a4 += $A4_s) # Default values # our $A4_s = 0.15; # our $A4_1 = 3.55; # our $A4_2 = 4.61; # our $A4_0 = $A4_1 - $A4_s; # => (3.55, 3.7, 3.85, 4, 4.15, 4.3, 4.45, 4.6) # # if used after use_new_psweep # accepts the following alternative parameter format # '=A4_1,step,number_of_positions' or # 'sweep=A4_1,step,number_of_positions' # e.g. hs_sweep '=3,0.1,10' # e.g. hs_sweep 'sweep=3,0.1,10' sub tt; # drive temperature. Temperature can be 100 '100 K' '100 C' or '100C' # if second parameter is specified, e.g tt 100,1; drives to 100K, but # do not block the execution, i.e. immediatly goes to the next command. sub tramp; # set temperature ramp in K/minute. tramp 0; - removes the ramp sub ttol; # set temperature tolerance sub tdbl; # set (1), or remove (0) double control. sub hsms; # sends SMS to the phone number, with message as a second # argument. For example: # hsms '+41769999999', 'some texts'; # or in combination with some other commands # 1. shell command lastnum: # $out=`lastnum`; hsms '+41769999999', "Last measured number is $out"; # 2. any library/perl command: # $out=tt; hsms '+41769999999', "Last actual temperature was $out"; sub hmail # sends email to the address, with message as a second # argument, similar to hsms. For example: # hmail 'some.one@psi.ch',"It is time to refill Helium"; # $out=`hlog -100`; hmail 'some.one@psi.ch',"Log file of last 100 numors: $out"; sub hs_tt; # setup different temperature related parameters for ORI4, # like ramp to 0, etc... # sics ' # tt tm/alarm 325 # tt ts/alarm 325 # tt set/limit 320 # tt set/ramp 0 # tt set/maxpower 1000 # cc hh 95 # cc hl 5 # nv set 2.3 # nv 2 # nv flowmax 20 # tt dblctrl 1'; sub hinit; # simple init to 1.9HI, beam reduction br to 50x15 sub hstrobo; # set both hrptdaq and hrpt banana parameters of stroboscopic # mode. # usage: hstrobo tmax, tbin, # time in milliseconds, e.g: # hstrobo 10000,20 # 10seconds chopped by 20ms # # the SICS server should be switched to stroboscopic mode by # command `hs_banana 1' sub hs_banana; # hs_banana 1/0 # strobo/non-strobo # set SICS server in respective mode sub restart_sics; # restart SICS server: First stopps and observes the status, # then start again and wait until the server is running hsave_data_hdf # saves HRPT hdf-data file without stopping the current # data acquisition # usage: # hsave_data_hdf # e.g. hsave_data_hdf 'first_cycle_' # the title will be prepended to the existent title # if no title is given a default title will be added: on_fly_[timestamp] #---------------------- # # Commands related to beam reduction br. # #---------------------- sub br_info; # Current positions of beam reductions and slit parameters with respect to # beam center sub brv_info; # Current positions of vertical br and slit with respect to # beam center sub brh_info; # Current positions of horizontal br and slit with respect to # beam center sub brtop; # my $wdt = shift or return; # open top slit $wdt mm from the beam center # brbo: open 0, sym closed -27, better -26 # brto open 0, sym closed -33, better -32 # limits for brtop: -10.5 mm < brtop < 33.5 mm. sub brbot; # my $wdt = shift or return; # open bottom slit $wdt mm from the beam center # limits for brbot setpoints: -20.5 mm < brbot < 27.5 mm, corresponding to the # final absolute brbot slit positions -27.5 mm < brtop < 20.5 mm, sub brvert; # my $wdt = shift or return; # open vertical slit symmetrically. # minimal vertical slit opening is 2 mm. # maximal (symmetric) vertical slit opening is 54.9 mm. sub brv_slit; # opens vertically at position $p with width $w or 5 # + is up # minimal vert. slit at any position -11.5 <$p < 21.5 from center is 2 mm. # maximal (asymmetric) vertical slit opening is 61 mm, mith middle $p at +3 mm. sub brlef; # my $wdt = shift or return; # open left slit $wdt mm from the beam center # possible values for brlef: -2.04 mm < brlef < 13.45 mm. sub brrig; # my $wdt = shift or return; # open right slit $wdt mm from the beam center # possible values for brrig: -3.64 mm < brrig < 10.95 mm. sub brhoriz; # my $wdt = shift or return; # open horiz slit symmetrically # minimal horizontal slit opening is 0.8 mm. # maximal (symmetric) horizontal slit opening is 21.9 mm. sub brh_slit; # opens vertically at position $p with width $w or 5 # + is right # minimal horiz slit opening at any position -4 < $p < 2.4 from center is 0.8 mm. # maximal (asymmetric) horiz slit opening is 24.4 mm, mith middle $p at -1.3 mm. sub br_init; # special init for beam reduction br. # should be used if really needed. # Usage of br_init should possibly be avoided! #---------------------- # # lower level commands. # #---------------------- sub sics; # execute six command(s) and return the output. # For example: # sics 'a4 list'; # or several commands are possible # sics ' # temperature ramp 0 # a4 list # bla-bla # ...'; # sub tt; # drivet temperature to 1st arg within default tolerance. # Format of temperature is the same as for # hcount command. If second argument is present the tolerance # is ignored sub count; # execute six count with argument e.g. 'timer 10', and return the output. sub hsweep; # measure one sweep sub hd_mode; # drives motors given by $arg1 and $arg2{arg1} # e.g. hd_mode($lambda, \%Lambdas); sub hd_sch; # drive sch to argument or to global $Sample_no # my $sample_no = ( shift or $Sample_no); #---------------------- # # Commands related to counter box el737 # #---------------------- sub hs_thres # set threshold to arg, e.g. hs_thres 10; or hs_thres 0; sub hgetpreset; # calculate preset for NM # for given lambda and resolution # updates the $Presets{$mod} if the last parameter is 1 # my $lam = shift; # my $res = shift; # my $setp = shift; sub hs_presets; # calculate presets for NM # for all possible sets of lambda and resol # and updates the global %Presets # if an argument $arg is given normalise the presets # to the SINQ current $arg # $Psinq is the default current for %Presets table sub hs_preset; # calculate presets for NM # for given lambda, resol # and updates the global %Presets # if an argument $arg is given normalise the presets # to the SINQ current $arg sub hscan; # # scans the motor or virtual motor 0 with the argument listed below # and returns n-, p-monitors and acquasition time. Uses only counter box # to count. # Also writes in the file hrpt_mot.log: motor_value n-/p-monitor errbar # can be on-line viewed with command on linux-prompt hplot.pl hrpt_mot.log # my $mot = shift; # my $range = shift or return; # my ($f, $t, $s) = split '\s+', $range; # from to step # my $stat = (shift or 10); # 10 seconds by default # my $mod =(shift or 'timer'); # example: hscan a3,'-5 5 0.2' # hscan 0,'1 100 1' sub hcbox; # will work ONLY if counterbox is not in run state # uses devexec fource... Should be used carefully # my $mon = (shift or 10); # my $mod = (shift or 'timer'); sub hsinq; # returns array of accumulated sinq rate in uA # and current rate if arguments is given, which specifies # time interval to measure in seconds. # the command does not start/stop counter box, but # uses the running values. #---------------------- # # misc commands. # #---------------------- sub hs_slim; # general: set softlim for motor e.g. a4,1,5 sub hs_stxy; # set stxy soft limits... obsolete # set softlim for motor stx, sty/ or print the current values sub lt5_pos #position the stxy defined at a3=0 to the values in the #rotated CS. #args: x,y,angle sub hhelp; sub hmotors_values; # prints actual values for all the motors # and their last target positions from sics backup of 2015 #---------------------- # # direct access to EL734 controller and some other motor related stuff # all should be called with prefix Hrpt::Exe:: # use these commands only if you know what you do... # #---------------------- sub hmotors_list; # list all el734 motors in sics and controller # notations sub hmotors_direct; # perform the command to the controller # for motor,key,value # if key is not specified then 'p' command is used # which prints the last target value # for example # Hrpt::Exe::hmotors_direct 'moml' # Hrpt::Exe::hmotors_direct 'moml','h' #--> prints hardware limits # Hrpt::Exe::hmotors_direct 'chpos','h','-1000 1000' #--> sets hardware limits # Hrpt::Exe::hmotors_direct 'chpos','u' #--> prints actual value # Hrpt::Exe::hmotors_direct 'mtvu','u', 0 #--> sets actual value to 0 (v recalculated) # Hrpt::Exe::hmotors_direct 'mtvu','uu', 0 #--> sets actual value to 0 (v unchanged) # to view the table with controller commands say on linux prompt xpdf /afs/psi.ch/user/p/pomjakushin/perl/lib/Hrpt//el734.pdf sub hmotors_allparam; # prints all (useful) parameters for all motors in # EL734. If used with arg looks for regex, e.g. '...l' # will do the job for all lower position monochromator # motors sub hmotors_msr; # prints and interprets status register msr for the motor # given as arg #---------------------- # # some globals see Hrpt::Tables.pm for info # #---------------------- # hcount and default choice of mode our $Preset=20; our $CounterMode = 'timer'; our $CounterMode = 'monitor'; # no defaults our $Lambda='1p89?'; our $Lambda=''; our $Resol ='HI?'; our $Resol =''; #Table of updated presets for neutron monitor #-------------------------------------------- # hs_presets 1480 # , actual SINQ current was 1485.8 %Presets = ( '1p89HI' => '454223', '1p49HI' => '360199', '2p45MR' => '202441', '1p15HI' => '222232', '2p45cMR' => '43255', '1p15MR' => '70343', '1p49MR' => '121789', '2p45HI' => '787038', '2p45cHI' => '157971', '1p89MR' => '133456' ); # sweep counting related # Default values our $A4_s = 0.15; our $A4_1 = 3.55; our $A4_2 = 4.61; our $A4_0 = $A4_1 - $A4_s; # will count at => (3.55, 3.7, 3.85, 4, 4.15, 4.3, 4.45, 4.6) # hs_sweep() # restores A4_? for sweep if no args # or set the new values # e.g. hs_sweep (0.15, 3.95, 5.01); # will count at => (3.95, 4.1, 4.25, 4.4, 4.55, 4.7, 4.85, 5) # sweep is: for (my $a4 = $A4_1; $a4 < $A4_2; $a4 += $A4_s) #------------------------- # # lowest level calls to hrpt sics server # #------------------------- sub hx; # main sics exe-command, second arg 1/0. If 1 returns all at once and # suppress some debug output sub hxw; # The above hx, but with wait, to avoid boring trailing ,1... sub hxx; # alternative socket exec sub hxxa; # alternative socket exec non blocking sub hxa; # an old one. Does not wait/block sub hx2; # something old with BUSY issue sub hr; # main read from sics. Blocks sub hr2; # an old one. Kind of async sub hd; # drive command within tolerance. # Expects e.g. 'chpos -300',0.05. if second arg is 0, no checks # return the final motor value sub hds; # asymmetric drive, similar to the above command sub hdp; # drive with predrive within tolerance, if within return # "a4 3",[predrive shift, tolerance] sub hmv; # get motor/parameter value sub hint_sics; # setup the reaction on SIGINT # ^C or kill -KILL PID # with 'all' stops sics and dies # with 'exec' stops sics and continues # with no arg, restorts the default sub hstop_count; sub hstop_all; # main stop all execution in SICS and dies # presently binded with sigint, default sub hstop_exec; # stop all execution in SICS and continue sub open_h; sub close_h; #---------------- # daq related Hrpt::Six #---------------- sub set_th ; # std 802.38mV # set threshold in DAQ in mV to arg or to 802.38mV if no arg is given sub scan_th; # count PHS # scan_th 7200, 150, 25, 'el_noise_and_cosmic'; # my ($mon, $min_th, $step_th, $tit) = @_; # for ($thh=$min_th; $thh<2380; $thh += $step_th) sub scan_thd;# count PHS down by threshold # scan_thd 7200, 2380, 25, 'el_noise_and_cosmic'; # my ($mon, $max_th, $step_th) = @_; # for ($thh=$max_th; $thh>150; $thh -= $step_th) -- V. Pomjakushin, 2016