implemented slot based busy state for performance testing

This commit is contained in:
DJ2LS 2023-04-23 14:58:03 +02:00
parent 542c527554
commit fbfc036f9f
4 changed files with 38 additions and 17 deletions

View file

@ -198,6 +198,7 @@ client.on("data", function (socketdata) {
dbfs_level: data["audio_dbfs"],
fft: data["fft"],
channel_busy: data["channel_busy"],
channel_busy_slot: data["channel_busy_slot"],
scatter: data["scatter"],
info: data["info"],
rx_buffer_length: data["rx_buffer_length"],

View file

@ -1219,23 +1219,42 @@ class RF:
# 2700Hz = 266
# 3200Hz = 315
# define the area, we are detecting busy state
dfft = dfft[120:176] if static.LOW_BANDWIDTH_MODE else dfft[65:231]
# slot
slot = 0
slot1 = [0, 65]
slot2 = [65,120]
slot3 = [120, 176]
slot4 = [176, 231]
slot5 = [231, len(dfftlist)]
for range in [slot1, slot2, slot3, slot4, slot5]:
range_start = range[0]
range_end = range[1]
# define the area, we are detecting busy state
#dfft = dfft[120:176] if static.LOW_BANDWIDTH_MODE else dfft[65:231]
dfft = dfft[range_start:range_end]
# Check for signals higher than average by checking for "100"
# If we have a signal, increment our channel_busy delay counter
# so we have a smoother state toggle
if np.sum(dfft[dfft > avg + 15]) >= 400 and not static.TRANSMITTING:
static.CHANNEL_BUSY = True
static.CHANNEL_BUSY_SLOT[slot] = True
# Limit delay counter to a maximum of 200. The higher this value,
# the longer we will wait until releasing state
channel_busy_delay = min(channel_busy_delay + 10, 200)
else:
# Decrement channel busy counter if no signal has been detected.
channel_busy_delay = max(channel_busy_delay - 1, 0)
# When our channel busy counter reaches 0, toggle state to False
if channel_busy_delay == 0:
static.CHANNEL_BUSY = False
static.CHANNEL_BUSY_SLOT[slot] = False
# increment slot
slot += 1
print(static.CHANNEL_BUSY_SLOT)
# Check for signals higher than average by checking for "100"
# If we have a signal, increment our channel_busy delay counter
# so we have a smoother state toggle
if np.sum(dfft[dfft > avg + 15]) >= 400 and not static.TRANSMITTING:
static.CHANNEL_BUSY = True
# Limit delay counter to a maximum of 200. The higher this value,
# the longer we will wait until releasing state
channel_busy_delay = min(channel_busy_delay + 10, 200)
else:
# Decrement channel busy counter if no signal has been detected.
channel_busy_delay = max(channel_busy_delay - 1, 0)
# When our channel busy counter reaches 0, toggle state to False
if channel_busy_delay == 0:
static.CHANNEL_BUSY = False
static.FFT = dfftlist[:315] # 315 --> bandwidth 3200
except Exception as err:

View file

@ -996,7 +996,6 @@ def send_tnc_state():
send the tnc state to network
"""
encoding = "utf-8"
output = {
"command": "tnc_state",
"ptt_state": str(static.PTT_STATE),
@ -1017,6 +1016,7 @@ def send_tnc_state():
"bandwidth": str(static.HAMLIB_BANDWIDTH),
"fft": str(static.FFT),
"channel_busy": str(static.CHANNEL_BUSY),
"channel_busy_slot": str(static.CHANNEL_BUSY_SLOT),
"is_codec2_traffic": str(static.IS_CODEC2_TRAFFIC),
"scatter": static.SCATTER,
"rx_buffer_length": str(RX_BUFFER.qsize()),

View file

@ -10,6 +10,7 @@ Not nice, suggestions are appreciated :-)
import subprocess
from enum import Enum
CHANNEL_BUSY_SLOT = [False] * 5
VERSION = "0.9.0-alpha-exp.1"