Skip to content

Commit

Permalink
Merge pull request #39 from mbridak/38-add-opon-dialog-and-code-from-…
Browse files Browse the repository at this point in the history
…notn1mm-to-fd-logger-and-wfd-logger

38 add opon dialog and code from notn1mm to fd logger and wfd logger
  • Loading branch information
mbridak authored Feb 22, 2024
2 parents 9cce3f4 + 0751dee commit f630f9c
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 28 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ brother.

## Recent Changes

- [24.2.21] Added OPON.
- [24.2.19] Corrected the datetime.utcnow() deprecation to work on Python 3.9+
- [24.2.11] Trapped a KeyError in get_state()
- [24.1.27] Removed some datetime.utcnow() and pkgutil.getloader() deprecations.
Expand Down
74 changes: 64 additions & 10 deletions fdlogger/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
GPL V3
"""
# pylint: disable=too-many-lines, invalid-name, no-member, no-value-for-parameter, line-too-long
# pylint: disable=logging-fstring-interpolation
# Nothing to see here move along.
# xplanet -body earth -window -longitude -117 -latitude 38
# -config Default -projection azmithal -radius 200 -wait 5
Expand All @@ -17,8 +18,6 @@
from json import dumps, loads, JSONDecodeError
from shutil import copyfile

# import pkgutil

# from xmlrpc.client import ServerProxy, Error
import struct
import datetime as dt
Expand All @@ -32,8 +31,6 @@
import time
from itertools import chain

# from time import gmtime, strftime

import requests
from PyQt5.QtNetwork import QUdpSocket, QHostAddress
from PyQt5.QtGui import QFontDatabase
Expand All @@ -47,6 +44,7 @@
from fdlogger.lib.database import DataBase
from fdlogger.lib.cwinterface import CW
from fdlogger.lib.n1mm import N1MM
from fdlogger.lib.edit_opon import OpOn
from fdlogger.lib.version import __version__
except ModuleNotFoundError:
from lib.lookup import HamDBlookup, HamQTH, QRZlookup
Expand All @@ -55,6 +53,7 @@
from lib.database import DataBase
from lib.cwinterface import CW
from lib.n1mm import N1MM
from lib.edit_opon import OpOn
from lib.version import __version__


Expand Down Expand Up @@ -119,6 +118,7 @@ class MainWindow(QtWidgets.QMainWindow):
groupcall = None
server_commands = []
server_seen = None
opon_dialog = None

def __init__(self, *args, **kwargs):
"""Initialize"""
Expand Down Expand Up @@ -262,6 +262,49 @@ def __init__(self, *args, **kwargs):
self.udp_socket.bind(QHostAddress.LocalHost, 2237)
self.udp_socket.readyRead.connect(self.on_udp_socket_ready_read)

def get_opon(self) -> None:
"""
Ctrl+O Open the OPON dialog.
Parameters
----------
None
Returns
-------
None
"""

self.opon_dialog = OpOn(os.path.dirname(__loader__.get_filename()))
self.opon_dialog.accepted.connect(self.new_op)
self.opon_dialog.open()

def new_op(self) -> None:
"""
Called when the user clicks the OK button on the OPON dialog.
Create the new directory and copy the phonetic files.
Parameters
----------
None
Returns
-------
None
"""

if self.opon_dialog.NewOperator.text():
newop = self.opon_dialog.NewOperator.text().upper()
if newop:
self.n1mm.set_operator(newop)
self.preference["mycall"] = newop
self.preference["n1mm_operator"] = newop
logger.debug(f"{newop=}")
self.writepreferences()
self.opon_dialog.close()

# self.make_op_dir()

def show_people(self):
"""Display operators"""
rev_dict = {}
Expand Down Expand Up @@ -1066,7 +1109,9 @@ def poll_radio(self):
else:
logger.info("cat_control %s", self.cat_control)
self.radio_icon.setPixmap(QtGui.QPixmap(self.radio_grey))
self.oldmode = self.mode # Set so the UDP packet sends mode when no radio connected - NY4I
self.oldmode = (
self.mode
) # Set so the UDP packet sends mode when no radio connected - NY4I

def flash(self):
"""Flash the screen"""
Expand Down Expand Up @@ -1396,6 +1441,10 @@ def calltest(self):
).upper()
self.callsign_entry.setText(cleaned)
self.callsign_entry.setCursorPosition(washere)
if cleaned == "OPON":
self.get_opon()
self.clearinputs()
return
self.super_check()

def classtest(self):
Expand Down Expand Up @@ -1663,12 +1712,16 @@ def log_contact(self):

if self.preference.get("send_n1mm_packets"):
if self.oldfreq == 0:
self.n1mm.contact_info["rxfreq"] = str(self.fakefreq(self.band, self.mode))
self.n1mm.contact_info["txfreq"] = str(self.fakefreq(self.band, self.mode))
self.n1mm.contact_info["rxfreq"] = str(
self.fakefreq(self.band, self.mode)
)
self.n1mm.contact_info["txfreq"] = str(
self.fakefreq(self.band, self.mode)
)
else:
self.n1mm.contact_info["rxfreq"] = str(self.oldfreq)[:-1]
self.n1mm.contact_info["txfreq"] = str(self.oldfreq)[:-1]

self.n1mm.contact_info["mode"] = self.oldmode
if self.oldmode in ("CW", "DG"):
self.n1mm.contact_info["points"] = "2"
Expand Down Expand Up @@ -2577,6 +2630,7 @@ def save_changes(self):

def delete_contact(self):
"""delete the contact"""
oldguy = self.database.contact_by_id(self.theitem)
self.database.delete_contact(self.theitem)
if window.connect_to_server:
stale = datetime.now() + timedelta(seconds=30)
Expand All @@ -2598,8 +2652,8 @@ def delete_contact(self):
window.n1mm.contactdelete["timestamp"] = datetime.now(
dt.timezone.utc
).strftime("%Y-%m-%d %H:%M:%S")
window.n1mm.contactdelete["call"] = self.contact.get("callsign")
window.n1mm.contactdelete["ID"] = self.contact.get("unique_id")
window.n1mm.contactdelete["call"] = oldguy[0][1]
window.n1mm.contactdelete["ID"] = self.unique_id
window.n1mm.send_contact_delete()

self.change.lineChanged.emit()
Expand Down
93 changes: 93 additions & 0 deletions fdlogger/data/opon.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>382</width>
<height>90</height>
</rect>
</property>
<property name="font">
<font>
<family>JetBrains Mono</family>
</font>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="formAlignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Operator:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="NewOperator">
<property name="accessibleName">
<string>Operator</string>
</property>
<property name="accessibleDescription">
<string>Callsign of current operator.</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
15 changes: 15 additions & 0 deletions fdlogger/lib/edit_opon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Edit OpOn"""

