TikiWiki Assistant Thank you for installing TikiWiki!
Click the :: options in the Menu for more options. Please, also see TikiMovies for more setup details. |
History: GEnSpecialEventsSource of version: 2-=How scripts are launched=-
^Here is quote from Bob Michaels: All the scripts except __epicsRunEnd__ are launched at the __start of a run__ by __~a-onl/scripts/getruninfo__ (which in turn calls __getruninfo_bgr__, a background process, done that way to avoid hanging up CODA). The script epicsRunEnd is called at the end of a run. The scripts are specified in the CODA database, and are called automatically (presumably by a system call but I never checked this) by CODA during the afore- mentioned transitions.^ -=Tree of scripts/executables launched by CODA=- * __~a-onl/scripts/getruninfo__ ** __~a-onl/scripts/getruninfo_bgr__ *** __~a-onl/scripts/ThresGenLog__ -- inserts thresholds as event type 135 *** __~a-onl/scripts/fileToEvent__ ''prescale.dat'' as event type 133 *** __~a-onl/scripts/HVgenlogger__ -- inserts high Voltages readout from ))BigHand(( and ))BigBite(( inserts them as event type 134 **** __~a-onl/scripts/get_hvs__ -- read information from particular detector ***** __~adev/slowc/scripts/hv_proc.com__ -- script interface to the hvcli executable ****** __~adev/slowc/hvg/hvcli__ -- executable to read data from ))LeCroy(( 1458 High Voltage mainframe *** __~a-onl/scripts/epicsRunStart__ -- inserts start of run information??? *** __~a-onl/scripts/getscaler__ -- inserts scaler data as event type 140 every 8 seconds *** __~a-onl/scripts/fastEpicsLogger__ -- script to insert epics variables as event type 131 every 4 second *** __~a-onl/scripts/epicsLogger__ -- script to insert epics variables as event type 131 every 30 second * __~a-onl/scripts/epicsRunEnd__ -- inserts end of run information -=getruninfo=- Start getruninfo_bgr as background process to avoid hang of CODA. {CODE()}#!/bin/ksh SCRIPT_DIR=/adaqfs/halla/a-onl/scripts $SCRIPT_DIR/getruninfo_bgr & exit 0{CODE} -=getruninfo_bgr=- Script manager to clean up old run, set up new run and start taking specially inserted event types. {CODE()} #!/bin/ksh SCRIPT_DIR=/adaqfs/halla/a-onl/scripts DETMAP_DIR=/adaqfs/halla/a-onl/detmap PRESCALE_DIR=/adaqfs/halla/a-onl/prescale EPICS_DIR=/adaqfs/halla/a-onl/epics RUNNUMBER_FILE=/adaqfs/halla/a-onl/datafile/rcRunNumber TRIGGER_FILE=/adaqfs/halla/atrig/trigger/trigger.setup STRIP_CLEAR=/adaqfs/halla/adaq/$EXPERIMENT/scaler/clear.ctl # # Run number - needed by mss storage script let num=$(eval /adaqfs/halla/a-onl/scripts/getrunnumber) echo "$num" > $RUNNUMBER_FILE # if [ -e $STRIP_CLEAR ] ; then echo "1" > $STRIP_CLEAR fi # $SCRIPT_DIR/linkassn > /dev/null 2> /dev/null & # # reenable scalers if last run died $SCRIPT_DIR/clevclr_bb # # first clean up from previous run (if necessary) $SCRIPT_DIR/end_clean # # This silly script may solve the end-run "hanging caget" problem $SCRIPT_DIR/startLooper # # start ET server (unless already running) $SCRIPT_DIR/startETserver # # Insert various files #$SCRIPT_DIR/fileToEvent $DETMAP_DIR/detmap.config 135 # Write GEN thresholds to event 135 $SCRIPT_DIR/ThresGenLog > /dev/null 2> /dev/null & # $SCRIPT_DIR/fileToEvent $PRESCALE_DIR/prescale.dat 133 # # write GEN HV to event 134 $SCRIPT_DIR/HVgenlogger > /dev/null 2> /dev/null & # # $SCRIPT_DIR/fileToEvent $TRIGGER_FILE 136 # # Charge asymmetry feedback # To enable/disable type "feedback on" or "feedback off". # (COMMENT OUT FOR NOW)/adaqfs/home/adaq/qasy/feedback/start_feedback # # Start-of-Run EPICS info to /adaqfs/halla/a-onl/epics/runfiles/Start_of_Run_NNN.epics $SCRIPT_DIR/epicsRunStart & # # Launch the scaler and EPICS loggers $SCRIPT_DIR/getscaler & $SCRIPT_DIR/epicsLogger & $SCRIPT_DIR/fastEpicsLogger & # # exit 0 {CODE} -=ThresGenLog=- This script will use ~a-onl/scripts/threshold-gen to obtain the threshold values of ))BigHand((, ))BigBite(( Preshower and Shower detectors. And using ~a-onl/scripts/fileToEvent executable to insert obtained information into data stream as event type 135. {CODE()}#!/bin/ksh # log() { # debug echo - send it to /dev/null when not needed echo $* >> $thresfile if [ ! -z "$PS1" ] ; then echo $* ; fi } # thresfile=$HOME/epics/thres.dat /bin/rm -f $thresfile log "Neutron arm threshold: "`/adaqfs/home/a-onl/scripts/threshold-gen get 0 | gawk '{print $1}` log "BigBite Preshower threshold: "`/adaqfs/home/a-onl/scripts/threshold-gen get 1 | gawk '{print $1}` log "BigBite TotalShower threshold: "`/adaqfs/home/a-onl/scripts/threshold-gen get 2 | gawk '{print $1}` $HOME/scripts/fileToEvent $thresfile 135 {CODE} -=fileToEvent=- This is executable which read file and inserts into data stream as event type specified on command line. Usage:{CODE()}fileToEvent <filename> <evtype>{CODE} -=HVgenlogger=- {CODE()}#!/bin/ksh # SCRIPTS=$HOME/scripts EPICS_DIR=/adaqfs/halla/a-onl/epics $SCRIPTS/get_hvs NA > $EPICS_DIR/gen_NA_hv.dat 2> /dev/null $SCRIPTS/get_hvs BB > $EPICS_DIR/gen_BB_hv.dat 2> /dev/null $SCRIPTS/fileToEvent $EPICS_DIR/gen_NA_hv.dat 134 $SCRIPTS/fileToEvent $EPICS_DIR/gen_BB_hv.dat 134 {CODE} -=get_hvs=- {CODE()}#!/bin/bash # #--- To be included in CODA start of run etc... #-- Get the HV parameters from the "hvs" server # PROG=`basename $0` # echo Start $PROG if [ $# -ne 1 ] ; then echo " ***" Error in $PROG: "one call parameter (NA,BB,...) is needed" help_dis exit 2 fi HVG=/adaqfs/home/adev/bin/hv_proc.com if ! test -x $HVG ; then echo " ***" Error in $PROG: binary $HVG is not found help_dis exit 2 fi det=XX tst=0 hlp=0 pid=$PPID declare -a ftmp i=0 ; while let $((i++)); [ $i -lt 3 ]; do ftmp[$i]=hv2coda.$i.$pid.tmp done # ========== Help routine start help_dis () { cat <<help_doc $PROG - a script to get HV parameters from the "hvs" server (in order to paste it into the CODA stream) Call parameters: $PROG detec where: detec - detector name ( BB, NA) -? or ? or -h print this help default: none Example: $PROG NA Example: $PROG BB help_doc } # ========== Help routine end # ========== Exit routine exit_proc () { i=0 ; while let $((i++)); [ $i -lt 3 ]; do fn=${ftmp[$i]} [ -f "$fn" ] && rm -f $fn done } # ========== Help routine end if [ "$1" = "?" -o "$1" = "-?" ]; then help_dis exit 2 fi # set -- `getopt htP:D: $*` # if [ $? != 0 ] ; then # echo *** Error in getopt . Usage: # help_dis # exit 2 # fi # for i in $* ; do # case $i in # -t) tst=1 ; shift 1;; # -h) hlp=1 ; shift 1;; # -c) comm=$2 ; shift 2;; # -P) hvpar=$2 ; shift 2;; # -D) detec=$2 ; shift 2;; # --) shift ; break;; # esac # done det=$1 $HVG -D $det -c MAPS 1>${ftmp[1]} 2>${ftmp[2]} if [ $? -ne 0 ]; then cat ${ftmp[2]} exit_proc exit 2 fi for map in `cat ${ftmp[1]} | awk '{print $1}'`; do echo "# Map " $map " Measured Voltage" $HVG -D $map -c GET -P MV if [ $? -ne 0 ]; then echo " Error in information retrieval in $HVS -D $map -c GET -P MV" fi echo "# Map " $map " Measured Current" $HVG -D $map -c GET -P MC if [ $? -ne 0 ]; then echo " Error in information retrieval in $HVS -D $map -c GET -P MC" fi done exit_proc exit 0 {CODE} -=hv_proc.com=- {CODE()}#!/bin/bash # #-- Get the HV parameters from the "hvs" server # PROG=`basename $0` # echo Start $PROG hostserv=XX hostsna=agen hostsbb=agen4 port=5555 detec=XX hvpar=DV chmap=XX tst=0 hlp=0 comm=GET setval=XX fnam=XX HVC=~/slowc/hvg/hvcli if ! test -x $HVC ; then HVC=/adaqfs/home/adev/slowc/hvg/hvcli fi if ! test -x $HVC ; then echo *** Error: binary $HVC is not found help_dis exit 2 fi pid=$PPID declare -a ftmp i=0 ; while let $((i++)); [ $i -lt 6 ]; do ftmp[$i]=hv.$i.$pid.tmp done # ========== Help routine start help_dis () { cat <<help_doc $PROG - a script to get HV parameters from the "hvs" server Call parameters: $PROG -D detec [-c command] -m range [-c command] [-P parameter-to-get] [-H host] [-p port] .... where: -c command (GET or SET or MAPS) default: $comm MAPS: just prints the maps names (-D should be defined, the other parameters are ignored) -P parameter to use : DV, MV, MC, CE default: $hvpar for -c SET the valid parameters are DV, CE -D detector maps default: none NA: NA_ND_L / NA_ND_R / NA_VT_L / NA_VT_R BB: BB_SH / BB_PS_L / BB_PS_R /BB_SC_L / BB_SC_R MO: MO_ALL (Moller) -m colums,rows range, ex: 3,17 or 2:13,7:9 default: none (if not defined - the max size will be taken) -v value to SET (used if no -f declared) default: none -f file name containing lines with "ix iy value" default: none -t test only default: none -H host name where the server is running default: none if not set - tries to find the server by looking the lockfile: a) local home directory, say ~/slowc/HV_??, where ?? is the map name b) ~adev/slowc/HV_?? -p port number default: $port -b client program default: $HVC -? or ? or -h print this help default: none Example: $PROG -c GET -P MV -D NA_ND_L -m 1:4,2:26 Example: $PROG -c GET -P MC -D BB_SH -m 1:7,1:27 Example: $PROG -c MAPS -P MC -D NA_VT_L -m 1:7,1:27 Example: $PROG -c SET -P DV -v -1200 -D NA_ND_L -m 1:7,1:27 Example: $PROG -c SET -P CE -v 1 -D NA_ND_L -m 1:7,1:27 help_doc } # ========== Help routine end # ========== Exit routine exit_proc () { i=0 ; while let $((i++)); [ $i -lt 6 ]; do fn=${ftmp[$i]} [ -f "$fn" ] && rm -f $fn done } # ========== Help routine end if [ "$1" = "?" -o "$1" = "-?" ]; then help_dis exit 1 fi set -- `getopt htP:D:c:v:m:f:H:p: $*` if [ $? != 0 ] ; then echo *** Error in getopt . Usage: help_dis exit 2 fi for i in $* ; do case $i in -t) tst=1 ; shift 1;; -h) hlp=1 ; shift 1;; -c) comm=$2 ; shift 2;; -P) hvpar=$2 ; shift 2;; -D) detec=$2 ; shift 2;; -m) chmap=$2 ; shift 2;; -v) setval=$2 ; shift 2;; -f) fnam=$2 ; shift 2;; -H) hostserv=$2 ; shift 2;; -p) port=$2 ; shift 2;; -b) HVC=$2 ; shift 2;; --) shift ; break;; esac done if [ $hlp -gt 0 ]; then help_dis exit 1 fi if [ ! -x $HVC ]; then echo " *** Error - the HV client program is missing " $HVC exit 2 fi # Get the server name if [ $hostserv == "XX" ]; then ok=0 det=`echo $detec | cut -f1 -d\_` # # -- Try to find a lockfile and learn the server host name # ddet=HV_$det lockf=.lock_hvs_$ddet declare -a lockname lockname[1]=~/slowc/$ddet/$lockf lockname[2]=~adev/slowc/$ddet/$lockf i=0 ; while let $((i++)); [ $ok -eq 0 ] && [ $i -lt 3 ]; do lockfile=${lockname[$i]} if test -f $lockfile ; then hostserv=`cat $lockfile | awk '{print $1}'` ok=1 fi done if [ $ok -ne 0 ]; then echo " -- Found: server hostname " $hostserv " from the lockfile " $lockfile 1>&2 else echo " *** Error - hostname for the server (-H) is not defined, and no local lockfile was found " i=0 ; while let $((i++)); [ $i -lt 3 ]; do echo " *** not found " ${lockname[$i]} done echo " *** Error - HV server host is unknown " help_dis exit 2 fi fi ok=0 for i in GET get SET set MAPS maps ; do [ $comm == $i ] && ok=1 done if [ $ok -eq 0 ]; then echo " *** Error - server command -c "$comm " is unknown " help_dis exit 2 fi # Just print the maps if [ "$comm" == "MAPS" ]; then $HVC -h $hostserv -p $port -m 'get maplist' | sed s"/^C/ /" exit 0 fi # Is the HV frame command valid? ok=0 j=0 for i in DV CE MV MC ; do let $((j++)) if [ "$hvpar" == "$i" ]; then [ "$j" -le 2 ] || [ "$comm" == "GET" ] && ok=1 fi done if [ $ok -eq 0 ]; then echo " *** Error - Wrong combination -c "$comm " and -P "$hvpar help_dis exit 2 fi if [ "$comm" == "SET" ]; then if [ "$fnam" == "XX" ]; then if [ "$setval" == "XX" ]; then echo " *** Error - for the SET operation -c "$comm " the value -c ..., of file -f ... should be defined" help_dis exit 2 fi else if [ ! -s "$fnam" ]; then echo " *** Error - for the SET operation -c "$comm " filename set -f "$fnam " is missing" help_dis exit 2 fi fi fi # echo $hvpar " " $detec " " $chmap " " $hostserv " " $port $HVC -h $hostserv -p $port -m 'get maplist' > ${ftmp[1]} # cp tmptmp ${ftmp[1]} # test head -1 ${ftmp[1]} | grep -i error >/dev/null ; ok=$? if [ $ok -eq 0 ]; then echo " *** Server at host " $hostserv " is not properly responding" exit_proc exit 2 fi lin=`cat ${ftmp[1]} | sed s"/^C/ /" | awk -v t=$detec ' $1 ~ t {print $2" "$3" "$4" "$5}'` nw=`echo $lin | wc -w` if [ $nw -lt 4 ]; then echo " *** Map name "$detec " is missing or not properly set in the server list :" echo $lin cat ${ftmp[1]} exit_proc exit 2 fi # --- Check the detector map if [ $chmap == "XX" ]; then # Get the map chmap=`echo $lin | awk '{k1=$3-1+$1;k2=$4-1+$2;print $3":"k1","$4":"k2}'` fi if [ "$comm" == "SET" ]; then $HVC -h $hostserv -p $port -m "$detec $comm $hvpar $chmap $setval" exit_proc exit 0 fi # comm=GET $HVC -h $hostserv -p $port -m "$detec $comm $hvpar $chmap" | sed s"/^C/ /" | sed s'/\*/\&/'g > ${ftmp[2]} # $HVC -h $hostserv -p $port -m "$detec $comm $hvpar $chmap" # | sed s"/^C/ /" # echo $HVC -h $hostserv -p $port -m "$detec $comm $hvpar $chmap" # | sed s"/^C/ /" head -1 ${ftmp[2]} | grep -i error >/dev/null ; ok=$? if [ $ok -eq 0 ]; then echo " *** Error in the HV server response:" cat ${ftmp[2]} exit_proc exit 1 fi aa=`echo $chmap | cut -d, -f1` echo $aa | grep '\:' > /dev/null ; onenmb=$? if [ "$onenmb" -eq 1 ]; then ix1=$aa nx=1 ix2=$ix1 else ix1=`echo $aa | cut -d: -f1` ix2=`echo $aa | cut -d: -f2` nx=$((ix2-ix1+1)) fi aa=`echo $chmap | cut -d, -f2` echo $aa | grep '\:' > /dev/null ; onenmb=$? if [ "$onenmb" -eq 1 ]; then iy1=$aa ny=1 iy2=$iy1 else iy1=`echo $aa | cut -d: -f1` iy2=`echo $aa | cut -d: -f2` ny=$((iy2-iy1+1)) fi # echo $nx" "$ix1" "$ix2 # echo $ny" "$iy1" "$iy2 iy=$iy1 ix=$ix1 newl=1 nw=`cat ${ftmp[2]} | wc -w` for i in `cat ${ftmp[2]}`; do # [ "$iy" -eq "$iy1" ] && printf " %3d " $iy # [ "$ix" -eq "$ix1" ] && printf " %3d " $iy if [ "$ny" -gt 1 -a "$newl" -eq 1 ]; then printf "%3d : " $iy newl=0 fi if [ "$i" == "&&&" ]; then printf " XXX " else printf "%6.0f " "$i" fi let $((ix++)) if [ "$ix" -gt "$ix2" ]; then let $((iy++)) ix=$ix1 printf "\n" newl=1 fi done exit_proc exit 0 {CODE} -=epicsRunStart=- {CODE()}{CODE} -=getscaler=- Uses __~a-onl/scaler/gen/onl/scread__ executable to read out scaller and insert every 8 seconds into data stream. {CODE()}#!/bin/ksh SCRIPTS=/adaqfs/halla/a-onl/scripts BBITE=/adaqfs/halla/a-onl/scaler/saw_server/RPC pidfile=$SCRIPTS/getscalers_pid DVCS=/adaqfs/halla/a-onl/scaler/dvcs_calo RIGHT=/adaqfs/halla/a-onl/scaler/right LEFT=/adaqfs/halla/a-onl/scaler/left BB=/adaqfs/halla/a-onl/scaler/gen/onl TSCALE=/adaqfs/halla/a-onl/vme/trigscal echo $$>$pidfile sleep 20 while [ 1 = 1 ] ; do $BB/scread -i sleep 8 done {CODE} -=epicsLogger=- {CODE()}{CODE} -=fastEpicsLogger=- {CODE()}{CODE} -=epicsRunEnd=- {CODE()}{CODE} -==- {CODE()}{CODE} -==- {CODE()}{CODE} History |
Login Search
|