Skip to content

Commit

Permalink
REBASE: squash
Browse files Browse the repository at this point in the history
  • Loading branch information
minhn02 committed Feb 19, 2019
1 parent 854b838 commit c93c8d0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.team2073.common.assertion.Assert;
import com.team2073.common.mediator.condition.Condition;
import com.team2073.common.mediator.conflict.Conflict;
import com.team2073.common.mediator.conflict.PositionBasedConflict;
import com.team2073.common.mediator.request.Request;
import com.team2073.common.mediator.subsys.ColleagueSubsystem;
import com.team2073.common.periodic.PeriodicRunnable;
Expand Down Expand Up @@ -225,7 +224,7 @@ private Request createConflictRequest(Conflict conflict) {
Request conflictingRequest = new Request<>(conflict.getOriginSubsystem(), conflict.getOriginInterimResolution(subsystemMap.get(conflict.getOriginSubsystem()),
subsystemMap.get(conflict.getConflictingSubsystem())));

if (conflict instanceof PositionBasedConflict) {
if (conflict.getParallelism()) {
request.setParallelRequest(conflictingRequest);
}
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ abstract class Conflict<OT, CT>(
val originCondition: Condition<OT>,
val conflictingSubsystem: Class<out ColleagueSubsystem<CT>>,
val conflictingCondition: Condition<CT>,
val canInvert: Boolean) {
val canInvert: Boolean,
val parallelism: Boolean) {

abstract fun invert(): Conflict<CT, OT>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class PositionBasedConflict(
val originConditionP: Condition<Double>,
val conflictingSubsystemP: Class<out ColleagueSubsystem<Double>>,
val conflictingConditionP: Condition<Double>,
val canInvertP: Boolean) :
Conflict<Double, Double>(originSubsystemP, originConditionP, conflictingSubsystemP, conflictingConditionP, canInvertP) {
val canInvertP: Boolean,
val parallelismP: Boolean) :
Conflict<Double, Double>(originSubsystemP, originConditionP, conflictingSubsystemP, conflictingConditionP, canInvertP, parallelismP) {

override fun isConditionConflicting(originCondition: Condition<Double>, conflictingCondition: Condition<Double>): Boolean {
return originCondition == originConditionP && conflictingCondition == conflictingConditionP
Expand All @@ -36,6 +37,8 @@ class PositionBasedConflict(
val nearestOriginSafeX: Double
val nearestConflictSafeX: Double
val originSafetyRange = originSubsystem.getSafetyRange()
val originResolution = getResolution(originSubsystem.getCurrentCondition(), originSubsystem)
val isOriginTop = false

if (originPoint.y > conflictingPoint.y) {
nearestOriginSafeY = originPoint.y - originSubsystem.getSafetyRange()
Expand All @@ -56,7 +59,8 @@ class PositionBasedConflict(
val nearestOriginSafePoint = Vector2D(nearestOriginSafeX, nearestOriginSafeY)
val nearestConflictSafePoint = Vector2D(nearestConflictSafeX, nearestConflictSafeY)

val nearestOriginSafePosition = originSubsystem.pointToPosition(nearestOriginSafePoint);
val nearestOriginSafePosition = originSubsystem.pointToPosition(nearestOriginSafePoint)


return PositionBasedCondition(nearestOriginSafePosition,
Range.between(nearestOriginSafePosition - originSafetyRange, nearestOriginSafePosition + originSafetyRange))
Expand All @@ -71,6 +75,6 @@ class PositionBasedConflict(
}

override fun invert(): Conflict<Double, Double> {
return PositionBasedConflict(conflictingSubsystemP, conflictingConditionP, originSubsystemP, originConditionP, canInvertP)
return PositionBasedConflict(conflictingSubsystemP, conflictingConditionP, originSubsystemP, originConditionP, canInvertP, parallelismP)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class PositionStateBasedConflict<T : Enum<T>>(
val conflictingSubsystemPS: Class<out ColleagueSubsystem<SubsystemStateCondition<T>>>,
val conflictingConditionPS: Condition<SubsystemStateCondition<T>>,
val resolveState: SubsystemStateCondition<T>?,
val canInvertPS: Boolean) :
Conflict<Double, SubsystemStateCondition<T>>(originSubsystemPS, originConditionPS, conflictingSubsystemPS, conflictingConditionPS, canInvertPS) {
val canInvertPS: Boolean,
val parallelismPS: Boolean) :
Conflict<Double, SubsystemStateCondition<T>>(originSubsystemPS, originConditionPS, conflictingSubsystemPS, conflictingConditionPS, canInvertPS, parallelismPS) {

override fun getOriginInterimResolution(originSubsystem: ColleagueSubsystem<Double>, conflictingSubsystem: ColleagueSubsystem<SubsystemStateCondition<T>>): Condition<Double> {
val originSafetyRange: Double = (originSubsystem as PositionBasedSubsystem).getSafetyRange()
Expand All @@ -39,6 +40,6 @@ class PositionStateBasedConflict<T : Enum<T>>(
}

override fun invert(): Conflict<SubsystemStateCondition<T>, Double> {
return StatePositionBasedConflict(conflictingSubsystemPS, conflictingConditionPS, originSubsystemPS, originConditionPS, null, canInvertPS)
return StatePositionBasedConflict(conflictingSubsystemPS, conflictingConditionPS, originSubsystemPS, originConditionPS, null, canInvertPS, parallelismPS)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ class StateBasedConflict<OT : Enum<OT>, CT : Enum<CT>>(
val conflictingConditionS: Condition<SubsystemStateCondition<CT>>,
val resolveState: SubsystemStateCondition<CT>?,
val inverseResolveState: SubsystemStateCondition<OT>?,
val canInvertS: Boolean) :
Conflict<SubsystemStateCondition<OT>, SubsystemStateCondition<CT>>(originSubsystemS, originConditionS, conflictingSubsystemS, conflictingConditionS, canInvertS) {
val canInvertS: Boolean,
val parallelismS: Boolean) :
Conflict<SubsystemStateCondition<OT>, SubsystemStateCondition<CT>>(originSubsystemS, originConditionS, conflictingSubsystemS, conflictingConditionS, canInvertS, parallelismS) {

override fun getOriginInterimResolution(originSubsystem: ColleagueSubsystem<SubsystemStateCondition<OT>>, conflictingSubsystem: ColleagueSubsystem<SubsystemStateCondition<CT>>): Condition<SubsystemStateCondition<OT>> {
return StateBasedCondition(originSubsystem.getCurrentCondition().getConditionValue())
}

override fun invert(): Conflict<SubsystemStateCondition<CT>, SubsystemStateCondition<OT>> {
return StateBasedConflict(conflictingSubsystemS, conflictingConditionS, originSubsystemS, originConditionS, inverseResolveState, resolveState, canInvertS)
return StateBasedConflict(conflictingSubsystemS, conflictingConditionS, originSubsystemS, originConditionS, inverseResolveState, resolveState, canInvertS, parallelismS)
}

override fun isRequestConflicting(request: Request<SubsystemStateCondition<OT>>, currentConflictingCondition: Condition<SubsystemStateCondition<CT>>, currentOriginCondition: Condition<SubsystemStateCondition<OT>>): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class StatePositionBasedConflict<T : Enum<T>>(val originSubsystemPS: Class<out C
val conflictingSubsystemPS: Class<out ColleagueSubsystem<Double>>,
val conflictingConditionPS: Condition<Double>,
val inverseResolveState: SubsystemStateCondition<T>?,
val canInvertPS: Boolean) :
Conflict<SubsystemStateCondition<T>, Double>(originSubsystemPS, originConditionPS, conflictingSubsystemPS, conflictingConditionPS, canInvertPS){
val canInvertPS: Boolean,
val parallelismSP: Boolean) :
Conflict<SubsystemStateCondition<T>, Double>(originSubsystemPS, originConditionPS, conflictingSubsystemPS, conflictingConditionPS, canInvertPS, parallelismSP){

override fun getOriginInterimResolution(originSubsystem: ColleagueSubsystem<SubsystemStateCondition<T>>, conflictingSubsystem: ColleagueSubsystem<Double>): Condition<SubsystemStateCondition<T>> {
return StateBasedCondition(originSubsystem.getCurrentCondition().getConditionValue())
Expand All @@ -38,6 +39,6 @@ class StatePositionBasedConflict<T : Enum<T>>(val originSubsystemPS: Class<out C
}

override fun invert(): Conflict<Double, SubsystemStateCondition<T>> {
return PositionStateBasedConflict(conflictingSubsystemPS, conflictingConditionPS, originSubsystemPS, originConditionPS, inverseResolveState, canInvertPS)
return PositionStateBasedConflict(conflictingSubsystemPS, conflictingConditionPS, originSubsystemPS, originConditionPS, inverseResolveState, canInvertPS, parallelismSP)
}
}

0 comments on commit c93c8d0

Please sign in to comment.