Busy slot states

This commit is contained in:
Mashintime 2023-11-28 17:29:01 -05:00
parent 99e6c86220
commit bf31ca5891
4 changed files with 25 additions and 40 deletions

View file

@ -243,9 +243,9 @@ export default {
data-bs-trigger="hover" data-bs-trigger="hover"
data-bs-html="true" data-bs-html="true"
v-bind:class="{ v-bind:class="{
'btn-warning': state.getChannelBusySlotState(0) === true, 'btn-warning': state.channel_busy_slot[0] === true,
'btn-outline-secondary': 'btn-outline-secondary':
state.getChannelBusySlotState(0) === false, state.channel_busy_slot[0] === false,
}" }"
title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>" title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>"
> >
@ -260,9 +260,9 @@ export default {
data-bs-trigger="hover" data-bs-trigger="hover"
data-bs-html="true" data-bs-html="true"
v-bind:class="{ v-bind:class="{
'btn-warning': state.getChannelBusySlotState(1) === true, 'btn-warning': state.channel_busy_slot[1] === true,
'btn-outline-secondary': 'btn-outline-secondary':
state.getChannelBusySlotState(1) === false, state.channel_busy_slot[1] === false,
}" }"
title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>" title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>"
> >
@ -277,9 +277,9 @@ export default {
data-bs-trigger="hover" data-bs-trigger="hover"
data-bs-html="true" data-bs-html="true"
v-bind:class="{ v-bind:class="{
'btn-warning': state.getChannelBusySlotState(2) === true, 'btn-warning': state.channel_busy_slot[2] === true,
'btn-outline-secondary': 'btn-outline-secondary':
state.getChannelBusySlotState(2) === false, state.channel_busy_slot[2] === false,
}" }"
title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>" title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>"
> >
@ -294,9 +294,9 @@ export default {
data-bs-trigger="hover" data-bs-trigger="hover"
data-bs-html="true" data-bs-html="true"
v-bind:class="{ v-bind:class="{
'btn-warning': state.getChannelBusySlotState(3) === true, 'btn-warning': state.channel_busy_slot[3] === true,
'btn-outline-secondary': 'btn-outline-secondary':
state.getChannelBusySlotState(3) === false, state.channel_busy_slot[3] === false,
}" }"
title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>" title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>"
> >
@ -311,9 +311,9 @@ export default {
data-bs-trigger="hover" data-bs-trigger="hover"
data-bs-html="true" data-bs-html="true"
v-bind:class="{ v-bind:class="{
'btn-warning': state.getChannelBusySlotState(4) === true, 'btn-warning': state.channel_busy_slot[4] === true,
'btn-outline-secondary': 'btn-outline-secondary':
state.getChannelBusySlotState(4) === false, state.channel_busy_slot[4] === false,
}" }"
title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>" title="Channel busy state: <strong class='text-success'>not busy</strong> / <strong class='text-danger'>busy </strong>"
> >

View file

@ -19,7 +19,7 @@ export const useStateStore = defineStore("stateStore", () => {
var speed_level = ref(0); var speed_level = ref(0);
var fft = ref(); var fft = ref();
var channel_busy = ref(false); var channel_busy = ref(false);
var channel_busy_slot = ref(); var channel_busy_slot = ref([false,false,false,false,false]);
var scatter = ref(); var scatter = ref();
var s_meter_strength_percent = ref(0); var s_meter_strength_percent = ref(0);
var s_meter_strength_raw = ref(0); var s_meter_strength_raw = ref(0);
@ -64,25 +64,6 @@ export const useStateStore = defineStore("stateStore", () => {
var rx_buffer_length = ref(); var rx_buffer_length = ref();
function getChannelBusySlotState(slot) {
const slot_state = channel_busy_slot.value;
if (typeof slot_state !== "undefined") {
// Replace 'False' with 'false' to match JavaScript's boolean representation
const string = slot_state
.replace(/False/g, "false")
.replace(/True/g, "true");
// Parse the string to get an array
const arr = JSON.parse(string);
return arr[slot];
} else {
// Handle the undefined case
return false;
}
}
function updateTncState(state) { function updateTncState(state) {
modem_connection.value = state; modem_connection.value = state;
@ -109,7 +90,6 @@ export const useStateStore = defineStore("stateStore", () => {
fft, fft,
channel_busy, channel_busy,
channel_busy_slot, channel_busy_slot,
getChannelBusySlotState,
scatter, scatter,
ptt_state, ptt_state,
s_meter_strength_percent, s_meter_strength_percent,

View file

@ -1399,6 +1399,7 @@ class RF:
slot3 = [120, 176] slot3 = [120, 176]
slot4 = [176, 231] slot4 = [176, 231]
slot5 = [231, len(dfftlist)] slot5 = [231, len(dfftlist)]
slotbusy = [False,False,False,False,False]
# Set to true if we should increment delay count; else false to decrement # Set to true if we should increment delay count; else false to decrement
addDelay=False addDelay=False
@ -1413,11 +1414,11 @@ class RF:
# so we have a smoother state toggle # so we have a smoother state toggle
if np.sum(slotdfft[slotdfft > avg + 15]) >= 200 and not self.states.isTransmitting(): if np.sum(slotdfft[slotdfft > avg + 15]) >= 200 and not self.states.isTransmitting():
addDelay=True addDelay=True
self.states.channel_busy_slot[slot] = True slotbusy[slot]=True
else: #self.states.channel_busy_slot[slot] = True
self.states.channel_busy_slot[slot] = False
# increment slot # increment slot
slot += 1 slot += 1
self.states.set_channel_slot_busy(slotbusy)
if addDelay: if addDelay:
# Limit delay counter to a maximum of 200. The higher this value, # Limit delay counter to a maximum of 200. The higher this value,
# the longer we will wait until releasing state # the longer we will wait until releasing state

View file

@ -51,9 +51,6 @@ class StateManager:
# Set rig control status regardless or rig control method # Set rig control status regardless or rig control method
self.radio_status = False self.radio_status = False
def sendState (self): def sendState (self):
currentState = self.get_state_event(False) currentState = self.get_state_event(False)
self.statequeue.put(currentState) self.statequeue.put(currentState)
@ -70,7 +67,15 @@ class StateManager:
if new_state != self.newstate: if new_state != self.newstate:
self.newstate = new_state self.newstate = new_state
self.sendStateUpdate() self.sendStateUpdate()
def set_channel_slot_busy(self, array):
for i in range(0,len(array),1):
if not array[i] == self.channel_busy_slot[i]:
self.channel_busy_slot = array
self.newstate = self.get_state_event(True)
self.sendStateUpdate()
continue
def get_state_event(self, isChangedState): def get_state_event(self, isChangedState):
msgtype = "state-change" msgtype = "state-change"
if (not isChangedState): if (not isChangedState):
@ -85,6 +90,7 @@ class StateManager:
"radio_status": self.radio_status, "radio_status": self.radio_status,
"radio_frequency": self.radio_frequency, "radio_frequency": self.radio_frequency,
"radio_mode": self.radio_mode, "radio_mode": self.radio_mode,
"channel_busy_slot": self.channel_busy_slot,
} }
# .wait() blocks until the event is set # .wait() blocks until the event is set
@ -101,8 +107,6 @@ class StateManager:
def waitForTransmission(self): def waitForTransmission(self):
self.transmitting_event.wait() self.transmitting_event.wait()
def register_arq_instance_by_id(self, id, instance): def register_arq_instance_by_id(self, id, instance):
self.arq_instance_table[id] = instance self.arq_instance_table[id] = instance