Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion gcs/src/components/connectionProgress.jsx
Original file line number Diff line number Diff line change
@@ -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" && (
<>
<p className="text-center my-4">{status.message}</p>
<p className="text-center mt-4">{status.message}</p>
<p className="text-center mb-4 text-falcongrey-400 text-sm">
{param ? <>Fetching {param}</> : "Fetching params..."}
</p>
<Progress
animated
size="lg"
Expand Down
5 changes: 5 additions & 0 deletions gcs/src/redux/middleware/socketMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import {
import {
resetParamsWriteProgressData,
setAutoPilotRebootModalOpen,
setFetchingParam,
setFetchingVars,
setFetchingVarsProgress,
setHasFetchedOnce,
Expand Down Expand Up @@ -548,6 +549,10 @@ const socketMiddleware = (store) => {
}
})

socket.socket.on("fetching_param", (msg) => {
store.dispatch(setFetchingParam(msg.message))
})
Comment thread
Turnlings marked this conversation as resolved.

// Link stats
socket.socket.on(SocketEvents.linkDebugStats, (msg) => {
window.ipcRenderer.invoke("app:update-link-stats", msg)
Expand Down
9 changes: 9 additions & 0 deletions gcs/src/redux/slices/paramsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const paramsSlice = createSlice({
showModifiedParams: false,
fetchingVars: false,
fetchingVarsProgress: { progress: 0, param_id: "" },
fetchingParam: "",
searchValue: "",
Comment thread
Turnlings marked this conversation as resolved.
hasFetchedOnce: false,
loadParamsFileModalOpen: false,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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,
Expand All @@ -207,6 +214,7 @@ export const {
setModifiedParams,
setFetchingVars,
setFetchingVarsProgress,
setFetchingParam,
setParamSearchValue,
toggleShowModifiedParams,
appendModifiedParams,
Expand Down Expand Up @@ -239,6 +247,7 @@ export const {
selectModifiedParams,
selectFetchingVars,
selectFetchingVarsProgress,
selectFetchingParam,
selectShowModifiedParams,
selectParamSearchValue,
selectHasFetchedOnce,
Expand Down
3 changes: 3 additions & 0 deletions radio/app/controllers/paramsController.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions radio/app/drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -99,6 +100,7 @@ def __init__(
self.droneDisconnectCb = droneDisconnectCb
self.droneConnectStatusCb = droneConnectStatusCb
self.linkDebugStatsCb = linkDebugStatsCb
self.fetchingParameterCb = fetchingParameterCb

self.connectionError: Optional[str] = None

Expand Down
2 changes: 2 additions & 0 deletions radio/app/endpoints/autopilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -55,6 +56,7 @@ def rebootAutopilot() -> None:
droneDisconnectCb=droneDisconnectCb,
droneConnectStatusCb=droneConnectStatusCb,
linkDebugStatsCb=linkDebugStatsCb,
fetchingParameterCb=fetchingParameterCb,
)
if droneStatus.drone.connectionError:
tries += 1
Expand Down
2 changes: 2 additions & 0 deletions radio/app/endpoints/comPorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
droneErrorCb,
getComPortNames,
getFlightSwVersionString,
fetchingParameterCb,
)


Expand Down Expand Up @@ -140,6 +141,7 @@ def connectToDrone(data: ConnectionDataType) -> None:
droneDisconnectCb=disconnectFromDrone,
droneConnectStatusCb=droneConnectStatusCb,
linkDebugStatsCb=sendLinkDebugStats,
fetchingParameterCb=fetchingParameterCb,
)

if drone.connectionError is not None:
Expand Down
13 changes: 13 additions & 0 deletions radio/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down