Skip to content

Commit

Permalink
Merge pull request #17 from Oblarg/update-2023
Browse files Browse the repository at this point in the history
Update for 2023
  • Loading branch information
Oblarg authored Nov 13, 2022
2 parents ab4e8e9 + 62712fd commit a2cb135
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 85 deletions.
2 changes: 1 addition & 1 deletion docs/index-all.html
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ <h2 class="title">R</h2>
<dl>
<dt><span class="memberNameLink"><a href="io/github/oblarg/oblog/annotations/Log.ThreeAxisAccelerometer.html#range()">range()</a></span> - Method in annotation type io.github.oblarg.oblog.annotations.<a href="io/github/oblarg/oblog/annotations/Log.ThreeAxisAccelerometer.html" title="annotation in io.github.oblarg.oblog.annotations">Log.ThreeAxisAccelerometer</a></dt>
<dd>&nbsp;</dd>
<dt><span class="memberNameLink"><a href="io/github/oblarg/oblog/Logger.html#registerEntry(edu.wpi.first.networktables.NetworkTableEntry,java.util.function.Supplier)">registerEntry(NetworkTableEntry, Supplier&lt;Object&gt;)</a></span> - Static method in class io.github.oblarg.oblog.<a href="io/github/oblarg/oblog/Logger.html" title="class in io.github.oblarg.oblog">Logger</a></dt>
<dt><span class="memberNameLink"><a href="io/github/oblarg/oblog/Logger.html#registerEntry(edu.wpi.first.networktables.GenericEntry,java.util.function.Supplier)">registerEntry(GenericEntry, Supplier&lt;Object&gt;)</a></span> - Static method in class io.github.oblarg.oblog.<a href="io/github/oblarg/oblog/Logger.html" title="class in io.github.oblarg.oblog">Logger</a></dt>
<dd>
<div class="block">Registers a new entry.</div>
</dd>
Expand Down
6 changes: 3 additions & 3 deletions docs/io/github/oblarg/oblog/Logger.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ <h3>Method Summary</h3>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static void</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#registerEntry(edu.wpi.first.networktables.NetworkTableEntry,java.util.function.Supplier)">registerEntry</a></span>&#8203;(edu.wpi.first.networktables.NetworkTableEntry&nbsp;entry,
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#registerEntry(edu.wpi.first.networktables.GenericEntry,java.util.function.Supplier)">registerEntry</a></span>&#8203;(edu.wpi.first.networktables.GenericEntry&nbsp;entry,
java.util.function.Supplier&lt;java.lang.Object&gt;&nbsp;supplier)</code></th>
<td class="colLast">
<div class="block">Registers a new entry.</div>
Expand Down Expand Up @@ -389,13 +389,13 @@ <h4>updateEntries</h4>
<div class="block">Updates all entries. Must be called periodically from the main robot loop.</div>
</li>
</ul>
<a id="registerEntry(edu.wpi.first.networktables.NetworkTableEntry,java.util.function.Supplier)">
<a id="registerEntry(edu.wpi.first.networktables.GenericEntry,java.util.function.Supplier)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>registerEntry</h4>
<pre class="methodSignature">public static&nbsp;void&nbsp;registerEntry&#8203;(edu.wpi.first.networktables.NetworkTableEntry&nbsp;entry,
<pre class="methodSignature">public static&nbsp;void&nbsp;registerEntry&#8203;(edu.wpi.first.networktables.GenericEntry&nbsp;entry,
java.util.function.Supplier&lt;java.lang.Object&gt;&nbsp;supplier)</pre>
<div class="block">Registers a new entry. To be called during initial logging configuration for any value that
will
Expand Down
4 changes: 2 additions & 2 deletions docs/io/github/oblarg/oblog/SimpleWidgetWrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h3>Method Summary</h3>
<th class="colLast" scope="col">Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>edu.wpi.first.networktables.NetworkTableEntry</code></td>
<td class="colFirst"><code>edu.wpi.first.networktables.GenericEntry</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#getEntry()">getEntry</a></span>()</code></th>
<td class="colLast">&nbsp;</td>
</tr>
Expand Down Expand Up @@ -196,7 +196,7 @@ <h3>Method Detail</h3>
<ul class="blockList">
<li class="blockList">
<h4>getEntry</h4>
<pre class="methodSignature">edu.wpi.first.networktables.NetworkTableEntry&nbsp;getEntry()</pre>
<pre class="methodSignature">edu.wpi.first.networktables.GenericEntry&nbsp;getEntry()</pre>
</li>
</ul>
<a id="withProperties(java.util.Map)">
Expand Down
2 changes: 1 addition & 1 deletion docs/member-search-index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java'
id 'maven-publish'
id "edu.wpi.first.GradleRIO" version "2022.1.1-beta-3"
id "edu.wpi.first.GradleRIO" version "2023.1.1-beta-3"
}

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
Expand Down
59 changes: 30 additions & 29 deletions lib/src/main/java/io/github/oblarg/oblog/Logger.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package io.github.oblarg.oblog;

