Skip to content

Commit

Permalink
Merge pull request #5 from FIRSTTeam6423/monologue-rewrite
Browse files Browse the repository at this point in the history
Merge monologue rewrite into main
  • Loading branch information
dabeycorn authored Feb 19, 2025
2 parents e60ef84 + 84b488f commit cd9c3d8
Show file tree
Hide file tree
Showing 50 changed files with 5,768 additions and 1,193 deletions.
11 changes: 1 addition & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ java {
targetCompatibility = JavaVersion.VERSION_17
}

def ROBOT_MAIN_CLASS = "org.frc6423.frc2025.Main"
def ROBOT_MAIN_CLASS = "wmironpatriots.Main"

version = '1.0.0'

Expand Down Expand Up @@ -80,9 +80,6 @@ dependencies {
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation "com.google.guava:guava:33.4.0-jre"

def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
annotationProcessor "org.littletonrobotics.akit:akit-autolog:$akitJson.version"
}

test {
Expand Down Expand Up @@ -114,12 +111,6 @@ tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
}

// Akit replay task
task(replayWatch, type: JavaExec) {
mainClass = "org.littletonrobotics.junction.ReplayWatch"
classpath = sourceSets.main.runtimeClasspath
}

// Build Constants generation
project.compileJava.dependsOn(createVersionFile)
gversion {
Expand Down
107 changes: 107 additions & 0 deletions src/main/java/monologue/Annotations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// Copyright (c) 2025 FRC 6423 - Ward Melville Iron Patriots
// https://github.com/FIRSTTeam6423
//
// Open Source Software; you can modify and/or share it under the terms of
// MIT license file in the root directory of this project

package monologue;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@SuppressWarnings("unchecked")
public class Annotations {
static final Class<? extends Annotation>[] ALL_ANNOTATIONS =
new Class[] {Log.class, Log.Once.class};

/**
* Logs the annotated field/method to NetworkTables if inside a {@link Logged} class.
*
* <p>Static fields and methods will emit a warning and not be logged.
*
* @param key [optional] the key to log the variable as. If empty, the key will be the name of the
* field/method
* @param sink [optional] the log sink to use
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface Log {

/** The relative path to log to. If empty, the path will be the name of the field/method. */
public String key() default "";

/** The {@link LogSink} to use. */
public LogSink sink() default LogSink.NT;

/**
* Logs the annotated field/method to NetworkTables if inside a {@link Logged} class.
*
* @param key [optional] the key to log the variable as. If empty, the key will be the name of
* the field/method
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
public @interface Once {
/** The relative path to log to. If empty, the path will be the name of the field/method. */
public String key() default "";

/** The {@link LogSink} to use. */
public LogSink sink() default LogSink.NT;
}
}

/**
* Makes the annotated field containing a {@link Logged} class not be recursed into.
*
* @apiNote this will also make fields inside the object in the field not be logged
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface IgnoreLogged {}

/**
* Allows singletons to be logged only once with a predefined key.
*
* <p>This also allows static variables to be logged under the singleton's key.
*
* @param key the key to log at, still appends the class name
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface SingletonLogged {
public String key();
}

/**
* Will cause the internal fields of the annotated field to be logged as if they were fields of
* the object this field is in. This is useful for flattening complex objects into a single path.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface FlattenedLogged {}

/**
* Will make Monologue aware that this field could contain an object that implements {@link
* Logged} but the type of the field itself does not implement {@link Logged}.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface MaybeLoggedType {}

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface OptionalLogged {
public Class<? extends Logged> type();
}
}
Loading

0 comments on commit cd9c3d8

Please sign in to comment.