From 0390af7e40af6aeff6bda04e99be78b67403b6dc Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Tue, 11 Jan 2022 14:30:41 -0800 Subject: [PATCH 01/27] ENH:Added full worded options --enable and --disable --- scripts/camViewer | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 6dda2907..384b10fb 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -142,8 +142,8 @@ OPTIONS: -w # (wait for # hours to ask to renew, default 2 and 12 for GIGEs) -u # update rate limit (default 5) -H hutch: use a specific hutches camviewer config file --e enable camera ioc --d disable camera ioc +-e/--enable enable camera ioc +-d/--disable disable camera ioc EOF } @@ -174,7 +174,7 @@ ENABLE=0 DISABLE=0 -while getopts "c:w:u:H:lmred" OPTION +while getopts "c:w:u:H:lmred":"-enab":"-disab" OPTION do case $OPTION in l) @@ -212,6 +212,12 @@ do d) DISABLE=1 ;; + -disable) + DISABLE=1 + ;; + -enable) + ENABLE=1 + ;; esac done From 7920e8ab1e8ae5e5847babab7bf5742a077548e9 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Wed, 12 Jan 2022 00:35:52 -0800 Subject: [PATCH 02/27] ENH:Allows cameras outside of hutch to be enabled and disabled --- scripts/camViewer | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 384b10fb..df9706a0 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -127,6 +127,8 @@ iocfpv() { grep_pv $1 | sed -n 's/\/reg\/d\/iocData\/\(\S*\)\/iocInfo/\1/p' } + + usage() { cat << EOF @@ -153,9 +155,11 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then fi hutch=`get_info --gethutch` + if [ $hutch = unknown_hutch ]; then echo 'unknown hutch, cannot use camViewer script' exit 1 + fi CAMNUM=0 @@ -166,6 +170,8 @@ MAINSCREEN=0 EXE=/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh PVLIST=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg imgr=/reg/g/pcds/pyps/apps/iocmanager/latest/imgr + + CAMNUM=0 WAIT=0 RATE=-1 @@ -264,15 +270,44 @@ fi if [ $ENABLE -gt 0 ]; then echo "Enabling ${CAMNAME}" - IOC=$(iocfpv "${CAMPVFULL}") - $imgr "$IOC" --hutch "$hutch" --enable + for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do + + INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") + if [ -z "$INFO" ]; then + + >&2 + else + + IOC=$(echo "$INFO" | sed -n "s/^.*id: '\(\S*\)'.*$/\1/p") + IOCHOST=$(echo "$INFO" | sed -n "s/^.*host: '\(\S*\)'.*$/\1/p") + + iochutch=$(echo $INFO | grep "/reg/g/pcds/pyps/config/*" | cut -d'/' -f7) + + fi + done + + $imgr "$ioc" --hutch "$iochutch" --enable exit fi if [ $DISABLE -gt 0 ]; then echo "Disabling ${CAMNAME}" - IOC=$(iocfpv "${CAMPVFULL}") - $imgr "$IOC" --hutch "$hutch" --disable + for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do + + INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") + if [ -z "$INFO" ]; then + + >&2 + else + + IOC=$(echo "$INFO" | sed -n "s/^.*id: '\(\S*\)'.*$/\1/p") + IOCHOST=$(echo "$INFO" | sed -n "s/^.*host: '\(\S*\)'.*$/\1/p") + iochutch=$(echo $INFO | grep "/reg/g/pcds/pyps/config/*" | cut -d'/' -f7) + + fi + done + + $imgr "$ioc" --hutch "$iochutch" --disable exit fi From 6570eafd623dd63415e5bc104cc4bdd8785cf149 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Wed, 12 Jan 2022 19:19:40 -0800 Subject: [PATCH 03/27] BUG: Fixed -H option --- scripts/camViewer | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index df9706a0..e9c5084f 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -154,23 +154,6 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then exit 0 fi -hutch=`get_info --gethutch` - -if [ $hutch = unknown_hutch ]; then - echo 'unknown hutch, cannot use camViewer script' - exit 1 - -fi - -CAMNUM=0 -WAIT=0 -RATE=-1 -MAINSCREEN=0 - -EXE=/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh -PVLIST=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg -imgr=/reg/g/pcds/pyps/apps/iocmanager/latest/imgr - CAMNUM=0 WAIT=0 @@ -178,7 +161,9 @@ RATE=-1 REBOOT=0 ENABLE=0 DISABLE=0 +MAINSCREEN=0 +#hutch="" while getopts "c:w:u:H:lmred":"-enab":"-disab" OPTION do @@ -227,6 +212,24 @@ do esac done + +if [ $hutch = '' ]; then + $hutch = `get_info --gethutch` + if [ $hutch = unknown_hutch ]; then + echo 'unknown hutch, cannot use camViewer script' + exit 1 +else + $hutch = $1 + fi +fi + + +EXE=/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh +PVLIST=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg +imgr=/reg/g/pcds/pyps/apps/iocmanager/latest/imgr + + + if [ $CAMNUM -eq 0 ]; then if [ $hutch = "tmo" ]; then CAMNAME=IM2K0 @@ -247,6 +250,7 @@ fi export EPICS_CA_MAX_ARRAY_BYTES=24000000 echo working with camera of name: $CAMNAME +echo pv directory: "$PVLIST" name_to_pv "$CAMNAME" $hutch From ef12eb1a094be5a904edc5d64cdaccd897f15ae3 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Wed, 12 Jan 2022 22:44:15 -0800 Subject: [PATCH 04/27] BUG: Modified previous -H fix to work with other options --- scripts/camViewer | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index e9c5084f..2815976d 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -137,15 +137,15 @@ usage: $0 options start the viewer for controls cameras OPTIONS: --c camera name as in camera list or gige # --m bring up the edm screen --r reboot the IOC --l print list of cameras --w # (wait for # hours to ask to renew, default 2 and 12 for GIGEs) --u # update rate limit (default 5) --H hutch: use a specific hutches camviewer config file --e/--enable enable camera ioc --d/--disable disable camera ioc +-c: camera name as in camera list or gige # +-m: bring up the edm screen +-r: reboot the IOC +-l: print list of cameras +-w #: (wait for # hours to ask to renew, default 2 and 12 for GIGEs) +-u #: update rate limit (default 5) +-H hutch: use a specific hutches camviewer config file +-e/--enable: enable camera ioc +-d/--disable: disable camera ioc EOF } @@ -163,7 +163,6 @@ ENABLE=0 DISABLE=0 MAINSCREEN=0 -#hutch="" while getopts "c:w:u:H:lmred":"-enab":"-disab" OPTION do @@ -213,20 +212,21 @@ do done -if [ $hutch = '' ]; then - $hutch = `get_info --gethutch` - if [ $hutch = unknown_hutch ]; then + +if [ "$hutch" == "" ]; then + hutch=`get_info --gethutch` + if [ "$hutch" == unknown_hutch ]; then echo 'unknown hutch, cannot use camViewer script' exit 1 -else - $hutch = $1 fi +else + hutch=$hutch fi + EXE=/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh PVLIST=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg -imgr=/reg/g/pcds/pyps/apps/iocmanager/latest/imgr @@ -250,7 +250,7 @@ fi export EPICS_CA_MAX_ARRAY_BYTES=24000000 echo working with camera of name: $CAMNAME -echo pv directory: "$PVLIST" + name_to_pv "$CAMNAME" $hutch @@ -290,7 +290,7 @@ if [ $ENABLE -gt 0 ]; then fi done - $imgr "$ioc" --hutch "$iochutch" --enable + imgr "$ioc" --hutch "$iochutch" --enable exit fi @@ -311,7 +311,7 @@ if [ $DISABLE -gt 0 ]; then fi done - $imgr "$ioc" --hutch "$iochutch" --disable + imgr "$ioc" --hutch "$iochutch" --disable exit fi From 20d716e0ade0b92706b97bf22308d0029c2279ea Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Wed, 12 Jan 2022 22:47:12 -0800 Subject: [PATCH 05/27] DEV: Initial commit for imgr script --- scripts/imgr | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 scripts/imgr diff --git a/scripts/imgr b/scripts/imgr new file mode 100755 index 00000000..65718779 --- /dev/null +++ b/scripts/imgr @@ -0,0 +1,41 @@ +#!/bin/bash + +usage() +{ +cat << EOF +Usage: $0 IOCNAME [--hutch HUTCH] --COMMAND + +Script to control an ioc. + +List of commands: +reboot soft +reboot hard +enable +disable +upgrade RELEASE_DIR +move HOST +move HOST:PORT +list [--host HOST] [--enabled_only|--disabled_only] + +EOF +} + +if [[ ($1 == "--help") || ($1 == "-h") ]]; then + usage + exit 0 +fi + +ulimit -c unlimited + +source /reg/g/pcds/setup/pathmunge.sh +ldpathmunge /usr/local/lib + +DIRTMP=`dirname "${BASH_SOURCE[0]}"` +DIR="$( cd $DIRTMP && pwd -P )" +pathmunge $DIR + + + + +/reg/g/pcds/pyps/apps/iocmanager/latest/imgr $1 --hutch $3 "$4" > /dev/null & + From 2132e0adb2e56778635b95dbb44fc99fe7d9310d Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 13 Jan 2022 03:38:36 -0800 Subject: [PATCH 06/27] BUG:Added conditions to take care of all commands --- scripts/imgr | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/imgr b/scripts/imgr index 65718779..d3f2685f 100755 --- a/scripts/imgr +++ b/scripts/imgr @@ -8,18 +8,25 @@ Usage: $0 IOCNAME [--hutch HUTCH] --COMMAND Script to control an ioc. List of commands: -reboot soft -reboot hard -enable -disable -upgrade RELEASE_DIR -move HOST -move HOST:PORT -list [--host HOST] [--enabled_only|--disabled_only] +$0 IOCNAME [--hutch HUTCH] --reboot soft +$0 IOCNAME [--hutch HUTCH] --reboot hard +$0 IOCNAME [--hutch HUTCH] --enable +$0 IOCNAME [--hutch HUTCH] --disable +$0 IOCNAME [--hutch HUTCH] --upgrade RELEASE_DIR +$0 IOCNAME [--hutch HUTCH] --move HOST +$0 IOCNAME [--hutch HUTCH] --move HOST:PORT +$0 [--hutch HUTCH] --list [--host HOST] [--enabled_only|--disabled_only] EOF } +if [ $# -lt 1 ]; then + echo 'need arguments' >&2 + usage + exit 0 +fi + + if [[ ($1 == "--help") || ($1 == "-h") ]]; then usage exit 0 @@ -35,7 +42,22 @@ DIR="$( cd $DIRTMP && pwd -P )" pathmunge $DIR +if [[ $1 == *'-'* ]]; then + if [[ $# -eq 4 ]]; then + /reg/g/pcds/pyps/apps/iocmanager/latest/imgr "$1" --hutch $3 "$4" > /dev/null & + elif [[ $5 == *':'* && $# -eq 5 ]]; then + /reg/g/pcds/pyps/apps/iocmanager/latest/imgr "$1" --hutch $3 "$4" "$5" > /dev/null & + elif [[ $3 == *'list'* && $# -eq 6 ]]; then + /reg/g/pcds/pyps/apps/iocmanager/latest/imgr --hutch $2 --list --host "$5" "$6" + elif [[ $# -eq 5 && $5 != *':'* || $3 != *'list'* ]]; then + /reg/g/pcds/pyps/apps/iocmanager/latest/imgr "$1" --hutch $3 "$4" "$5" > /dev/null & + else + echo 'Conditions not met' + fi +else + echo 'Ioc does not exist' >&2 +fi + -/reg/g/pcds/pyps/apps/iocmanager/latest/imgr $1 --hutch $3 "$4" > /dev/null & From 5cab3046d59155ff443b7c0a7f4b483375a6ab28 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 13 Jan 2022 19:37:54 -0800 Subject: [PATCH 07/27] Removed conditionals --- scripts/imgr | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/scripts/imgr b/scripts/imgr index d3f2685f..463edb4c 100755 --- a/scripts/imgr +++ b/scripts/imgr @@ -41,23 +41,5 @@ DIRTMP=`dirname "${BASH_SOURCE[0]}"` DIR="$( cd $DIRTMP && pwd -P )" pathmunge $DIR - -if [[ $1 == *'-'* ]]; then - if [[ $# -eq 4 ]]; then - /reg/g/pcds/pyps/apps/iocmanager/latest/imgr "$1" --hutch $3 "$4" > /dev/null & - elif [[ $5 == *':'* && $# -eq 5 ]]; then - /reg/g/pcds/pyps/apps/iocmanager/latest/imgr "$1" --hutch $3 "$4" "$5" > /dev/null & - elif [[ $3 == *'list'* && $# -eq 6 ]]; then - /reg/g/pcds/pyps/apps/iocmanager/latest/imgr --hutch $2 --list --host "$5" "$6" - elif [[ $# -eq 5 && $5 != *':'* || $3 != *'list'* ]]; then - /reg/g/pcds/pyps/apps/iocmanager/latest/imgr "$1" --hutch $3 "$4" "$5" > /dev/null & - else - echo 'Conditions not met' - fi -else - echo 'Ioc does not exist' >&2 -fi - - - +/reg/g/pcds/pyps/apps/iocmanager/latest/imgr $@ From d23b085b37632642a0b09682a83d1806f66e8248 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 13 Jan 2022 19:46:18 -0800 Subject: [PATCH 08/27] Created iocinfo() to avoid code duplication for enable/disable --- scripts/camViewer | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 2815976d..49a502e6 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -127,7 +127,17 @@ iocfpv() { grep_pv $1 | sed -n 's/\/reg\/d\/iocData\/\(\S*\)\/iocInfo/\1/p' } +iocinfo() { + for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do + INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") + if [ -z "$INFO" ]; then + : + else + iochutch=$(echo $INFO | cut -d'/' -f7) + fi + done +} usage() { @@ -274,44 +284,15 @@ fi if [ $ENABLE -gt 0 ]; then echo "Enabling ${CAMNAME}" - for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do - - INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") - if [ -z "$INFO" ]; then - - >&2 - else - - IOC=$(echo "$INFO" | sed -n "s/^.*id: '\(\S*\)'.*$/\1/p") - IOCHOST=$(echo "$INFO" | sed -n "s/^.*host: '\(\S*\)'.*$/\1/p") - - iochutch=$(echo $INFO | grep "/reg/g/pcds/pyps/config/*" | cut -d'/' -f7) - - fi - done - - imgr "$ioc" --hutch "$iochutch" --enable + iocinfo + ./imgr "$ioc" --hutch "$iochutch" --enable exit fi if [ $DISABLE -gt 0 ]; then echo "Disabling ${CAMNAME}" - for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do - - INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") - if [ -z "$INFO" ]; then - - >&2 - else - - IOC=$(echo "$INFO" | sed -n "s/^.*id: '\(\S*\)'.*$/\1/p") - IOCHOST=$(echo "$INFO" | sed -n "s/^.*host: '\(\S*\)'.*$/\1/p") - iochutch=$(echo $INFO | grep "/reg/g/pcds/pyps/config/*" | cut -d'/' -f7) - - fi - done - - imgr "$ioc" --hutch "$iochutch" --disable + iocinfo + ./imgr "$ioc" --hutch "$iochutch" --disable exit fi From 77f0bcfc6258a7b116cc490078e6cf365980d809 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 13 Jan 2022 19:51:13 -0800 Subject: [PATCH 09/27] Fixed fully worded enable/disable options and removed else statement when defining hutch --- scripts/camViewer | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 49a502e6..997daf8c 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -154,8 +154,8 @@ OPTIONS: -w #: (wait for # hours to ask to renew, default 2 and 12 for GIGEs) -u #: update rate limit (default 5) -H hutch: use a specific hutches camviewer config file --e/--enable: enable camera ioc --d/--disable: disable camera ioc +-e|--enable: enable camera ioc +-d|--disable: disable camera ioc EOF } @@ -174,7 +174,8 @@ DISABLE=0 MAINSCREEN=0 -while getopts "c:w:u:H:lmred":"-enab":"-disab" OPTION +while getopts " -o c:w:u:H:lmre:(enable)d:(disable)" OPTION + do case $OPTION in l) @@ -206,31 +207,22 @@ do r) REBOOT=1 ;; - e) + e|enable) ENABLE=1 ;; - d) - DISABLE=1 - ;; - -disable) + d|disable) DISABLE=1 ;; - -enable) - ENABLE=1 - ;; esac done - if [ "$hutch" == "" ]; then hutch=`get_info --gethutch` if [ "$hutch" == unknown_hutch ]; then echo 'unknown hutch, cannot use camViewer script' exit 1 fi -else - hutch=$hutch fi From 8aac235112e2c597dbcd4e0a4e8c80e15b4715dd Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 13 Jan 2022 19:54:53 -0800 Subject: [PATCH 10/27] Removed sourcing --- scripts/camViewer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 997daf8c..a6c5ca21 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -277,14 +277,14 @@ fi if [ $ENABLE -gt 0 ]; then echo "Enabling ${CAMNAME}" iocinfo - ./imgr "$ioc" --hutch "$iochutch" --enable + imgr "$ioc" --hutch "$iochutch" --enable exit fi if [ $DISABLE -gt 0 ]; then echo "Disabling ${CAMNAME}" iocinfo - ./imgr "$ioc" --hutch "$iochutch" --disable + imgr "$ioc" --hutch "$iochutch" --disable exit fi From c50a9c6ae9ac3b991b769269db0db3e9e7e1898c Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 14 Jan 2022 16:22:00 -0800 Subject: [PATCH 11/27] ENH: Changed how iocinfo deals with multiple iocs --- scripts/camViewer | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index a6c5ca21..1e552e62 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -131,9 +131,7 @@ iocinfo() { for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") - if [ -z "$INFO" ]; then - : - else + if [ -n "$INFO" ]; then iochutch=$(echo $INFO | cut -d'/' -f7) fi done From 7d0af74fe175154cce8c902b08b38542e0ea8dd4 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 14 Jan 2022 18:20:20 -0800 Subject: [PATCH 12/27] Added engineering tools to path --- scripts/camViewer | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/camViewer b/scripts/camViewer index 1e552e62..eced9836 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -1,5 +1,8 @@ #!/bin/bash +DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) +PATH=$PATH:$DIR + # # find_pv: use find_pv to get to the sysreset PV of the IOC for rebooting. # --> does not work. Need to know more. Maybe just use in case of gige, assuming naming convention. From c3c55c9fd4147edecdca75d8da35fb5508058231 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 14 Jan 2022 18:23:10 -0800 Subject: [PATCH 13/27] Revised adding engineering tools to path --- scripts/imgr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/imgr b/scripts/imgr index 463edb4c..af09825f 100755 --- a/scripts/imgr +++ b/scripts/imgr @@ -37,8 +37,8 @@ ulimit -c unlimited source /reg/g/pcds/setup/pathmunge.sh ldpathmunge /usr/local/lib -DIRTMP=`dirname "${BASH_SOURCE[0]}"` -DIR="$( cd $DIRTMP && pwd -P )" +DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) +PATH=$PATH:$DIR pathmunge $DIR /reg/g/pcds/pyps/apps/iocmanager/latest/imgr $@ From db69540f7f64a84ffbbf22a7456549d4e67a3614 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 20 Jan 2022 17:44:53 -0800 Subject: [PATCH 14/27] Updated imgr to use script specific to each hutch. Removed help function to let wrapper handle it. Removed pathmunge line. --- scripts/imgr | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/imgr b/scripts/imgr index af09825f..f75f9e1b 100755 --- a/scripts/imgr +++ b/scripts/imgr @@ -26,12 +26,6 @@ if [ $# -lt 1 ]; then exit 0 fi - -if [[ ($1 == "--help") || ($1 == "-h") ]]; then - usage - exit 0 -fi - ulimit -c unlimited source /reg/g/pcds/setup/pathmunge.sh @@ -39,7 +33,14 @@ ldpathmunge /usr/local/lib DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) PATH=$PATH:$DIR -pathmunge $DIR -/reg/g/pcds/pyps/apps/iocmanager/latest/imgr $@ +hutch=$(get_info --gethutch) + +if [ "$hutch" == unknown_hutch ]; then + echo 'unknown hutch, cannot use camViewer script' + exit 1 +fi + + +/reg/g/pcds/pyps/config/$hutch/iocmanager/imgr $@ From db4aba825ab01310675ad36030bbf564feaa2fd5 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 20 Jan 2022 18:23:01 -0800 Subject: [PATCH 15/27] Fixed styling and edited -l and -c options --- scripts/camViewer | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index eced9836..a92f1872 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -131,7 +131,7 @@ iocfpv() { } iocinfo() { - for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do + for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") if [ -n "$INFO" ]; then @@ -165,8 +165,9 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then exit 0 fi - +LIST=0 CAMNUM=0 +CAMNAME=0 WAIT=0 RATE=-1 REBOOT=0 @@ -180,18 +181,10 @@ while getopts " -o c:w:u:H:lmre:(enable)d:(disable)" OPTION do case $OPTION in l) - list_cams $hutch - exit 1 + LIST=1 ;; c) CAM=$OPTARG - if isNum $CAM; then - CAMNUM=$CAM - CAMNAME=`gige_num_to_name $hutch $CAM` - else - CAMNAME=$CAM - CAMNUM=-1 - fi ;; w) WAIT=$OPTARG @@ -228,9 +221,21 @@ fi -EXE=/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh -PVLIST=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg +EXE="/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh" +PVLIST="/reg/g/pcds/pyps/config/$hutch/camviewer.cfg" + +if [ $LIST -gt 0 ]; then + list_cams $hutch + exit 1 +fi +if isNum $CAM; then + CAMNUM=$CAM + CAMNAME=$(gige_num_to_name $hutch $CAM) +else + CAMNAME=$CAM + CAMNUM=-1 +fi if [ $CAMNUM -eq 0 ]; then From 3815117c65c0d2e2d050218e0dadb4313c42196f Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 20 Jan 2022 18:58:47 -0800 Subject: [PATCH 16/27] Amended where the hutch gets defined --- scripts/camViewer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/camViewer b/scripts/camViewer index a92f1872..f7df8aab 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -214,7 +214,7 @@ done if [ "$hutch" == "" ]; then hutch=`get_info --gethutch` if [ "$hutch" == unknown_hutch ]; then - echo 'unknown hutch, cannot use camViewer script' + echo 'unknown hutch, specify using -H option' exit 1 fi fi From 673b647ab8ce224e3db10a3510f7a480ae0802a9 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 20 Jan 2022 20:36:01 -0800 Subject: [PATCH 17/27] STY: Style fixes from shellcheck --- scripts/camViewer | 130 +++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index f7df8aab..216694c2 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -1,6 +1,6 @@ #!/bin/bash -DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) +DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") PATH=$PATH:$DIR # @@ -18,10 +18,10 @@ if [ $# -lt 2 ]; then exit fi CAMPVFULL="" -hutch=`echo $2 | tr A-Z a-z` +hutch=$(echo "$2" | tr A-Z a-z) VIEWERCFG=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg # Match "-" or "_" or " ". -NAME=`echo $1 | sed -e 's/-/ /g' -e 's/_/ /g' -e 's/ /[-_ ]/g'` +NAME=$(echo "$1" | sed -e 's/-/ /g' -e 's/_/ /g' -e 's/ /[-_ ]/g') # # The story here: # See how many matches we have in the hutch. @@ -34,37 +34,37 @@ NAME=`echo $1 | sed -e 's/-/ /g' -e 's/_/ /g' -e 's/ /[-_ ]/g'` # # Make a temp file with just the PVs and camera names that match. tmp=/tmp/cv.$$ -cat $VIEWERCFG | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp -c=`wc -l <$tmp` -if [ $c -eq 0 ]; then - VIEWERCFG=/reg/g/pcds/pyps/config/*/camviewer.cfg - cat $VIEWERCFG | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp - c=`wc -l <$tmp` - if [ $c -eq 0 ]; then +cat "$VIEWERCFG" | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp +c=$(wc -l <$tmp) +if [ "$c" -eq 0 ]; then + VIEWERCFG='/reg/g/pcds/pyps/config/*/camviewer.cfg' + cat "$VIEWERCFG" | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp + c=$(wc -l <$tmp) + if [ "$c" -eq 0 ]; then echo "No match for $1" rm -f $tmp exit fi fi -if [ $c -eq 1 ]; then - CAMPVFULL=`awk '{print $1;}' <$tmp` +if [ "$c" -eq 1 ]; then + CAMPVFULL=$(awk '{print $1;}' <$tmp) rm -f $tmp return fi # OK, ambiguous. Look for a complete match on the second word. -if [ `egrep -i " $NAME\$" < $tmp | wc -l` -eq 1 ]; then - CAMPVFULL=`egrep -i " $NAME\$" < $tmp | awk '{print $1;}'` +if [ "$(grep -E -i " $NAME\$" < $tmp | wc -l)" -eq 1 ]; then + CAMPVFULL=$(grep -E -i " $NAME\$" < $tmp | awk '{print $1;}') rm -f $tmp return fi # What about just a match at the end? (That is, if we are searching # for "yag1", prefer "mec_yag1" to "mec_yag11".) -if [ `egrep -i "$NAME\$" < $tmp | wc -l` -eq 1 ]; then - CAMPVFULL=`egrep -i "$NAME\$" < $tmp | awk '{print $1;}'` +if [ "$(grep -E -i "$NAME\$" < $tmp | wc -l)" -eq 1 ]; then + CAMPVFULL=$(grep -E -i "$NAME\$" < $tmp | awk '{print $1;}') rm -f $tmp return fi -echo '"'$1'" is ambiguous:' +echo '"'"$1"'" is ambiguous:' awk '{print $2;}' <$tmp rm -f $tmp exit @@ -78,10 +78,10 @@ fi HUTCH=${1^^} hutch=${1,,} VIEWERCFG=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg -printf -v GIGENUM "%02d" $2 +printf -v GIGENUM "%02d" "$2" GIGEBASE=$HUTCH:GIGE:$GIGENUM -echo `grep $GIGEBASE $VIEWERCFG | grep -v '#' | awk -F, '{print $4}'` +echo "$(grep "$GIGEBASE" "$VIEWERCFG" | grep -v '#' | awk -F, '{print $4}')" } isNum(){ @@ -100,42 +100,42 @@ list_cams() if [ $# -lt 1 ]; then echo 'need one arguments: hutch ' fi -HUTCH=`echo $1 | tr a-z A-Z` -hutch=`echo $1 | tr A-Z a-z` +HUTCH=$(echo "$1" | tr a-z A-Z) +hutch=$(echo "$1" | tr A-Z a-z) ALLVIEWERCFG=/reg/g/pcds/pyps/config/*/camviewer.cfg -echo cat $ALLVIEWERCFG | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' +echo cat "$ALLVIEWERCFG" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' VIEWERCFGLFE=/reg/g/pcds/pyps/config/lfe/camviewer.cfg VIEWERCFG=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg VIEWERCFGXRT=/reg/g/pcds/pyps/config/xrt/camviewer.cfg -if [ $hutch != 'tmo' ] && [ $hutch != 'rix' ]; then - for gige_cam in `grep -v '#' $VIEWERCFGLFE | awk -F, '{print $4 "\n" }'`; do - echo $gige_cam +if [ "$hutch" != 'tmo' ] && [ "$hutch" != 'rix' ]; then + for gige_cam in $(grep -v '#' $VIEWERCFGLFE | awk -F, '{print $4 "\n" '); do + echo "$gige_cam" done - for gige_cam in `grep -v '#' $VIEWERCFGXRT | awk -F, '{print $4 "\n" }'`; do - echo $gige_cam + for gige_cam in $(grep -v '#' $VIEWERCFGXRT | awk -F, '{print $4 "\n" }'); do + echo "$gige_cam" done fi -for gige_cam in `grep -v '#' $VIEWERCFG | awk -F, '{print $4 "\n" }'`; do - echo $gige_cam +for gige_cam in $(grep -v '#' "$VIEWERCFG" | awk -F, '{print $4 "\n" }'); do + echo "$gige_cam" done } iocfpv() { - grep_pv $1 | sed -n 's/\/reg\/d\/iocData\/\(\S*\)\/iocInfo/\1/p' + grep_pv "$1" | sed -n 's/\/reg\/d\/iocData\/\(\S*\)\/iocInfo/\1/p' } iocinfo() { - for ioc in `iocfpv "$CAMPVFULL:IMAGE1"`; do + for ioc in $(iocfpv "$CAMPVFULL:IMAGE1"); do INFO=$(grep_ioc "$ioc" all | grep "id:'$ioc'") if [ -n "$INFO" ]; then - iochutch=$(echo $INFO | cut -d'/' -f7) + iochutch=$(echo "$INFO" | cut -d'/' -f7) fi done } @@ -212,7 +212,7 @@ done if [ "$hutch" == "" ]; then - hutch=`get_info --gethutch` + hutch=$(get_info --gethutch) if [ "$hutch" == unknown_hutch ]; then echo 'unknown hutch, specify using -H option' exit 1 @@ -225,13 +225,13 @@ EXE="/reg/g/pcds/pyps/config/$hutch/camviewer/run_viewer.csh" PVLIST="/reg/g/pcds/pyps/config/$hutch/camviewer.cfg" if [ $LIST -gt 0 ]; then - list_cams $hutch + list_cams "$hutch" exit 1 fi -if isNum $CAM; then +if isNum "$CAM"; then CAMNUM=$CAM - CAMNAME=$(gige_num_to_name $hutch $CAM) + CAMNAME=$(gige_num_to_name "$hutch" "$CAM") else CAMNAME=$CAM CAMNUM=-1 @@ -239,17 +239,17 @@ fi if [ $CAMNUM -eq 0 ]; then - if [ $hutch = "tmo" ]; then + if [ "$hutch" = "tmo" ]; then CAMNAME=IM2K0 - elif [ $hutch = "rix" ]; then + elif [ "$hutch" = "rix" ]; then CAMNAME=IM1K1 - elif [ $hutch = "xpp" ]; then + elif [ "$hutch" = "xpp" ]; then CAMNAME=hx2_sb1_yag - elif [ $hutch = "mfx" ]; then + elif [ "$hutch" = "mfx" ]; then CAMNAME=mfx_dg1_yag - elif [ $hutch = "cxi" ]; then + elif [ "$hutch" = "cxi" ]; then CAMNAME=cxi_dg1_yag - elif [ $hutch = "mec" ]; then + elif [ "$hutch" = "mec" ]; then CAMNAME=GigE_Questar1 else CAMNAME=xcs_yag2 @@ -260,23 +260,23 @@ export EPICS_CA_MAX_ARRAY_BYTES=24000000 echo working with camera of name: $CAMNAME -name_to_pv "$CAMNAME" $hutch +name_to_pv "$CAMNAME" "$hutch" if [ $MAINSCREEN -gt 0 ]; then echo 'try to get the main screen for: ' $CAMNAME - echo 'start the main screen for camera base PV: ' $CAMPVFULL - cmdName=`caget -St $CAMPVFULL:LAUNCH_EDM` - echo calling edm main screen from: $cmdName + echo 'start the main screen for camera base PV: ' "$CAMPVFULL" + cmdName=$(caget -St "$CAMPVFULL":LAUNCH_EDM) + echo calling edm main screen from: "$cmdName" $cmdName exit fi if [ $REBOOT -gt 0 ]; then echo 'reboot IOC for camera: ' $CAMNAME - edmcmdName=`caget -St $CAMPVFULL:LAUNCH_EDM` - IOCPV=`grep 'export IOC_PV' $edmcmdName | awk '{print $2 "\n" }' | sed s/IOC_PV=/''/g` - echo 'restart IOC last started on: ' `caget -t $IOCPV:STARTTOD` - caput $IOCPV:SYSRESET 1 + edmcmdName=$(caget -St "$CAMPVFULL":LAUNCH_EDM) + IOCPV=$(grep 'export IOC_PV' "$edmcmdName" | awk '{print $2 "\n" }' | sed s/IOC_PV=/''/g) + echo 'restart IOC last started on: ' "$(caget -t "$IOCPV":STARTTOD)" + caput "$IOCPV":SYSRESET 1 exit fi @@ -294,30 +294,30 @@ if [ $DISABLE -gt 0 ]; then exit fi -IS_ACQUIRING=`caget -t -n $CAMPVFULL:Acquire_RBV` -if isNum $IS_ACQUIRING; then - if [ $IS_ACQUIRING -eq 0 ]; then +IS_ACQUIRING=$(caget -t -n "$CAMPVFULL":Acquire_RBV) +if isNum "$IS_ACQUIRING"; then + if [ "$IS_ACQUIRING" -eq 0 ]; then echo 'start acquiring for camera ' $CAMNAME - caput -n $CAMPVFULL:Acquire 1 + caput -n "$CAMPVFULL":Acquire 1 fi else echo 'cannot check Acquiring PV, try to open camera viewer anyways....' fi -if [ $WAIT -gt 0 ]; then - if [ $RATE -gt 0 ]; then - echo $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST --idle $WAIT --rate $RATE& - $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST --idle $WAIT --rate $RATE& +if [ "$WAIT" -gt 0 ]; then + if [ "$RATE" -gt 0 ]; then + echo "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" --idle "$WAIT" --rate "$RATE"& + "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" --idle "$WAIT" --rate "$RATE"& else - echo $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST --idle $WAIT& - $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST --idle $WAIT& + echo "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" --idle "$WAIT"& + "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" --idle "$WAIT"& fi else - if [ $RATE -gt 0 ]; then - echo $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST --rate $RATE& - $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST --rate $RATE& + if [ "$RATE" -gt 0 ]; then + echo "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" --rate "$RATE"& + "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" --rate "$RATE"& else - echo $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST & - $EXE --camerapv $CAMPVFULL --instrument $hutch --pvlist $PVLIST & + echo "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" & + "$EXE" --camerapv "$CAMPVFULL" --instrument "$hutch" --pvlist "$PVLIST" & fi fi From aa398e1ef8a3a9cd559f6ae1b52a5b90c7d2c225 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 25 Feb 2022 12:13:25 -0800 Subject: [PATCH 18/27] Removed imgr --- scripts/imgr | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100755 scripts/imgr diff --git a/scripts/imgr b/scripts/imgr deleted file mode 100755 index f75f9e1b..00000000 --- a/scripts/imgr +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -usage() -{ -cat << EOF -Usage: $0 IOCNAME [--hutch HUTCH] --COMMAND - -Script to control an ioc. - -List of commands: -$0 IOCNAME [--hutch HUTCH] --reboot soft -$0 IOCNAME [--hutch HUTCH] --reboot hard -$0 IOCNAME [--hutch HUTCH] --enable -$0 IOCNAME [--hutch HUTCH] --disable -$0 IOCNAME [--hutch HUTCH] --upgrade RELEASE_DIR -$0 IOCNAME [--hutch HUTCH] --move HOST -$0 IOCNAME [--hutch HUTCH] --move HOST:PORT -$0 [--hutch HUTCH] --list [--host HOST] [--enabled_only|--disabled_only] - -EOF -} - -if [ $# -lt 1 ]; then - echo 'need arguments' >&2 - usage - exit 0 -fi - -ulimit -c unlimited - -source /reg/g/pcds/setup/pathmunge.sh -ldpathmunge /usr/local/lib - -DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}")) -PATH=$PATH:$DIR - -hutch=$(get_info --gethutch) - -if [ "$hutch" == unknown_hutch ]; then - echo 'unknown hutch, cannot use camViewer script' - exit 1 -fi - - -/reg/g/pcds/pyps/config/$hutch/iocmanager/imgr $@ - From 31a2f44dc1dfdb9680643aaab4f7622be20740c5 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Tue, 1 Mar 2022 16:28:01 -0800 Subject: [PATCH 19/27] BUG: Fixed syntax errors that broke the default camera selection --- scripts/camViewer | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 216694c2..b7f8d6ae 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -37,8 +37,8 @@ tmp=/tmp/cv.$$ cat "$VIEWERCFG" | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp c=$(wc -l <$tmp) if [ "$c" -eq 0 ]; then - VIEWERCFG='/reg/g/pcds/pyps/config/*/camviewer.cfg' - cat "$VIEWERCFG" | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp + VIEWERCFG=/reg/g/pcds/pyps/config/*/camviewer.cfg + cat $VIEWERCFG | grep -i "$NAME" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' >$tmp c=$(wc -l <$tmp) if [ "$c" -eq 0 ]; then echo "No match for $1" @@ -104,14 +104,14 @@ HUTCH=$(echo "$1" | tr a-z A-Z) hutch=$(echo "$1" | tr A-Z a-z) ALLVIEWERCFG=/reg/g/pcds/pyps/config/*/camviewer.cfg -echo cat "$ALLVIEWERCFG" | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' +echo cat $ALLVIEWERCFG | grep -v '#' | awk -F, '{ if (split($2,a,";")==1) n=$2; else n=a[2]; gsub(" ","",n); gsub(" ","",$4); printf "%s %s\n", n, $4; }' VIEWERCFGLFE=/reg/g/pcds/pyps/config/lfe/camviewer.cfg VIEWERCFG=/reg/g/pcds/pyps/config/$hutch/camviewer.cfg VIEWERCFGXRT=/reg/g/pcds/pyps/config/xrt/camviewer.cfg if [ "$hutch" != 'tmo' ] && [ "$hutch" != 'rix' ]; then - for gige_cam in $(grep -v '#' $VIEWERCFGLFE | awk -F, '{print $4 "\n" '); do + for gige_cam in $(grep -v '#' $VIEWERCFGLFE | awk -F, '{print $4 "\n"} '); do echo "$gige_cam" done @@ -167,7 +167,7 @@ fi LIST=0 CAMNUM=0 -CAMNAME=0 +CAM=0 WAIT=0 RATE=-1 REBOOT=0 From 8536d200681ce85840e5adebceaafc7a8248b70e Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 10 Mar 2022 22:30:27 -0800 Subject: [PATCH 20/27] Fixed enable and disable command line long options --- scripts/camViewer | 67 +++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index b7f8d6ae..9437ec92 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -164,6 +164,7 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then usage exit 0 fi + LIST=0 CAMNUM=0 @@ -176,38 +177,52 @@ DISABLE=0 MAINSCREEN=0 -while getopts " -o c:w:u:H:lmre:(enable)d:(disable)" OPTION +OPTIONS=$(getopt -o lmredc:w:u:H: --long list,main,reboot,enable,disable,cam:,wait:rate:hutch: -- "$@") +if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + +eval set -- "$OPTIONS" + +while [ : ] do - case $OPTION in - l) - LIST=1 - ;; - c) - CAM=$OPTARG - ;; - w) - WAIT=$OPTARG - ;; - u) - RATE=$OPTARG - ;; - H) - hutch=$OPTARG - ;; - m) - MAINSCREEN=1 - ;; - r) - REBOOT=1 - ;; - e|enable) + case "$1" in + -l|--list) + LIST=1 + shift + ;; + -c|--cam) + CAM=$2 + shift 2 ;; + -w|--wait) + WAIT=$2 + shift 2 ;; + -u|--rate) + RATE=$2 + shift 2 ;; + -H|--hutch) + hutch=$2 + shift 2 ;; + -m|--main) + MAINSCREEN=1 + shift + ;; + -r|--rate) + REBOOT=1 + shift + ;; + -e|--enable) ENABLE=1 + shift ;; - d|disable) + -d|--disable) DISABLE=1 + shift + ;; + --) shift + break ;; - esac + + esac done From fb4a672d780ec279afe179b3faa1db8d7bce2182 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Thu, 10 Mar 2022 22:54:17 -0800 Subject: [PATCH 21/27] Updated usage function --- scripts/camViewer | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 9437ec92..44ab1a0e 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -148,15 +148,15 @@ usage: $0 options start the viewer for controls cameras OPTIONS: --c: camera name as in camera list or gige # --m: bring up the edm screen --r: reboot the IOC --l: print list of cameras --w #: (wait for # hours to ask to renew, default 2 and 12 for GIGEs) --u #: update rate limit (default 5) --H hutch: use a specific hutches camviewer config file --e|--enable: enable camera ioc --d|--disable: disable camera ioc +-c|--cam : camera name as in camera list or gige # +-m|--main : bring up the edm screen +-r|--reboot : reboot the IOC +-l|--list : print list of cameras +-w|--wait # : (wait for # hours to ask to renew, default 2 and 12 for GIGEs) +-u|--rate # : update rate limit (default 5) +-H|--hutch : use a specific hutches camviewer config file +-e|--enable : enable camera ioc +-d|--disable: disable camera ioc EOF } From bda7203974f2fe356c8e38a16015d103ec14c437 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 11 Mar 2022 17:39:23 -0800 Subject: [PATCH 22/27] Changed path instance --- scripts/camViewer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/camViewer b/scripts/camViewer index 44ab1a0e..01f4c387 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -1,7 +1,7 @@ #!/bin/bash DIR=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")") -PATH=$PATH:$DIR +PATH=$DIR:$PATH # # find_pv: use find_pv to get to the sysreset PV of the IOC for rebooting. From e4f53db493af6a460fc42ca81eb6245126d8f7ca Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Tue, 15 Mar 2022 18:50:48 -0700 Subject: [PATCH 23/27] Style Fixes --- scripts/camViewer | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 01f4c387..3458d803 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -148,15 +148,15 @@ usage: $0 options start the viewer for controls cameras OPTIONS: --c|--cam : camera name as in camera list or gige # --m|--main : bring up the edm screen --r|--reboot : reboot the IOC --l|--list : print list of cameras --w|--wait # : (wait for # hours to ask to renew, default 2 and 12 for GIGEs) --u|--rate # : update rate limit (default 5) --H|--hutch : use a specific hutches camviewer config file --e|--enable : enable camera ioc --d|--disable: disable camera ioc +-c|--cam : camera name as in camera list or gige # +-m|--main : bring up the edm screen +-r|--reboot : reboot the IOC +-l|--list : print list of cameras +-w|--wait <#> : wait for # hours to ask to renew, default 2 (12 for GIGEs) +-u|--rate <#> : update rate limit in Hz (default 5) +-H|--hutch : use a specific hutches camviewer config file +-e|--enable : enable camera ioc +-d|--disable : disable camera ioc EOF } @@ -177,7 +177,7 @@ DISABLE=0 MAINSCREEN=0 -OPTIONS=$(getopt -o lmredc:w:u:H: --long list,main,reboot,enable,disable,cam:,wait:rate:hutch: -- "$@") +OPTIONS=$(getopt -o lmredc:w:u:H: --long list,main,reboot,enable,disable,cam:,wait:,rate:,hutch: -- "$@") if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi @@ -221,6 +221,7 @@ do --) shift break ;; + esac done From 1a8a31174638684719612f38b7e5151d03b6ff7b Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Tue, 15 Mar 2022 18:57:23 -0700 Subject: [PATCH 24/27] More style fixes --- scripts/camViewer | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 3458d803..9b3babda 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -148,15 +148,15 @@ usage: $0 options start the viewer for controls cameras OPTIONS: --c|--cam : camera name as in camera list or gige # --m|--main : bring up the edm screen --r|--reboot : reboot the IOC --l|--list : print list of cameras --w|--wait <#> : wait for # hours to ask to renew, default 2 (12 for GIGEs) --u|--rate <#> : update rate limit in Hz (default 5) --H|--hutch : use a specific hutches camviewer config file --e|--enable : enable camera ioc --d|--disable : disable camera ioc +-c|--cam : camera name as in camera list or gige # +-m|--main : bring up the edm screen +-r|--reboot : reboot the IOC +-l|--list : print list of cameras +-w|--wait <#> : wait for # hours to ask to renew, default 2 (12 for GIGEs) +-u|--rate <#> : update rate limit in Hz (default 5) +-H|--hutch : use a specific hutches camviewer config file +-e|--enable : enable camera ioc +-d|--disable : disable camera ioc EOF } From 2935c5232e0074ffb3e5aab67a53475b3ce39303 Mon Sep 17 00:00:00 2001 From: Aalayah Spencer <35245246+spenc333@users.noreply.github.com> Date: Fri, 18 Mar 2022 20:57:01 -0700 Subject: [PATCH 25/27] Error handling Co-authored-by: Tyler Pennebaker --- scripts/camViewer | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/camViewer b/scripts/camViewer index 9b3babda..556ae2e2 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -226,6 +226,11 @@ do esac done +if [ $# -ge 1 ]; then + echo "Positional arguments unsupported: $@" >&2 + usage + exit 1 +fi if [ "$hutch" == "" ]; then hutch=$(get_info --gethutch) From 9a67d9708a141e32ce59267f080393fc9f7b4f9c Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 18 Mar 2022 21:13:06 -0700 Subject: [PATCH 26/27] Added usage function to unknown hutch error. --- scripts/camViewer | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/scripts/camViewer b/scripts/camViewer index 9b3babda..ebb4f509 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -148,6 +148,7 @@ usage: $0 options start the viewer for controls cameras OPTIONS: + -c|--cam : camera name as in camera list or gige # -m|--main : bring up the edm screen -r|--reboot : reboot the IOC @@ -157,6 +158,7 @@ OPTIONS: -H|--hutch : use a specific hutches camviewer config file -e|--enable : enable camera ioc -d|--disable : disable camera ioc + EOF } @@ -164,7 +166,9 @@ if [[ ($1 == "--help") || ($1 == "-h") ]]; then usage exit 0 fi - + + + LIST=0 CAMNUM=0 @@ -177,12 +181,16 @@ DISABLE=0 MAINSCREEN=0 -OPTIONS=$(getopt -o lmredc:w:u:H: --long list,main,reboot,enable,disable,cam:,wait:,rate:,hutch: -- "$@") +OPTIONS=$(getopt -o lmredc:w:u:H: --long list,main,reboot,enable,disable,cam:,wait:,rate:,hutch: -n \'$0\' -- "$@") if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi + + eval set -- "$OPTIONS" + + while [ : ] do case "$1" in @@ -218,19 +226,27 @@ do DISABLE=1 shift ;; - --) shift + ?) + usage + break + ;; + --) + shift break ;; - - + *) + echo "Internal Error" + exit 1 + ;; esac -done +done if [ "$hutch" == "" ]; then hutch=$(get_info --gethutch) if [ "$hutch" == unknown_hutch ]; then echo 'unknown hutch, specify using -H option' + usage exit 1 fi fi @@ -254,7 +270,8 @@ else fi -if [ $CAMNUM -eq 0 ]; then + +if [ $CAMNUM -eq 0 ]; then if [ "$hutch" = "tmo" ]; then CAMNAME=IM2K0 elif [ "$hutch" = "rix" ]; then @@ -270,6 +287,8 @@ if [ $CAMNUM -eq 0 ]; then else CAMNAME=xcs_yag2 fi + + fi export EPICS_CA_MAX_ARRAY_BYTES=24000000 From 7044a3e9d11b1b7041ca35bfd6c8e9e43f8b9b83 Mon Sep 17 00:00:00 2001 From: Aalayah I Spencer Date: Fri, 18 Mar 2022 21:38:08 -0700 Subject: [PATCH 27/27] Syntax fixes --- scripts/camViewer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/camViewer b/scripts/camViewer index c18e39cd..5274588b 100755 --- a/scripts/camViewer +++ b/scripts/camViewer @@ -241,7 +241,7 @@ do esac done -======= + if [ $# -ge 1 ]; then echo "Positional arguments unsupported: $@" >&2 usage