Refined network management (#1672)

This PR implements several refinements to the way that NetworkManager
controls the network interface.

- The monitor detects and logs changes to the network address
- The monitor detects and logs changes to the connection and will
reinitialize the connection if needed
- Remove NetworkInterface.java class, which wasn't used anywhere
- Use java.net.NetworkInterface to get IP addresses for any interface
(device)
- Adds a metric for the current IP address (address on the currently
selected interface)
This commit is contained in:
Craig Schardt
2025-01-03 08:29:18 -06:00
committed by GitHub
parent 7c254ec5dc
commit 474e4f07f8
12 changed files with 273 additions and 204 deletions

View File

@@ -242,7 +242,7 @@ const setSelectedVideoFormat = (format: VideoFormat) => {
<td>{{ value.verticalFOV !== undefined ? value.verticalFOV.toFixed(2) + "°" : "-" }}</td>
<td>{{ value.diagonalFOV !== undefined ? value.diagonalFOV.toFixed(2) + "°" : "-" }}</td>
<v-tooltip bottom>
<template v-slot:activator="{ on, attrs }">
<template #activator="{ on, attrs }">
<td v-bind="attrs" v-on="on" @click="setSelectedVideoFormat(value)">
<v-icon small class="mr-2">mdi-information</v-icon>
</td>

View File

@@ -9,24 +9,36 @@ interface MetricItem {
value?: string;
}
const generalMetrics = computed<MetricItem[]>(() => [
{
header: "Version",
value: useSettingsStore().general.version || "Unknown"
},
{
header: "Hardware Model",
value: useSettingsStore().general.hardwareModel || "Unknown"
},
{
header: "Platform",
value: useSettingsStore().general.hardwarePlatform || "Unknown"
},
{
header: "GPU Acceleration",
value: useSettingsStore().general.gpuAcceleration || "Unknown"
const generalMetrics = computed<MetricItem[]>(() => {
const stats = [
{
header: "Version",
value: useSettingsStore().general.version || "Unknown"
},
{
header: "Hardware Model",
value: useSettingsStore().general.hardwareModel || "Unknown"
},
{
header: "Platform",
value: useSettingsStore().general.hardwarePlatform || "Unknown"
},
{
header: "GPU Acceleration",
value: useSettingsStore().general.gpuAcceleration || "Unknown"
}
];
if (!useSettingsStore().network.networkingDisabled) {
stats.push({
header: "IP Address",
value: useSettingsStore().metrics.ipAddress || "Unknown"
});
}
]);
return stats;
});
const platformMetrics = computed<MetricItem[]>(() => {
const stats = [

View File

@@ -62,7 +62,8 @@ export const useSettingsStore = defineStore("settings", {
cpuThr: undefined,
cpuUptime: undefined,
diskUtilPct: undefined,
npuUsage: undefined
npuUsage: undefined,
ipAddress: undefined
},
currentFieldLayout: {
field: {
@@ -95,7 +96,8 @@ export const useSettingsStore = defineStore("settings", {
cpuThr: data.cpuThr || undefined,
cpuUptime: data.cpuUptime || undefined,
diskUtilPct: data.diskUtilPct || undefined,
npuUsage: data.npuUsage || undefined
npuUsage: data.npuUsage || undefined,
ipAddress: data.ipAddress || undefined
};
},
updateGeneralSettingsFromWebsocket(data: WebsocketSettingsUpdate) {

View File

@@ -23,6 +23,7 @@ export interface MetricData {
cpuUptime?: string;
diskUtilPct?: string;
npuUsage?: string;
ipAddress?: string;
}
export enum NetworkConnectionType {

View File

@@ -167,11 +167,11 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<v-row>
<!-- Active modules -->
<v-col
v-for="(module, index) in activeVisionModules"
:key="`enabled-${module.uniqueName}`"
cols="12"
sm="6"
lg="4"
v-for="(module, index) in activeVisionModules"
:key="`enabled-${module.uniqueName}`"
>
<v-card dark color="primary">
<v-card-title>{{ module.nickname }}</v-card-title>
@@ -223,8 +223,8 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
</tbody>
</v-simple-table>
<photon-camera-stream
class="mt-3"
id="output-camera-stream"
class="mt-3"
:camera-settings="module"
stream-type="Processed"
style="width: 100%; height: auto"
@@ -233,16 +233,16 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<v-card-text class="pt-0">
<v-row>
<v-col cols="12" md="4" class="pr-md-0 pb-0 pb-md-3">
<v-btn color="secondary" @click="setCameraView(module.matchedCameraInfo, true)" style="width: 100%">
<v-btn color="secondary" style="width: 100%" @click="setCameraView(module.matchedCameraInfo, true)">
<span>Details</span>
</v-btn>
</v-col>
<v-col cols="6" md="5" class="pr-0">
<v-btn
class="black--text"
@click="deactivateCamera(module.uniqueName)"
color="accent"
style="width: 100%"
@click="deactivateCamera(module.uniqueName)"
>
Deactivate
</v-btn>
@@ -250,9 +250,9 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<v-col cols="6" md="3">
<v-btn
class="black--text pa-0"
@click="deleteThisCamera(module.uniqueName)"
color="red"
style="width: 100%"
@click="deleteThisCamera(module.uniqueName)"
>
<v-icon>mdi-trash-can-outline</v-icon>
</v-btn>
@@ -263,7 +263,7 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
</v-col>
<!-- Disabled modules -->
<v-col cols="12" sm="6" lg="4" v-for="module in disabledVisionModules" :key="`disabled-${module.uniqueName}`">
<v-col v-for="module in disabledVisionModules" :key="`disabled-${module.uniqueName}`" cols="12" sm="6" lg="4">
<v-card dark color="primary">
<v-card-title>{{ module.nickname }}</v-card-title>
<v-card-subtitle>Status: <span class="inactive-status">Deactivated</span></v-card-subtitle>
@@ -299,16 +299,16 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<v-card-text class="pt-0">
<v-row>
<v-col cols="12" md="4" class="pr-md-0 pb-0 pb-md-3">
<v-btn color="secondary" @click="setCameraView(module.matchedCameraInfo)" style="width: 100%">
<v-btn color="secondary" style="width: 100%" @click="setCameraView(module.matchedCameraInfo)">
<span>Details</span>
</v-btn>
</v-col>
<v-col cols="6" md="5" class="pr-0">
<v-btn
class="black--text"
@click="activateModule(module.uniqueName)"
color="accent"
style="width: 100%"
@click="activateModule(module.uniqueName)"
>
Activate
</v-btn>
@@ -316,9 +316,9 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<v-col cols="6" md="3">
<v-btn
class="black--text pa-0"
@click="deleteThisCamera(module.uniqueName)"
color="red"
style="width: 100%"
@click="deleteThisCamera(module.uniqueName)"
>
<v-icon>mdi-trash-can-outline</v-icon>
</v-btn>
@@ -329,7 +329,7 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
</v-col>
<!-- Unassigned cameras -->
<v-col cols="12" sm="6" lg="4" v-for="(camera, index) in unmatchedCameras" :key="index">
<v-col v-for="(camera, index) in unmatchedCameras" :key="index" cols="12" sm="6" lg="4">
<v-card dark color="primary">
<v-card-title>
<span v-if="camera.PVUsbCameraInfo">USB Camera:</span>
@@ -345,12 +345,12 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<v-card-text class="pt-0">
<v-row>
<v-col cols="6" class="pr-0">
<v-btn color="secondary" @click="setCameraView(camera)" style="width: 100%">
<v-btn color="secondary" style="width: 100%" @click="setCameraView(camera)">
<span>Details</span>
</v-btn>
</v-col>
<v-col cols="6">
<v-btn class="black--text" @click="activateCamera(camera)" color="accent" style="width: 100%">
<v-btn class="black--text" color="accent" style="width: 100%" @click="activateCamera(camera)">
Activate
</v-btn>
</v-col>
@@ -377,7 +377,7 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
<!-- Camera details modal -->
<v-dialog v-model="viewingDetails">
<v-card dark flat color="primary" v-if="viewingCamera !== null">
<v-card v-if="viewingCamera !== null" dark flat color="primary">
<v-card-title class="d-flex justify-space-between">
<span>{{ cameraInfoFor(viewingCamera)?.name ?? cameraInfoFor(viewingCamera)?.baseName }}</span>
<v-btn text @click="setCameraView(null)">
@@ -398,10 +398,10 @@ const setCameraView = (camera: PVCameraInfo | null, showCurrent: boolean = false
</v-banner>
<div v-if="showCurrentView">
<h3>Saved camera</h3>
<PvCameraInfoCard :camera="viewingCamera" :showTitle="false" />
<PvCameraInfoCard :camera="viewingCamera" :show-title="false" />
<br />
<h3>Current camera</h3>
<PvCameraInfoCard :camera="getMatchedDevice(viewingCamera)" :showTitle="false" />
<PvCameraInfoCard :camera="getMatchedDevice(viewingCamera)" :show-title="false" />
</div>
<div v-else>
<PvCameraInfoCard :camera="viewingCamera" />

View File

@@ -62,8 +62,8 @@ const arducamWarningShown = computed<boolean>(() => {
<template>
<v-container class="pa-3" fluid>
<v-banner
v-model="arducamWarningShown"
v-if="arducamWarningShown"
v-model="arducamWarningShown"
rounded
color="red"
dark
@@ -86,7 +86,7 @@ const arducamWarningShown = computed<boolean>(() => {
<PipelineConfigCard />
<!-- TODO - not sure this belongs here -->
<v-dialog :persistent="false" v-model="warningShown" v-if="warningShown" max-width="800" dark>
<v-dialog v-if="warningShown" v-model="warningShown" :persistent="false" max-width="800" dark>
<v-card dark flat color="primary">
<v-card-title>Setup some cameras to get started!</v-card-title>
<v-card-text>