diff --git a/FA-functions b/FA-functions index a04e76d..e013079 100644 --- a/FA-functions +++ b/FA-functions @@ -296,6 +296,9 @@ xdg-open $MAP #-------------------------------- # Alternate Grid Download #-------------------------------- + +#THIS FUNCTION DEPRECATED BUT LEFT FOR REFERENCE 11MARCH2022 + #make new dir in pat menu dir if needed mkdir -p $HOME/patmenu2/alt-ardop-list @@ -355,6 +358,10 @@ exit #-------------------------------- # Load Alternate Grid List #-------------------------------- + +#THIS FUNCTION DEPRECATED BUT LEFT FOR REFERENCE 11MARCH2022 + + LOADALTGRID(){ OUTFILE=/run/user/$UID/alt-grid.list @@ -411,7 +418,115 @@ $MAIN & exit } - +#-------------------------------- +# Recalculate Distance & Bearings +#-------------------------------- + +NEWCALC(){ +#Function to update the distance and bearing between +#your current grid and the winlink gateways. +#this is necessary because the calculations are initially +#based on the grid in the pat config file at the time the +#list is downloaded. +#10MARCH2022 KM4ACK + +DIR=/run/user/$UID +TMPFILE=$DIR/tempfile +TMPFILE2=$DIR/tempfile2 +TMPFILE3=$DIR/tempfile3 +MYGRID=$(cat /run/user/$UID/gridinfo.txt | cut -c1-6) + +MYGRID=$(yad --form --width=450 --text="Recalculate Distance and Bearings to Gateways\rThis takes 2-3 minutes to complete" \ +--text-align=center --center --title="Recalculate" --text-align=center --separator="|" --item-separator="|" \ +--image=$LOGO --window-icon=$LOGO --image-on-top \ +--field="Current Grid Square" "$MYGRID" \ +--button="Recalculate":2 \ +--button="Cancel":1) +BUT=$? +MYGRID=`echo $MYGRID | awk -F "|" '{print $1}'` + +if [ $BUT = 252 ]; then +exit +elif [ $BUT = 1 ]; then +$MAIN & +exit +fi + +#create file that has grid variable used in calculations +touch $HOME/patmenu2/ardop-list/grid.txt +echo "GRID=$MYGRID" > $HOME/patmenu2/ardop-list/grid.txt +echo "LASTDL=Recalculated `date`" >> $HOME/patmenu2/ardop-list/grid.txt + +MAIN(){ +echo "Recalculating 20M List" +RECALC 20mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 20M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating 30M List" +RECALC 30mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 30M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating 40M List" +RECALC 40mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 40M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating 80M List" +RECALC 80mardoplist.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating 80M List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." + +echo "Recalculating Packet list" +RECALC packet.txt | yad --center --progress --pulsate --auto-close --no-buttons --text-align=center --title="Recalculate" \ +--text="Recalculating Packet List\rDO NOT CLOSE THIS WINDOW\rDoing so will abort the process\rand leave you with a corrupt list." +} + +RECALC(){ +FILE=$HOME/patmenu2/ardop-list/$1 +#check for and remove existing temp file +if [ -f $TMPFILE3 ]; then +rm $TMPFILE3 +fi + +#create temp list to work with and remove headers/blank lines +cp $FILE $TMPFILE +sed -i 's/.*information...//;s/.*succeeded.//;s/.*url//' $TMPFILE +sed -i '/^$/d' $TMPFILE + + + +#read file, calculate new distance, and update +while read LINE; +do +GRID=`echo $LINE | awk '{print $2}' | sed 's/\[//;s/\]//'` +DISTANCE=`echo $LINE | awk '{print $3 }'` +BEARING=`echo $LINE | awk '{print $4 }'` +CALC=`/usr/bin/wwl $MYGRID $GRID` +NEWDISTANCE=`echo $CALC | awk '{print $2}'` +NEWBEARING=`echo $CALC | awk '{print $5}'` +echo $LINE | sed "s/$DISTANCE/$NEWDISTANCE/;s/$BEARING/$NEWBEARING/" >> $TMPFILE2 +done < $TMPFILE +rm $TMPFILE + +#pad distance with zeros for sorting +while read LINE + do + DISTANCE=$(echo $LINE | awk '{ print $3 }') + NEWDISTANCE=$(echo $LINE | awk '{ print $3 }' | sed -e :a -e 's/^.\{1,4\}$/0&/;ta') + echo $LINE | sed "s/$DISTANCE/$NEWDISTANCE/" >> $TMPFILE3 +done < $TMPFILE2 +rm $TMPFILE2 + +#sort list by distance +sort -k3 -o $TMPFILE3 $TMPFILE3 + +cp $TMPFILE3 $HOME/patmenu2/ardop-list/$1 +} + +#call main function +MAIN +#return to pat menu +$MAIN + +}