Skip to content

Commit

Permalink
Add boolean values
Browse files Browse the repository at this point in the history
  • Loading branch information
aschokking committed Mar 1, 2020
1 parent 16aac2c commit eb0f8f9
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions RobotReader/src/main/java/xbot/roboreader/RobotReaderMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,28 @@ public Void call() throws Exception
// if we don't do this repeatedly we might miss new properties that
// get added after this starts. consider doing it only every N loops if perf is
// an issue.
NetworkTableEntry[] entries = inst.getEntries(
NetworkTableEntry[] doubleEntries = inst.getEntries(
"/SmartDashboard",
NetworkTableType.kDouble.getValue()
);

NetworkTableEntry[] booleanEntries = inst.getEntries(
"/SmartDashboard",
NetworkTableType.kBoolean.getValue()
);

if (debugLogging) {
System.out.println(inst.isConnected());
System.out.println(currentSession);
System.out.println(netX.getDouble(0));
System.out.println(netY.getDouble(0));
System.out.println(netHeading.getDouble(0));
System.out.println("num entries:" + entries.length);
System.out.println("num entries:" + doubleEntries.length);
}

if (inst.isConnected() && currentSession != "NoSessionSetYet") {
// write every double
for(NetworkTableEntry entry : entries) {
for(NetworkTableEntry entry : doubleEntries) {
// strip the /SmartDashboard/ prefix from the entry names, they're on everything and not helpful
String name = entry.getName().substring(16);
String[] parts = name.split("/", 2);
Expand All @@ -120,6 +125,27 @@ public Void call() throws Exception
.build());
}

// write every boolean
for(NetworkTableEntry entry : booleanEntries) {
// strip the /SmartDashboard/ prefix from the entry names, they're on everything and not helpful
String name = entry.getName().substring(16);
String[] parts = name.split("/", 2);
String prefix = parts[0];
String suffix = parts[parts.length - 1];

idb.write(
dbName,
dbRetentionPolicy,
Point.measurement(doubleValuesDbMeasurement)
.time(currentTimestmap, TimeUnit.MILLISECONDS)
.tag("Session", currentSession)
.tag("Prop", name)
.tag("PropPrefix", prefix)
.tag("PropSuffix", suffix)
.addField("Value", entry.getBoolean(false) ? 1.0 : 0.0)
.build());
}

// write pose
idb.write(
dbName,
Expand Down

0 comments on commit eb0f8f9

Please sign in to comment.