소스 검색

Manual Mode for Switch works now

dominik.rieder 7 년 전
부모
커밋
3c9767b574
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 0
      src/classes/HolonSwitch.java
  2. 2 2
      src/ui/controller/SimulationManager.java

+ 8 - 0
src/classes/HolonSwitch.java

@@ -65,6 +65,14 @@ public class HolonSwitch extends CpsObject {
 			this.manualActive = !manualActive;
 		}
 	}
+	
+	public boolean getState(int timeStep){
+		if(manualMode){
+			return this.manualActive;
+		} else {
+			return getActiveAt()[timeStep];
+		}
+	}
 
 	public boolean getState() {
 		if (manualMode) {

+ 2 - 2
src/ui/controller/SimulationManager.java

@@ -306,9 +306,9 @@ public class SimulationManager {
 	
 	public boolean legitState(CpsObject neighbor, CpsObject current){
 		if(current instanceof HolonSwitch){
-			if(((HolonSwitch) current).getActiveAt()[timeStep]){
+			if(((HolonSwitch) current).getState(timeStep)){
 				if(neighbor instanceof HolonSwitch){
-					if(((HolonSwitch) neighbor).getActiveAt()[timeStep]){
+					if(((HolonSwitch) neighbor).getState(timeStep)){
 						return true;
 					}else{
 						return false;