v1.4 Complete rewrite of zone parsing

This commit is contained in:
K2IE 2024-04-03 10:27:51 -04:00
parent 2680769fcd
commit 4f1e7e49d2
4 changed files with 50 additions and 55 deletions

View File

@ -1,5 +1,5 @@
Package: noaacap Package: noaacap
Version: 1.3.1 Version: 1.4.0
Section: hamradio Section: hamradio
Priority: extra Priority: extra
Maintainer: Dan Srebnick <k2ie at k2ie.net> Maintainer: Dan Srebnick <k2ie at k2ie.net>

View File

@ -1,7 +1,7 @@
[noaacap] [noaacap]
myTZ = America/New_York myTZ = America/New_York
myZone = NJC025 myZone = NJZ012
myResend = 30 myResend = 30
adjZone1 = NJZ012 adjZone1 = NJZ013
adjZone2 = NJZ020 adjZone2 = NJZ014
Logging = 2 Logging = 2

View File

@ -6,7 +6,7 @@
## ##
## See /usr/local/share/noaacap/CHANGELOG for change history ## See /usr/local/share/noaacap/CHANGELOG for change history
## ##
version = "1.3.1" version = "1.4.0"
import sys import sys
import pytz import pytz
@ -278,8 +278,6 @@ for i in range(0, count):
continue continue
zcs = '' zcs = ''
streak = 0
dupe_flag = 0
sorted_zcs = (sorted(zcs_discrete)) sorted_zcs = (sorted(zcs_discrete))
# Move myZone to first position in case of truncation # Move myZone to first position in case of truncation
@ -296,63 +294,57 @@ for i in range(0, count):
move_entry(sorted_zcs,adjZone2,adjZone2Index) move_entry(sorted_zcs,adjZone2,adjZone2Index)
log.debug("adjZone2 found in sorted zcs and moved to index " + str(adjZone2Index)) log.debug("adjZone2 found in sorted zcs and moved to index " + str(adjZone2Index))
prev_item = ''
prev_prefix = ''
prev_suffix = ''
next_item = ''
# next_prefix = ''
next_suffix = ''
k = 0 k = 0
for j in sorted_zcs[:-1]: for j in sorted_zcs:
k += 1 k += 1
curr_item = j curr_item = j
if (k == 1):
zcs = curr_item try:
next_item = sorted_zcs[k] next_item = sorted_zcs[k]
curr_prefix = curr_item[0:3] except:
next_prefix = next_item[0:3] next_item = ''
curr_suffix = curr_item[3:6] if next_item != '':
# next_prefix = next_item[0:3]
next_suffix = next_item[3:6] next_suffix = next_item[3:6]
i_curr_suffix = int(curr_suffix)
i_next_suffix = int(next_suffix) i_next_suffix = int(next_suffix)
curr_prefix = curr_item[0:3]
curr_suffix = curr_item[3:6]
i_curr_suffix = int(curr_suffix)
i_curr_plus1 = i_curr_suffix + 1 i_curr_plus1 = i_curr_suffix + 1
# Prefix differs # Always print entire first item
if next_prefix != curr_prefix: if k == 1:
# If not on streak, print next_item zcs = curr_item
if streak == 0: # Did prefix change?
zcs = zcs + '-' + next_item elif prev_prefix != curr_prefix:
# Otherwise the streak is over and is printed, along with the next item zcs = zcs + "-" + curr_item
else: # Current suffix is 1 more than previous
streak = 0 elif i_prev_plus1 == i_curr_suffix:
streak_end = curr_suffix if i_next_suffix != i_curr_plus1:
zcs = zcs + '-' + streak_start + '>' + streak_end + "-" + next_item zcs = zcs + ">" + curr_suffix
elif i_next_suffix != i_curr_plus1: # Current suffix is not 1 more than previous
# If not on a streak set dupe flag in case a streak is next elif i_prev_plus1 != i_curr_suffix:
if streak == 0: zcs = zcs + "-" + curr_suffix
zcs = zcs + '-' + next_suffix
dupe_flag = 1
else:
# The streak is over
streak = 0
streak_end = curr_suffix
# The beginning of the streak was not previously printer
if dupe_flag == 0:
zcs = zcs + '-' + streak_start + '>' + streak_end
# Don't print the start of the streak as it is a dupe
else:
zcs = zcs + '>' + streak_end
dupe_flag = 0
elif i_next_suffix == i_curr_plus1:
# Set flag when new streak detected
if streak == 0:
streak = 1
streak_start = curr_suffix
streak_end = next_suffix
# The streak continues
else:
streak_end == next_suffix
else: else:
log.error("Unexpected condition during zcs compression") log.error("Unexpected condition during zcs compression")
ErrExit() ErrExit()
if streak == 1: # For debugging only
streak_end = next_suffix # print (zcs)
zcs = zcs + '>' + streak_end
prev_item = curr_item
prev_prefix = curr_prefix
prev_suffix = curr_suffix
i_prev_suffix = int(prev_suffix)
i_prev_plus1 = i_prev_suffix + 1
log.debug("ZCS Value: " + zcs) log.debug("ZCS Value: " + zcs)
type = pp[bytes(Phenomena, 'utf-8')].decode('utf-8') type = pp[bytes(Phenomena, 'utf-8')].decode('utf-8')

View File

@ -1,3 +1,6 @@
The current release of noaacap is 1.4.0. If you are running older than this
version, please update before asking for support.
This software is written in python3 and has been tested with aprx 2.9.x. This software is written in python3 and has been tested with aprx 2.9.x.
If you are running a version < 2.9.0 you should first update aprx. The current If you are running a version < 2.9.0 you should first update aprx. The current
release of aprx may be found at http://thelifeofkenneth.com/aprx/debs/. release of aprx may be found at http://thelifeofkenneth.com/aprx/debs/.
@ -14,7 +17,7 @@ https://github.com/K2IE/noaacap/releases
Once you are running aprx >= 2.9 or direwolf >= 1.3, install noaacap: Once you are running aprx >= 2.9 or direwolf >= 1.3, install noaacap:
Install via sudo dpkg -i noaacap-1.3.deb. Then, to satisfy the dependencies, Install via sudo dpkg -i noaacap-1.4.deb. Then, to satisfy the dependencies,
run sudo apt-get -f install. run sudo apt-get -f install.
==> APRX CONFIGURATION <== ==> APRX CONFIGURATION <==
@ -61,7 +64,7 @@ myZone should be set to your zone code. A list of zone codes may be found
at https://www.weather.gov/pimar/PubZone. Only list one zone. The program at https://www.weather.gov/pimar/PubZone. Only list one zone. The program
will send the alert for all affected zones that will fit in the allocated 67 will send the alert for all affected zones that will fit in the allocated 67
characters. You could instead use a county code if you wish. However the characters. You could instead use a county code if you wish. However the
associated zone may also be sent in, wasting characters. associated zone may also be sent, wasting characters.
As an example, if you're located in Lancaster, PA, the map shows that you As an example, if you're located in Lancaster, PA, the map shows that you
are in zone 066. Enter PAZ066 for myZone. are in zone 066. Enter PAZ066 for myZone.
@ -86,4 +89,4 @@ weather alerts via this program.
Dan Srebnick, K2IE Dan Srebnick, K2IE
02/06/2020 02/06/2020
Updated 03/27/2024 Updated 04/03/2024