#!/bin/sh
script_path=`echo $0 | awk -F '/' '{for(i=2;i<NF;i++) printf"/"$i}'`
echo  $script_path > $script_path/test

getconf()
{
	val=`cat $1 | grep $2: | sed -e "s/$2://g" -e "s/\r//g" -e "s/\n//g" -e "s/$(echo -e '\015')//g"`
	if [ ! $val ]; then
		echo "getconf $2 failed" >> $script_path/test
	fi
	echo -n $val
}

filename=$script_path/aging_test.ini
agingSpeak=$(getconf $filename agingSpeak)
agingInfraredLamp=$(getconf $filename agingInfraredLamp)
agingInfraredLampInteral=$(getconf $filename agingInfraredLampInteral)
agingInfraredLampDuration=$(getconf $filename agingInfraredLampDuration)
agingWhiteLed=$(getconf $filename agingWhiteLed)
agingWhiteLedInteral=$(getconf $filename agingWhiteLedInteral)
agingWhiteLedDuration=$(getconf $filename agingWhiteLedDuration)
agingMotor=$(getconf $filename agingMotor)

if [ "$agingInfraredLamp" = "yes" ];then
	echo "agingInfraredLamp start!" >> $script_path/test
	sh  $script_path/aging_rled.sh $agingInfraredLampInteral $agingInfraredLampDuration &
fi
if [ "$agingWhiteLed" = "yes" ];then
	echo "agingWhiteLed start!" >> $script_path/test
	sh  $script_path/aging_wled.sh $agingWhiteLedInteral $agingWhiteLedDuration &
fi
if [ "$agingMotor" = "yes" ];then
	echo "agingMotor start!" >> $script_path/test
	sh  $script_path/aging_motor.sh &
fi
if [ "$agingSpeak" = "yes" ];then
	echo "--------------agingSpeak start!---------------"
while [ 1 ]
do
	./playOrRecord -p audio/wohewodezuguo.pcm -s 8000 -f 0 -a 100
	sleep 1
done
	
fi
