visualizer-components 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/assets/RudderIcon.d.ts +23 -0
- package/dist/assets/RudderIcon.d.ts.map +1 -0
- package/dist/assets/RudderIcon.js +23 -0
- package/dist/assets/RudderIcon.js.map +1 -0
- package/dist/assets/svgSources.d.ts +18 -0
- package/dist/assets/svgSources.d.ts.map +1 -0
- package/dist/assets/svgSources.js +18 -0
- package/dist/assets/svgSources.js.map +1 -0
- package/dist/components/Joystick.d.ts +23 -0
- package/dist/components/Joystick.d.ts.map +1 -0
- package/dist/components/Joystick.js +114 -0
- package/dist/components/Joystick.js.map +1 -0
- package/dist/components/TelemetryDashboard.d.ts +31 -0
- package/dist/components/TelemetryDashboard.d.ts.map +1 -0
- package/dist/components/TelemetryDashboard.js +127 -0
- package/dist/components/TelemetryDashboard.js.map +1 -0
- package/dist/components/controls/ControlOverlay.d.ts +64 -0
- package/dist/components/controls/ControlOverlay.d.ts.map +1 -0
- package/dist/components/controls/ControlOverlay.js +88 -0
- package/dist/components/controls/ControlOverlay.js.map +1 -0
- package/dist/components/controls/ControlsDrawer.d.ts +37 -0
- package/dist/components/controls/ControlsDrawer.d.ts.map +1 -0
- package/dist/components/controls/ControlsDrawer.js +93 -0
- package/dist/components/controls/ControlsDrawer.js.map +1 -0
- package/dist/components/controls/ForceVectorsPanel.d.ts +37 -0
- package/dist/components/controls/ForceVectorsPanel.d.ts.map +1 -0
- package/dist/components/controls/ForceVectorsPanel.js +76 -0
- package/dist/components/controls/ForceVectorsPanel.js.map +1 -0
- package/dist/components/controls/InfoPopover.d.ts +34 -0
- package/dist/components/controls/InfoPopover.d.ts.map +1 -0
- package/dist/components/controls/InfoPopover.js +41 -0
- package/dist/components/controls/InfoPopover.js.map +1 -0
- package/dist/components/controls/Legend.d.ts +29 -0
- package/dist/components/controls/Legend.d.ts.map +1 -0
- package/dist/components/controls/Legend.js +74 -0
- package/dist/components/controls/Legend.js.map +1 -0
- package/dist/components/controls/MobileBottomNav.d.ts +17 -0
- package/dist/components/controls/MobileBottomNav.d.ts.map +1 -0
- package/dist/components/controls/MobileBottomNav.js +46 -0
- package/dist/components/controls/MobileBottomNav.js.map +1 -0
- package/dist/components/hud/SceneHUD.d.ts +100 -0
- package/dist/components/hud/SceneHUD.d.ts.map +1 -0
- package/dist/components/hud/SceneHUD.js +216 -0
- package/dist/components/hud/SceneHUD.js.map +1 -0
- package/dist/components/hud/telemetry/Batteries.d.ts +40 -0
- package/dist/components/hud/telemetry/Batteries.d.ts.map +1 -0
- package/dist/components/hud/telemetry/Batteries.js +137 -0
- package/dist/components/hud/telemetry/Batteries.js.map +1 -0
- package/dist/components/hud/telemetry/Compass.d.ts +2 -0
- package/dist/components/hud/telemetry/Compass.d.ts.map +1 -0
- package/dist/components/hud/telemetry/Compass.js +147 -0
- package/dist/components/hud/telemetry/Compass.js.map +1 -0
- package/dist/components/hud/telemetry/Log.d.ts +2 -0
- package/dist/components/hud/telemetry/Log.d.ts.map +1 -0
- package/dist/components/hud/telemetry/Log.js +65 -0
- package/dist/components/hud/telemetry/Log.js.map +1 -0
- package/dist/components/hud/telemetry/Map.d.ts +4 -0
- package/dist/components/hud/telemetry/Map.d.ts.map +1 -0
- package/dist/components/hud/telemetry/Map.js +293 -0
- package/dist/components/hud/telemetry/Map.js.map +1 -0
- package/dist/components/hud/telemetry/PowerRudderPanel.d.ts +2 -0
- package/dist/components/hud/telemetry/PowerRudderPanel.d.ts.map +1 -0
- package/dist/components/hud/telemetry/PowerRudderPanel.js +115 -0
- package/dist/components/hud/telemetry/PowerRudderPanel.js.map +1 -0
- package/dist/components/hud/telemetry/RadiusVisualizer.d.ts +63 -0
- package/dist/components/hud/telemetry/RadiusVisualizer.d.ts.map +1 -0
- package/dist/components/hud/telemetry/RadiusVisualizer.js +139 -0
- package/dist/components/hud/telemetry/RadiusVisualizer.js.map +1 -0
- package/dist/components/hud/telemetry/RadiusVisualizerPanel.d.ts +31 -0
- package/dist/components/hud/telemetry/RadiusVisualizerPanel.d.ts.map +1 -0
- package/dist/components/hud/telemetry/RadiusVisualizerPanel.js +37 -0
- package/dist/components/hud/telemetry/RadiusVisualizerPanel.js.map +1 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizer.d.ts +43 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizer.d.ts.map +1 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizer.js +121 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizer.js.map +1 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizerPanel.d.ts +26 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizerPanel.d.ts.map +1 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizerPanel.js +29 -0
- package/dist/components/hud/telemetry/ShipRudderVisualizerPanel.js.map +1 -0
- package/dist/components/hud/telemetry/SignalLog.d.ts +7 -0
- package/dist/components/hud/telemetry/SignalLog.d.ts.map +1 -0
- package/dist/components/hud/telemetry/SignalLog.js +28 -0
- package/dist/components/hud/telemetry/SignalLog.js.map +1 -0
- package/dist/components/hud/telemetry/SignalStrength.d.ts +9 -0
- package/dist/components/hud/telemetry/SignalStrength.d.ts.map +1 -0
- package/dist/components/hud/telemetry/SignalStrength.js +53 -0
- package/dist/components/hud/telemetry/SignalStrength.js.map +1 -0
- package/dist/components/hud/telemetry/Speedometer.d.ts +2 -0
- package/dist/components/hud/telemetry/Speedometer.d.ts.map +1 -0
- package/dist/components/hud/telemetry/Speedometer.js +70 -0
- package/dist/components/hud/telemetry/Speedometer.js.map +1 -0
- package/dist/components/hud/telemetry/Task.d.ts +2 -0
- package/dist/components/hud/telemetry/Task.d.ts.map +1 -0
- package/dist/components/hud/telemetry/Task.js +61 -0
- package/dist/components/hud/telemetry/Task.js.map +1 -0
- package/dist/components/hud/telemetry/TaskData.d.ts +2 -0
- package/dist/components/hud/telemetry/TaskData.d.ts.map +1 -0
- package/dist/components/hud/telemetry/TaskData.js +62 -0
- package/dist/components/hud/telemetry/TaskData.js.map +1 -0
- package/dist/components/hud/telemetry/index.d.ts +40 -0
- package/dist/components/hud/telemetry/index.d.ts.map +1 -0
- package/dist/components/hud/telemetry/index.js +40 -0
- package/dist/components/hud/telemetry/index.js.map +1 -0
- package/dist/components/hud/telemetry/powerColor.d.ts +16 -0
- package/dist/components/hud/telemetry/powerColor.d.ts.map +1 -0
- package/dist/components/hud/telemetry/powerColor.js +15 -0
- package/dist/components/hud/telemetry/powerColor.js.map +1 -0
- package/dist/components/scenes/MappingScene.d.ts +19 -0
- package/dist/components/scenes/MappingScene.d.ts.map +1 -0
- package/dist/components/scenes/MappingScene.js +353 -0
- package/dist/components/scenes/MappingScene.js.map +1 -0
- package/dist/components/scenes/SceneCanvas.d.ts +96 -0
- package/dist/components/scenes/SceneCanvas.d.ts.map +1 -0
- package/dist/components/scenes/SceneCanvas.js +151 -0
- package/dist/components/scenes/SceneCanvas.js.map +1 -0
- package/dist/components/scenes/SceneRenderer.d.ts +16 -0
- package/dist/components/scenes/SceneRenderer.d.ts.map +1 -0
- package/dist/components/scenes/SceneRenderer.js +60 -0
- package/dist/components/scenes/SceneRenderer.js.map +1 -0
- package/dist/components/scenes/TelemetryScene.d.ts +6 -0
- package/dist/components/scenes/TelemetryScene.d.ts.map +1 -0
- package/dist/components/scenes/TelemetryScene.js +6 -0
- package/dist/components/scenes/TelemetryScene.js.map +1 -0
- package/dist/components/svg/CompassRose.d.ts +129 -0
- package/dist/components/svg/CompassRose.d.ts.map +1 -0
- package/dist/components/svg/CompassRose.js +221 -0
- package/dist/components/svg/CompassRose.js.map +1 -0
- package/dist/connection/config.d.ts +41 -0
- package/dist/connection/config.d.ts.map +1 -0
- package/dist/connection/config.js +44 -0
- package/dist/connection/config.js.map +1 -0
- package/dist/contexts/SceneContext.d.ts +35 -0
- package/dist/contexts/SceneContext.d.ts.map +1 -0
- package/dist/contexts/SceneContext.js +24 -0
- package/dist/contexts/SceneContext.js.map +1 -0
- package/dist/hooks/useAutoPathAnimation.d.ts +22 -0
- package/dist/hooks/useAutoPathAnimation.d.ts.map +1 -0
- package/dist/hooks/useAutoPathAnimation.js +102 -0
- package/dist/hooks/useAutoPathAnimation.js.map +1 -0
- package/dist/hooks/useLayoutConfig.d.ts +29 -0
- package/dist/hooks/useLayoutConfig.d.ts.map +1 -0
- package/dist/hooks/useLayoutConfig.js +30 -0
- package/dist/hooks/useLayoutConfig.js.map +1 -0
- package/dist/hooks/useSceneContext.d.ts +64 -0
- package/dist/hooks/useSceneContext.d.ts.map +1 -0
- package/dist/hooks/useSceneContext.js +37 -0
- package/dist/hooks/useSceneContext.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/TelemetryProvider.d.ts +27 -0
- package/dist/providers/TelemetryProvider.d.ts.map +1 -0
- package/dist/providers/TelemetryProvider.js +50 -0
- package/dist/providers/TelemetryProvider.js.map +1 -0
- package/dist/providers/TelemetryThemeProvider.d.ts +25 -0
- package/dist/providers/TelemetryThemeProvider.d.ts.map +1 -0
- package/dist/providers/TelemetryThemeProvider.js +54 -0
- package/dist/providers/TelemetryThemeProvider.js.map +1 -0
- package/dist/store/actions/connectionActions.d.ts +39 -0
- package/dist/store/actions/connectionActions.d.ts.map +1 -0
- package/dist/store/actions/connectionActions.js +162 -0
- package/dist/store/actions/connectionActions.js.map +1 -0
- package/dist/store/actions/fetchTelemetry.d.ts +51 -0
- package/dist/store/actions/fetchTelemetry.d.ts.map +1 -0
- package/dist/store/actions/fetchTelemetry.js +135 -0
- package/dist/store/actions/fetchTelemetry.js.map +1 -0
- package/dist/store/index.d.ts +23 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +22 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/slices/connectionSlice.d.ts +15 -0
- package/dist/store/slices/connectionSlice.d.ts.map +1 -0
- package/dist/store/slices/connectionSlice.js +39 -0
- package/dist/store/slices/connectionSlice.js.map +1 -0
- package/dist/store/slices/discoveredGridSlice.d.ts +168 -0
- package/dist/store/slices/discoveredGridSlice.d.ts.map +1 -0
- package/dist/store/slices/discoveredGridSlice.js +146 -0
- package/dist/store/slices/discoveredGridSlice.js.map +1 -0
- package/dist/store/slices/sceneSlice.d.ts +185 -0
- package/dist/store/slices/sceneSlice.d.ts.map +1 -0
- package/dist/store/slices/sceneSlice.js +95 -0
- package/dist/store/slices/sceneSlice.js.map +1 -0
- package/dist/store/slices/simulationSlice.d.ts +87 -0
- package/dist/store/slices/simulationSlice.d.ts.map +1 -0
- package/dist/store/slices/simulationSlice.js +55 -0
- package/dist/store/slices/simulationSlice.js.map +1 -0
- package/dist/store/slices/telemetrySlice.d.ts +10 -0
- package/dist/store/slices/telemetrySlice.d.ts.map +1 -0
- package/dist/store/slices/telemetrySlice.js +88 -0
- package/dist/store/slices/telemetrySlice.js.map +1 -0
- package/dist/store/slices/videoSlice.d.ts +12 -0
- package/dist/store/slices/videoSlice.d.ts.map +1 -0
- package/dist/store/slices/videoSlice.js +27 -0
- package/dist/store/slices/videoSlice.js.map +1 -0
- package/dist/store/slices/visualizationSlice.d.ts +152 -0
- package/dist/store/slices/visualizationSlice.d.ts.map +1 -0
- package/dist/store/slices/visualizationSlice.js +58 -0
- package/dist/store/slices/visualizationSlice.js.map +1 -0
- package/dist/store/store.d.ts +61 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +78 -0
- package/dist/store/store.js.map +1 -0
- package/dist/theme/index.d.ts +14 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +14 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/lightTheme.d.ts +151 -0
- package/dist/theme/lightTheme.d.ts.map +1 -0
- package/dist/theme/lightTheme.js +194 -0
- package/dist/theme/lightTheme.js.map +1 -0
- package/dist/theme/telemetryTheme.d.ts +90 -0
- package/dist/theme/telemetryTheme.d.ts.map +1 -0
- package/dist/theme/telemetryTheme.js +157 -0
- package/dist/theme/telemetryTheme.js.map +1 -0
- package/dist/types/detectedObjectsTypes.d.ts +18 -0
- package/dist/types/detectedObjectsTypes.d.ts.map +1 -0
- package/dist/types/detectedObjectsTypes.js +8 -0
- package/dist/types/detectedObjectsTypes.js.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/ros.d.ts +87 -0
- package/dist/types/ros.d.ts.map +1 -0
- package/dist/types/ros.js +17 -0
- package/dist/types/ros.js.map +1 -0
- package/dist/types/statusTypes.d.ts +81 -0
- package/dist/types/statusTypes.d.ts.map +1 -0
- package/dist/types/statusTypes.js +52 -0
- package/dist/types/statusTypes.js.map +1 -0
- package/dist/types/taskTypes.d.ts +65 -0
- package/dist/types/taskTypes.d.ts.map +1 -0
- package/dist/types/taskTypes.js +18 -0
- package/dist/types/taskTypes.js.map +1 -0
- package/dist/types/telemetryInterfaces.d.ts +81 -0
- package/dist/types/telemetryInterfaces.d.ts.map +1 -0
- package/dist/types/telemetryInterfaces.js +30 -0
- package/dist/types/telemetryInterfaces.js.map +1 -0
- package/dist/utils/basestation.d.ts +7 -0
- package/dist/utils/basestation.d.ts.map +1 -0
- package/dist/utils/basestation.js +49 -0
- package/dist/utils/basestation.js.map +1 -0
- package/dist/utils/batteryUtil.d.ts +8 -0
- package/dist/utils/batteryUtil.d.ts.map +1 -0
- package/dist/utils/batteryUtil.js +32 -0
- package/dist/utils/batteryUtil.js.map +1 -0
- package/dist/utils/telemetry/index.d.ts +13 -0
- package/dist/utils/telemetry/index.d.ts.map +1 -0
- package/dist/utils/telemetry/index.js +13 -0
- package/dist/utils/telemetry/index.js.map +1 -0
- package/dist/utils/telemetry/telemetryFactory.d.ts +48 -0
- package/dist/utils/telemetry/telemetryFactory.d.ts.map +1 -0
- package/dist/utils/telemetry/telemetryFactory.js +390 -0
- package/dist/utils/telemetry/telemetryFactory.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @file TelemetryThemeProvider.tsx
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* This file defines the TelemetryThemeProvider component, which is responsible for providing a custom Material-UI theme to the telemetry-related components in the application.
|
|
7
|
+
* It uses the ThemeProvider component from Material-UI to wrap its children with the custom telemetry theme defined in the telemetryTheme file.
|
|
8
|
+
*
|
|
9
|
+
* @author Carson Fujita
|
|
10
|
+
* @license MIT
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* - Specifically for telemetry-related components
|
|
14
|
+
*/
|
|
15
|
+
/*
|
|
16
|
+
|
|
17
|
+
MIT License
|
|
18
|
+
|
|
19
|
+
Copyright (c) 2026 HumberASV
|
|
20
|
+
Copyright (c) 2026 Carson Fujita
|
|
21
|
+
|
|
22
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
23
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
24
|
+
in the Software without restriction, including without limitation the rights
|
|
25
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
26
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
27
|
+
furnished to do so, subject to the following conditions:
|
|
28
|
+
|
|
29
|
+
The above copyright notice and this permission notice shall be included in all
|
|
30
|
+
copies or substantial portions of the Software.
|
|
31
|
+
|
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
|
+
SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
import React from "react";
|
|
41
|
+
import { ThemeProvider as MuiThemeProvider } from "@mui/material/styles";
|
|
42
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
43
|
+
import { telemetryTheme } from "../theme/telemetryTheme";
|
|
44
|
+
/**
|
|
45
|
+
* the provider component for the telemetry page,
|
|
46
|
+
* which wraps its children with the Material-UI ThemeProvider to give them access to the custom telemetry theme.
|
|
47
|
+
* @param children the child components that will have access to the custom telemetry theme.
|
|
48
|
+
* @returns the TelemetryThemeProvider component that wraps its children with the Material-UI ThemeProvider,
|
|
49
|
+
*/
|
|
50
|
+
const TelemetryThemeProvider = ({ children, }) => {
|
|
51
|
+
return (_jsxs(MuiThemeProvider, { theme: telemetryTheme, children: [_jsx(CssBaseline, {}), children] }));
|
|
52
|
+
};
|
|
53
|
+
export default TelemetryThemeProvider;
|
|
54
|
+
//# sourceMappingURL=TelemetryThemeProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TelemetryThemeProvider.js","sourceRoot":"","sources":["../../src/providers/TelemetryThemeProvider.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;;;;;;;;;;;;EAwBE;AAEF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,WAAW,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,sBAAsB,GAA4C,CAAC,EACvE,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,MAAC,gBAAgB,IAAC,KAAK,EAAE,cAAc,aACrC,KAAC,WAAW,KAAG,EACd,QAAQ,IACQ,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file connectionActions.ts
|
|
3
|
+
* @description Redux actions for managing the WebSocket connection to the ASV basestation.
|
|
4
|
+
*
|
|
5
|
+
* @author Carson Fujita
|
|
6
|
+
*/
|
|
7
|
+
import type { AppDispatch } from '../store';
|
|
8
|
+
/**
|
|
9
|
+
* Attempts a WebSocket connection to the basestation.
|
|
10
|
+
*
|
|
11
|
+
* @param options.silentFail - When true (auto-retry from mock mode), failures stay in mock
|
|
12
|
+
* rather than transitioning to 'failed'. This prevents the dashboard from being replaced
|
|
13
|
+
* by the connection interstitial during background retries.
|
|
14
|
+
*
|
|
15
|
+
* Flow:
|
|
16
|
+
* 1. Health-check the HTTP server.
|
|
17
|
+
* 2. If online, open WebSocket.
|
|
18
|
+
* 3. On first data frame: mark connected and show success toast.
|
|
19
|
+
* 4. On failure: silentFail → stay in mock; else → 'failed' (interstitial in Connect.tsx).
|
|
20
|
+
*/
|
|
21
|
+
export declare const initConnection: (options?: {
|
|
22
|
+
silentFail?: boolean;
|
|
23
|
+
}) => (dispatch: AppDispatch) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Auto-retry used by Telemetry.tsx while in mock mode. Failures stay in mock
|
|
26
|
+
* so the dashboard remains visible.
|
|
27
|
+
*/
|
|
28
|
+
export declare const retryConnection: () => (dispatch: AppDispatch) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* User-initiated reconnect from the 'failed' interstitial. Failures return to
|
|
31
|
+
* 'failed' so the interstitial is shown again.
|
|
32
|
+
*/
|
|
33
|
+
export declare const reconnect: () => (dispatch: AppDispatch) => Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Transitions from 'failed' to 'mock', starting simulation data.
|
|
36
|
+
* Called when the user clicks "Use Simulation Data" on the failed interstitial.
|
|
37
|
+
*/
|
|
38
|
+
export declare const startSimulation: () => (dispatch: AppDispatch) => void;
|
|
39
|
+
//# sourceMappingURL=connectionActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionActions.d.ts","sourceRoot":"","sources":["../../../src/store/actions/connectionActions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAqB5C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,UAAS;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,MAAY,UAAU,WAAW,kBA6FrG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,SAAgB,UAAU,WAAW,kBAYhE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,SAAgB,UAAU,WAAW,kBAW1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,SAAU,UAAU,WAAW,SAG1D,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file connectionActions.ts
|
|
3
|
+
* @description Redux actions for managing the WebSocket connection to the ASV basestation.
|
|
4
|
+
*
|
|
5
|
+
* @author Carson Fujita
|
|
6
|
+
*/
|
|
7
|
+
import { getTelemetryConnectionConfig } from '../../connection/config';
|
|
8
|
+
import { setConnectionStatus, setConnectionUrl, showToast } from '../slices/connectionSlice';
|
|
9
|
+
import { fetchTelemetrySuccess, startMockTelemetryUpdates, stopMockTelemetryUpdates } from './fetchTelemetry';
|
|
10
|
+
import { setVideoStreamUrl } from '../slices/videoSlice';
|
|
11
|
+
import { resetDiscovery } from '../slices/discoveredGridSlice';
|
|
12
|
+
import { isBasestationOnline } from '../../utils/basestation';
|
|
13
|
+
// Module-level reference so the socket can be cleaned up if needed.
|
|
14
|
+
let socket = null;
|
|
15
|
+
function fallbackToMock(dispatch) {
|
|
16
|
+
dispatch(resetDiscovery());
|
|
17
|
+
dispatch(setConnectionStatus('mock'));
|
|
18
|
+
dispatch(showToast({ message: 'Basestation unreachable — using simulation data', severity: 'warning' }));
|
|
19
|
+
dispatch(startMockTelemetryUpdates());
|
|
20
|
+
}
|
|
21
|
+
function failedToConnect(dispatch) {
|
|
22
|
+
dispatch(setConnectionStatus('failed'));
|
|
23
|
+
// Pre-populate the map with simulation data so the visualizer has something to show.
|
|
24
|
+
// retryConnection calls stopMockTelemetryUpdates first, so this is safe to re-run on retry.
|
|
25
|
+
dispatch(startMockTelemetryUpdates());
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Attempts a WebSocket connection to the basestation.
|
|
29
|
+
*
|
|
30
|
+
* @param options.silentFail - When true (auto-retry from mock mode), failures stay in mock
|
|
31
|
+
* rather than transitioning to 'failed'. This prevents the dashboard from being replaced
|
|
32
|
+
* by the connection interstitial during background retries.
|
|
33
|
+
*
|
|
34
|
+
* Flow:
|
|
35
|
+
* 1. Health-check the HTTP server.
|
|
36
|
+
* 2. If online, open WebSocket.
|
|
37
|
+
* 3. On first data frame: mark connected and show success toast.
|
|
38
|
+
* 4. On failure: silentFail → stay in mock; else → 'failed' (interstitial in Connect.tsx).
|
|
39
|
+
*/
|
|
40
|
+
export const initConnection = (options = {}) => async (dispatch) => {
|
|
41
|
+
const { silentFail = false } = options;
|
|
42
|
+
// Resolve endpoints at call time so configureTelemetryConnection() overrides
|
|
43
|
+
// applied before dispatch are honored.
|
|
44
|
+
const { wsUrl, timeoutMs } = getTelemetryConnectionConfig();
|
|
45
|
+
if (socket && socket.readyState <= WebSocket.OPEN)
|
|
46
|
+
return;
|
|
47
|
+
dispatch(setConnectionUrl(wsUrl));
|
|
48
|
+
if (!silentFail) {
|
|
49
|
+
dispatch(setConnectionStatus('connecting'));
|
|
50
|
+
}
|
|
51
|
+
const online = await isBasestationOnline();
|
|
52
|
+
if (!online) {
|
|
53
|
+
if (silentFail) {
|
|
54
|
+
// Reset from 'connecting' (set by retryConnection) back to mock.
|
|
55
|
+
dispatch(setConnectionStatus('mock'));
|
|
56
|
+
dispatch(startMockTelemetryUpdates());
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
failedToConnect(dispatch);
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
socket = new WebSocket(wsUrl);
|
|
64
|
+
const opened = await new Promise((resolve) => {
|
|
65
|
+
const timeout = setTimeout(() => {
|
|
66
|
+
socket?.close();
|
|
67
|
+
resolve(false);
|
|
68
|
+
}, timeoutMs);
|
|
69
|
+
socket.onopen = () => {
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
resolve(true);
|
|
72
|
+
};
|
|
73
|
+
socket.onerror = () => {
|
|
74
|
+
clearTimeout(timeout);
|
|
75
|
+
resolve(false);
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
if (!opened) {
|
|
79
|
+
if (silentFail)
|
|
80
|
+
fallbackToMock(dispatch);
|
|
81
|
+
else
|
|
82
|
+
failedToConnect(dispatch);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Defer "connected" toast until the first data frame arrives.
|
|
86
|
+
let connected = false;
|
|
87
|
+
socket.onmessage = (event) => {
|
|
88
|
+
if (!connected) {
|
|
89
|
+
connected = true;
|
|
90
|
+
dispatch(setConnectionStatus('connected'));
|
|
91
|
+
dispatch(showToast({ message: 'Connected to ASV basestation', severity: 'success' }));
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
const rawData = JSON.parse(event.data);
|
|
95
|
+
if (rawData.video?.streamUrl) {
|
|
96
|
+
const { httpBase } = getTelemetryConnectionConfig();
|
|
97
|
+
const streamUrl = rawData.video.streamUrl.startsWith('/')
|
|
98
|
+
? `${httpBase}${rawData.video.streamUrl}`
|
|
99
|
+
: rawData.video.streamUrl;
|
|
100
|
+
dispatch(setVideoStreamUrl(streamUrl));
|
|
101
|
+
}
|
|
102
|
+
dispatch(fetchTelemetrySuccess(rawData));
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// ignore malformed frames
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
socket.onclose = () => {
|
|
109
|
+
if (!connected) {
|
|
110
|
+
// Socket closed before any data — treat same as failed-to-open.
|
|
111
|
+
if (silentFail)
|
|
112
|
+
fallbackToMock(dispatch);
|
|
113
|
+
else
|
|
114
|
+
failedToConnect(dispatch);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Mid-session disconnect: stay on dashboard in mock mode.
|
|
118
|
+
dispatch(showToast({ message: 'Connection lost — switching to simulation', severity: 'warning' }));
|
|
119
|
+
fallbackToMock(dispatch);
|
|
120
|
+
};
|
|
121
|
+
socket.onerror = () => {
|
|
122
|
+
// onclose fires immediately after onerror, no extra dispatch needed.
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Auto-retry used by Telemetry.tsx while in mock mode. Failures stay in mock
|
|
127
|
+
* so the dashboard remains visible.
|
|
128
|
+
*/
|
|
129
|
+
export const retryConnection = () => async (dispatch) => {
|
|
130
|
+
dispatch(stopMockTelemetryUpdates());
|
|
131
|
+
dispatch(setConnectionStatus('connecting'));
|
|
132
|
+
if (socket) {
|
|
133
|
+
socket.onclose = null;
|
|
134
|
+
socket.onerror = null;
|
|
135
|
+
socket.close();
|
|
136
|
+
socket = null;
|
|
137
|
+
}
|
|
138
|
+
await initConnection({ silentFail: true })(dispatch);
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* User-initiated reconnect from the 'failed' interstitial. Failures return to
|
|
142
|
+
* 'failed' so the interstitial is shown again.
|
|
143
|
+
*/
|
|
144
|
+
export const reconnect = () => async (dispatch) => {
|
|
145
|
+
dispatch(stopMockTelemetryUpdates());
|
|
146
|
+
if (socket) {
|
|
147
|
+
socket.onclose = null;
|
|
148
|
+
socket.onerror = null;
|
|
149
|
+
socket.close();
|
|
150
|
+
socket = null;
|
|
151
|
+
}
|
|
152
|
+
await initConnection()(dispatch);
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Transitions from 'failed' to 'mock', starting simulation data.
|
|
156
|
+
* Called when the user clicks "Use Simulation Data" on the failed interstitial.
|
|
157
|
+
*/
|
|
158
|
+
export const startSimulation = () => (dispatch) => {
|
|
159
|
+
dispatch(setConnectionStatus('mock'));
|
|
160
|
+
dispatch(startMockTelemetryUpdates());
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=connectionActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionActions.js","sourceRoot":"","sources":["../../../src/store/actions/connectionActions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,oEAAoE;AACpE,IAAI,MAAM,GAAqB,IAAI,CAAC;AAEpC,SAAS,cAAc,CAAC,QAAqB;IACzC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3B,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,iDAAiD,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACzG,QAAQ,CAAC,yBAAyB,EAAE,CAAC,CAAC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,QAAQ,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,QAAqB,EAAE,EAAE;IAC3D,QAAQ,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAErC,IAAI,MAAM,EAAE,CAAC;QACT,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,cAAc,EAAE,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,CAAC,QAAqB,EAAE,EAAE;IAC3D,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtC,QAAQ,CAAC,yBAAyB,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TelemetryActionTypes } from '../../types/telemetryInterfaces';
|
|
2
|
+
import type { Status as TelemetryState } from '../../types';
|
|
3
|
+
import type { AppDispatch } from '../store';
|
|
4
|
+
/**
|
|
5
|
+
* This action creator is dispatched when telemetry data is successfully received from the basestation.
|
|
6
|
+
* @param data data - The telemetry data received, which includes various parameters such as speed, heading, battery levels, etc.
|
|
7
|
+
* @returns An action object indicating successful telemetry fetch.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fetchTelemetrySuccess: (data: TelemetryState) => TelemetryActionTypes;
|
|
10
|
+
/**
|
|
11
|
+
* This action creator is dispatched when there is an error in fetching telemetry data from the basestation.
|
|
12
|
+
* @param error error - A string describing the error that occurred during the telemetry data fetch attempt.
|
|
13
|
+
* @returns An action object indicating failed telemetry fetch, containing the error message.
|
|
14
|
+
*/
|
|
15
|
+
export declare const fetchTelemetryFailure: (error: string) => TelemetryActionTypes;
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* This function generates mock telemetry data for testing purposes without needing a WebSocket connection.
|
|
19
|
+
* It can be used in development or testing environments to simulate receiving telemetry data.
|
|
20
|
+
*
|
|
21
|
+
* @author Carson Fujita
|
|
22
|
+
* @returns A thunk action that dispatches the generated mock telemetry data to the Redux store.
|
|
23
|
+
* @remarks
|
|
24
|
+
* - Optional utility function to generate random telemetry data for testing purposes without needing a WebSocket connection.
|
|
25
|
+
* - This can be used in development or testing environments to simulate receiving telemetry data.
|
|
26
|
+
*/
|
|
27
|
+
export declare const getMockStatus: () => (dispatch: AppDispatch) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Starts generating mock telemetry updates at regular intervals.
|
|
30
|
+
* @returns A thunk action that initiates the mock telemetry updates.
|
|
31
|
+
*/
|
|
32
|
+
export declare const startMockTelemetryUpdates: () => (dispatch: AppDispatch) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Stops generating mock telemetry updates.
|
|
35
|
+
* @returns A thunk action that stops the mock telemetry updates.
|
|
36
|
+
*/
|
|
37
|
+
export declare const stopMockTelemetryUpdates: () => () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Generates a fresh random telemetry state, replacing any existing mock state and
|
|
40
|
+
* restarting the update interval. Useful for getting a new map layout on demand.
|
|
41
|
+
*/
|
|
42
|
+
export declare const regenerateMockTelemetry: () => (dispatch: AppDispatch) => void;
|
|
43
|
+
export declare const TelemetryActions: {
|
|
44
|
+
fetchTelemetrySuccess: (data: TelemetryState) => TelemetryActionTypes;
|
|
45
|
+
fetchTelemetryFailure: (error: string) => TelemetryActionTypes;
|
|
46
|
+
getMockStatus: () => (dispatch: AppDispatch) => void;
|
|
47
|
+
startMockTelemetryUpdates: () => (dispatch: AppDispatch) => void;
|
|
48
|
+
stopMockTelemetryUpdates: () => () => void;
|
|
49
|
+
regenerateMockTelemetry: () => (dispatch: AppDispatch) => void;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=fetchTelemetry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchTelemetry.d.ts","sourceRoot":"","sources":["../../../src/store/actions/fetchTelemetry.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,MAAM,cAAc,KAAG,oBAG3D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,KAAG,oBAGpD,CAAC;AAMH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,SACd,UAAU,WAAW,SAQhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,SAC1B,UAAU,WAAW,SA2BhC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,kBAOpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,SACxB,UAAU,WAAW,SAoBhC,CAAC;AAEF,eAAO,MAAM,gBAAgB;kCAnHe,cAAc,KAAG,oBAAoB;mCAUpC,MAAM,KAAG,oBAAoB;0BAqB9D,UAAU,WAAW;sCAerB,UAAU,WAAW;;oCA+CrB,UAAU,WAAW;CA6BhC,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file fetchTelemetry.ts
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This file contains Redux action creators for fetching telemetry data from the basestation.
|
|
6
|
+
* It includes actions for handling successful data retrieval as well as error handling for failed attempts.
|
|
7
|
+
* Additionally, it provides utility functions for starting and stopping mock telemetry updates,
|
|
8
|
+
* which can be used for testing purposes without needing a live WebSocket connection.
|
|
9
|
+
*
|
|
10
|
+
* @author Carson Fujita
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
13
|
+
import { FETCH_TELEMETRY_SUCCESS, FETCH_TELEMETRY_FAILURE, } from '../../types/telemetryInterfaces';
|
|
14
|
+
import generateRandomState, { generateMockStateUpdate, generateMockVideoUrl } from '../../utils/telemetry/telemetryFactory';
|
|
15
|
+
import { SET_STATUS } from '../slices/telemetrySlice';
|
|
16
|
+
import { setFineGrid } from '../slices/simulationSlice';
|
|
17
|
+
import { setVideoStreamUrl } from '../slices/videoSlice';
|
|
18
|
+
/**
|
|
19
|
+
* This action creator is dispatched when telemetry data is successfully received from the basestation.
|
|
20
|
+
* @param data data - The telemetry data received, which includes various parameters such as speed, heading, battery levels, etc.
|
|
21
|
+
* @returns An action object indicating successful telemetry fetch.
|
|
22
|
+
*/
|
|
23
|
+
export const fetchTelemetrySuccess = (data) => ({
|
|
24
|
+
type: FETCH_TELEMETRY_SUCCESS,
|
|
25
|
+
payload: data
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* This action creator is dispatched when there is an error in fetching telemetry data from the basestation.
|
|
29
|
+
* @param error error - A string describing the error that occurred during the telemetry data fetch attempt.
|
|
30
|
+
* @returns An action object indicating failed telemetry fetch, containing the error message.
|
|
31
|
+
*/
|
|
32
|
+
export const fetchTelemetryFailure = (error) => ({
|
|
33
|
+
type: FETCH_TELEMETRY_FAILURE,
|
|
34
|
+
payload: error
|
|
35
|
+
});
|
|
36
|
+
// Additional action creators for starting and stopping mock telemetry updates can be added here,
|
|
37
|
+
let mockTelemetryInterval = null;
|
|
38
|
+
let mockTelemetryState = null;
|
|
39
|
+
/**
|
|
40
|
+
* @description
|
|
41
|
+
* This function generates mock telemetry data for testing purposes without needing a WebSocket connection.
|
|
42
|
+
* It can be used in development or testing environments to simulate receiving telemetry data.
|
|
43
|
+
*
|
|
44
|
+
* @author Carson Fujita
|
|
45
|
+
* @returns A thunk action that dispatches the generated mock telemetry data to the Redux store.
|
|
46
|
+
* @remarks
|
|
47
|
+
* - Optional utility function to generate random telemetry data for testing purposes without needing a WebSocket connection.
|
|
48
|
+
* - This can be used in development or testing environments to simulate receiving telemetry data.
|
|
49
|
+
*/
|
|
50
|
+
export const getMockStatus = () => {
|
|
51
|
+
return (dispatch) => {
|
|
52
|
+
console.log("Generating mock telemetry data...");
|
|
53
|
+
const { status, fineGrid } = generateRandomState();
|
|
54
|
+
mockTelemetryState = status;
|
|
55
|
+
dispatch(fetchTelemetrySuccess(status));
|
|
56
|
+
dispatch(setFineGrid(fineGrid));
|
|
57
|
+
dispatch(setVideoStreamUrl(generateMockVideoUrl()));
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Starts generating mock telemetry updates at regular intervals.
|
|
62
|
+
* @returns A thunk action that initiates the mock telemetry updates.
|
|
63
|
+
*/
|
|
64
|
+
export const startMockTelemetryUpdates = () => {
|
|
65
|
+
return (dispatch) => {
|
|
66
|
+
if (mockTelemetryInterval) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Narrow through a local — TS cannot narrow the module-level `let` inside closures.
|
|
70
|
+
let current = mockTelemetryState;
|
|
71
|
+
if (!current) {
|
|
72
|
+
const { status, fineGrid } = generateRandomState();
|
|
73
|
+
current = status;
|
|
74
|
+
mockTelemetryState = status;
|
|
75
|
+
dispatch(setFineGrid(fineGrid));
|
|
76
|
+
dispatch(setVideoStreamUrl(generateMockVideoUrl()));
|
|
77
|
+
}
|
|
78
|
+
dispatch(fetchTelemetrySuccess(current));
|
|
79
|
+
mockTelemetryInterval = setInterval(() => {
|
|
80
|
+
if (!mockTelemetryState) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const next = generateMockStateUpdate(mockTelemetryState);
|
|
84
|
+
mockTelemetryState = next;
|
|
85
|
+
const { asv: _asv, ...statusUpdate } = next;
|
|
86
|
+
dispatch(SET_STATUS(statusUpdate));
|
|
87
|
+
}, 1000);
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Stops generating mock telemetry updates.
|
|
92
|
+
* @returns A thunk action that stops the mock telemetry updates.
|
|
93
|
+
*/
|
|
94
|
+
export const stopMockTelemetryUpdates = () => {
|
|
95
|
+
return () => {
|
|
96
|
+
if (mockTelemetryInterval) {
|
|
97
|
+
clearInterval(mockTelemetryInterval);
|
|
98
|
+
mockTelemetryInterval = null;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Generates a fresh random telemetry state, replacing any existing mock state and
|
|
104
|
+
* restarting the update interval. Useful for getting a new map layout on demand.
|
|
105
|
+
*/
|
|
106
|
+
export const regenerateMockTelemetry = () => {
|
|
107
|
+
return (dispatch) => {
|
|
108
|
+
if (mockTelemetryInterval) {
|
|
109
|
+
clearInterval(mockTelemetryInterval);
|
|
110
|
+
mockTelemetryInterval = null;
|
|
111
|
+
}
|
|
112
|
+
const { status, fineGrid } = generateRandomState();
|
|
113
|
+
mockTelemetryState = status;
|
|
114
|
+
dispatch(fetchTelemetrySuccess(status));
|
|
115
|
+
dispatch(setFineGrid(fineGrid));
|
|
116
|
+
dispatch(setVideoStreamUrl(generateMockVideoUrl()));
|
|
117
|
+
mockTelemetryInterval = setInterval(() => {
|
|
118
|
+
if (!mockTelemetryState)
|
|
119
|
+
return;
|
|
120
|
+
const next = generateMockStateUpdate(mockTelemetryState);
|
|
121
|
+
mockTelemetryState = next;
|
|
122
|
+
const { asv: _asv, ...statusUpdate } = next;
|
|
123
|
+
dispatch(SET_STATUS(statusUpdate));
|
|
124
|
+
}, 1000);
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export const TelemetryActions = {
|
|
128
|
+
fetchTelemetrySuccess,
|
|
129
|
+
fetchTelemetryFailure,
|
|
130
|
+
getMockStatus,
|
|
131
|
+
startMockTelemetryUpdates,
|
|
132
|
+
stopMockTelemetryUpdates,
|
|
133
|
+
regenerateMockTelemetry,
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=fetchTelemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchTelemetry.js","sourceRoot":"","sources":["../../../src/store/actions/fetchTelemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACH,uBAAuB,EACvB,uBAAuB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,OAAO,mBAAmB,EAAE,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAI5H,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAoB,EAAwB,EAAE,CAAC,CAAC;IAClF,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,IAAI;CAChB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAwB,EAAE,CAAC,CAAC;IAC3E,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,KAAK;CACjB,CAAC,CAAC;AAEH,iGAAiG;AACjG,IAAI,qBAAqB,GAA0C,IAAI,CAAC;AACxE,IAAI,kBAAkB,GAA0B,IAAI,CAAC;AAErD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAC9B,OAAO,CAAC,QAAqB,EAAE,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,mBAAmB,EAAE,CAAC;QACnD,kBAAkB,GAAG,MAAM,CAAC;QAC5B,QAAQ,CAAC,qBA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**
|
|
2
|
+
* @file store/index.ts
|
|
3
|
+
* @description
|
|
4
|
+
* This file serves as a central export point for the Redux store configuration and related types in the ASV telemetry application.
|
|
5
|
+
* It exports the configured store, the root state type, the dispatch type, the typed hooks, and every slice's actions/selectors
|
|
6
|
+
* plus the connection/telemetry thunks for use throughout the application.
|
|
7
|
+
* @author Carson Fujita
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/
|
|
10
|
+
export { default } from './store';
|
|
11
|
+
export { default as store } from './store';
|
|
12
|
+
export type { RootState, AppDispatch } from './store';
|
|
13
|
+
export * from './store';
|
|
14
|
+
export * from './actions/fetchTelemetry';
|
|
15
|
+
export * from './actions/connectionActions';
|
|
16
|
+
export * from './slices/telemetrySlice';
|
|
17
|
+
export * from './slices/connectionSlice';
|
|
18
|
+
export * from './slices/visualizationSlice';
|
|
19
|
+
export * from './slices/simulationSlice';
|
|
20
|
+
export * from './slices/videoSlice';
|
|
21
|
+
export * from './slices/discoveredGridSlice';
|
|
22
|
+
export * from './slices/sceneSlice';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtD,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file store/index.ts
|
|
3
|
+
* @description
|
|
4
|
+
* This file serves as a central export point for the Redux store configuration and related types in the ASV telemetry application.
|
|
5
|
+
* It exports the configured store, the root state type, the dispatch type, the typed hooks, and every slice's actions/selectors
|
|
6
|
+
* plus the connection/telemetry thunks for use throughout the application.
|
|
7
|
+
* @author Carson Fujita
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/
|
|
10
|
+
export { default } from './store';
|
|
11
|
+
export { default as store } from './store';
|
|
12
|
+
export * from './store';
|
|
13
|
+
export * from './actions/fetchTelemetry';
|
|
14
|
+
export * from './actions/connectionActions';
|
|
15
|
+
export * from './slices/telemetrySlice';
|
|
16
|
+
export * from './slices/connectionSlice';
|
|
17
|
+
export * from './slices/visualizationSlice';
|
|
18
|
+
export * from './slices/simulationSlice';
|
|
19
|
+
export * from './slices/videoSlice';
|
|
20
|
+
export * from './slices/discoveredGridSlice';
|
|
21
|
+
export * from './slices/sceneSlice';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAE3C,cAAc,SAAS,CAAC;AACxB,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type ConnectionStatus = 'idle' | 'connecting' | 'connected' | 'mock' | 'failed';
|
|
2
|
+
export interface ToastState {
|
|
3
|
+
open: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
severity: 'success' | 'error' | 'info' | 'warning';
|
|
6
|
+
}
|
|
7
|
+
export interface ConnectionState {
|
|
8
|
+
status: ConnectionStatus;
|
|
9
|
+
url: string;
|
|
10
|
+
toast: ToastState;
|
|
11
|
+
}
|
|
12
|
+
export declare const setConnectionStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<ConnectionStatus, "connection/setConnectionStatus">, setConnectionUrl: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "connection/setConnectionUrl">, showToast: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToastState, "message" | "severity">, "connection/showToast">, dismissToast: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"connection/dismissToast">;
|
|
13
|
+
declare const _default: import("redux").Reducer<ConnectionState>;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=connectionSlice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionSlice.d.ts","sourceRoot":"","sources":["../../../src/store/slices/connectionSlice.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEvF,MAAM,WAAW,UAAU;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACtD;AAED,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,gBAAgB,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,UAAU,CAAC;CACrB;AA6BD,eAAO,MAAQ,mBAAmB,2GAAE,gBAAgB,8FAAE,SAAS,yHAAE,YAAY,mFAA4B,CAAC;;AAC1G,wBAAuC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file connectionSlice.ts
|
|
3
|
+
* @description Manages the connection state for the ASV.
|
|
4
|
+
*
|
|
5
|
+
* @author Carson Fujita
|
|
6
|
+
* @license MIT
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* - The connection state includes the current status of the connection (idle, connecting, connected, mock) and the WebSocket URL.
|
|
10
|
+
*/
|
|
11
|
+
import { createSlice } from '@reduxjs/toolkit';
|
|
12
|
+
const initialState = {
|
|
13
|
+
// Populated by initConnection() with the URL resolved from the runtime
|
|
14
|
+
// connection config (see connection/config.ts) at connect time.
|
|
15
|
+
status: 'idle',
|
|
16
|
+
url: '',
|
|
17
|
+
toast: { open: false, message: '', severity: 'info' },
|
|
18
|
+
};
|
|
19
|
+
const connectionSlice = createSlice({
|
|
20
|
+
name: 'connection',
|
|
21
|
+
initialState,
|
|
22
|
+
reducers: {
|
|
23
|
+
setConnectionStatus(state, action) {
|
|
24
|
+
state.status = action.payload;
|
|
25
|
+
},
|
|
26
|
+
setConnectionUrl(state, action) {
|
|
27
|
+
state.url = action.payload;
|
|
28
|
+
},
|
|
29
|
+
showToast(state, action) {
|
|
30
|
+
state.toast = { open: true, ...action.payload };
|
|
31
|
+
},
|
|
32
|
+
dismissToast(state) {
|
|
33
|
+
state.toast.open = false;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export const { setConnectionStatus, setConnectionUrl, showToast, dismissToast } = connectionSlice.actions;
|
|
38
|
+
export default connectionSlice.reducer;
|
|
39
|
+
//# sourceMappingURL=connectionSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionSlice.js","sourceRoot":"","sources":["../../../src/store/slices/connectionSlice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAsB,MAAM,kBAAkB,CAAC;AAgBnE,MAAM,YAAY,GAAoB;IAClC,uEAAuE;IACvE,gEAAgE;IAChE,MAAM,EAAE,MAAM;IACd,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;CACxD,CAAC;AAEF,MAAM,eAAe,GAAG,WAAW,CAAC;IAChC,IAAI,EAAE,YAAY;IAClB,YAAY;IACZ,QAAQ,EAAE;QACN,mBAAmB,CAAC,KAAK,EAAE,MAAuC;YAC9D,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;QAClC,CAAC;QACD,gBAAgB,CAAC,KAAK,EAAE,MAA6B;YACjD,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC;QAC/B,CAAC;QACD,SAAS,CAAC,KAAK,EAAE,MAA+D;YAC5E,KAAK,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QACpD,CAAC;QACD,YAAY,CAAC,KAAK;YACd,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;QAC7B,CAAC;KACJ;CACJ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,eAAe,CAAC,OAAO,CAAC;AAC1G,eAAe,eAAe,CAAC,OAAO,CAAC"}
|