import edu.wpi.first.cscore.VideoSource;
import edu.wpi.first.networktables.EntryListenerFlags;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.networktables.NetworkTableEvent;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.util.sendable.Sendable;
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.shuffleboard.*;

import io.github.oblarg.oblog.annotations.*;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;

import static java.util.Map.entry;

Expand Down Expand Up @@ -130,7 +131,7 @@ public static void updateEntries() {
* @param entry The entry to be updated.
* @param supplier The supplier with which to update the entry.
*/
public static void registerEntry(NetworkTableEntry entry, Supplier<Object> supplier) {
public static void registerEntry(GenericEntry entry, Supplier<Object> supplier) {
entrySupplierMap.put(entry, supplier);
}

Expand Down Expand Up @@ -258,7 +259,7 @@ static void configureLoggingTest(
}

/** A map of the suppliers that are used to update each entry. */
private static final Map<NetworkTableEntry, Supplier<Object>> entrySupplierMap = new HashMap<>();
private static final Map<GenericEntry, Supplier<Object>> entrySupplierMap = new HashMap<>();

enum LogType {
LOG,
Expand Down Expand Up @@ -304,41 +305,41 @@ void processSetter(
params.tabName().equals("DEFAULT")
? bin
: new WrappedShuffleboardContainer(Shuffleboard.getTab(params.tabName()));
NetworkTableEntry entry =
GenericEntry entry =
bin.add(
(params.name().equals("NO_NAME")) ? name : params.name(),
params.defaultValueBoolean())
.withWidget(BuiltInWidgets.kToggleButton.getWidgetName())
.withPosition(params.columnIndex(), params.rowIndex())
.withSize(params.width(), params.height())
.getEntry();
nt.addEntryListener(
entry,
nt.addListener(
entry.getTopic(),
EnumSet.of(NetworkTableEvent.Kind.kValueAll),
(entryNotification) ->
setterRunner.execute(
() -> setter.accept((boolean) entryNotification.value.getValue())),
EntryListenerFlags.kUpdate);
() -> setter.accept(entryNotification.valueData.value.getValue())));
setter.accept(params.defaultValueBoolean());
} else {
Config params = (Config) rawParams;
bin =
params.tabName().equals("DEFAULT")
? bin
: new WrappedShuffleboardContainer(Shuffleboard.getTab(params.tabName()));
NetworkTableEntry entry =
GenericEntry entry =
bin.add(
(params.name().equals("NO_NAME")) ? name : params.name(),
params.defaultValueNumeric())
.withWidget(BuiltInWidgets.kTextView.getWidgetName())
.withPosition(params.columnIndex(), params.rowIndex())
.withSize(params.width(), params.height())
.getEntry();
nt.addEntryListener(
entry,
nt.addListener(
entry.getTopic(),
EnumSet.of(NetworkTableEvent.Kind.kValueAll),
(entryNotification) ->
setterRunner.execute(
() -> setter.accept((Number) entryNotification.value.getValue())),
EntryListenerFlags.kUpdate);
() -> setter.accept(entryNotification.valueData.value.getValue())));
setter.accept(params.defaultValueNumeric());
}
}),
Expand All @@ -350,20 +351,20 @@ void processSetter(
params.tabName().equals("DEFAULT")
? bin
: new WrappedShuffleboardContainer(Shuffleboard.getTab(params.tabName()));
NetworkTableEntry entry =
GenericEntry entry =
bin.add(
(params.name().equals("NO_NAME")) ? name : params.name(),
params.defaultValue())
.withWidget(BuiltInWidgets.kToggleButton.getWidgetName())
.withPosition(params.columnIndex(), params.rowIndex())
.withSize(params.width(), params.height())
.getEntry();
nt.addEntryListener(
entry,
nt.addListener(
entry.getTopic(),
EnumSet.of(NetworkTableEvent.Kind.kValueAll),
(entryNotification) ->
setterRunner.execute(
() -> setter.accept((boolean) entryNotification.value.getValue())),
EntryListenerFlags.kUpdate);
() -> setter.accept(entryNotification.valueData.value.getValue())));
setter.accept(params.defaultValue());
}),
entry(
Expand All @@ -374,20 +375,20 @@ void processSetter(
params.tabName().equals("DEFAULT")
? bin
: new WrappedShuffleboardContainer(Shuffleboard.getTab(params.tabName()));
NetworkTableEntry entry =
GenericEntry entry =
bin.add(
(params.name().equals("NO_NAME")) ? name : params.name(),
params.defaultValue())
.withWidget(BuiltInWidgets.kToggleSwitch.getWidgetName())
.withPosition(params.columnIndex(), params.rowIndex())
.withSize(params.width(), params.height())
.getEntry();
nt.addEntryListener(
entry,
nt.addListener(
entry.getTopic(),
EnumSet.of(NetworkTableEvent.Kind.kValueAll),
(entryNotification) ->
setterRunner.execute(
() -> setter.accept((boolean) entryNotification.value.getValue())),
EntryListenerFlags.kUpdate);
() -> setter.accept(entryNotification.valueData.value.getValue())));
setter.accept(params.defaultValue());
}),
entry(
Expand All @@ -398,7 +399,7 @@ void processSetter(
params.tabName().equals("DEFAULT")
? bin
: new WrappedShuffleboardContainer(Shuffleboard.getTab(params.tabName()));
NetworkTableEntry entry =
GenericEntry entry =
bin.add(
(params.name().equals("NO_NAME")) ? name : params.name(),
params.defaultValue())
Expand All @@ -411,12 +412,12 @@ void processSetter(
.withPosition(params.columnIndex(), params.rowIndex())
.withSize(params.width(), params.height())
.getEntry();
nt.addEntryListener(
entry,
nt.addListener(
entry.getTopic(),
EnumSet.of(NetworkTableEvent.Kind.kValueAll),
(entryNotification) ->
setterRunner.execute(
() -> setter.accept((Number) entryNotification.value.getValue())),
EntryListenerFlags.kUpdate);
() -> setter.accept(entryNotification.valueData.value.getValue())));
setter.accept(params.defaultValue());
}));

Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/io/github/oblarg/oblog/NTContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ShuffleboardLayoutWrapper getLayout(String title, LayoutType type) {
public SimpleWidgetWrapper add(String title, Object defaultValue) {
logErrorCheck(defaultValue, title, table.getPath());
try {
return new NTSimpleWidget(table.getEntry(title), defaultValue);
return new NTSimpleWidget(table.getTopic(title).getGenericEntry(), defaultValue);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Error! Attempted to log duplicate widget "
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/io/github/oblarg/oblog/NTLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ShuffleboardLayoutWrapper getLayout(String title, LayoutType type) {
public SimpleWidgetWrapper add(String title, Object defaultValue) {
logErrorCheck(defaultValue, title, table.getPath());
try {
return new NTSimpleWidget(table.getEntry(title), defaultValue);
return new NTSimpleWidget(table.getTopic(title).getGenericEntry(), defaultValue);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Error! Attempted to log duplicate widget "
Expand Down
7 changes: 4 additions & 3 deletions lib/src/main/java/io/github/oblarg/oblog/NTSimpleWidget.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.networktables.NetworkTableEntry;

import java.util.Map;

class NTSimpleWidget implements SimpleWidgetWrapper {

NetworkTableEntry entry;
GenericEntry entry;

NTSimpleWidget(NetworkTableEntry entry, Object value) {
NTSimpleWidget(GenericEntry entry, Object value) {
this.entry = entry;
entry.setValue(value);
}

@Override
public NetworkTableEntry getEntry() {
public GenericEntry getEntry() {
return entry;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;

import java.util.Map;

Expand All @@ -9,7 +9,7 @@
* implementation if desired.
*/
public interface SimpleWidgetWrapper {
NetworkTableEntry getEntry();
GenericEntry getEntry();

SimpleWidgetWrapper withProperties(Map<String, Object> properties);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.SimpleWidget;

import java.util.Map;
Expand All @@ -14,7 +14,7 @@ class WrappedSimpleWidget implements SimpleWidgetWrapper {
}

@Override
public NetworkTableEntry getEntry() {
public GenericEntry getEntry() {
return widget.getEntry();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import org.junit.Test;

Expand All @@ -16,7 +16,7 @@ public class ArraysAndListsTester {
public void testArraysAndLists() {
long startTime = System.currentTimeMillis();

List<NetworkTableEntry> mockedEntries = new ArrayList<>();
List<GenericEntry> mockedEntries = new ArrayList<>();

TestRootContainer rootContainer = new TestRootContainer();

Expand Down Expand Up @@ -47,7 +47,7 @@ public void testArraysAndLists() {

Logger.updateEntries();

for (NetworkTableEntry entry : mockedEntries) {
for (GenericEntry entry : mockedEntries) {
verify(entry).setValue(any());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import org.junit.Test;

Expand All @@ -14,7 +14,7 @@
public class ChildRecursionTester {
@Test
public void testChildRecursion() {
List<NetworkTableEntry> mockedEntries = new ArrayList<>();
List<GenericEntry> mockedEntries = new ArrayList<>();

TestRootContainer rootContainer = new TestRootContainer();

Expand All @@ -32,7 +32,7 @@ public void testChildRecursion() {

Logger.updateEntries();

for (NetworkTableEntry entry : mockedEntries) {
for (GenericEntry entry : mockedEntries) {
verify(entry).setValue(any());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;

import io.github.oblarg.oblog.annotations.Config;
Expand All @@ -14,7 +14,7 @@
public class ConfigMethodNameTester {
@Test
public void testConfigMethodName() {
List<NetworkTableEntry> mockedEntries = new ArrayList<>();
List<GenericEntry> mockedEntries = new ArrayList<>();

TestRootContainer rootContainer = new TestRootContainer();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.oblarg.oblog;

import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.GenericEntry;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import org.junit.Test;

Expand All @@ -14,7 +14,7 @@ public class CyclicDetectionTester {

@Test
public void testCyclic() {
List<NetworkTableEntry> mockedEntries = new ArrayList<>();
List<GenericEntry> mockedEntries = new ArrayList<>();

TestRootContainer rootContainer = new TestRootContainer();

Expand All @@ -30,7 +30,7 @@ public void testCyclic() {

Logger.updateEntries();

for (NetworkTableEntry entry : mockedEntries) {
for (GenericEntry entry : mockedEntries) {
verify(entry).setValue(any());
}
}
Expand Down
Loading

0 comments on commit a2cb135

Please sign in to comment.