Browse Source

Switch variablen für zeitlichen status und comments

Kevin Trometer 7 years ago
parent
commit
7170fd0f99
2 changed files with 51 additions and 3 deletions
  1. 8 2
      src/classes/HolonElement.java
  2. 43 1
      src/classes/HolonSwitch.java

+ 8 - 2
src/classes/HolonElement.java

@@ -24,7 +24,7 @@ public class HolonElement {
 	/* Object where the Element is Stored*/
 	String obj;
 	/*
-	 * Energy at each point of the graph with 50 predefined points. At the
+	 * Energy at each point of the graph with 100 predefined points. At the
 	 * beginning, it starts with all values at energy
 	 */
 	float[] energyAt = new float[100];
@@ -51,12 +51,18 @@ public class HolonElement {
 		setObj(element.getObj());
 	}
 
+	/**
+	 * get the EnergyAt Array
+	 */
 	public float[] getEnergyAt() {
 		return energyAt;
 	}
 
+	/**
+	 * @param energy, the value
+	 */
 	public void setEnergyAt(float energy) {
-		for (int i = 0; i < 49; i++) {
+		for (int i = 0; i < energyAt.length; i++) {
 			this.energyAt[i] = energy;
 		}
 	}

+ 43 - 1
src/classes/HolonSwitch.java

@@ -1,5 +1,8 @@
 package classes;
 
+import java.awt.Point;
+import java.util.LinkedList;
+
 public class HolonSwitch extends CpsObject {
 	/*
 	 * True, if this wire is working (capable of carrying electricity), else
@@ -7,6 +10,14 @@ public class HolonSwitch extends CpsObject {
 	 */
 	boolean active;
 
+	/*
+	 * Energy at each point of the graph with 50 predefined points. At the
+	 * beginning, it starts with all values at energy
+	 */
+	boolean[] activeAt = new boolean[100];
+	//Points on the UnitGraph
+	LinkedList<Point> graphPoints = new LinkedList<>();
+	
 	public HolonSwitch(String ObjName) {
 		super(ObjName);
 		setState(false);
@@ -16,6 +27,7 @@ public class HolonSwitch extends CpsObject {
 		super(ObjName);
 		super.setName(obj);
 		setState(false);
+		setActiveAt(true);
 	}
 
 	public HolonSwitch(CpsObject obj) {
@@ -34,4 +46,34 @@ public class HolonSwitch extends CpsObject {
 	public void setState(boolean state){
 		this.active = state;
 	}
-}
+	
+	/**
+	 * @return the Graph Points
+	 */
+	public LinkedList<Point> getGraphPoints() {
+		return graphPoints;
+	}
+
+	/**
+	 * @param points, the Graph points
+	 */
+	public void setGraphPoints(LinkedList<Point> points) {
+		this.graphPoints = points;
+	}
+	/**
+	 * get the activeAt Array
+	 */
+	public boolean[] getActiveAt() {
+		return activeAt;
+	}
+
+	
+	/**
+	 * @param active, the default value
+	 */
+	public void setActiveAt(boolean active) {
+		for (int i = 0; i < activeAt.length; i++) {
+			this.activeAt[i] = active;
+		}
+	}
+}