#!/bin/sh
# Script to acquire data on local RP(s) and plot the data.

# Assumed file hierachy on local:
# ./ (current dir)
# ├── plot_sayma_data.py
# ├── rp_get_sayma_data.py
# └── <dir-name>/
#     |   (possible existing data files, will be overwritten)
#     ├── rp_..._y1_raw.bin.py
#     ├── rp_..._y2_raw.bin.py
#     └── ...

if [[ $1 = "" ]] || [[ $2 = "" ]] || [[ $3 = "" ]] || [[ $4 = "" ]] || [[ $5 = "" ]] || [[ $6 = "" ]]
then
    echo "Arguments: <dir name> <RP#1 name> <RP#1 channel> <RP#2 name> <RP#1 channel> <RP#1 name>:<IN1 gain>,<IN2 gain> [<RP#2 name>:<IN1 gain>,<IN2 gain>]"
    echo "(If RP#1 and RP#2 are the same, skip the bracketed arguments)"
    echo "Examples: "
    echo "(1) mlabs-raw mlabs 1 mlabs 2 mlabs:LV,HV"
    echo "(2) creotech-raw creotech-1 1 creotech-2 1 creotech-1:LV,LV creotech-2:HV,HV"
    exit
fi

# Acquire data from RPs
if [[ $2 = $4 ]]
then
	python3 rp_get_sayma_data.py $1 $6
else
	python3 rp_get_sayma_data.py $1 $6 $7
fi

# Plot data from saved data
# (Note: requires numpy, matplotlib and scipy on local)
python plot_sayma_data.py $1 $2:$3 $4:$5