mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Add protobuf publish setting slider (#1075)
Allows logging software and live data view to see results. Also removes the requirement for AScope to keep up with the packet serde schema and instead just use the Protobuf descriptor.
This commit is contained in:
@@ -5,10 +5,12 @@ import PvInput from "@/components/common/pv-input.vue";
|
||||
import PvRadio from "@/components/common/pv-radio.vue";
|
||||
import PvSwitch from "@/components/common/pv-switch.vue";
|
||||
import PvSelect from "@/components/common/pv-select.vue";
|
||||
import { NetworkConnectionType } from "@/types/SettingTypes";
|
||||
import { NetworkConnectionType, type NetworkSettings } from "@/types/SettingTypes";
|
||||
import { useStateStore } from "@/stores/StateStore";
|
||||
|
||||
const settingsValid = ref(true);
|
||||
// Copy object to remove reference to store
|
||||
const tempSettingsStruct = ref<NetworkSettings>(Object.assign({}, useSettingsStore().network));
|
||||
const isValidNetworkTablesIP = (v: string | undefined): boolean => {
|
||||
// Check if it is a valid team number between 1-9999
|
||||
const teamNumberRegex = /^[1-9][0-9]{0,3}$/;
|
||||
@@ -38,9 +40,31 @@ const isValidHostname = (v: string | undefined) => {
|
||||
return hostnameRegex.test(v);
|
||||
};
|
||||
|
||||
const settingsHaveChanged = (): boolean => {
|
||||
const a = useSettingsStore().network;
|
||||
const b = tempSettingsStruct.value;
|
||||
|
||||
return (
|
||||
a.ntServerAddress !== b.ntServerAddress ||
|
||||
a.connectionType !== b.connectionType ||
|
||||
a.staticIp !== b.staticIp ||
|
||||
a.hostname !== b.hostname ||
|
||||
a.runNTServer !== b.runNTServer ||
|
||||
a.shouldManage !== b.shouldManage ||
|
||||
a.shouldPublishProto !== b.shouldPublishProto ||
|
||||
a.canManage !== b.canManage ||
|
||||
a.networkManagerIface !== b.networkManagerIface ||
|
||||
a.setStaticCommand !== b.setStaticCommand ||
|
||||
a.setDHCPcommand !== b.setDHCPcommand
|
||||
);
|
||||
};
|
||||
|
||||
const saveGeneralSettings = () => {
|
||||
const changingStaticIp = useSettingsStore().network.connectionType === NetworkConnectionType.Static;
|
||||
|
||||
// Update with new values
|
||||
Object.assign(useSettingsStore().network, tempSettingsStruct.value);
|
||||
|
||||
useSettingsStore()
|
||||
.saveGeneralSettings()
|
||||
.then((response) => {
|
||||
@@ -80,7 +104,7 @@ const saveGeneralSettings = () => {
|
||||
|
||||
const currentNetworkInterfaceIndex = computed<number>({
|
||||
get: () => useSettingsStore().networkInterfaceNames.indexOf(useSettingsStore().network.networkManagerIface || ""),
|
||||
set: (v) => (useSettingsStore().network.networkManagerIface = useSettingsStore().networkInterfaceNames[v])
|
||||
set: (v) => (tempSettingsStruct.value.networkManagerIface = useSettingsStore().networkInterfaceNames[v])
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -90,11 +114,11 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
<div class="ml-5">
|
||||
<v-form ref="form" v-model="settingsValid">
|
||||
<pv-input
|
||||
v-model="useSettingsStore().network.ntServerAddress"
|
||||
v-model="tempSettingsStruct.ntServerAddress"
|
||||
label="Team Number/NetworkTables Server Address"
|
||||
tooltip="Enter the Team Number or the IP address of the NetworkTables Server"
|
||||
:label-cols="4"
|
||||
:disabled="useSettingsStore().network.runNTServer"
|
||||
:disabled="tempSettingsStruct.runNTServer"
|
||||
:rules="[
|
||||
(v) =>
|
||||
isValidNetworkTablesIP(v) ||
|
||||
@@ -102,10 +126,7 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
]"
|
||||
/>
|
||||
<v-banner
|
||||
v-show="
|
||||
!isValidNetworkTablesIP(useSettingsStore().network.ntServerAddress) &&
|
||||
!useSettingsStore().network.runNTServer
|
||||
"
|
||||
v-show="!isValidNetworkTablesIP(tempSettingsStruct.ntServerAddress) && !tempSettingsStruct.runNTServer"
|
||||
rounded
|
||||
color="red"
|
||||
text-color="white"
|
||||
@@ -115,33 +136,33 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
The NetworkTables Server Address is not set or is invalid. NetworkTables is unable to connect.
|
||||
</v-banner>
|
||||
<pv-radio
|
||||
v-model="useSettingsStore().network.connectionType"
|
||||
v-model="tempSettingsStruct.connectionType"
|
||||
label="IP Assignment Mode"
|
||||
tooltip="DHCP will make the radio (router) automatically assign an IP address; this may result in an IP address that changes across reboots. Static IP assignment means that you pick the IP address and it won't change."
|
||||
:input-cols="12 - 4"
|
||||
:list="['DHCP', 'Static']"
|
||||
:disabled="!(useSettingsStore().network.shouldManage && useSettingsStore().network.canManage)"
|
||||
:disabled="!(tempSettingsStruct.shouldManage && tempSettingsStruct.canManage)"
|
||||
/>
|
||||
<pv-input
|
||||
v-if="useSettingsStore().network.connectionType === NetworkConnectionType.Static"
|
||||
v-model="useSettingsStore().network.staticIp"
|
||||
v-if="tempSettingsStruct.connectionType === NetworkConnectionType.Static"
|
||||
v-model="tempSettingsStruct.staticIp"
|
||||
:input-cols="12 - 4"
|
||||
label="Static IP"
|
||||
:rules="[(v) => isValidIPv4(v) || 'Invalid IPv4 address']"
|
||||
:disabled="!(useSettingsStore().network.shouldManage && useSettingsStore().network.canManage)"
|
||||
:disabled="!(tempSettingsStruct.shouldManage && tempSettingsStruct.canManage)"
|
||||
/>
|
||||
<pv-input
|
||||
v-model="useSettingsStore().network.hostname"
|
||||
v-model="tempSettingsStruct.hostname"
|
||||
label="Hostname"
|
||||
:input-cols="12 - 4"
|
||||
:rules="[(v) => isValidHostname(v) || 'Invalid hostname']"
|
||||
:disabled="!(useSettingsStore().network.shouldManage && useSettingsStore().network.canManage)"
|
||||
:disabled="!(tempSettingsStruct.shouldManage && tempSettingsStruct.canManage)"
|
||||
/>
|
||||
<v-divider class="pb-3" />
|
||||
<span style="font-weight: 700">Advanced Networking</span>
|
||||
<pv-switch
|
||||
v-model="useSettingsStore().network.shouldManage"
|
||||
:disabled="!useSettingsStore().network.canManage"
|
||||
v-model="tempSettingsStruct.shouldManage"
|
||||
:disabled="!tempSettingsStruct.canManage"
|
||||
label="Manage Device Networking"
|
||||
tooltip="If enabled, Photon will manage device hostname and network settings."
|
||||
:label-cols="4"
|
||||
@@ -150,7 +171,7 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
<pv-select
|
||||
v-model="currentNetworkInterfaceIndex"
|
||||
label="NetworkManager interface"
|
||||
:disabled="!(useSettingsStore().network.shouldManage && useSettingsStore().network.canManage)"
|
||||
:disabled="!(tempSettingsStruct.shouldManage && tempSettingsStruct.canManage)"
|
||||
:select-cols="12 - 4"
|
||||
tooltip="Name of the interface PhotonVision should manage the IP address of"
|
||||
:items="useSettingsStore().networkInterfaceNames"
|
||||
@@ -158,8 +179,8 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
<v-banner
|
||||
v-show="
|
||||
!useSettingsStore().networkInterfaceNames.length &&
|
||||
useSettingsStore().network.shouldManage &&
|
||||
useSettingsStore().network.canManage
|
||||
tempSettingsStruct.shouldManage &&
|
||||
tempSettingsStruct.canManage
|
||||
"
|
||||
rounded
|
||||
color="red"
|
||||
@@ -169,14 +190,14 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
Photon cannot detect any wired connections! Please send program logs to the developers for help.
|
||||
</v-banner>
|
||||
<pv-switch
|
||||
v-model="useSettingsStore().network.runNTServer"
|
||||
v-model="tempSettingsStruct.runNTServer"
|
||||
label="Run NetworkTables Server (Debugging Only)"
|
||||
tooltip="If enabled, this device will create a NT server. This is useful for home debugging, but should be disabled on-robot."
|
||||
class="mt-3 mb-3"
|
||||
class="mt-3 mb-2"
|
||||
:label-cols="4"
|
||||
/>
|
||||
<v-banner
|
||||
v-show="useSettingsStore().network.runNTServer"
|
||||
v-show="tempSettingsStruct.runNTServer"
|
||||
rounded
|
||||
color="red"
|
||||
text-color="white"
|
||||
@@ -184,12 +205,29 @@ const currentNetworkInterfaceIndex = computed<number>({
|
||||
>
|
||||
This mode is intended for debugging; it should be off for proper usage. PhotonLib will NOT work!
|
||||
</v-banner>
|
||||
<pv-switch
|
||||
v-model="tempSettingsStruct.shouldPublishProto"
|
||||
label="Also Publish Protobuf"
|
||||
tooltip="If enabled, Photon will publish all pipeline results in both the Packet and Protobuf formats. This is useful for visualizing pipeline results from NT viewers such as glass and logging software such as AdvantageScope. Note: photon-lib will ignore this value and is not recommended on the field for performance."
|
||||
class="mt-3 mb-2"
|
||||
:label-cols="4"
|
||||
/>
|
||||
<v-banner
|
||||
v-show="tempSettingsStruct.shouldPublishProto"
|
||||
rounded
|
||||
color="red"
|
||||
class="mb-3"
|
||||
text-color="white"
|
||||
icon="mdi-information-outline"
|
||||
>
|
||||
This mode is intended for debugging; it should be off for field use. You may notice a performance hit by using
|
||||
this mode.
|
||||
</v-banner>
|
||||
</v-form>
|
||||
<v-btn
|
||||
color="accent"
|
||||
:class="useSettingsStore().network.runNTServer ? 'mt-3' : ''"
|
||||
style="color: black; width: 100%"
|
||||
:disabled="!settingsValid && !useSettingsStore().network.runNTServer"
|
||||
:disabled="!settingsValid || !settingsHaveChanged()"
|
||||
@click="saveGeneralSettings"
|
||||
>
|
||||
Save
|
||||
|
||||
Reference in New Issue
Block a user