Skip to content
Permalink
Browse files

fix Inverted status when Inconsistent

  • Loading branch information...
icklesteve committed Aug 2, 2019
1 parent 90186c5 commit 8f6d6a5af7dc04919cba2b5608b4e53f4ba0bd45
Showing with 11 additions and 3 deletions.
  1. +8 −3 java/src/jmri/Turnout.java
  2. +3 −0 java/test/jmri/TurnoutTest.java
@@ -247,14 +247,19 @@
public void setTurnoutOperation(@Nullable TurnoutOperation toper);

/**
* return the inverted state of the specified state
* Return the inverted state of the specified state
* Does NOT invert INCONSISTENT
* @param inState the specified state
* @return the inverted state
*/
public static int invertTurnoutState(int inState) {
int result = CLOSED;
if (result == inState) {
int result = UNKNOWN;
if (inState == CLOSED) {
result = THROWN;
} else if (inState == THROWN){
result = CLOSED;
} else if (inState == INCONSISTENT){
result = INCONSISTENT;
}
return result;
}
@@ -19,12 +19,15 @@ public void testStateConstants() {
Assert.assertTrue("Off and Unknown differ", (Turnout.CLOSED & Turnout.UNKNOWN) == 0);
Assert.assertTrue("Thrown and Inconsistent differ", (Turnout.THROWN & Turnout.INCONSISTENT) == 0);
Assert.assertTrue("Closed and Inconsistent differ", (Turnout.CLOSED & Turnout.INCONSISTENT) == 0);
Assert.assertTrue("Unknown and Inconsistent differ", (Turnout.UNKNOWN & Turnout.INCONSISTENT) == 0);
}

@Test
public void testInvertTurnoutState() {
Assert.assertEquals("Closed state Inverted",Turnout.THROWN,Turnout.invertTurnoutState(Turnout.CLOSED));
Assert.assertEquals("Thrown state Inverted",Turnout.CLOSED,Turnout.invertTurnoutState(Turnout.THROWN));
Assert.assertEquals("Inconsistent state Inverted",Turnout.INCONSISTENT,Turnout.invertTurnoutState(Turnout.INCONSISTENT));
Assert.assertEquals("Unknown state Inverted",Turnout.UNKNOWN,Turnout.invertTurnoutState(Turnout.UNKNOWN));
}

}

0 comments on commit 8f6d6a5

Please sign in to comment.
You can’t perform that action at this time.