From 94fd68ebc635b5441fe20901a264775c4e8733a8 Mon Sep 17 00:00:00 2001 From: Froze-N-Milk Date: Thu, 7 Mar 2024 12:54:52 +1100 Subject: [PATCH] feat(Dairy): changed to use Dairy Features - added Dairy:Core pre-release-2-0 as a dependency - rolled back annotation version for compatability - changed from recieving opmode notifications to using the Feature system - switched to using the dependency set annotation aquiring api - switched to using isAttached() instead of if annotation is null to check for activation - moved @Photon annotation to @PhotonCore.Attach to match Dairy standards --- PhotonCore/build.gradle | 7 +- .../photoncore/Photon.java | 20 ------ .../photoncore/PhotonCore.java | 67 ++++++++++++++----- .../hardware/PhotonLynxVoltageSensor.java | 1 - .../commands/PhotonLynxGetADCCommand.java | 4 +- .../PhotonLynxGetBulkInputDataCommand.java | 4 +- ...tMotorChannelCurrentAlertLevelCommand.java | 4 +- ...hotonLynxGetMotorChannelEnableCommand.java | 4 +- .../PhotonLynxGetMotorChannelModeCommand.java | 4 +- ...hotonLynxGetMotorConstantPowerCommand.java | 4 +- ...otorPIDControlLoopCoefficientsCommand.java | 4 +- ...torPIDFControlLoopCoefficientsCommand.java | 4 +- ...otonLynxGetMotorTargetPositionCommand.java | 4 +- ...otonLynxGetMotorTargetVelocityCommand.java | 4 +- .../PhotonLynxResetMotorEncoderCommand.java | 4 +- ...tMotorChannelCurrentAlertLevelCommand.java | 4 +- ...hotonLynxSetMotorChannelEnableCommand.java | 4 +- .../PhotonLynxSetMotorChannelModeCommand.java | 4 +- ...hotonLynxSetMotorConstantPowerCommand.java | 4 +- ...torPIDFControlLoopCoefficientsCommand.java | 4 +- ...otonLynxSetMotorTargetPositionCommand.java | 4 +- ...otonLynxSetMotorTargetVelocityCommand.java | 4 +- ...hotonLynxGetServoConfigurationCommand.java | 4 +- .../PhotonLynxGetServoEnableCommand.java | 4 +- .../PhotonLynxGetServoPulseWidthCommand.java | 4 +- 25 files changed, 99 insertions(+), 80 deletions(-) delete mode 100644 PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/Photon.java diff --git a/PhotonCore/build.gradle b/PhotonCore/build.gradle index 66a116b..ba9df04 100644 --- a/PhotonCore/build.gradle +++ b/PhotonCore/build.gradle @@ -5,6 +5,7 @@ plugins { repositories { mavenCentral() + maven { url 'https://jitpack.io' } } android { @@ -42,8 +43,10 @@ afterEvaluate { } dependencies { - compileOnly 'org.jetbrains:annotations:15.0' - compileOnly "androidx.annotation:annotation:1.7.0" + compileOnly 'org.jetbrains:annotations:13.0' + compileOnly "androidx.annotation:annotation:1.1.0" + + compileOnly('com.github.Dairy-Foundation.Dairy:Core:pre-release-2-0') compileOnly 'org.firstinspires.ftc:RobotCore:9.0.1' compileOnly 'org.firstinspires.ftc:Hardware:9.0.1' diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/Photon.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/Photon.java deleted file mode 100644 index 41fc207..0000000 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/Photon.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.outoftheboxrobotics.photoncore; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -/** - * Add this to a {@link com.qualcomm.robotcore.eventloop.opmode.OpMode} in order to apply PhotonCore optimizations - */ -@Documented -@Inherited -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Photon { - int maximumParallelCommands() default 8; - - boolean singleThreadOptimized() default true; -} diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/PhotonCore.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/PhotonCore.java index 15ebfad..4b6371b 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/PhotonCore.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/PhotonCore.java @@ -2,6 +2,9 @@ import android.content.Context; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.outoftheboxrobotics.photoncore.hardware.PhotonLynxVoltageSensor; import com.outoftheboxrobotics.photoncore.hardware.motor.PhotonDcMotor; import com.outoftheboxrobotics.photoncore.hardware.motor.PhotonLynxDcMotorController; @@ -15,10 +18,8 @@ import com.qualcomm.hardware.lynx.LynxModuleIntf; import com.qualcomm.hardware.lynx.LynxServoController; import com.qualcomm.hardware.lynx.LynxVoltageSensor; -import com.qualcomm.robotcore.eventloop.opmode.OpMode; import com.qualcomm.robotcore.eventloop.opmode.OpModeManager; import com.qualcomm.robotcore.eventloop.opmode.OpModeManagerImpl; -import com.qualcomm.robotcore.eventloop.opmode.OpModeManagerNotifier; import com.qualcomm.robotcore.exception.RobotCoreException; import com.qualcomm.robotcore.hardware.CRServo; import com.qualcomm.robotcore.hardware.CRServoImpl; @@ -31,6 +32,13 @@ import org.firstinspires.ftc.ftccommon.external.OnCreateEventLoop; +import java.lang.annotation.Annotation; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,12 +46,34 @@ import java.util.Set; import java.util.concurrent.Semaphore; -public class PhotonCore implements OpModeManagerNotifier.Notifications { +import dev.frozenmilk.dairy.core.Feature; +import dev.frozenmilk.dairy.core.dependencyresolution.dependencies.Dependency; +import dev.frozenmilk.dairy.core.dependencyresolution.dependencyset.DependencySet; +import dev.frozenmilk.dairy.core.wrapper.Wrapper; +import dev.frozenmilk.util.cell.LateInitCell; + +public class PhotonCore implements Feature { + private final LateInitCell attach = new LateInitCell<>(); + private final DependencySet dependencySet = new DependencySet(this) + .includesExactlyOneOf(Attach.class) + .bindOutputTo(attach); + @NonNull + @Override + public Set> getDependencies() { + return dependencySet; + } + // Configuration and singleton values private static final String TAG = "PhotonCore"; private static final PhotonCore instance = new PhotonCore(); public static final boolean DEBUG=true; - public static Photon photon; + public static boolean attached() { + return instance.isAttached(); + } + @Nullable + public static Attach photon() { + return (Attach) instance.attach.safeGet(); + } private OpModeManagerImpl opModeManager; @@ -54,8 +84,7 @@ public class PhotonCore implements OpModeManagerNotifier.Notifications { public static void attachEventLoop(Context context, FtcEventLoop eventLoop) { if(DEBUG) RobotLog.ii(TAG, "attachEventLoop: Attached PhotonCore to event loop"); - eventLoop.getOpModeManager().registerListener(instance); - instance.opModeManager=eventLoop.getOpModeManager(); + instance.opModeManager = eventLoop.getOpModeManager(); } public static void acquire(LynxModuleIntf module) throws InterruptedException { @@ -67,18 +96,17 @@ public static void release(LynxModuleIntf module) throws InterruptedException { } @Override - public void onOpModePreInit(OpMode opMode) { + public void preUserInitHook(@NonNull Wrapper opMode) { if(opModeManager.getActiveOpModeName().equals(OpModeManager.DEFAULT_OP_MODE_NAME)) return; - photon = opMode.getClass().getAnnotation(Photon.class); - if(photon!=null) { + if(photon()!=null) { if(DEBUG) RobotLog.ii(TAG, "onOpModePreInit: Enabling PhotonCore optimizations for opMode %s", opModeManager.getActiveOpModeName()); - HardwareMap hardwareMap = opMode.hardwareMap; + HardwareMap hardwareMap = opMode.getOpMode().hardwareMap; // Get the names of devices using reflection - Map> deviceNames = ReflectionUtils.getFieldValue(opMode.hardwareMap, "deviceNames"); + Map> deviceNames = ReflectionUtils.getFieldValue(opMode.getOpMode().hardwareMap, "deviceNames"); assert deviceNames!=null; // The first step is to replace all LynxModules with PhotonLynxModules @@ -238,8 +266,17 @@ public void onOpModePreInit(OpMode opMode) { }*/ } } - @Override - public void onOpModePreStart(OpMode opMode) {} - @Override - public void onOpModePostStop(OpMode opMode) {} + + /** + * Add this to a {@link com.qualcomm.robotcore.eventloop.opmode.OpMode} in order to apply PhotonCore optimizations + */ + @Documented + @Inherited + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + public @interface Attach { + int maximumParallelCommands() default 8; + + boolean singleThreadOptimized() default true; + } } diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/PhotonLynxVoltageSensor.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/PhotonLynxVoltageSensor.java index 6dd9a53..c76dc74 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/PhotonLynxVoltageSensor.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/PhotonLynxVoltageSensor.java @@ -2,7 +2,6 @@ import android.content.Context; -import com.outoftheboxrobotics.photoncore.Photon; import com.outoftheboxrobotics.photoncore.PhotonLastKnown; import com.outoftheboxrobotics.photoncore.hardware.motor.commands.PhotonLynxGetADCCommand; import com.qualcomm.hardware.lynx.LynxModule; diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetADCCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetADCCommand.java index bf7937c..383d49c 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetADCCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetADCCommand.java @@ -39,7 +39,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -48,7 +48,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetBulkInputDataCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetBulkInputDataCommand.java index 7058ab5..81551c2 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetBulkInputDataCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetBulkInputDataCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelCurrentAlertLevelCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelCurrentAlertLevelCommand.java index c9ef247..03cb48a 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelCurrentAlertLevelCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelCurrentAlertLevelCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelEnableCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelEnableCommand.java index 49bc9c7..b6b7c8e 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelEnableCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelEnableCommand.java @@ -34,7 +34,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -43,7 +43,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelModeCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelModeCommand.java index a7d1113..6b3867d 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelModeCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorChannelModeCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorConstantPowerCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorConstantPowerCommand.java index a155c83..fff7ffe 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorConstantPowerCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorConstantPowerCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDControlLoopCoefficientsCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDControlLoopCoefficientsCommand.java index a8f8e04..9b15254 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDControlLoopCoefficientsCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDControlLoopCoefficientsCommand.java @@ -35,7 +35,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -44,7 +44,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDFControlLoopCoefficientsCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDFControlLoopCoefficientsCommand.java index 23403f4..51c3a2d 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDFControlLoopCoefficientsCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorPIDFControlLoopCoefficientsCommand.java @@ -35,7 +35,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -44,7 +44,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetPositionCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetPositionCommand.java index 47b292c..70672f9 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetPositionCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetPositionCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetVelocityCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetVelocityCommand.java index fbc8562..033b1c9 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetVelocityCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxGetMotorTargetVelocityCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxResetMotorEncoderCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxResetMotorEncoderCommand.java index 518039f..eca2b6c 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxResetMotorEncoderCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxResetMotorEncoderCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelCurrentAlertLevelCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelCurrentAlertLevelCommand.java index c178539..8047987 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelCurrentAlertLevelCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelCurrentAlertLevelCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelEnableCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelEnableCommand.java index 0687d94..59bf9a7 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelEnableCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelEnableCommand.java @@ -34,7 +34,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -43,7 +43,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelModeCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelModeCommand.java index ee0a5eb..d25ed36 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelModeCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorChannelModeCommand.java @@ -39,7 +39,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -48,7 +48,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorConstantPowerCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorConstantPowerCommand.java index c67420e..7960a33 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorConstantPowerCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorConstantPowerCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorPIDFControlLoopCoefficientsCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorPIDFControlLoopCoefficientsCommand.java index 59837fa..ece6ec0 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorPIDFControlLoopCoefficientsCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorPIDFControlLoopCoefficientsCommand.java @@ -35,7 +35,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -44,7 +44,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetPositionCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetPositionCommand.java index 8227a4d..55a5a6c 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetPositionCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetPositionCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetVelocityCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetVelocityCommand.java index ff56bfe..f13d3e4 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetVelocityCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/motor/commands/PhotonLynxSetMotorTargetVelocityCommand.java @@ -34,7 +34,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -43,7 +43,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoConfigurationCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoConfigurationCommand.java index 65797db..f69836b 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoConfigurationCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoConfigurationCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoEnableCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoEnableCommand.java index 3570f11..15292f9 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoEnableCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoEnableCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module); diff --git a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoPulseWidthCommand.java b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoPulseWidthCommand.java index 23d3a38..756ac70 100644 --- a/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoPulseWidthCommand.java +++ b/PhotonCore/src/main/java/com/outoftheboxrobotics/photoncore/hardware/servo/commands/PhotonLynxGetServoPulseWidthCommand.java @@ -38,7 +38,7 @@ public void onNackReceived(LynxNack nack) { @Override public void acquireNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.acquireNetworkLock(); }else { PhotonCore.acquire(module); @@ -47,7 +47,7 @@ public void acquireNetworkLock() throws InterruptedException { @Override public void releaseNetworkLock() throws InterruptedException { - if(PhotonCore.photon == null){ + if(!PhotonCore.attached()){ super.releaseNetworkLock(); }else { PhotonCore.release(module);