diff --git a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/Conflict.kt b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/Conflict.kt index d97ff576..ed4ef4e0 100644 --- a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/Conflict.kt +++ b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/Conflict.kt @@ -12,7 +12,7 @@ abstract class Conflict( abstract fun invert(): Conflict - abstract fun isRequestConflicting(request: Request, conflictingCondition: Condition, currentOriginCondition: Condition): Boolean + abstract fun isRequestConflicting(request: Request, currentConflictingCondition: Condition, currentOriginCondition: Condition): Boolean abstract fun isConditionConflicting(originCondition: Condition, conflictingCondition: Condition): Boolean diff --git a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionBasedConflict.kt b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionBasedConflict.kt index 0d21d038..5d32d5da 100644 --- a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionBasedConflict.kt +++ b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionBasedConflict.kt @@ -26,10 +26,10 @@ class PositionBasedConflict( } - override fun isRequestConflicting(request: Request, conflictingCondition: Condition, currentOriginCondition: Condition): Boolean { - var range: Range = Range.between(currentOriginCondition.getConditionValue(), request.condition.getConditionValue()) - var conflictingRange: Range = Range.between((conflictingCondition as PositionBasedCondition).range.minimum, - conflictingCondition.range.maximum) + override fun isRequestConflicting(request: Request, currentConflictingCondition: Condition, currentOriginCondition: Condition): Boolean { + val range: Range = Range.between(currentOriginCondition.getConditionValue(), request.condition.getConditionValue()) + val conflictingRange: Range = Range.between((currentConflictingCondition as PositionBasedCondition).range.minimum, + currentConflictingCondition.range.maximum) return range.isOverlappedBy(conflictingRange) } diff --git a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionStateBasedConflict.kt b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionStateBasedConflict.kt index c098fcf3..e7ab5243 100644 --- a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionStateBasedConflict.kt +++ b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/PositionStateBasedConflict.kt @@ -5,6 +5,7 @@ import com.team2073.common.mediator.condition.StateBasedCondition import com.team2073.common.mediator.request.Request import com.team2073.common.mediator.subsys.ColleagueSubsystem import com.team2073.common.mediator.subsys.SubsystemStateCondition +import org.apache.commons.lang3.Range class PositionStateBasedConflict>( val originSubsystemPS: Class>, @@ -22,9 +23,10 @@ class PositionStateBasedConflict>( return StateBasedCondition(resolveState) } - override fun isRequestConflicting(request: Request, conflictingCondition: Condition>, currentOriginCondition: Condition): Boolean { - return conflictingCondition.isInCondition(conflictingConditionPS) - && originCondition.isInCondition(request.condition) + override fun isRequestConflicting(request: Request, currentConflictingCondition: Condition>, currentOriginCondition: Condition): Boolean { + val travelRange: Range = Range.between(currentOriginCondition.getConditionValue(), request.condition.getConditionValue()) + return currentConflictingCondition.isInCondition(conflictingConditionPS) + && travelRange.contains(originConditionPS.getConditionValue()) } override fun invert(): Conflict, Double> { diff --git a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StateBasedConflict.kt b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StateBasedConflict.kt index 43163bb9..c1227be1 100644 --- a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StateBasedConflict.kt +++ b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StateBasedConflict.kt @@ -19,8 +19,8 @@ class StateBasedConflict, CT : Enum>( return StateBasedConflict(conflictingSubsystemS, conflictingConditionS, originSubsystemS, originConditionS, inverseResolveState, resolveState) } - override fun isRequestConflicting(request: Request>, conflictingCondition: Condition>, currentOriginCondition: Condition>): Boolean { - return originCondition.isInCondition(request.condition) && conflictingCondition.isInCondition(conflictingConditionS) + override fun isRequestConflicting(request: Request>, currentConflictingCondition: Condition>, currentOriginCondition: Condition>): Boolean { + return originCondition.isInCondition(request.condition) && currentConflictingCondition.isInCondition(conflictingConditionS) } override fun isConditionConflicting(originCondition: Condition>, conflictingCondition: Condition>): Boolean { diff --git a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StatePositionBasedConflict.kt b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StatePositionBasedConflict.kt index 5fb3272d..1a6997aa 100644 --- a/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StatePositionBasedConflict.kt +++ b/common-wpi-util/src/main/java/com/team2073/common/mediator/conflict/StatePositionBasedConflict.kt @@ -27,18 +27,8 @@ class StatePositionBasedConflict>(val originSubsystemPS: Class>, conflictingCondition: Condition, currentOriginCondition: Condition>): Boolean { - var conflictCase = false - var originCase = false - - if (conflictingCondition.isInCondition(conflictingConditionPS)) { - conflictCase = true - } - if (originCondition.isInCondition(request.condition)) { - originCase = true - } - - return originCase && conflictCase + override fun isRequestConflicting(request: Request>, currentConflictingCondition: Condition, currentOriginCondition: Condition>): Boolean { + return request.condition.isInCondition(originCondition) && currentConflictingCondition.isInCondition(conflictingConditionPS) } override fun invert(): Conflict> {