From 7c73e131a514463809f64fdc1b170259eba25780 Mon Sep 17 00:00:00 2001 From: Mashintime Date: Sat, 18 Nov 2023 17:50:40 -0500 Subject: [PATCH] Some rig control work --- gui/src/components/main_footer_navbar.vue | 4 ++-- gui/src/components/main_modem_healthcheck.vue | 8 +------- gui/src/components/main_startup_check.vue | 9 ++------- gui/src/js/eventHandler.js | 3 ++- gui/src/store/stateStore.js | 4 +++- modem/modem.py | 8 ++++---- modem/rigctld.py | 2 +- modem/rigdummy.py | 2 +- modem/state_manager.py | 8 +++++--- modem/tci.py | 2 +- 10 files changed, 22 insertions(+), 28 deletions(-) diff --git a/gui/src/components/main_footer_navbar.vue b/gui/src/components/main_footer_navbar.vue index b03635d4..66a1edc3 100644 --- a/gui/src/components/main_footer_navbar.vue +++ b/gui/src/components/main_footer_navbar.vue @@ -110,8 +110,8 @@ const state = useStateStore(pinia); data-bs-trigger="hover" data-bs-html="true" v-bind:class="{ - 'btn-warning': state.channel_busy === 'True', - 'btn-secondary': state.channel_busy === 'False', + 'btn-warning': state.channel_busy === true, + 'btn-secondary': state.channel_busy === false, }" style="pointer-events: auto" data-bs-title="Channel busy" diff --git a/gui/src/components/main_modem_healthcheck.vue b/gui/src/components/main_modem_healthcheck.vue index 5e2342a6..d50a3d44 100644 --- a/gui/src/components/main_modem_healthcheck.vue +++ b/gui/src/components/main_modem_healthcheck.vue @@ -3,8 +3,6 @@ import { setActivePinia } from "pinia"; import pinia from "../store/index"; setActivePinia(pinia); -import { settingsStore as settings } from "../store/settingsStore.js"; - import { useStateStore } from "../store/stateStore.js"; const state = useStateStore(pinia); @@ -13,11 +11,7 @@ function getOverallHealth() { let health = 0; if (state.modem_connection !== "connected") health += 5; if (!state.is_modem_running) health += 3; - if ( - settings.remote.RADIO.control === "rigctld" && - (state.rigctld_started === undefined || state.rigctld_started === "false") - ) - health += 2; + if ( state.radio_status === false) health += 2; if (process.env.FDUpdateAvail === "1") health += 1; return health; } diff --git a/gui/src/components/main_startup_check.vue b/gui/src/components/main_startup_check.vue index 616eb2e8..655aa959 100644 --- a/gui/src/components/main_startup_check.vue +++ b/gui/src/components/main_startup_check.vue @@ -48,18 +48,13 @@ function getRigControlStuff() { case "disabled": return true; case "rigctld": - if (state.rigctld_started === true) { - return true; - } else { - return false; - } case "tci": - return true; + return state.radio_status default: console.error( "Unknown radio control mode " + settings.remote.RADIO.control, ); - return "Unknown control type"; + return "Unknown control type" + settings.remote.RADIO.control; } } diff --git a/gui/src/js/eventHandler.js b/gui/src/js/eventHandler.js index 4f0c6aba..e7353a6a 100644 --- a/gui/src/js/eventHandler.js +++ b/gui/src/js/eventHandler.js @@ -37,7 +37,8 @@ export function stateDispatcher(data) { stateStore.dbfs_level = data["audio_dbfs"]; stateStore.channel_busy_slot = data["channel_busy_slot"]; stateStore.beacon_state = data["is_beacon_running"]; - + stateStore.radio_status = data["radio_status"]; + stateStore.frequency = data["radio_frequency"]; /* self.is_arq_state = False self.is_arq_session = False diff --git a/gui/src/store/stateStore.js b/gui/src/store/stateStore.js index 43ab47da..6e7d5fac 100644 --- a/gui/src/store/stateStore.js +++ b/gui/src/store/stateStore.js @@ -12,12 +12,13 @@ export const useStateStore = defineStore("stateStore", () => { var bandwidth = ref("-"); var dbfs_level_percent = ref(0); var dbfs_level = ref(0); + var radio_status = ref(false); var ptt_state = ref("False"); var speed_level = ref(0); var fft = ref(); - var channel_busy = ref(""); + var channel_busy = ref(false); var channel_busy_slot = ref(); var scatter = ref(); var s_meter_strength_percent = ref(0); @@ -139,5 +140,6 @@ export const useStateStore = defineStore("stateStore", () => { python_version, modem_version, rx_buffer_length, + radio_status, }; }); diff --git a/modem/modem.py b/modem/modem.py index 79302c8a..ca6b836b 100644 --- a/modem/modem.py +++ b/modem/modem.py @@ -1291,20 +1291,20 @@ class RF: while True: try: # this looks weird, but is necessary for avoiding rigctld packet colission sock - threading.Event().wait(0.25) + #threading.Event().wait(0.1) + self.states.set("radio_status", self.radio.get_status()) + #threading.Event().wait(0.25) self.states.set("radio_frequency", self.radio.get_frequency()) threading.Event().wait(0.1) self.states.set("radio_mode", self.radio.get_mode()) threading.Event().wait(0.1) self.states.set("radio_bandwidth", self.radio.get_bandwidth()) threading.Event().wait(0.1) - self.states.set("radio_status", self.radio.get_status()) - threading.Event().wait(0.1) if self.states.is_transmitting: self.radio_alc = self.radio.get_alc() threading.Event().wait(0.1) self.states.set("radio_rf_power", self.radio.get_level()) - # threading.Event().wait(0.1) + threading.Event().wait(0.1) self.states.set("radio_strength", self.radio.get_strength()) except Exception as e: diff --git a/modem/rigctld.py b/modem/rigctld.py index bf24e0c1..6d761b00 100644 --- a/modem/rigctld.py +++ b/modem/rigctld.py @@ -197,7 +197,7 @@ class radio: def get_status(self): """ """ - return "connected" if self.data_connected and self.ptt_connected else "unknown/disconnected" + return True if self.data_connected and self.ptt_connected else False def get_level(self): try: diff --git a/modem/rigdummy.py b/modem/rigdummy.py index 0b8596cf..1b63834d 100644 --- a/modem/rigdummy.py +++ b/modem/rigdummy.py @@ -79,7 +79,7 @@ class radio: Returns: """ - return "connected" + return True def get_ptt(self): """ """ return None diff --git a/modem/state_manager.py b/modem/state_manager.py index cb1df5dd..69d490a5 100644 --- a/modem/state_manager.py +++ b/modem/state_manager.py @@ -44,6 +44,8 @@ class STATES: self.radio_bandwidth = 0 self.radio_rf_power = 0 self.radio_strength = 0 + # Set rig control status regardless or rig control method + self.radio_status = False def sendState (self): currentState = self.getAsJSON(False) @@ -56,9 +58,8 @@ class STATES: def set(self, key, value): setattr(self, key, value) + #print(f"State ==> Setting {key} to value {value}") # only process data if changed - # but also send an update if more than a 'updateCadence' second(s) has lapsed - # Otherwise GUI can't tell if modem is active due to lack of state messages on startup new_state = self.getAsJSON(True) if new_state != self.newstate: self.newstate = new_state @@ -77,5 +78,6 @@ class STATES: "is_codec2_traffic": self.is_codec2_traffic, "is_modem_running": self.is_modem_running, "is_beacon_running": self.is_beacon_running, - + "radio_status": self.radio_status, + "radio_frequency": self.radio_frequency, }) \ No newline at end of file diff --git a/modem/tci.py b/modem/tci.py index 262c8d29..45fd97e8 100644 --- a/modem/tci.py +++ b/modem/tci.py @@ -307,7 +307,7 @@ class TCICtrl: Returns: """ - return "connected" + return True def get_ptt(self): """ """