#!/bin/bash

. lib.sh

main() {
    #Check that the test wasn't skipped.
    if [ "$(ls -A ../nop-highprio)" ]; then
        #Otherwise this would create *.txt file and plot.sh and break the automation
        ln -s ../nop-highprio/*.txt .
    else
        SKIPPED=1; return;
    fi;
}

ADDITIONAL_PLOTS=detail

plot_cmds() {
    if [[ "$1" = detail ]]; then
	range=0.0:0.3
    else
	range=0.01:4
	echo "set logscale y"
    fi
    min=$(head -n 1 len2-msgs.txt | awk '{ print $2 }')
    cat <<EOF
set title "Single GW rule for all messages, no modifications, high (soft)irq task priority"
set grid xtics ytics mytics lw 1, lw 0.5
set key left
set xlabel "Experiment time [s]"
set ylabel "GW latency [ms]"
plot [:] [$range] \\
          "len2-msgs.txt" using (\$2-$min):(1000*\$14-0.001*\$16) with points title "2 byte messages", \\
          "len4-msgs.txt" using (\$2-$min):(1000*\$14-0.001*\$16) with points title "4 byte messages", \\
          "len6-msgs.txt" using (\$2-$min):(1000*\$14-0.001*\$16) with points title "6 byte messages", \\
          "len8-msgs.txt" using (\$2-$min):(1000*\$14-0.001*\$16) with points title "8 byte messages"
EOF
}
    
test_end