Browse Source

set state

dominik.rieder 7 years ago
parent
commit
76a66ccf2b
1 changed files with 35 additions and 16 deletions
  1. 35 16
      src/classes/CpsEdge.java

+ 35 - 16
src/classes/CpsEdge.java

@@ -1,14 +1,17 @@
 package classes;
 
+import java.util.ArrayList;
+
 public class CpsEdge {
 
 	float maxCapacity;
 	float flow;
 	boolean isWorking;
-	// State represents the real status of the edge
-	// If it breaks --> stay ruin no matter the actual scenario
-	// The only way to repair it is through manual change (setStateEdge)
-	// boolean state = true;
+	//State represents the real status of the edge
+	//If it breaks --> stay ruin no matter the actual scenario
+	//The only way to repair it is through manual change (setStateEdge) 
+	
+	ArrayList<Integer> tags;
 
 	CpsObject A;
 	CpsObject B;
@@ -62,25 +65,25 @@ public class CpsEdge {
 	public void setFlow(float flow) {
 		this.flow = flow;
 		/**
-		 * if (flow <= maxCapacity || flow == -1) { isWorking = true; } else {
-		 * isWorking = false; state = false; }
-		 **/
+		if (flow <= maxCapacity || flow == -1) {
+			isWorking = true;
+		} else {
+			isWorking = false;
+			state = false;
+		}
+		**/
 	}
-
-	public void calculateState(boolean simMode) {
-		if (flow > maxCapacity && maxCapacity != -1) {
+	
+	public void calculateState(boolean simMode){
+		if(flow > maxCapacity && maxCapacity != -1){
 			isWorking = false;
-		} else {
-			if (!simMode && flow <= maxCapacity) {
+		}else {
+			if(!simMode && flow <= maxCapacity){
 				isWorking = true;
 			}
 		}
 	}
 
-	public void setState(boolean isActive) {
-		isWorking = isActive;
-	}
-
 	/**
 	 * @return the a
 	 */
@@ -110,9 +113,25 @@ public class CpsEdge {
 	public void setB(CpsObject b) {
 		B = b;
 	}
+	
+	public void setState(boolean state){
+		isWorking = state;
+	}
 
 	public boolean getState() {
 		return isWorking;
 	}
+	
+	public void setTags(ArrayList<Integer> tags){
+		this.tags = tags;
+	}
+	
+	public ArrayList<Integer> getTags(){
+		return tags;
+	}
+	
+	public void addTag(int tag){
+		tags.add(tag);
+	}
 
 }