Use tracker mac address to save tracker configs

This commit is contained in:
Eiren Rain
2021-09-22 22:37:45 +03:00
parent 5e4a128d25
commit ef504c40b6
5 changed files with 20 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ import io.eiren.util.logging.LogManager;
public class Main {
public static String VERSION = "0.0.19";
public static String VERSION = "0.0.19 Test 1";
public static VRServer vrServer;

View File

@@ -94,7 +94,7 @@ public class VRServer extends Thread {
synchronized(configuration) {
TrackerConfig config = configuration.get(tracker.getName());
if(config == null) {
config = new TrackerConfig(tracker.getName());
config = new TrackerConfig(tracker);
configuration.put(tracker.getName(), config);
}
return config;

View File

@@ -38,4 +38,8 @@ public interface Tracker {
public boolean hasPosition();
public boolean isComputed();
public default String getDescriptiveName() {
return getName();
}
}

View File

@@ -8,16 +8,20 @@ public class TrackerConfig {
public final String trackerName;
public String designation;
public String description;
public boolean hide;
public Quaternion adjustment;
public String mountingRotation;
public TrackerConfig(String trackerName) {
this.trackerName = trackerName;
public TrackerConfig(Tracker tracker) {
this.trackerName = tracker.getName();
this.description = tracker.getDescriptiveName();
this.designation = tracker.getBodyPosition() != null ? tracker.getBodyPosition().designation : null;
}
public TrackerConfig(YamlNode node) {
this.trackerName = node.getString("name");
this.description = node.getString("description");
this.designation = node.getString("designation");
this.hide = node.getBoolean("hide", false);
this.mountingRotation = node.getString("rotation");
@@ -54,5 +58,10 @@ public class TrackerConfig {
} else {
configNode.removeProperty("rotation");
}
if(description != null) {
configNode.setProperty("description", description);
} else {
configNode.removeProperty("description");
}
}
}

View File

@@ -103,7 +103,8 @@ public class TrackersUDPServer extends Thread {
firmware.append("owoTrack");
isOwo = true;
}
IMUTracker imu = new IMUTracker("udp:/" + handshakePacket.getAddress().toString(), this);
String trackerName = macString != null ? "upd://" + macString : "udp:/" + handshakePacket.getAddress().toString();
IMUTracker imu = new IMUTracker(trackerName, this);
ReferenceAdjustedTracker<IMUTracker> adjustedTracker = new ReferenceAdjustedTracker<>(imu);
trackersConsumer.accept(adjustedTracker);
sensor = new TrackerConnection(imu, handshakePacket.getSocketAddress());
@@ -114,7 +115,7 @@ public class TrackersUDPServer extends Thread {
trackers.add(sensor);
trackersMap.put(addr, sensor);
}
System.out.println("[TrackerServer] Sensor " + i + " added with address " + handshakePacket.getSocketAddress() + ". Board type: " + boardType + ", imu type: " + imuType + ", firmware: " + firmware + " (" + firmwareBuild + "), mac: " + macString);
System.out.println("[TrackerServer] Sensor " + i + " added with address " + handshakePacket.getSocketAddress() + ". Board type: " + boardType + ", imu type: " + imuType + ", firmware: " + firmware + " (" + firmwareBuild + "), mac: " + macString + ", name: " + trackerName);
}
sensor.tracker.setStatus(TrackerStatus.OK);
socket.send(new DatagramPacket(HANDSHAKE_BUFFER, HANDSHAKE_BUFFER.length, handshakePacket.getAddress(), handshakePacket.getPort()));