mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
first test with states
This commit is contained in:
parent
5a10a07e21
commit
aef44b1536
5 changed files with 27 additions and 12 deletions
|
@ -20,8 +20,16 @@ import { useSettingsStore } from "../store/settingsStore.js";
|
|||
const settings = useSettingsStore(pinia);
|
||||
|
||||
export function stateDispatcher(data) {
|
||||
if (data["command"] == "modem_state") {
|
||||
//console.log(data)
|
||||
console.log(data)
|
||||
|
||||
if (data["freedata-message"] == "state-change") {
|
||||
|
||||
stateStore.channel_busy = data["channel_busy"];
|
||||
stateStore.is_codec2_traffic = data["is_codec2_traffic"];
|
||||
stateStore.is_modem_running = data["is_modem_running"];
|
||||
|
||||
|
||||
/*
|
||||
|
||||
stateStore.rx_buffer_length = data["rx_buffer_length"];
|
||||
stateStore.frequency = data["frequency"];
|
||||
|
@ -58,7 +66,6 @@ export function stateDispatcher(data) {
|
|||
stateStore.ptt_state = data["ptt_state"];
|
||||
stateStore.speed_level = data["speed_level"];
|
||||
stateStore.fft = JSON.parse(data["fft"]);
|
||||
stateStore.channel_busy = data["channel_busy"];
|
||||
stateStore.channel_busy_slot = data["channel_busy_slot"];
|
||||
|
||||
addDataToWaterfall(JSON.parse(data["fft"]));
|
||||
|
@ -96,7 +103,6 @@ export function stateDispatcher(data) {
|
|||
stateStore.alc = data["alc"];
|
||||
stateStore.rf_level = data["rf_level"];
|
||||
|
||||
stateStore.is_codec2_traffic = data["is_codec2_traffic"];
|
||||
|
||||
stateStore.arq_session_state = data["arq_session"];
|
||||
stateStore.arq_state = data["arq_state"];
|
||||
|
@ -109,6 +115,7 @@ export function stateDispatcher(data) {
|
|||
if (data["speed_list"].length > 0) {
|
||||
prepareStatsDataForStore(data["speed_list"]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
export function eventDispatcher(data) {
|
||||
|
|
|
@ -25,7 +25,7 @@ export const useStateStore = defineStore("stateStore", () => {
|
|||
|
||||
var modem_connection = ref("disconnected");
|
||||
var modemStartCount = ref(0);
|
||||
var modem_running_state = ref("--------");
|
||||
var is_modem_running = ref();
|
||||
|
||||
var arq_total_bytes = ref(0);
|
||||
var arq_transmission_percent = ref(0);
|
||||
|
@ -128,7 +128,7 @@ export const useStateStore = defineStore("stateStore", () => {
|
|||
arq_seconds_until_timeout,
|
||||
arq_seconds_until_timeout_percent,
|
||||
modem_connection,
|
||||
modem_running_state,
|
||||
is_modem_running,
|
||||
arq_session_state,
|
||||
is_codec2_traffic,
|
||||
rf_level,
|
||||
|
|
|
@ -197,7 +197,7 @@ def sock_states(sock):
|
|||
# it seems we have to keep the logics inside a loop, otherwise connection will be terminated
|
||||
client_list.add(sock)
|
||||
while True:
|
||||
state = app.states.get()
|
||||
state = app.state_queue.get()
|
||||
transmit_sock_data(state)
|
||||
|
||||
|
||||
|
|
|
@ -28,12 +28,16 @@ class SM:
|
|||
if cmd in ['start'] and not self.modem:
|
||||
audio_test = audio.test_audio_devices(self.config['AUDIO']['input_device'], self.config['AUDIO']['output_device'])
|
||||
print(audio_test)
|
||||
if False not in audio_test and None not in audio_test:
|
||||
if False not in audio_test and None not in audio_test and not self.states.is_modem_running:
|
||||
self.log.info("starting modem....")
|
||||
self.modem = modem.RF(self.config, self.modem_events, self.modem_fft, self.modem_service, self.states)
|
||||
self.data_handler = data_handler.DATA(self.config, self.modem_events)
|
||||
self.states.set("is_modem_running", True)
|
||||
|
||||
else:
|
||||
self.log.warning("starting modem failed", input_test=audio_test[0], output_test=audio_test[1])
|
||||
self.states.set("is_modem_running", False)
|
||||
|
||||
|
||||
else:
|
||||
print("--------------------------------------")
|
||||
|
@ -42,4 +46,6 @@ class SM:
|
|||
del self.data_handler
|
||||
self.modem = False
|
||||
self.data_handler = False
|
||||
self.states.set("is_modem_running", False)
|
||||
|
||||
threading.Event().wait(0.5)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
|
||||
import ujson as json
|
||||
class STATES:
|
||||
def __init__(self, statequeue):
|
||||
self.statequeue = statequeue
|
||||
|
@ -9,14 +9,16 @@ class STATES:
|
|||
self.channel_busy = False
|
||||
self.channel_busy_slot = [False, False, False, False, False]
|
||||
self.is_codec2_traffic = False
|
||||
self.is_modem_running = False
|
||||
|
||||
def set(self, key, value):
|
||||
setattr(self, key, value)
|
||||
self.statequeue.put(self.getAsJSON())
|
||||
|
||||
def getAsJSON(self):
|
||||
return {
|
||||
return json.dumps({
|
||||
"freedata-message": "state-change",
|
||||
"channel_busy": self.channel_busy,
|
||||
"is_codec2_traffic": self.is_codec2_traffic
|
||||
}
|
||||
"is_codec2_traffic": self.is_codec2_traffic,
|
||||
"is_modem_running": self.is_modem_running,
|
||||
})
|
Loading…
Reference in a new issue