From b46d7c8413f096540a16fec42960c6bd6420e1fa Mon Sep 17 00:00:00 2001 From: team3492backup Date: Wed, 4 Mar 2026 18:07:43 -0500 Subject: [PATCH 1/6] bugfix/loop-overrun --- src/org/parts3492/partslib/network/PARTsNT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/parts3492/partslib/network/PARTsNT.java b/src/org/parts3492/partslib/network/PARTsNT.java index 80c60bd..ae16316 100644 --- a/src/org/parts3492/partslib/network/PARTsNT.java +++ b/src/org/parts3492/partslib/network/PARTsNT.java @@ -482,6 +482,6 @@ public void removeEntry(String name) { * @param data The sendable to add. */ public void putSmartDashboardSendable(String key, Sendable data) { - SmartDashboard.putData(String.format("%s/%s", name, key), data); + //SmartDashboard.putData(String.format("%s/%s", name, key), data); } } From 2c5ca192568cf1ae9f9a790e9f6ff721a0e72904 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 4 Mar 2026 21:49:45 -0500 Subject: [PATCH 2/6] comments --- src/org/parts3492/partslib/network/PARTsDashboard.java | 8 +++++--- src/org/parts3492/partslib/network/PARTsNT.java | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/org/parts3492/partslib/network/PARTsDashboard.java b/src/org/parts3492/partslib/network/PARTsDashboard.java index a1d246f..be98158 100644 --- a/src/org/parts3492/partslib/network/PARTsDashboard.java +++ b/src/org/parts3492/partslib/network/PARTsDashboard.java @@ -13,6 +13,7 @@ public class PARTsDashboard { private static DashboardTab state = DashboardTab.AUTONOMOUS; + private final static PARTsNT partsNT = new PARTsNT(); public enum DashboardTab { AUTONOMOUS("Autonomous"), @@ -26,14 +27,15 @@ public enum DashboardTab { } } - public PARTsDashboard() {} + public PARTsDashboard() { + } public static void setSubsystems(ArrayList subsystems) { - subsystems.forEach(s -> SmartDashboard.putData(s)); + subsystems.forEach(s -> partsNT.putSmartDashboardSendable(s.getName().replace("Phys", "").replace("Sim", ""), s)); } public static void setCommandScheduler() { - SmartDashboard.putData(CommandScheduler.getInstance()); + partsNT.putSmartDashboardSendable("Command Scheduler", CommandScheduler.getInstance()); } public static void setTab(DashboardTab dashboardState) { diff --git a/src/org/parts3492/partslib/network/PARTsNT.java b/src/org/parts3492/partslib/network/PARTsNT.java index ae16316..7458cfd 100644 --- a/src/org/parts3492/partslib/network/PARTsNT.java +++ b/src/org/parts3492/partslib/network/PARTsNT.java @@ -482,6 +482,9 @@ public void removeEntry(String name) { * @param data The sendable to add. */ public void putSmartDashboardSendable(String key, Sendable data) { - //SmartDashboard.putData(String.format("%s/%s", name, key), data); + String topic = key; + if (!name.equals("Generic")) + topic = String.format("%s/%s", name, key); + // SmartDashboard.putData(topic, data); // loop-overrun } } From 0fececfa147f5290c8373dfdd03db1bae62e787a Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 4 Mar 2026 22:04:12 -0500 Subject: [PATCH 3/6] add control --- src/org/parts3492/partslib/network/PARTsNT.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/org/parts3492/partslib/network/PARTsNT.java b/src/org/parts3492/partslib/network/PARTsNT.java index 7458cfd..3406ef1 100644 --- a/src/org/parts3492/partslib/network/PARTsNT.java +++ b/src/org/parts3492/partslib/network/PARTsNT.java @@ -487,4 +487,9 @@ public void putSmartDashboardSendable(String key, Sendable data) { topic = String.format("%s/%s", name, key); // SmartDashboard.putData(topic, data); // loop-overrun } + + public void putSmartDashboardSendable(String key, Sendable data, boolean debug) { + if (debug) + putSmartDashboardSendable(key, data); + } } From 7875b2e14892ccdd79d545ffe5fbed7f36aa91d9 Mon Sep 17 00:00:00 2001 From: Awsmeworld304 Date: Thu, 5 Mar 2026 10:33:18 -0500 Subject: [PATCH 4/6] Apply spotless formatting. --- src/org/parts3492/partslib/PARTsCandle.java | 3 ++- .../parts3492/partslib/network/PARTsDashboard.java | 11 ++++++----- src/org/parts3492/partslib/network/PARTsNT.java | 7 ++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/org/parts3492/partslib/PARTsCandle.java b/src/org/parts3492/partslib/PARTsCandle.java index 5e3cb48..4fcc69f 100644 --- a/src/org/parts3492/partslib/PARTsCandle.java +++ b/src/org/parts3492/partslib/PARTsCandle.java @@ -171,7 +171,8 @@ public PARTsCandle(String className, int canID, int ledLength, String canBusName /*---------------------------------- Custom Private Functions ---------------------------------*/ protected void setColor(Color color) { setControl(new EmptyAnimation(0)); - setControl(new SolidColor(0, LED_LENGTH).withColor(new RGBWColor(color.r, color.g, color.b))); + setControl( + new SolidColor(0, LED_LENGTH).withColor(new RGBWColor(color.r, color.g, color.b))); } protected void setNoColor() { diff --git a/src/org/parts3492/partslib/network/PARTsDashboard.java b/src/org/parts3492/partslib/network/PARTsDashboard.java index be98158..cba8167 100644 --- a/src/org/parts3492/partslib/network/PARTsDashboard.java +++ b/src/org/parts3492/partslib/network/PARTsDashboard.java @@ -6,14 +6,13 @@ import org.parts3492.partslib.command.IPARTsSubsystem; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandScheduler; import java.util.ArrayList; public class PARTsDashboard { private static DashboardTab state = DashboardTab.AUTONOMOUS; - private final static PARTsNT partsNT = new PARTsNT(); + private static final PARTsNT partsNT = new PARTsNT(); public enum DashboardTab { AUTONOMOUS("Autonomous"), @@ -27,11 +26,13 @@ public enum DashboardTab { } } - public PARTsDashboard() { - } + public PARTsDashboard() {} public static void setSubsystems(ArrayList subsystems) { - subsystems.forEach(s -> partsNT.putSmartDashboardSendable(s.getName().replace("Phys", "").replace("Sim", ""), s)); + subsystems.forEach( + s -> + partsNT.putSmartDashboardSendable( + s.getName().replace("Phys", "").replace("Sim", ""), s)); } public static void setCommandScheduler() { diff --git a/src/org/parts3492/partslib/network/PARTsNT.java b/src/org/parts3492/partslib/network/PARTsNT.java index 3406ef1..f598bb6 100644 --- a/src/org/parts3492/partslib/network/PARTsNT.java +++ b/src/org/parts3492/partslib/network/PARTsNT.java @@ -15,7 +15,6 @@ import edu.wpi.first.networktables.StringEntry; import edu.wpi.first.networktables.StringTopic; import edu.wpi.first.util.sendable.Sendable; -import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import java.util.ArrayList; import java.util.List; @@ -483,13 +482,11 @@ public void removeEntry(String name) { */ public void putSmartDashboardSendable(String key, Sendable data) { String topic = key; - if (!name.equals("Generic")) - topic = String.format("%s/%s", name, key); + if (!name.equals("Generic")) topic = String.format("%s/%s", name, key); // SmartDashboard.putData(topic, data); // loop-overrun } public void putSmartDashboardSendable(String key, Sendable data, boolean debug) { - if (debug) - putSmartDashboardSendable(key, data); + if (debug) putSmartDashboardSendable(key, data); } } From 66db13bc0906b74604f9792bd0a6fd13d4c22ce9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Thu, 5 Mar 2026 22:04:52 -0500 Subject: [PATCH 5/6] add control of post --- src/org/parts3492/partslib/PARTsCandle.java | 1 - .../partslib/network/PARTsDashboard.java | 14 +- .../parts3492/partslib/network/PARTsNT.java | 208 ++++++++++-------- 3 files changed, 127 insertions(+), 96 deletions(-) diff --git a/src/org/parts3492/partslib/PARTsCandle.java b/src/org/parts3492/partslib/PARTsCandle.java index 4fcc69f..5dc30e9 100644 --- a/src/org/parts3492/partslib/PARTsCandle.java +++ b/src/org/parts3492/partslib/PARTsCandle.java @@ -413,7 +413,6 @@ public void periodic() { @Override public void outputTelemetry() { - super.partsNT.putString("Animation", candle.getAppliedControl().getName()); } @Override diff --git a/src/org/parts3492/partslib/network/PARTsDashboard.java b/src/org/parts3492/partslib/network/PARTsDashboard.java index cba8167..3b46785 100644 --- a/src/org/parts3492/partslib/network/PARTsDashboard.java +++ b/src/org/parts3492/partslib/network/PARTsDashboard.java @@ -26,17 +26,17 @@ public enum DashboardTab { } } - public PARTsDashboard() {} + public PARTsDashboard() { + } - public static void setSubsystems(ArrayList subsystems) { + public static void setSubsystems(ArrayList subsystems, boolean post) { subsystems.forEach( - s -> - partsNT.putSmartDashboardSendable( - s.getName().replace("Phys", "").replace("Sim", ""), s)); + s -> partsNT.putSmartDashboardSendable( + s.getName().replace("Phys", "").replace("Sim", ""), s, post)); } - public static void setCommandScheduler() { - partsNT.putSmartDashboardSendable("Command Scheduler", CommandScheduler.getInstance()); + public static void setCommandScheduler(boolean post) { + partsNT.putSmartDashboardSendable("Command Scheduler", CommandScheduler.getInstance(), post); } public static void setTab(DashboardTab dashboardState) { diff --git a/src/org/parts3492/partslib/network/PARTsNT.java b/src/org/parts3492/partslib/network/PARTsNT.java index f598bb6..c18a14e 100644 --- a/src/org/parts3492/partslib/network/PARTsNT.java +++ b/src/org/parts3492/partslib/network/PARTsNT.java @@ -15,6 +15,7 @@ import edu.wpi.first.networktables.StringEntry; import edu.wpi.first.networktables.StringTopic; import edu.wpi.first.util.sendable.Sendable; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import java.util.ArrayList; import java.util.List; @@ -22,9 +23,11 @@ /** * PARTs NetworkTables Easy API. * - *

{@code PARTsNT partsNT = new PARTsNT(this)} + *

+ * {@code PARTsNT partsNT = new PARTsNT(this)} * - *

This class is meant to be used as an instance for each class. + *

+ * This class is meant to be used as an instance for each class. */ public class PARTsNT { public String name = "Generic"; @@ -35,13 +38,15 @@ public class PARTsNT { /** * Generic topic entry that is not designed to be used by itself. * - *

Use the other chilld classes instead. + *

+ * Use the other chilld classes instead. */ private class EasyGenericEntry { /** The NetworkTables topic name. */ public String topicName; - public EasyGenericEntry() {} + public EasyGenericEntry() { + } } class EasyBooleanEntry extends EasyGenericEntry { @@ -54,7 +59,9 @@ class EasyBooleanEntry extends EasyGenericEntry { /** * The value last gotten from set or get. * - *

Its purpose here is to provide a way to get the previous cached result, saving some + *

+ * Its purpose here is to provide a way to get the previous cached result, + * saving some * time. */ public boolean cachedValue; @@ -84,7 +91,9 @@ class EasyIntegerEntry extends EasyGenericEntry { /** * The value last gotten from set or get. * - *

Its purpose here is to provide a way to get the previous cached result, saving some + *

+ * Its purpose here is to provide a way to get the previous cached result, + * saving some * time. */ public int cachedValue; @@ -114,7 +123,9 @@ class EasyDoubleEntry extends EasyGenericEntry { /** * The value last gotten from set or get. * - *

Its purpose here is to provide a way to get the previous cached result, saving some + *

+ * Its purpose here is to provide a way to get the previous cached result, + * saving some * time. */ public double cachedValue; @@ -144,7 +155,9 @@ class EasyStringEntry extends EasyGenericEntry { /** * The value last gotten from set or get. * - *

Its purpose here is to provide a way to get the previous cached result, saving some + *

+ * Its purpose here is to provide a way to get the previous cached result, + * saving some * time. */ public String cachedValue; @@ -174,7 +187,8 @@ public EasyStringEntry(String name, String value) { /** * Sets up the master list and the entry lists. * - *

Internal function. + *

+ * Internal function. */ private void setupEntryLists() { topicsList = new ArrayList<>(); @@ -193,9 +207,11 @@ private void setupEntryLists() { /** * Creates a new PARTsNT instance. * - *

Creates/uses the subtable "Generic" instead of the class subtable. + *

+ * Creates/uses the subtable "Generic" instead of the class subtable. * - *

The object variation should be used instead. + *

+ * The object variation should be used instead. */ public PARTsNT() { table = nt_Instance.getTable("PARTs").getSubTable("Generic"); @@ -205,7 +221,8 @@ public PARTsNT() { /** * Creates a new PARTsNT instance. * - *

Creates/uses the class subtable. + *

+ * Creates/uses the class subtable. * * @param o The class object. (E.g. passing in 'this'.) */ @@ -218,9 +235,11 @@ public PARTsNT(Object o) { /** * Creates a new PARTsNT instance. * - *

Creates/uses the subtable of the class via its name. + *

+ * Creates/uses the subtable of the class via its name. * - *

If the name is empty, then the "Generic" table will be used instead. + *

+ * If the name is empty, then the "Generic" table will be used instead. * * @param className The name of the class. */ @@ -254,10 +273,12 @@ private void addEntryToList(EasyGenericEntry entry) { * @param name The name of the entry. * @return The entry if it exists, otherwise null. */ - private EasyGenericEntry getEntry(String name) { - for (EasyGenericEntry entry : topicsList) { - if (entry.topicName.equals(name)) return entry; - } + private EasyGenericEntry getEntry(String name, boolean pull) { + if (pull) + for (EasyGenericEntry entry : topicsList) { + if (entry.topicName.equals(name)) + return entry; + } return null; } @@ -269,10 +290,12 @@ private EasyGenericEntry getEntry(String name) { * @param name The name of the entry. * @return The entry if it exists, otherwise null. */ - private EasyBooleanEntry getBooleanEntry(String name) { - for (EasyBooleanEntry entry : booleanEntries) { - if (entry.topicName.equals(name)) return entry; - } + private EasyBooleanEntry getBooleanEntry(String name, boolean pull) { + if (pull) + for (EasyBooleanEntry entry : booleanEntries) { + if (entry.topicName.equals(name)) + return entry; + } return null; } @@ -282,10 +305,12 @@ private EasyBooleanEntry getBooleanEntry(String name) { * @param name The name of the entry. * @return The entry if it exists, otherwise null. */ - private EasyIntegerEntry getIntegerEntry(String name) { - for (EasyIntegerEntry entry : integerEntries) { - if (entry.topicName.equals(name)) return entry; - } + private EasyIntegerEntry getIntegerEntry(String name, boolean pull) { + if (pull) + for (EasyIntegerEntry entry : integerEntries) { + if (entry.topicName.equals(name)) + return entry; + } return null; } @@ -295,10 +320,12 @@ private EasyIntegerEntry getIntegerEntry(String name) { * @param name The name of the entry. * @return The entry if it exists, otherwise null. */ - private EasyDoubleEntry getDoubleEntry(String name) { - for (EasyDoubleEntry entry : doubleEntries) { - if (entry.topicName.equals(name)) return entry; - } + private EasyDoubleEntry getDoubleEntry(String name, boolean pull) { + if (pull) + for (EasyDoubleEntry entry : doubleEntries) { + if (entry.topicName.equals(name)) + return entry; + } return null; } @@ -308,10 +335,12 @@ private EasyDoubleEntry getDoubleEntry(String name) { * @param name The name of the entry. * @return The entry if it exists, otherwise null. */ - private EasyStringEntry getStringEntry(String name) { - for (EasyStringEntry entry : stringEntries) { - if (entry.topicName.equals(name)) return entry; - } + private EasyStringEntry getStringEntry(String name, boolean pull) { + if (pull) + for (EasyStringEntry entry : stringEntries) { + if (entry.topicName.equals(name)) + return entry; + } return null; } @@ -323,24 +352,25 @@ private EasyStringEntry getStringEntry(String name) { * @param name The topic name. * @return Returns the boolean value if entry is found, otherwise returns false. */ - public boolean getBoolean(String name) { - EasyBooleanEntry entry = getBooleanEntry(name); + public boolean getBoolean(String name, boolean pull) { + EasyBooleanEntry entry = getBooleanEntry(name, pull); return (entry == null) ? false : (entry.cachedValue = entry.entry.get()); } /** * Sets the boolean value for the requested entry. * - * @param name The name of the entry. + * @param name The name of the entry. * @param value The new value to publish to the entry. */ - public void putBoolean(String name, boolean value) { - EasyBooleanEntry entry = getBooleanEntry(name); - if (entry == null) { - booleanEntries.add(new EasyBooleanEntry(name, value)); - } else if (entry.cachedValue != value) { - entry.entry.set((entry.cachedValue = value)); - } + public void putBoolean(String name, boolean value, boolean post) { + EasyBooleanEntry entry = getBooleanEntry(name, post); + if (post) + if (entry == null) { + booleanEntries.add(new EasyBooleanEntry(name, value)); + } else if (entry.cachedValue != value) { + entry.entry.set((entry.cachedValue = value)); + } } // * -------- INTEGER FUNCTIONS -------- *// @@ -351,24 +381,25 @@ public void putBoolean(String name, boolean value) { * @param name The name of the entry. * @return Returns the value if entry is found, otherwise returns zero. */ - public int getInteger(String name) { - EasyIntegerEntry entry = getIntegerEntry(name); + public int getInteger(String name, boolean pull) { + EasyIntegerEntry entry = getIntegerEntry(name, pull); return (entry == null) ? 0 : (entry.cachedValue = Math.toIntExact(entry.entry.get())); } /** * Sets the integer value for the requested entry. * - * @param name The name of the entry. + * @param name The name of the entry. * @param value The new value to publish to the entry. */ - public void putInteger(String name, int value) { - EasyIntegerEntry entry = getIntegerEntry(name); - if (entry == null) { - integerEntries.add(new EasyIntegerEntry(name, value)); - } else if (entry.cachedValue != value) { - entry.entry.set((entry.cachedValue = value)); - } + public void putInteger(String name, int value, boolean post) { + EasyIntegerEntry entry = getIntegerEntry(name, post); + if (post) + if (entry == null) { + integerEntries.add(new EasyIntegerEntry(name, value)); + } else if (entry.cachedValue != value) { + entry.entry.set((entry.cachedValue = value)); + } } // * -------- DOUBLE FUNCTIONS -------- *// @@ -379,44 +410,45 @@ public void putInteger(String name, int value) { * @param name The name of the entry. * @return Returns the value if entry is found, otherwise returns zero. */ - public double getDouble(String name) { - EasyDoubleEntry entry = getDoubleEntry(name); + public double getDouble(String name, boolean pull) { + EasyDoubleEntry entry = getDoubleEntry(name, pull); return (entry == null) ? 0 : (entry.cachedValue = entry.entry.get()); } /** * Sets the double value for the requested entry. * - * @param name The name of the entry. + * @param name The name of the entry. * @param value The new value to publish to the entry. */ - public void putDouble(String name, double value) { - EasyDoubleEntry entry = getDoubleEntry(name); - if (entry == null) { - doubleEntries.add(new EasyDoubleEntry(name, value)); - } else if (entry.cachedValue != value) { - entry.entry.set((entry.cachedValue = value)); - } + public void putDouble(String name, double value, boolean post) { + EasyDoubleEntry entry = getDoubleEntry(name, post); + if (post) + if (entry == null) { + doubleEntries.add(new EasyDoubleEntry(name, value)); + } else if (entry.cachedValue != value) { + entry.entry.set((entry.cachedValue = value)); + } } /** * Sets the double value for the requested entry. * - * @param name The name of the entry. + * @param name The name of the entry. * @param value The new value to publish to the entry. */ - public void putNumber(String name, double value) { - putDouble(name, value); + public void putNumber(String name, double value, boolean post) { + putDouble(name, value, post); } /** * Sets the integer value for the requested entry. * - * @param name The name of the entry. + * @param name The name of the entry. * @param value The new value to publish to the entry. */ - public void putNumber(String name, int value) { - putInteger(name, value); + public void putNumber(String name, int value, boolean post) { + putInteger(name, value, post); } // * -------- STRING FUNCTIONS -------- *// @@ -425,26 +457,28 @@ public void putNumber(String name, int value) { * Gets the string value from the requested entry. * * @param name The name of the entry. - * @return Returns the value if entry is found, otherwise returns an empty string. + * @return Returns the value if entry is found, otherwise returns an empty + * string. */ - public String getString(String name) { - EasyStringEntry entry = getStringEntry(name); + public String getString(String name, boolean pull) { + EasyStringEntry entry = getStringEntry(name, pull); return (entry == null) ? "" : (entry.cachedValue = entry.entry.get()); } /** * Sets the string value for the requested entry. * - * @param name The name of the entry. + * @param name The name of the entry. * @param value The new value to publish to the entry. */ - public void putString(String name, String value) { - EasyStringEntry entry = getStringEntry(name); - if (entry == null) { - stringEntries.add(new EasyStringEntry(name, value)); - } else if (entry.cachedValue != value) { - entry.entry.set((entry.cachedValue = value)); - } + public void putString(String name, String value, boolean post) { + EasyStringEntry entry = getStringEntry(name, post); + if (post) + if (entry == null) { + stringEntries.add(new EasyStringEntry(name, value)); + } else if (entry.cachedValue != value) { + entry.entry.set((entry.cachedValue = value)); + } } // * -------- REMOVAL FUNCTIONS -------- *// @@ -480,13 +514,11 @@ public void removeEntry(String name) { * * @param data The sendable to add. */ - public void putSmartDashboardSendable(String key, Sendable data) { + public void putSmartDashboardSendable(String key, Sendable data, boolean post) { String topic = key; - if (!name.equals("Generic")) topic = String.format("%s/%s", name, key); - // SmartDashboard.putData(topic, data); // loop-overrun - } - - public void putSmartDashboardSendable(String key, Sendable data, boolean debug) { - if (debug) putSmartDashboardSendable(key, data); + if (!name.equals("Generic")) + topic = String.format("%s/%s", name, key); + if (post) + SmartDashboard.putData(topic, data); // loop-overrun } } From 6cd2ca8394a408f1886cb48dcc98a64521770a53 Mon Sep 17 00:00:00 2001 From: Brandon Duke Date: Fri, 6 Mar 2026 09:32:08 -0500 Subject: [PATCH 6/6] conditional logging --- src/org/parts3492/partslib/PARTsCandle.java | 6 - src/org/parts3492/partslib/PARTsLogger.java | 120 +++++++++++--------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/src/org/parts3492/partslib/PARTsCandle.java b/src/org/parts3492/partslib/PARTsCandle.java index 5dc30e9..d799d81 100644 --- a/src/org/parts3492/partslib/PARTsCandle.java +++ b/src/org/parts3492/partslib/PARTsCandle.java @@ -417,19 +417,13 @@ public void outputTelemetry() { @Override public void stop() { - // TODO Auto-generated method stub - // throw new UnsupportedOperationException("Unimplemented method 'stop'"); } @Override public void reset() { - // TODO Auto-generated method stub - // throw new UnsupportedOperationException("Unimplemented method 'reset'"); } @Override public void log() { - // TODO Auto-generated method stub - super.partsLogger.logString("Animation", candle.getAppliedControl().getName()); } } diff --git a/src/org/parts3492/partslib/PARTsLogger.java b/src/org/parts3492/partslib/PARTsLogger.java index b3bed3f..32668b7 100644 --- a/src/org/parts3492/partslib/PARTsLogger.java +++ b/src/org/parts3492/partslib/PARTsLogger.java @@ -23,7 +23,8 @@ public class PARTsLogger { /** * Create a new PARTsLogger. * - *

By default, logging is disabled. + *

+ * By default, logging is disabled. */ public PARTsLogger() { instantiate(false); @@ -43,7 +44,8 @@ public PARTsLogger(boolean allowLogging) { /** * Create a new PARTsLogger with the following name. * - *

By default, logging is disabled. + *

+ * By default, logging is disabled. */ public PARTsLogger(String name) { instantiate(false); @@ -65,9 +67,11 @@ public PARTsLogger(String name, boolean allowLogging) { /** * Create a new PARTsLogger with the object's class name. * - *

E.g. PARTsLogger. + *

+ * E.g. PARTsLogger. * - *

By default, logging is disabled. + *

+ * By default, logging is disabled. */ public PARTsLogger(Object o) { name = o.getClass().getSimpleName(); @@ -77,7 +81,8 @@ public PARTsLogger(Object o) { /** * Create a new PARTsLogger with the object's class name. * - *

E.g. PARTsLogger. + *

+ * E.g. PARTsLogger. * *

* @@ -90,11 +95,12 @@ public PARTsLogger(Object o, boolean allowLogging) { private void instantiate(boolean allowLogging) { loggingEnabled = allowLogging; - if (loggingEnabled) { - // Starts recording to data log - DataLogManager.start(); + if (loggingEnabled) { - if (log == null) log = DataLogManager.getLog(); + if (log == null){ + // Starts recording to data log + DataLogManager.start(); + log = DataLogManager.getLog();} } } @@ -108,67 +114,73 @@ public void disableLogging() { instantiate(false); } - public boolean logBoolean(String key, boolean b) { - if (loggingEnabled) { + public boolean logBoolean(String key, boolean b, boolean logEntry) { + if (loggingEnabled && logEntry) { new BooleanLogEntry(log, name.length() > 0 ? String.format("%s/%s", name, key) : key) .append(b); return true; - } else return false; + } else + return false; } - public boolean logDouble(String key, double d) { - if (loggingEnabled) { + public boolean logDouble(String key, double d, boolean logEntry) { + if (loggingEnabled && logEntry) { new DoubleLogEntry(log, name.length() > 0 ? String.format("%s/%s", name, key) : key) .append(d); return true; - } else return false; + } else + return false; } - public boolean logString(String key, String s) { - if (loggingEnabled) { + public boolean logString(String key, String s, boolean logEntry) { + if (loggingEnabled && logEntry) { new StringLogEntry(log, name.length() > 0 ? String.format("%s/%s", name, key) : key) .append(s); return true; - } else return false; + } else + return false; } - public void logCommandScheduler() { - - // Set the scheduler to log events for command initialize, interrupt, finish - CommandScheduler.getInstance() - .onCommandInitialize( - command -> { - logString(command.getName(), "Command initialized"); - }); - CommandScheduler.getInstance() - .onCommandInterrupt( - command -> { - logString(command.getName(), "Command interrupted"); - }); - CommandScheduler.getInstance() - .onCommandFinish( - command -> { - logString(command.getName(), "Command finished"); - }); + public void logCommandScheduler(boolean logEntry) { + if (logEntry) { + // Set the scheduler to log events for command initialize, interrupt, finish + CommandScheduler.getInstance() + .onCommandInitialize( + command -> { + logString(command.getName(), "Command initialized", true); + }); + CommandScheduler.getInstance() + .onCommandInterrupt( + command -> { + logString(command.getName(), "Command interrupted", true); + }); + CommandScheduler.getInstance() + .onCommandFinish( + command -> { + logString(command.getName(), "Command finished", true); + }); + } } - public void logPathPlanner() { - // Logging callback for target robot pose - PathPlannerLogging.setLogTargetPoseCallback( - (pose) -> { - // Do whatever you want with the pose here - FieldBase.FIELD2D - .getObject("target pose") - .setPose(FieldBase.conditionallyTransformToOppositeAlliance(pose)); - }); - - // Logging callback for the active path, this is sent as a list of poses - PathPlannerLogging.setLogActivePathCallback( - (poses) -> { - // Do whatever you want with the poses here - FieldBase.FIELD2D - .getObject("path") - .setPoses(FieldBase.conditionallyTransformToOppositeAlliance(poses)); - }); + public void logPathPlanner(boolean logEntry) { + if (logEntry) { + // Logging callback for target robot pose + PathPlannerLogging.setLogTargetPoseCallback( + (pose) -> { + // Do whatever you want with the pose here + FieldBase.FIELD2D + .getObject("target pose") + .setPose(FieldBase.conditionallyTransformToOppositeAlliance(pose)); + }); + + // Logging callback for the active path, this is sent as a list of poses + PathPlannerLogging.setLogActivePathCallback( + (poses) -> { + // Do whatever you want with the poses here + FieldBase.FIELD2D + .getObject("path") + .setPoses(FieldBase.conditionallyTransformToOppositeAlliance(poses)); + }); + } } }