From: Tomas Mudrunka Date: Fri, 3 Aug 2012 07:32:47 +0000 (+0200) Subject: Parralel integration X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=43f096b6df33a61b9649067c807d72e7aab5f6d0;p=mirrors%2FPrograms.git Parralel integration --- diff --git a/c/goertzel/sleepmon.sh b/c/goertzel/sleepmon.sh index 72c8275..729d9bb 100755 --- a/c/goertzel/sleepmon.sh +++ b/c/goertzel/sleepmon.sh @@ -17,7 +17,9 @@ graphout="${out%%.*}.png" killall speaker-test &>/dev/null speaker-test -t sine &>/dev/null & -pid_test=$! + +touch "$out" +bash ./sleepstats.sh "$out" &>/dev/null & tresh=10 lastdate="$(date +%s)" @@ -30,6 +32,8 @@ graph=false export LC_ALL=C +#trap 'kill -9 $(jobs -p);' SIGINT + while getopts "sg" OPT; do test "$OPT" == 's' && screen=true; test "$OPT" == 'g' && graph=true; @@ -74,7 +78,7 @@ arecord | ./goertzel -n i -q -l c -t $tresh -d 4 | while read line; do lastdate="$date"; laststate="$statenum"; done | tee "$out" -kill $pid_test; sleep 0.2 +kill $(jobs -p); sleep 0.2 echo echo "Your log: $out" $graph && { diff --git a/c/goertzel/sleepplot.sh b/c/goertzel/sleepplot.sh index ab68226..a47f7e2 100755 --- a/c/goertzel/sleepplot.sh +++ b/c/goertzel/sleepplot.sh @@ -38,7 +38,9 @@ set grid #set pointsize 0.5 plot\ "$in" using 2:5 title "Sensor state" with steps,\ -"" using 2:((\$6*3+\$7*6+\$8*6+\$9+\$10)/5) title "Avg." with lines\ +"$in.stats" using 1:((\$3*3+\$4*6+\$5*6+\$6+\$7)/5) title "Avg." smooth bezier\ +#"" using 2:((\$6*3+\$7*6+\$8*6+\$9+\$10)/5) title "Avg." with lines,\ +#"$in.stats" using 1:((\$3*3+\$4*6+\$5*6+\$6+\$7)/5) title "Avg." with lines,\ #"" using 2:(\$6*2) title "Avg. 10s" with lines,\ #"" using 2:(\$7*3) title "Avg. 30s" with lines,\ #"" using 2:(\$8*3) title "Avg. 60s" with lines,\ diff --git a/c/goertzel/sleepstats.sh b/c/goertzel/sleepstats.sh new file mode 100755 index 0000000..5a6e9fd --- /dev/null +++ b/c/goertzel/sleepstats.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +export LC_ALL=C + +historymax=120; +historylen='10 30 60 90 120' +laststate=0; +lastdate='' +history=''; + +#statsdone=$(tail -n $historymax "$1".stats | head -n 1 | cut -d ' ' -f 1); + +tail -f "$1" --pid=$$ | while read line; do + date="$(echo "$line" | cut -d ' ' -f 2)" + #test -n "$statsdone" && test "$date" -le "$statsdone" && continue; + state="$(echo "$line" | cut -d ' ' -f 5)" + test -z "$lastdate" && lastdate="$(( $date - 1 ))" + + #echo $line + #echo $lastdate $date $state + + for i in $(seq $lastdate $(( $date - 1 ))); do + echo -ne "$i $state\t" + history=$(echo -n "$laststate$history" | head -c $historymax) + for len in $historylen; do + on="$(echo -n ${history::$len} | tr -d 0 | wc -c)" + on="$(echo "scale=2; $on/$len" | bc)" + printf " %.2f" "$on" + done + echo + done + + #History + #after=$(( $date - $lastdate)) + #test $historymax -gt 0 && { + #} + + + #Prepare invariants for next round + lastdate="$date"; + laststate="$state"; +done > "$1.stats"