diff --git a/gcs/src/components/connectionProgress.jsx b/gcs/src/components/connectionProgress.jsx index 9c902d0ea..7e885b41f 100644 --- a/gcs/src/components/connectionProgress.jsx +++ b/gcs/src/components/connectionProgress.jsx @@ -1,13 +1,19 @@ import { Progress } from "@mantine/core" +import { useSelector } from "react-redux" +import { selectFetchingParam } from "../redux/slices/paramsSlice" export default function ConnectionProgress({ connecting, status }) { + const param = useSelector(selectFetchingParam) return ( <> {connecting && status.message !== null && typeof status.progress === "number" && ( <> -

{status.message}

+

{status.message}

+

+ {param ? <>Fetching {param} : "Fetching params..."} +

{ } }) + socket.socket.on("fetching_param", (msg) => { + store.dispatch(setFetchingParam(msg.message)) + }) + // Link stats socket.socket.on(SocketEvents.linkDebugStats, (msg) => { window.ipcRenderer.invoke("app:update-link-stats", msg) diff --git a/gcs/src/redux/slices/paramsSlice.js b/gcs/src/redux/slices/paramsSlice.js index d71ca5782..2d47aaa2f 100644 --- a/gcs/src/redux/slices/paramsSlice.js +++ b/gcs/src/redux/slices/paramsSlice.js @@ -11,6 +11,7 @@ const paramsSlice = createSlice({ showModifiedParams: false, fetchingVars: false, fetchingVarsProgress: { progress: 0, param_id: "" }, + fetchingParam: "", searchValue: "", hasFetchedOnce: false, loadParamsFileModalOpen: false, @@ -56,6 +57,10 @@ const paramsSlice = createSlice({ if (action.payload === state.fetchingVarsProgress) return state.fetchingVarsProgress = action.payload }, + setFetchingParam: (state, action) => { + if (action.payload === state.fetchingParam) return + state.fetchingParam = action.payload + }, setParamSearchValue: (state, action) => { if (action.payload === state.searchValue) return state.searchValue = action.payload @@ -120,6 +125,7 @@ const paramsSlice = createSlice({ resetParamState: (state) => { state.fetchingVars = false state.fetchingVarsProgress = { progress: 0, param_id: "" } + state.fetchingParam = "" state.params = [] state.shownParams = [] state.modifiedParams = [] @@ -182,6 +188,7 @@ const paramsSlice = createSlice({ selectShowModifiedParams: (state) => state.showModifiedParams, selectFetchingVars: (state) => state.fetchingVars, selectFetchingVarsProgress: (state) => state.fetchingVarsProgress, + selectFetchingParam: (state) => state.fetchingParam, selectParamSearchValue: (state) => state.searchValue, selectHasFetchedOnce: (state) => state.hasFetchedOnce, selectLoadParamsFileModalOpen: (state) => state.loadParamsFileModalOpen, @@ -207,6 +214,7 @@ export const { setModifiedParams, setFetchingVars, setFetchingVarsProgress, + setFetchingParam, setParamSearchValue, toggleShowModifiedParams, appendModifiedParams, @@ -239,6 +247,7 @@ export const { selectModifiedParams, selectFetchingVars, selectFetchingVarsProgress, + selectFetchingParam, selectShowModifiedParams, selectParamSearchValue, selectHasFetchedOnce, diff --git a/radio/app/controllers/paramsController.py b/radio/app/controllers/paramsController.py index dbe7575cd..977b12c35 100644 --- a/radio/app/controllers/paramsController.py +++ b/radio/app/controllers/paramsController.py @@ -61,6 +61,9 @@ def getSingleParam(self, param_name: str, timeout: float = 3) -> Response: try: time.sleep(0.05) # Brief pause for stability + if self.drone.fetchingParameterCb: + self.drone.fetchingParameterCb(param_name) + self.drone.master.mav.param_request_read_send( self.drone.target_system, self.drone.target_component, diff --git a/radio/app/drone.py b/radio/app/drone.py index 54ca9d0c6..57e6f7e72 100644 --- a/radio/app/drone.py +++ b/radio/app/drone.py @@ -81,6 +81,7 @@ def __init__( droneDisconnectCb: Optional[Callable] = None, droneConnectStatusCb: Optional[Callable] = None, linkDebugStatsCb: Optional[Callable] = None, + fetchingParameterCb: Optional[Callable] = None, ) -> None: """ The drone class interfaces with the UAS via MavLink. @@ -99,6 +100,7 @@ def __init__( self.droneDisconnectCb = droneDisconnectCb self.droneConnectStatusCb = droneConnectStatusCb self.linkDebugStatsCb = linkDebugStatsCb + self.fetchingParameterCb = fetchingParameterCb self.connectionError: Optional[str] = None diff --git a/radio/app/endpoints/autopilot.py b/radio/app/endpoints/autopilot.py index fd1920608..5ae2e8f5e 100644 --- a/radio/app/endpoints/autopilot.py +++ b/radio/app/endpoints/autopilot.py @@ -22,6 +22,7 @@ def rebootAutopilot() -> None: droneDisconnectCb = droneStatus.drone.droneDisconnectCb droneConnectStatusCb = droneStatus.drone.droneConnectStatusCb linkDebugStatsCb = droneStatus.drone.linkDebugStatsCb + fetchingParameterCb = droneStatus.drone.fetchingParameterCb forwarding_address = droneStatus.drone.forwarding_address socketio.emit("disconnected_from_drone") @@ -55,6 +56,7 @@ def rebootAutopilot() -> None: droneDisconnectCb=droneDisconnectCb, droneConnectStatusCb=droneConnectStatusCb, linkDebugStatsCb=linkDebugStatsCb, + fetchingParameterCb=fetchingParameterCb, ) if droneStatus.drone.connectionError: tries += 1 diff --git a/radio/app/endpoints/comPorts.py b/radio/app/endpoints/comPorts.py index 709e869e2..6d97b38cb 100644 --- a/radio/app/endpoints/comPorts.py +++ b/radio/app/endpoints/comPorts.py @@ -13,6 +13,7 @@ droneErrorCb, getComPortNames, getFlightSwVersionString, + fetchingParameterCb, ) @@ -140,6 +141,7 @@ def connectToDrone(data: ConnectionDataType) -> None: droneDisconnectCb=disconnectFromDrone, droneConnectStatusCb=droneConnectStatusCb, linkDebugStatsCb=sendLinkDebugStats, + fetchingParameterCb=fetchingParameterCb, ) if drone.connectionError is not None: diff --git a/radio/app/utils.py b/radio/app/utils.py index f5562cefc..e94557630 100644 --- a/radio/app/utils.py +++ b/radio/app/utils.py @@ -178,6 +178,19 @@ def notConnectedError(action: Optional[str] = None) -> None: ) +def fetchingParameterCb(param_name: str) -> None: + """ + Send the parameter currently being fetched to the socket. + + Args: + param_name (str): The name of the parameter currently being fetched. + """ + socketio.emit( + "fetching_param", + {"success": True, "message": param_name}, + ) + + def missingParameterError(endpoint: str, params: Union[str, list[str]]) -> None: """ " Send error to the socket indicating that a request made to the server was missing required parameters