1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-04-21 06:56:27 -04:00
aprsd/aprsd/packets.py
Hemna de62579852 Add admin UI tabs for charts, messages, config
This patch updates the admin UI to include 3 tabs
of content.
Charts
messages
config

The charts tab is the existing line charts.
The messages tab shows a list of RX (green) and TX (red) messages
from/to aprsd.
The config tab shows the config loaded at startup time.
2021-07-12 12:12:14 -04:00

31 lines
710 B
Python

import logging
import threading
import time
LOG = logging.getLogger("APRSD")
class PacketList:
"""Class to track all of the packets rx'd and tx'd by aprsd."""
_instance = None
packet_list = {}
def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance.packet_list = {}
cls._instance.lock = threading.Lock()
return cls._instance
def __iter__(self):
with self.lock:
return iter(self.packet_list)
def add(self, packet):
with self.lock:
now = time.time()
ts = str(now).split(".")[0]
self.packet_list[ts] = packet