first test with stats system

This commit is contained in:
DJ2LS 2023-02-02 18:03:22 +01:00
parent 559116fef0
commit 9514565290
5 changed files with 27 additions and 3 deletions

View file

@ -83,7 +83,8 @@ class CONFIG:
'fmax': data[20],
'qrv': data[23],
'rxbuffersize': data[24],
'explorer': data[25]
'explorer': data[25],
'stats': data[28]
}
try:
with open(self.config_name, 'w') as configfile:

View file

@ -158,7 +158,8 @@ class DAEMON:
# data[24] rx_buffer_size
# data[25] explorer
# data[26] ssid_list
# data[26] auto_tune
# data[27] auto_tune
# data[28] stats
if data[0] == "STARTTNC":
self.log.warning("[DMN] Starting TNC", rig=data[5], port=data[6])
@ -253,7 +254,7 @@ class DAEMON:
if data[25] == "True":
options.append("--explorer")
# wen want our ssid like this: --ssid 1 2 3 4
# we want our ssid like this: --ssid 1 2 3 4
ssid_list = ""
for i in data[26]:
ssid_list += str(i) + " "
@ -263,6 +264,9 @@ class DAEMON:
if data[27] == "True":
options.append("--tune")
if data[28] == "True":
options.append("--stats")
# safe data to config file
config.write_entire_config(data)
import os, sys

View file

@ -23,6 +23,7 @@ import numpy as np
import sock
import static
import structlog
import stats
import ujson as json
from codec2 import FREEDV_MODE
from exceptions import NoCallsign
@ -36,6 +37,7 @@ class DATA:
"""Terminal Node Controller for FreeDATA"""
log = structlog.get_logger("DATA")
stats = stats.stats()
def __init__(self) -> None:
# Initial call sign. Will be overwritten later
@ -1307,6 +1309,8 @@ class DATA:
overflows=static.BUFFER_OVERFLOW_COUNTER,
)
if static.ENABLE_STATS:
stats.push()
# finally do an arq cleanup
self.arq_cleanup()
@ -1327,6 +1331,10 @@ class DATA:
"[TNC] ARQ | TX | TRANSMISSION FAILED OR TIME OUT!",
overflows=static.BUFFER_OVERFLOW_COUNTER,
)
if static.ENABLE_STATS:
stats.push()
self.stop_transmission()
if TESTMODE:

View file

@ -284,6 +284,13 @@ if __name__ == "__main__":
action="store_true",
help="Enable auto tuning of audio level with ALC information form hamlib",
)
PARSER.add_argument(
"--stats",
dest="enable_stats",
action="store_true",
help="Enable publishing stats to https://freedata.app",
)
ARGS = PARSER.parse_args()
# set save to folder state for allowing downloading files to local file system
@ -341,6 +348,7 @@ if __name__ == "__main__":
static.RX_BUFFER_SIZE = ARGS.rx_buffer_size
static.ENABLE_EXPLORER = ARGS.enable_explorer
static.AUDIO_AUTO_TUNE = ARGS.enable_audio_auto_tune
static.ENABLE_STATS = ARGS.enable_stats
except Exception as e:
log.error("[DMN] Error reading config file", exception=e)
@ -396,6 +404,7 @@ if __name__ == "__main__":
static.RX_BUFFER_SIZE = int(config['TNC']['rxbuffersize'])
static.ENABLE_EXPLORER = config['TNC']['explorer'] in ["True", "true", True]
static.AUDIO_AUTO_TUNE = config['AUDIO']['auto_tune'] in ["True", "true", True]
static.ENABLE_STATS = config['TNC']['stats'] in ["True", "true", True]
except KeyError as e:
log.warning("[CFG] Error reading config file near", key=str(e))

View file

@ -14,6 +14,7 @@ from enum import Enum
VERSION = "0.7.2-alpha.1-exp"
ENABLE_EXPLORER = False
ENABLE_STATS = False
# DAEMON
@ -133,6 +134,7 @@ RX_BUFFER_SIZE: int = 16
HEARD_STATIONS: list = []
# ------- INFO MESSAGE BUFFER
# TODO: This can be removed?
INFO: list = []
# ------- CODEC2 SETTINGS