Skip to content

Commit

Permalink
Update custom display/db generator scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rjwills28 committed Sep 29, 2023
1 parent 288ac7c commit 383676e
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 108 deletions.
34 changes: 30 additions & 4 deletions performance/caput_to_array_pv.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion performance/create_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ record(calcout, "$record_name")
field(OUT, "$record_name.A")
}
EOF
done >>performanceTestDb.db
done >>performanceTestDb.db
99 changes: 99 additions & 0 deletions performance/create_example_db.sh
Original file line number Diff line number Diff line change
@@ -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 <options...>"
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 <<EOF
record(calcout, "$record_name")
{
field(DESC, "Performance test record")
field(SCAN, "$RATE")
field(A, "0")
field(CALC, "A == 0 ? 1 : 0")
field(OUT, "$record_name.A")
}
EOF
done >>performanceTestDbCustom.db

echo '
record(waveform, "TEST:ARR'$repeat'")
{
field(DESC, "Performance test record")
field(NELM,"3000")
field(FTVL, "SHORT")
}' >>performanceTestDbCustom.db
done
51 changes: 0 additions & 51 deletions performance/create_example_db_.sh

This file was deleted.

Loading

0 comments on commit 383676e

Please sign in to comment.