mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-27 02:01:40 +00:00
Add NT servermode switch (#120)
This commit is contained in:
@@ -110,6 +110,7 @@ export default new Vuex.Store({
|
||||
staticIp: "",
|
||||
netmask: "",
|
||||
hostname: "photonvision",
|
||||
runNTServer: false,
|
||||
},
|
||||
lighting: {
|
||||
supported: true,
|
||||
|
||||
@@ -4,6 +4,12 @@
|
||||
v-model="settings.teamNumber"
|
||||
name="Team Number"
|
||||
:rules="[v => (v > 0) || 'Team number must be greater than zero', v => (v < 10000) || 'Team number must have fewer than five digits']"
|
||||
class="mb-4"
|
||||
/>
|
||||
<CVSwitch
|
||||
v-model="settings.runNTServer"
|
||||
name="Run NetworkTables Server"
|
||||
tooltip="If enabled, this device will create a NT server. This is useful for home debugging, but should be disabled on-robot."
|
||||
/>
|
||||
<template v-if="$store.state.settings.networkSettings.supported">
|
||||
<CVradio
|
||||
@@ -32,6 +38,7 @@
|
||||
import CVnumberinput from '../../components/common/cv-number-input'
|
||||
import CVradio from '../../components/common/cv-radio'
|
||||
import CVinput from '../../components/common/cv-input'
|
||||
import CVSwitch from "@/components/common/cv-switch";
|
||||
|
||||
// https://stackoverflow.com/a/17871737
|
||||
const ipv4Regex = /^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])$/;
|
||||
@@ -41,6 +48,7 @@
|
||||
export default {
|
||||
name: 'Networking',
|
||||
components: {
|
||||
CVSwitch,
|
||||
CVnumberinput,
|
||||
CVradio,
|
||||
CVinput
|
||||
|
||||
@@ -28,6 +28,7 @@ public class NetworkConfig {
|
||||
public String staticIp = "";
|
||||
public String netmask = "";
|
||||
public String hostname = "photonvision";
|
||||
public boolean runNTServer = false;
|
||||
|
||||
public boolean shouldManage;
|
||||
|
||||
@@ -39,12 +40,14 @@ public class NetworkConfig {
|
||||
String staticIp,
|
||||
String netmask,
|
||||
String hostname,
|
||||
boolean runNTServer,
|
||||
boolean shouldManage) {
|
||||
this.teamNumber = teamNumber;
|
||||
this.connectionType = connectionType;
|
||||
this.staticIp = staticIp;
|
||||
this.netmask = netmask;
|
||||
this.hostname = hostname;
|
||||
this.runNTServer = runNTServer;
|
||||
|
||||
this.shouldManage = shouldManage || Platform.isRaspberryPi();
|
||||
}
|
||||
@@ -59,6 +62,7 @@ public class NetworkConfig {
|
||||
ret.staticIp = (String) map.get("staticIp");
|
||||
ret.netmask = (String) map.get("netmask");
|
||||
ret.hostname = (String) map.get("hostname");
|
||||
ret.runNTServer = (Boolean) map.get("runNTServer");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -70,6 +74,7 @@ public class NetworkConfig {
|
||||
tmp.put("staticIp", staticIp);
|
||||
tmp.put("netmask", netmask);
|
||||
tmp.put("hostname", hostname);
|
||||
tmp.put("runNTServer", runNTServer);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ public class NetworkTablesManager {
|
||||
}
|
||||
|
||||
public void setConfig(NetworkConfig config) {
|
||||
if (config.teamNumber > 0) {
|
||||
setClientMode(config.teamNumber);
|
||||
} else {
|
||||
if (config.runNTServer) {
|
||||
setServerMode();
|
||||
} else {
|
||||
setClientMode(config.teamNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user