diff --git a/eiger/sf-daq-4/control/start_acquisition.sh b/eiger/sf-daq-4/control/start_acquisition.sh new file mode 100755 index 0000000..b9a6798 --- /dev/null +++ b/eiger/sf-daq-4/control/start_acquisition.sh @@ -0,0 +1,28 @@ +#!/bin/bash +ENDPOINT="http://127.0.0.1:5000" +SYNC="/write_sync" +ASYNC="/write_async" +KILL="/kill" +HEADER="Content-Type:application/json" +N_IMAGES=5 +SOURCES="eiger" +# Define a timestamp function +timestamp() { + date +"%T" # current time +} +generate_post_data() +{ + cat < -c -b " + echo " help_flag : show this help and exits." + echo " config_file : detector configuration file." + echo " bit_depth : detector bit depth." + exit +fi + +if [ -f "${CONFIG_FILE}" ]; then + N_UDP_RECVS="`cat ${CONFIG_FILE} | grep -P '"n_modules":' | grep -o '[0-9]\+'`" +else + echo "Something went wrong with the config file... ${CONFIG_FILE}..." + exit +fi + +if [ ${N_MPI_EXEC} -gt 0 ] +then + echo "Number of mpi writers: ${N_MPI_EXEC}." +else + echo "Something went wrong with the number of mpi writer processes..." + exit +fi + + + +if [ -f "${CONFIG_FILE}" ]; then + N_UDP_RECVS="`cat ${CONFIG_FILE} | grep -P '"n_modules":' | grep -o '[0-9]\+'`" +else + echo "Something went wrong with the config file... ${CONFIG_FILE}..." + exit +fi + +# Start the receivers +echo "Starting ${N_UDP_RECVS} udp receivers..." +COUNTER=0 +if [ -f "${BUILD_PATH}${UDP_RECV}" ]; then + if [ -f "${CONFIG_FILE}" ]; then + if [ ${BIT_DEPTH} -ne 0 ]; then + while [ $COUNTER -lt ${N_UDP_RECVS} ]; do + ${BUILD_PATH}${UDP_RECV} ${CONFIG_FILE} ${COUNTER} ${BIT_DEPTH} & + let COUNTER=COUNTER+1 + sleep 0.5 + done + else + echo "Error: ${BIT_DEPTH} can't be zero..." + exit + fi + else + echo "Something went wrong while starting the ${UDP_RECV}..." + exit + fi +else + echo "Error: ${UDP_RECV} wasn't found..." + exit +fi + + +# Start the std-udp-sync +echo "Starting the ${UDP_SYNC}..." +COUNTER=0 +if [ -f "${BUILD_PATH}${UDP_SYNC}" ]; then + if [ -f "${CONFIG_FILE}" ]; then + if [ ${BIT_DEPTH} -ne 0 ]; then + ${BUILD_PATH}${UDP_SYNC} ${CONFIG_FILE} ${BIT_DEPTH} & + sleep 0.5 + else + echo "Error: ${BIT_DEPTH} can't be zero..." + exit + fi + else + echo "Something went wrong while starting the ${UDP_SYNC}..." + exit + fi +else + echo "Error: ${UDP_SYNC} wasn't found..." + exit +fi + + +# Start the eiger assembler +echo "Starting the ${EIGER_ASSEMBLER}..." +if [ -f "${BUILD_PATH}${EIGER_ASSEMBLER}" ]; then + if [ -f "${CONFIG_FILE}" ]; then + if [ ${BIT_DEPTH} -ne 0 ]; then + ${BUILD_PATH}${EIGER_ASSEMBLER} ${CONFIG_FILE} ${BIT_DEPTH} & + sleep 0.5 + else + echo "Error: ${BIT_DEPTH} can't be zero..." + exit + fi + else + echo "Something went wrong while starting the ${EIGER_ASSEMBLER}..." + exit + fi +else + echo "Error: ${EIGER_ASSEMBLER} wasn't found..." + exit +fi + +# Start the eiger writer +echo "Starting the ${STD_DET_WRITER}..." +export PATH="/usr/lib64/mpich/bin:${PATH}"; +export LD_LIBRARY_PATH="/usr/lib64/mpich/lib:${LD_LIBRARY_PATH}"; + +if [ -f "${BUILD_PATH}${STD_DET_WRITER}" ]; then + if [ -f "${CONFIG_FILE}" ]; then + mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} ${BIT_DEPTH} & + sleep 0.5 + else + echo "Something went wrong while starting the ${STD_DET_WRITER}..." + exit + fi +else + echo "Error: ${STD_DET_WRITER} wasn't found..." + exit +fi \ No newline at end of file