diff --git a/performance/caput_to_array_pv.sh b/performance/caput_to_array_pv.sh index 65f098d..a7a1bd3 100755 --- a/performance/caput_to_array_pv.sh +++ b/performance/caput_to_array_pv.sh @@ -1,15 +1,41 @@ #!/bin/bash +VALID_ARGS=$(getopt -o n: --long nrepeats:, -- "$@") +if [[ $? -ne 0 ]]; then + exit 1; +fi + +eval set -- "$VALID_ARGS" +while [ : ]; do + case "$1" in + -n | --nrepeats) + N_REPEATS="$2" + shift 2 + ;; + --) shift; + break + ;; + esac +done + +if [ -z $N_REPEATS ]; then + N_REPEATS=1 +fi -echo "Calling caput on TEST:ARR0 at 1Hz" count=0 while [ true ] do + for ((i=0;i<$N_REPEATS;i++)) + do + if [[ $count -eq 0 ]]; then + caput -at TEST:ARR$i 3000 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 > /dev/null >&1 + else + caput -at TEST:ARR$i 3000 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 > /dev/null >&1 + fi + done if [[ $count -eq 0 ]]; then - caput -at TEST:ARR0 3000 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 > /dev/null >&1 - count=1 + count=1 else - caput -at TEST:ARR0 3000 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 > /dev/null >&1 count=0 fi sleep 1 diff --git a/performance/create_db.sh b/performance/create_db.sh index 58428e8..29b08a0 100755 --- a/performance/create_db.sh +++ b/performance/create_db.sh @@ -79,4 +79,4 @@ record(calcout, "$record_name") field(OUT, "$record_name.A") } EOF -done >>performanceTestDb.db \ No newline at end of file +done >>performanceTestDb.db diff --git a/performance/create_example_db.sh b/performance/create_example_db.sh new file mode 100755 index 0000000..06c9124 --- /dev/null +++ b/performance/create_example_db.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +# Parameters +N_PV_10Hz=10 +N_PV_5Hz=50 +N_PV_1Hz=250 + + +Help() +{ + echo " ************************************************************************ " + echo " Script to run create performance test EPICS .db file " + + echo " - Usage:" + echo " ./create_example_db.sh " + echo " options:" + echo " -h | --help: display this help message" + echo " -n | --nrepeats: [optional] number of repeats. If not " + echo " provided then default is 1." + echo " E.g." + echo " ./create_example_db.sh" + echo " ./create_example_db.sh -n 2" + echo " ************************************************************************ " +} + +VALID_ARGS=$(getopt -o hn: --long help,nrepeats:, -- "$@") +if [[ $? -ne 0 ]]; then + exit 1; +fi + +eval set -- "$VALID_ARGS" +while [ : ]; do + case "$1" in + -h | --help) + #Help + exit 1 + ;; + -n | --nrepeats) + N_REPEATS="$2" + shift 2 + ;; + --) shift; + break + ;; + esac +done + +if [ -z $N_REPEATS ]; then + N_REPEATS=1 +fi + +N_PVS=$(($N_PV_10Hz+$N_PV_5Hz+$N_PV_1Hz)) + +# Setup: create db file for EPICS +echo "-> Creating EPICS db with $N_PVS PVs:" +echo " $N_PV_10Hz @ 10Hz," +echo " $N_PV_5Hz @ 5Hz," +echo " $N_PV_1Hz @ 1Hz" + + +# Empty file +echo "" >performanceTestDbCustom.db + +for ((repeat=0;repeat<$N_REPEATS;repeat++)) +do + echo "Creating repeat: $repeat" + START=$(($N_PVS*$repeat)) + + for ((i=0;i<$N_PVS;i++)) + do + index=$(($START+$i)) + record_name="TEST:REC$index" + RATE=".1 second" + + if [[ $i -ge $(($N_PV_10Hz+$N_PV_5Hz)) ]]; then + RATE="1 second" + elif [[ $i -ge $(($N_PV_10Hz)) ]]; then + RATE=".5 second" + fi + cat <>performanceTestDbCustom.db + + echo ' +record(waveform, "TEST:ARR'$repeat'") +{ + field(DESC, "Performance test record") + field(NELM,"3000") + field(FTVL, "SHORT") +}' >>performanceTestDbCustom.db +done diff --git a/performance/create_example_db_.sh b/performance/create_example_db_.sh deleted file mode 100755 index 878388e..0000000 --- a/performance/create_example_db_.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# Parameters -N_PV_10Hz=10 -N_PV_5Hz=50 -N_PV_1Hz=250 - - -N_PVS=$(($N_PV_10Hz+$N_PV_5Hz+$N_PV_1Hz)) - - -# Setup: create db file for EPICS -echo "-> Creating EPICS db with $N_PVS PVs:" -echo " $N_PV_10Hz @ 10Hz," -echo " $N_PV_5Hz @ 5Hz," -echo " $N_PV_1Hz @ 1Hz" - -# Empty file -echo "" >performanceTestDbCustom.db - - -for ((i=0;i<$N_PVS;i++)) -do - record_name="TEST:REC$i" - RATE=".1 second" - - if [[ $i -ge $(($N_PV_10Hz+$N_PV_5Hz)) ]]; then - RATE="1 second" - elif [[ $i -ge $(($N_PV_10Hz)) ]]; then - RATE=".5 second" - fi - cat <>performanceTestDbCustom.db - -echo ' -record(waveform, "TEST:ARR0") -{ - field(DESC, "Performance test record") - field(NELM,"3000") - field(FTVL, "SHORT") - -}' >>performanceTestDbCustom.db diff --git a/performance/create_example_opi.sh b/performance/create_example_opi.sh index 837e92e..9527e7a 100755 --- a/performance/create_example_opi.sh +++ b/performance/create_example_opi.sh @@ -6,18 +6,94 @@ N_PV_5Hz=50 N_PV_1Hz=250 -N_PVS=$(($N_PV_10Hz+$N_PV_5Hz+$N_PV_1Hz)) +Help() +{ + echo " ************************************************************************ " + echo " Script to create the performance test OPI file " -N_COLS=30 + echo " - Usage:" + echo " ./create_example_opi.sh " + echo " options:" + echo " -h | --help: display this help message" + echo " -n | --screen: [optional] number of screens. Default is 1" + echo " E.g." + echo " ./create_example_opi.sh" + echo " ./create_example_opi.sh -n 2" + echo " ************************************************************************ " +} + +# Parse command line options +VALID_ARGS=$(getopt -o hs:n: --long help,start:nscreens:, -- "$@") +if [[ $? -ne 0 ]]; then + exit 1; +fi + +eval set -- "$VALID_ARGS" +while [ : ]; do + case "$1" in + -h | --help) + Help + exit 1 + ;; + -n | --nscreens) + N_SCREENS="$2" + if ! [[ $N_SCREENS =~ ^[0-9]+$ ]]; then + echo "Screen index must be an integer" + exit + fi + shift 2 + ;; + --) shift; + break + ;; + esac +done + +if [ -z $N_SCREENS ]; then + N_SCREENS=1 +fi -FILENAME="public/performanceTestPage.opi" +N_PVS=$(($N_PV_10Hz+$N_PV_5Hz+$N_PV_1Hz)) +N_COLS=30 # Setup: create opi file for PVs echo "-> Creating OPI filewith $N_PVS PVs" + +for ((repeat=0;repeat<$N_SCREENS;repeat++)) +do + echo "Creating repeat: $repeat" + START=$(($N_PVS*$repeat)) + + FILENAME="performanceTestPage$repeat.opi" + JSON_FILE="public/performancePage$repeat.json" + + # Create JSON file + echo ' + { + "type": "flexcontainer", + "position": "relative", + "children": [ + { + "type": "embeddedDisplay", + "position": "relative", + "margin": "10px", + "file": { + "path": "/'$FILENAME'", + "macros": {}, + "defaultProtocol": "ca" + } + } + ] + } + ' >$JSON_FILE + + + FILENAME="public/"$FILENAME + # Add screen boilerplate -echo ' + echo ' @@ -91,48 +167,44 @@ echo ' 0 ' >$FILENAME -HEIGHT=20 -WIDTH=40 -YPOS=100 -XZERO=0 -COL_COUNT=0 -for ((i=0;i<$N_PVS;i++)) -do - MARGIN=1 - #if (( $i % 10 == 0 )); then - # MARGIN=10 - #fi - - - if [[ $i -eq $(($N_PV_10Hz+$N_PV_5Hz)) ]]; then - YPOS=$(( $YPOS + ($HEIGHT+20) )) - XPOS=XZERO - COL_COUNT=0 - elif [[ $i -eq $(($N_PV_10Hz)) ]]; then - YPOS=$(( $YPOS + ($HEIGHT+20) )) - XPOS=XZERO - COL_COUNT=0 - elif [[ $i -eq 0 ]]; then - XPOS=XZERO - else - echo $COL_COUNT $N_COLS - if [[ $COL_COUNT -eq $(($N_COLS)) ]]; then - MARGIN=10 + HEIGHT=20 + WIDTH=40 + YPOS=100 + XZERO=0 + COL_COUNT=0 + + for ((i=0;i<$N_PVS;i++)) + do + MARGIN=1 + if [[ $i -eq $(($N_PV_10Hz+$N_PV_5Hz)) ]]; then + YPOS=$(( $YPOS + ($HEIGHT+20) )) + XPOS=XZERO + COL_COUNT=0 + elif [[ $i -eq $(($N_PV_10Hz)) ]]; then + YPOS=$(( $YPOS + ($HEIGHT+20) )) + XPOS=XZERO COL_COUNT=0 - YPOS=$(( $YPOS + ($HEIGHT+$MARGIN) )) + elif [[ $i -eq 0 ]]; then XPOS=XZERO - else - if [[ $COL_COUNT -eq $(($N_COLS/2)) ]]; then - MARGIN=20 + else + if [[ $COL_COUNT -eq $(($N_COLS)) ]]; then + MARGIN=1 + COL_COUNT=0 + YPOS=$(( $YPOS + ($HEIGHT+$MARGIN) )) + XPOS=XZERO + else + if [[ $COL_COUNT -eq $(($N_COLS/2)) ]]; then + MARGIN=20 + fi + XPOS=$(( $XPOS + ($WIDTH+$MARGIN) )) + fi fi - XPOS=$(( $XPOS + ($WIDTH+$MARGIN) )) - fi - fi - COL_COUNT=$(( $COL_COUNT + 1 )) - echo $COL_COUNT - - record_name="TEST:REC$i" - cat < false @@ -185,16 +257,11 @@ do EOF -done >>$FILENAME - - - - + done >>$FILENAME -YPOS=500 + YPOS=450 -# Add plot widget -echo ' + echo ' false @@ -265,7 +332,7 @@ echo ' - TEST:ARR0 + TEST:ARR'$repeat' @@ -315,6 +382,7 @@ $(trace_0_y_pv_value) 185 '$YPOS' ' >>$FILENAME +done