From e14b16f3cffa68f2b3fa43e17658553efc39508e Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Wed, 26 Apr 2023 18:23:49 +0200 Subject: [PATCH] added placeholder for dataclasses --- tnc/data_handler.py | 2 ++ tnc/explorer.py | 2 ++ tnc/helpers.py | 1 + tnc/main.py | 3 ++- tnc/modem.py | 1 + tnc/queues.py | 1 + tnc/rigctld.py | 1 + tnc/selftest.py | 2 ++ tnc/sock.py | 1 + tnc/static.py | 51 ++++++++++++++++++++++++++++++++++++++++++++- tnc/stats.py | 1 + tnc/tci.py | 1 + 12 files changed, 65 insertions(+), 2 deletions(-) diff --git a/tnc/data_handler.py b/tnc/data_handler.py index 8af77267..f7e0d6e3 100644 --- a/tnc/data_handler.py +++ b/tnc/data_handler.py @@ -22,6 +22,7 @@ import modem import numpy as np import sock import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC import structlog import stats import ujson as json @@ -30,6 +31,7 @@ from exceptions import NoCallsign from queues import DATA_QUEUE_RECEIVED, DATA_QUEUE_TRANSMIT, RX_BUFFER from static import FRAME_TYPE as FR_TYPE + TESTMODE = False diff --git a/tnc/explorer.py b/tnc/explorer.py index aaf6d3ee..927ec66e 100644 --- a/tnc/explorer.py +++ b/tnc/explorer.py @@ -13,6 +13,8 @@ import time import ujson as json import structlog import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC + log = structlog.get_logger("explorer") diff --git a/tnc/helpers.py b/tnc/helpers.py index 85aa2f05..600d0637 100644 --- a/tnc/helpers.py +++ b/tnc/helpers.py @@ -8,6 +8,7 @@ import time from datetime import datetime,timezone import crcengine import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC import structlog import numpy as np import threading diff --git a/tnc/main.py b/tnc/main.py index 5be8b819..dc33dbaa 100755 --- a/tnc/main.py +++ b/tnc/main.py @@ -29,6 +29,7 @@ import helpers import log_handler import modem import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC import structlog import explorer import json @@ -394,7 +395,7 @@ if __name__ == "__main__": log.error("[DMN] logger init error", exception=err) log.info( - "[TNC] Starting FreeDATA", author="DJ2LS", version=static.VERSION + "[TNC] Starting FreeDATA", author="DJ2LS", version=TNC.version ) # start data handler diff --git a/tnc/modem.py b/tnc/modem.py index df0d0a9e..02aec8c2 100644 --- a/tnc/modem.py +++ b/tnc/modem.py @@ -23,6 +23,7 @@ import numpy as np import sock import sounddevice as sd import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC from static import FRAME_TYPE import structlog import ujson as json diff --git a/tnc/queues.py b/tnc/queues.py index 762113ea..f4659b2b 100644 --- a/tnc/queues.py +++ b/tnc/queues.py @@ -3,6 +3,7 @@ Hold queues used by more than one module to eliminate cyclic imports. """ import queue import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC DATA_QUEUE_TRANSMIT = queue.Queue() DATA_QUEUE_RECEIVED = queue.Queue() diff --git a/tnc/rigctld.py b/tnc/rigctld.py index a6800087..77dfdd6a 100644 --- a/tnc/rigctld.py +++ b/tnc/rigctld.py @@ -10,6 +10,7 @@ import time import structlog import threading import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC # set global hamlib version hamlib_version = 0 diff --git a/tnc/selftest.py b/tnc/selftest.py index f4da6462..5cfec42a 100644 --- a/tnc/selftest.py +++ b/tnc/selftest.py @@ -7,6 +7,8 @@ simple TNC self tests # pylint: disable=import-outside-toplevel, attribute-defined-outside-init import sys import structlog +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC + log = structlog.get_logger("selftest") diff --git a/tnc/sock.py b/tnc/sock.py index f7b90d54..e4c519c6 100644 --- a/tnc/sock.py +++ b/tnc/sock.py @@ -27,6 +27,7 @@ import time import wave import helpers import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC import structlog from random import randrange import ujson as json diff --git a/tnc/static.py b/tnc/static.py index 09d8c74a..de1f32a8 100644 --- a/tnc/static.py +++ b/tnc/static.py @@ -8,11 +8,15 @@ Here we are saving application wide variables and stats, which have to be access Not nice, suggestions are appreciated :-) """ + + + +from dataclasses import dataclass, field +from typing import List import subprocess from enum import Enum CHANNEL_BUSY_SLOT = [False] * 5 -VERSION = "0.9.0-alpha-exp.5" ENABLE_EXPLORER = False ENABLE_STATS = False @@ -173,3 +177,48 @@ class FRAME_TYPE(Enum): FEC = 251 IDENT = 254 TEST_FRAME = 255 + + + +# TODO: Move settings above to dataclasses + +@dataclass +class ARQ: + pass + +@dataclass +class Audio: + pass + +@dataclass +class Beacon: + pass + +@dataclass +class Channel: + pass + +@dataclass +class Daemon: + pass + +@dataclass +class Hamlib: + pass + +@dataclass +class Modem: + pass + +@dataclass +class Station: + pass + +@dataclass +class TCI: + pass + +@dataclass +class TNC: + version = "0.9.0-alpha-exp.5" + diff --git a/tnc/stats.py b/tnc/stats.py index 96338da8..8aa17426 100644 --- a/tnc/stats.py +++ b/tnc/stats.py @@ -13,6 +13,7 @@ import time import ujson as json import structlog import static +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC log = structlog.get_logger("stats") diff --git a/tnc/tci.py b/tnc/tci.py index 6739d9a1..cfa3629c 100644 --- a/tnc/tci.py +++ b/tnc/tci.py @@ -7,6 +7,7 @@ import websocket import numpy as np import time from queues import AUDIO_TRANSMIT_QUEUE, AUDIO_RECEIVED_QUEUE +from static import ARQ, Audio, Beacon, Channel, Daemon, Hamlib, Modem, Station, TCI, TNC class TCI: def __init__(self, hostname='127.0.0.1', port=50001):