mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[ntcore] Remove NT3 support (#7625)
- Remove StartClient3 - Rename StartClient4 to StartClient - Remove port3 parameter from StartServer - Remove 3-suffix constants - Remove 4 suffix from constants Also remove Shuffleboard build from CI.
This commit is contained in:
@@ -44,66 +44,59 @@ void NetworkTablesSettings::Thread::Main() {
|
||||
|
||||
// if just changing servers in client mode, no need to stop and restart
|
||||
unsigned int curMode = nt::GetNetworkMode(m_inst);
|
||||
if ((mode == 0 || mode == 3) ||
|
||||
(mode == 1 && (curMode & NT_NET_MODE_CLIENT4) == 0) ||
|
||||
(mode == 2 && (curMode & NT_NET_MODE_CLIENT3) == 0)) {
|
||||
if ((mode == 0 || mode == 2) ||
|
||||
(mode == 1 && (curMode & NT_NET_MODE_CLIENT) == 0)) {
|
||||
nt::StopClient(m_inst);
|
||||
nt::StopServer(m_inst);
|
||||
nt::StopLocal(m_inst);
|
||||
}
|
||||
|
||||
if ((m_mode == 0 || m_mode == 3) || !dsClient) {
|
||||
if ((m_mode == 0 || m_mode == 2) || !dsClient) {
|
||||
nt::StopDSClient(m_inst);
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
} while (mode != m_mode || dsClient != m_dsClient);
|
||||
|
||||
if (m_mode == 1 || m_mode == 2) {
|
||||
if (m_mode == 1) {
|
||||
std::string_view serverTeam{m_serverTeam};
|
||||
std::optional<unsigned int> team;
|
||||
if (m_mode == 1) {
|
||||
nt::StartClient4(m_inst, m_clientName);
|
||||
} else if (m_mode == 2) {
|
||||
nt::StartClient3(m_inst, m_clientName);
|
||||
nt::StartClient(m_inst, m_clientName);
|
||||
}
|
||||
|
||||
unsigned int port = m_mode == 1 ? m_port4 : m_port3;
|
||||
if (!wpi::contains(serverTeam, '.') &&
|
||||
(team = wpi::parse_integer<unsigned int>(serverTeam, 10))) {
|
||||
nt::SetServerTeam(m_inst, team.value(), port);
|
||||
nt::SetServerTeam(m_inst, team.value(), m_port);
|
||||
} else {
|
||||
wpi::SmallVector<std::string_view, 4> serverNames;
|
||||
std::vector<std::pair<std::string_view, unsigned int>> servers;
|
||||
wpi::split(serverTeam, serverNames, ',', -1, false);
|
||||
for (auto&& serverName : serverNames) {
|
||||
servers.emplace_back(serverName, port);
|
||||
servers.emplace_back(serverName, m_port);
|
||||
}
|
||||
nt::SetServer(m_inst, servers);
|
||||
}
|
||||
|
||||
if (m_dsClient) {
|
||||
nt::StartDSClient(m_inst, port);
|
||||
nt::StartDSClient(m_inst, m_port);
|
||||
}
|
||||
} else if (m_mode == 3) {
|
||||
nt::StartServer(m_inst, m_iniName.c_str(), m_listenAddress.c_str(),
|
||||
m_port3, m_port4);
|
||||
m_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkTablesSettings::NetworkTablesSettings(std::string_view clientName,
|
||||
Storage& storage, NT_Inst inst)
|
||||
: m_mode{storage.GetString("mode"),
|
||||
0,
|
||||
{"Disabled", "Client (NT4)", "Client (NT3)", "Server"}},
|
||||
: m_mode{storage.GetString("mode"), 0, {"Disabled", "Client", "Server"}},
|
||||
m_persistentFilename{
|
||||
storage.GetString("persistentFilename", "networktables.json")},
|
||||
m_serverTeam{storage.GetString("serverTeam")},
|
||||
m_listenAddress{storage.GetString("listenAddress")},
|
||||
m_clientName{storage.GetString("clientName", clientName)},
|
||||
m_port3{storage.GetInt("port3", NT_DEFAULT_PORT3)},
|
||||
m_port4{storage.GetInt("port4", NT_DEFAULT_PORT4)},
|
||||
m_port{storage.GetInt("port", NT_DEFAULT_PORT)},
|
||||
m_dsClient{storage.GetBool("dsClient", true)} {
|
||||
m_thread.Start(inst);
|
||||
}
|
||||
@@ -122,8 +115,7 @@ void NetworkTablesSettings::Update() {
|
||||
thr->m_serverTeam = m_serverTeam;
|
||||
thr->m_listenAddress = m_listenAddress;
|
||||
thr->m_clientName = m_clientName;
|
||||
thr->m_port3 = m_port3;
|
||||
thr->m_port4 = m_port4;
|
||||
thr->m_port = m_port;
|
||||
thr->m_dsClient = m_dsClient;
|
||||
thr->m_cond.notify_one();
|
||||
}
|
||||
@@ -137,24 +129,22 @@ static void LimitPortRange(int* port) {
|
||||
}
|
||||
|
||||
bool NetworkTablesSettings::Display() {
|
||||
m_mode.Combo("Mode", m_serverOption ? 4 : 3);
|
||||
m_mode.Combo("Mode", m_serverOption ? 3 : 2);
|
||||
switch (m_mode.GetValue()) {
|
||||
case 1:
|
||||
case 2: {
|
||||
ImGui::InputText("Team/IP", &m_serverTeam);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
ImGui::SetTooltip("Team number or IP/MDNS address of server");
|
||||
}
|
||||
int* port = m_mode.GetValue() == 1 ? &m_port4 : &m_port3;
|
||||
if (ImGui::InputInt("Port", port)) {
|
||||
LimitPortRange(port);
|
||||
if (ImGui::InputInt("Port", &m_port)) {
|
||||
LimitPortRange(&m_port);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
ImGui::SetTooltip("TCP Port - leave this at the default");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Default")) {
|
||||
*port = m_mode.GetValue() == 1 ? NT_DEFAULT_PORT4 : NT_DEFAULT_PORT3;
|
||||
m_port = NT_DEFAULT_PORT;
|
||||
}
|
||||
ImGui::InputText("Network Identity", &m_clientName);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
@@ -167,33 +157,22 @@ bool NetworkTablesSettings::Display() {
|
||||
ImGui::SetTooltip("Attempt to fetch server IP from Driver Station");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
case 2:
|
||||
ImGui::InputText("Listen Address", &m_listenAddress);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
ImGui::SetTooltip(
|
||||
"Address for server to listen on. Leave blank to listen on all "
|
||||
"interfaces.");
|
||||
}
|
||||
if (ImGui::InputInt("NT3 port", &m_port3)) {
|
||||
LimitPortRange(&m_port3);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
ImGui::SetTooltip("TCP Port for NT3. Leave at default if unsure.");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Default##default3")) {
|
||||
m_port3 = NT_DEFAULT_PORT3;
|
||||
}
|
||||
if (ImGui::InputInt("NT4 port", &m_port4)) {
|
||||
LimitPortRange(&m_port4);
|
||||
if (ImGui::InputInt("Port", &m_port)) {
|
||||
LimitPortRange(&m_port);
|
||||
}
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
ImGui::SetTooltip("TCP Port for NT4. Leave at default if unsure.");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Default##default4")) {
|
||||
m_port4 = NT_DEFAULT_PORT4;
|
||||
m_port = NT_DEFAULT_PORT;
|
||||
}
|
||||
ImGui::InputText("Persistent Filename", &m_persistentFilename);
|
||||
if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal)) {
|
||||
|
||||
Reference in New Issue
Block a user