Skip to content

Commit

Permalink
v1.4 Complete rewrite of zone parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
K2IE committed Apr 3, 2024
1 parent 2680769 commit 4f1e7e4
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 55 deletions.
2 changes: 1 addition & 1 deletion noaacap/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: noaacap
Version: 1.3.1
Version: 1.4.0
Section: hamradio
Priority: extra
Maintainer: Dan Srebnick <k2ie at k2ie.net>
Expand Down
6 changes: 3 additions & 3 deletions noaacap/etc/noaacap.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[noaacap]
myTZ = America/New_York
myZone = NJC025
myZone = NJZ012
myResend = 30
adjZone1 = NJZ012
adjZone2 = NJZ020
adjZone1 = NJZ013
adjZone2 = NJZ014
Logging = 2
88 changes: 40 additions & 48 deletions noaacap/usr/local/bin/noaacap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
##
## See /usr/local/share/noaacap/CHANGELOG for change history
##
version = "1.3.1"
version = "1.4.0"

import sys
import pytz
Expand Down Expand Up @@ -278,8 +278,6 @@ def move_entry(mylist,entry_val,entry_pos):
continue

zcs = ''
streak = 0
dupe_flag = 0
sorted_zcs = (sorted(zcs_discrete))

# Move myZone to first position in case of truncation
Expand All @@ -296,63 +294,57 @@ def move_entry(mylist,entry_val,entry_pos):
move_entry(sorted_zcs,adjZone2,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
for j in sorted_zcs[:-1]:
for j in sorted_zcs:
k += 1
curr_item = j
if (k == 1):
zcs = curr_item
next_item = sorted_zcs[k]

try:
next_item = sorted_zcs[k]
except:
next_item = ''
if next_item != '':
# next_prefix = next_item[0:3]
next_suffix = next_item[3:6]
i_next_suffix = int(next_suffix)

curr_prefix = curr_item[0:3]
next_prefix = next_item[0:3]
curr_suffix = curr_item[3:6]
next_suffix = next_item[3:6]
i_curr_suffix = int(curr_suffix)
i_next_suffix = int(next_suffix)
i_curr_plus1 = i_curr_suffix + 1

# Prefix differs
if next_prefix != curr_prefix:
# If not on streak, print next_item
if streak == 0:
zcs = zcs + '-' + next_item
# Otherwise the streak is over and is printed, along with the next item
else:
streak = 0
streak_end = curr_suffix
zcs = zcs + '-' + streak_start + '>' + streak_end + "-" + next_item
elif i_next_suffix != i_curr_plus1:
# If not on a streak set dupe flag in case a streak is next
if streak == 0:
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
# Always print entire first item
if k == 1:
zcs = curr_item
# Did prefix change?
elif prev_prefix != curr_prefix:
zcs = zcs + "-" + curr_item
# Current suffix is 1 more than previous
elif i_prev_plus1 == i_curr_suffix:
if i_next_suffix != i_curr_plus1:
zcs = zcs + ">" + curr_suffix
# Current suffix is not 1 more than previous
elif i_prev_plus1 != i_curr_suffix:
zcs = zcs + "-" + curr_suffix
else:
log.error("Unexpected condition during zcs compression")
ErrExit()

if streak == 1:
streak_end = next_suffix
zcs = zcs + '>' + streak_end
# For debugging only
# print (zcs)

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)
type = pp[bytes(Phenomena, 'utf-8')].decode('utf-8')
Expand Down
9 changes: 6 additions & 3 deletions noaacap/usr/local/share/noaacap/README
Original file line number Diff line number Diff line change
@@ -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.
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/.
Expand All @@ -14,7 +17,7 @@ https://github.com/K2IE/noaacap/releases

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.

==> APRX CONFIGURATION <==
Expand Down Expand Up @@ -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
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
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
are in zone 066. Enter PAZ066 for myZone.
Expand All @@ -86,4 +89,4 @@ weather alerts via this program.

Dan Srebnick, K2IE
02/06/2020
Updated 03/27/2024
Updated 04/03/2024

0 comments on commit 4f1e7e4

Please sign in to comment.