from PyQt5 import QtWidgets, uic


class OpOn(QtWidgets.QDialog):
"""Change the current operator"""

def __init__(self, WORKING_PATH, parent=None):
super().__init__(parent)
uic.loadUi(WORKING_PATH + "/data/opon.ui", self)
self.buttonBox.clicked.connect(self.store)

def store(self):
"""dialog magic"""
32 changes: 16 additions & 16 deletions fdlogger/lib/n1mm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class N1MM:
""" "Send N1MM style packets"""

radio_info = {
"app": "K6GTE-WFD",
"app": "K6GTE-FDLOGGER",
"StationName": "",
"uNICORNbLOOD": "1",
"RadioNr": "1",
Expand All @@ -43,8 +43,8 @@ class N1MM:
}

contact_info = {
"app": "K6GTE-WFD",
"contestname": "Winter Field Day",
"app": "K6GTE-FDLOGGER",
"contestname": "ARRL Field Day",
"contestnr": "1",
"timestamp": "",
"mycall": "",
Expand Down Expand Up @@ -92,26 +92,26 @@ class N1MM:
}

contactdelete = {
"app": "K6GTE-WFD",
"app": "K6GTE-FDLOGGER",
"timestamp": "",
"call": "",
"contestnr": "1",
"StationName": "",
"ID": "",
}

bandToUDPBand = {
"160" : "1.8",
"80" : "3.5",
"40" : "7",
"20" : "14",
"15" : "21",
"10" : "28",
"6" : "50",
"2" : "144",
"222" : "222",
"432" : "420",
"SAT" : "144", # The fakefreqs are 2m so I picked 2m for SAT - NY4I
"160": "1.8",
"80": "3.5",
"40": "7",
"20": "14",
"15": "21",
"10": "28",
"6": "50",
"2": "144",
"222": "222",
"432": "420",
"SAT": "144", # The fakefreqs are 2m so I picked 2m for SAT - NY4I
}

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion fdlogger/lib/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""It's the version"""
__version__ = "24.2.19"
__version__ = "24.2.21"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "fdlogger"
version = "24.2.19"
version = "24.2.21"
description = "ARRL Field Day logger GUI"
readme = "README.md"
requires-python = ">=3.9"
Expand Down

0 comments on commit f630f9c

Please sign in to comment.