Skip to content

Commit

Permalink
new override files
Browse files Browse the repository at this point in the history
  • Loading branch information
auriium2 committed Jan 28, 2024
1 parent ad03241 commit 1a0f91d
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 40 deletions.
2 changes: 1 addition & 1 deletion mattlib2-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

public class MattlibSettings {

public enum Robot {
MCR,
CARY
}


/**
* Set this to false to kill logging
*/
public static boolean USE_LOGGING = true;
public static Robot ROBOT = Robot.CARY;

}
4 changes: 2 additions & 2 deletions mattlib2-auto-wpi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-auto</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>edu.wpi.first.wpilibNewCommands</groupId>
Expand Down
6 changes: 3 additions & 3 deletions mattlib2-auto/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -26,12 +26,12 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-api</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-hardware</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
28 changes: 14 additions & 14 deletions mattlib2-foxe-ext/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions mattlib2-hardware/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-api</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xyz.auriium</groupId>
Expand Down
4 changes: 2 additions & 2 deletions mattlib2-log-foxe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -41,7 +41,7 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-api</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions mattlib2-log-nt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-api</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>edu.wpi.first.ntcore</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@
import edu.wpi.first.wpilibj.RobotBase;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.description.ByteCodeElement;
import net.bytebuddy.description.type.TypeDefinition;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
import net.bytebuddy.implementation.*;
import net.bytebuddy.jar.asm.Opcodes;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
import xyz.auriium.mattlib2.Exceptions;
import xyz.auriium.mattlib2.IMattLog;
import xyz.auriium.mattlib2.IPeriodicLooped;
import xyz.auriium.mattlib2.Mattlib2Exception;
import xyz.auriium.mattlib2.*;
import xyz.auriium.mattlib2.log.INetworkedComponent;
import xyz.auriium.mattlib2.log.ProcessMap;
import xyz.auriium.mattlib2.log.ProcessPath;
Expand All @@ -26,15 +22,13 @@
import yuukonfig.core.YuuKonfig;
import yuukonfig.core.impl.safe.HandlesPrimitiveManipulator;
import yuukonfig.core.impl.safe.HandlesSafeManipulator;
import yuukonfig.core.impl.safe.ManipulatorSafe;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
Expand Down Expand Up @@ -71,10 +65,15 @@ public void preInit() {

String load = "config.toml";
String sim = "sim.toml";
String cary = "cary.toml";
String mcr = "mcr.toml";

var conf_dir = new File(Filesystem.getDeployDirectory(), "mattlib");
var conf_file = new File(conf_dir, load);
var sim_file = new File(conf_dir, sim);
var cary_file = new File(conf_dir, cary);
var mcr_file = new File(conf_dir, mcr);


boolean isSim = RobotBase.isSimulation();
boolean shouldDoFunnyOverwriteOfFile = false;
Expand All @@ -91,6 +90,8 @@ public void preInit() {
if (!sim_file.exists()) {
throw Exceptions.MATTLIB_FILE_EXCEPTION(sim);
}
if (!cary_file.exists()) throw Exceptions.MATTLIB_FILE_EXCEPTION(cary);
if (!mcr_file.exists()) throw Exceptions.MATTLIB_FILE_EXCEPTION(mcr);

//System.out.println("has read: " + traj_file.canRead() + " has write: " + traj_file.canWrite());

Expand Down Expand Up @@ -126,7 +127,20 @@ public void preInit() {
.overrideMainConfigFromFile(sim_file.toPath())
.loadToMemoryConfig();
} else {
map = loader.loadOnlyUser().loadToMemoryConfig();
var contentBridge = loader.loadOnlyUser();

if (MattlibSettings.ROBOT == MattlibSettings.Robot.CARY) {
map = contentBridge
.overrideMainConfigFromFile(cary_file.toPath())
.loadToMemoryConfig();
} else if (MattlibSettings.ROBOT == MattlibSettings.Robot.MCR) {
map = contentBridge
.overrideMainConfigFromFile(mcr_file.toPath())
.loadToMemoryConfig();
} else {
map = contentBridge.loadToMemoryConfig();
}

}

for (LoadStruct<?> struct : structs) {
Expand Down
6 changes: 3 additions & 3 deletions mattlib2-rev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -28,12 +28,12 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-api</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-hardware</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.revrobotics.frc</groupId>
Expand Down
4 changes: 2 additions & 2 deletions mattlib2-sim/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>mattlib2</artifactId>
<groupId>xyz.auriium</groupId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2-hardware</artifactId>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>edu.wpi.first.wpilibj</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>xyz.auriium</groupId>
<artifactId>mattlib2</artifactId>
<packaging>pom</packaging>
<version>1.3.12-SNAPSHOT</version>
<version>1.3.13-SNAPSHOT</version>
<modules>
<module>mattlib2-api</module>
<module>mattlib2-rev</module>
Expand Down

0 comments on commit 1a0f91d

Please sign in to comment.