kopia lustrzana https://github.com/bmo/py-wsjtx
image, configurable thread count
rodzic
50b95104a7
commit
edb1c56bc8
Plik binarny nie jest wyświetlany.
Po Szerokość: | Wysokość: | Rozmiar: 162 KiB |
|
@ -26,6 +26,7 @@ else:
|
||||||
|
|
||||||
MY_MAX_SCHEMA = 3
|
MY_MAX_SCHEMA = 3
|
||||||
|
|
||||||
|
LOOKUP_THREADS = 4
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
|
@ -184,7 +185,7 @@ class Cty:
|
||||||
# lookup the callsign in the CTY file data, return the prefix.
|
# lookup the callsign in the CTY file data, return the prefix.
|
||||||
prefixes = [k for k in self.table.keys() if k==callsign[0:len(k)] or k=="={}".format(callsign)]
|
prefixes = [k for k in self.table.keys() if k==callsign[0:len(k)] or k=="={}".format(callsign)]
|
||||||
prefixes.sort(key = lambda s: 100-len(s))
|
prefixes.sort(key = lambda s: 100-len(s))
|
||||||
print("Prefixes {}".format(prefixes))
|
#print("Prefixes {}".format(prefixes))
|
||||||
found_prefix = None
|
found_prefix = None
|
||||||
# exact matches first
|
# exact matches first
|
||||||
unique_call = [ c for c in prefixes if c.startswith('=')]
|
unique_call = [ c for c in prefixes if c.startswith('=')]
|
||||||
|
@ -276,28 +277,29 @@ def main():
|
||||||
|
|
||||||
# take calls that are CQing, or replying, etc. and colorize them after the dupe check
|
# take calls that are CQing, or replying, etc. and colorize them after the dupe check
|
||||||
|
|
||||||
cw = CallsignWorker(4, cty, N1MM_DB_FILE,{'contestnr':CONTESTNR})
|
cw = CallsignWorker(LOOKUP_THREADS, cty, N1MM_DB_FILE,{'contestnr':CONTESTNR})
|
||||||
|
|
||||||
# get a callsign
|
# get a callsign
|
||||||
# put on queue
|
# put on queue
|
||||||
|
|
||||||
s = pywsjtx.extra.simple_server.SimpleServer(IP_ADDRESS, PORT, timeout=2.0)
|
s = pywsjtx.extra.simple_server.SimpleServer(IP_ADDRESS, PORT, timeout=2.0)
|
||||||
mult_foreground_color = pywsjtx.QCOLOR.Black()
|
mult_foreground_color = pywsjtx.QCOLOR.White()
|
||||||
mult_background_color = pywsjtx.QCOLOR.Red()
|
mult_background_color = pywsjtx.QCOLOR.Red()
|
||||||
|
|
||||||
dupe_background_color = pywsjtx.QCOLOR.RGBA(255,211,211,211) # light grey
|
dupe_background_color = pywsjtx.QCOLOR.RGBA(255,211,211,211) # light grey
|
||||||
dupe_foreground_color = pywsjtx.QCOLOR.RGBA(255,169,169,169) # dark grey
|
dupe_foreground_color = pywsjtx.QCOLOR.RGBA(255,169,169,169) # dark grey
|
||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
(pkt, addr_port) = s.rx_packet()
|
(pkt, addr_port) = s.rx_packet()
|
||||||
if (pkt != None):
|
if (pkt != None):
|
||||||
the_packet = pywsjtx.WSJTXPacketClassFactory.from_udp_packet(addr_port, pkt)
|
the_packet = pywsjtx.WSJTXPacketClassFactory.from_udp_packet(addr_port, pkt)
|
||||||
|
|
||||||
if type(the_packet) == pywsjtx.HeartBeatPacket:
|
if type(the_packet) == pywsjtx.HeartBeatPacket:
|
||||||
max_schema = max(the_packet.max_schema, MY_MAX_SCHEMA)
|
max_schema = max(the_packet.max_schema, MY_MAX_SCHEMA)
|
||||||
reply_beat_packet = pywsjtx.HeartBeatPacket.Builder(the_packet.wsjtx_id, max_schema)
|
reply_beat_packet = pywsjtx.HeartBeatPacket.Builder(the_packet.wsjtx_id, max_schema)
|
||||||
s.send_packet(addr_port, reply_beat_packet)
|
s.send_packet(addr_port, reply_beat_packet)
|
||||||
|
|
||||||
if type(the_packet) == pywsjtx.DecodePacket:
|
if type(the_packet) == pywsjtx.DecodePacket:
|
||||||
m = re.match(r"^CQ\s+(\S{3,}?)\s+", the_packet.message) or re.match(r"^CQ\s+\S{2}\s+(\S{3,}?)\s+", the_packet.message)
|
m = re.match(r"^CQ\s+(\S{3,}?)\s+", the_packet.message) or re.match(r"^CQ\s+\S{2}\s+(\S{3,}?)\s+", the_packet.message)
|
||||||
if m:
|
if m:
|
||||||
|
@ -313,12 +315,14 @@ def main():
|
||||||
resolved = cw.output_queue.get(False)
|
resolved = cw.output_queue.get(False)
|
||||||
print("Resolved packet available callsign:{}, dupe:{}, mult:{}".format(resolved['callsign'], resolved['dupe'], resolved['is_mult']))
|
print("Resolved packet available callsign:{}, dupe:{}, mult:{}".format(resolved['callsign'], resolved['dupe'], resolved['is_mult']))
|
||||||
wsjtx_id = resolved['input'].wsjtx_id
|
wsjtx_id = resolved['input'].wsjtx_id
|
||||||
|
|
||||||
if resolved['dupe']:
|
if resolved['dupe']:
|
||||||
color_pkt = pywsjtx.HighlightCallsignPacket.Builder(wsjtx_id, resolved['callsign'],
|
color_pkt = pywsjtx.HighlightCallsignPacket.Builder(wsjtx_id, resolved['callsign'],
|
||||||
dupe_background_color,
|
dupe_background_color,
|
||||||
dupe_foreground_color,
|
dupe_foreground_color,
|
||||||
True)
|
True)
|
||||||
s.send_packet(resolved['addr_port'], color_pkt)
|
s.send_packet(resolved['addr_port'], color_pkt)
|
||||||
|
|
||||||
if resolved['is_mult']:
|
if resolved['is_mult']:
|
||||||
color_pkt = pywsjtx.HighlightCallsignPacket.Builder(wsjtx_id, resolved['callsign'],
|
color_pkt = pywsjtx.HighlightCallsignPacket.Builder(wsjtx_id, resolved['callsign'],
|
||||||
mult_background_color,
|
mult_background_color,
|
||||||
|
|
Ładowanie…
Reference in New Issue