|
@@ -3,6 +3,14 @@ package classes;
|
|
|
import java.awt.Point;
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
+/**
|
|
|
+ * The class HolonSwitch represents an Object in the system, that has the
|
|
|
+ * capacity of manipulate the electricity flow. The switch can be manage
|
|
|
+ * automatically through a graph or direct manually.
|
|
|
+ *
|
|
|
+ * @author Gruppe14
|
|
|
+ *
|
|
|
+ */
|
|
|
public class HolonSwitch extends CpsObject {
|
|
|
/*
|
|
|
* manual state True, if this wire is working (capable of carrying
|
|
@@ -29,6 +37,13 @@ public class HolonSwitch extends CpsObject {
|
|
|
// Points on the UnitGraph
|
|
|
LinkedList<Point> graphPoints = new LinkedList<>();
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a new HolonSwitch with the default name ("Switch"), a default
|
|
|
+ * value of automatic handle and active status
|
|
|
+ *
|
|
|
+ * @param ObjName
|
|
|
+ * String
|
|
|
+ */
|
|
|
public HolonSwitch(String ObjName) {
|
|
|
super(ObjName);
|
|
|
setManualState(true);
|
|
@@ -37,6 +52,15 @@ public class HolonSwitch extends CpsObject {
|
|
|
setManualMode(false);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a new HolonSwitch with user-defined name, a default value of
|
|
|
+ * automatic handle and active status
|
|
|
+ *
|
|
|
+ * @param ObjName
|
|
|
+ * String
|
|
|
+ * @param obj
|
|
|
+ * String
|
|
|
+ */
|
|
|
public HolonSwitch(String ObjName, String obj) {
|
|
|
super(ObjName);
|
|
|
super.setName(obj);
|
|
@@ -46,6 +70,11 @@ public class HolonSwitch extends CpsObject {
|
|
|
setManualMode(false);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a copy of an existing HolonSwitch.
|
|
|
+ *
|
|
|
+ * @param obj
|
|
|
+ */
|
|
|
public HolonSwitch(CpsObject obj) {
|
|
|
super(obj);
|
|
|
super.setName(obj.getName());
|
|
@@ -55,6 +84,9 @@ public class HolonSwitch extends CpsObject {
|
|
|
setManualMode(false);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Calculates the state of the Switch
|
|
|
+ */
|
|
|
public void switchState() {
|
|
|
if (manualMode) {
|
|
|
if (this.manualActive == true) {
|
|
@@ -65,15 +97,27 @@ public class HolonSwitch extends CpsObject {
|
|
|
this.manualActive = !manualActive;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public boolean getState(int timeStep){
|
|
|
- if(manualMode){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Getter for the status of the Switch at a given timestep
|
|
|
+ *
|
|
|
+ * @param timeStep
|
|
|
+ * int
|
|
|
+ * @return state value
|
|
|
+ */
|
|
|
+ public boolean getState(int timeStep) {
|
|
|
+ if (manualMode) {
|
|
|
return this.manualActive;
|
|
|
} else {
|
|
|
return getActiveAt()[timeStep];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Overall status of the switch (manual or automatic mode)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public boolean getState() {
|
|
|
if (manualMode) {
|
|
|
return this.manualActive;
|
|
@@ -83,16 +127,29 @@ public class HolonSwitch extends CpsObject {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Change the state of the Switch to manual
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ */
|
|
|
public void setManualState(boolean state) {
|
|
|
this.manualActive = state;
|
|
|
setImage();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set the state of the Switch to automatic
|
|
|
+ *
|
|
|
+ * @param state
|
|
|
+ */
|
|
|
public void setAutoState(boolean state) {
|
|
|
this.autoActive = state;
|
|
|
setImage();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set Image of the Switch
|
|
|
+ */
|
|
|
private void setImage() {
|
|
|
if (manualMode) {
|
|
|
if (this.manualActive == false) {
|
|
@@ -110,6 +167,8 @@ public class HolonSwitch extends CpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * For automatic use only (throught the graph)
|
|
|
+ *
|
|
|
* @return the Graph Points
|
|
|
*/
|
|
|
public LinkedList<Point> getGraphPoints() {
|
|
@@ -117,6 +176,8 @@ public class HolonSwitch extends CpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the values of the switch in the graph (auto. mode only)
|
|
|
+ *
|
|
|
* @param points,
|
|
|
* the Graph points
|
|
|
*/
|
|
@@ -125,17 +186,25 @@ public class HolonSwitch extends CpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * get the activeAt Array
|
|
|
+ * All values of the graph for the selected Switch (only auto-Mode) get the
|
|
|
+ * activeAt Array
|
|
|
*/
|
|
|
public boolean[] getActiveAt() {
|
|
|
return activeAt;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Overall value of the Swtich (only manual-Mode)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public boolean getActiveManual() {
|
|
|
return this.manualActive;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the value of the Switch
|
|
|
+ *
|
|
|
* @param active,
|
|
|
* the default value
|
|
|
*/
|
|
@@ -145,10 +214,20 @@ public class HolonSwitch extends CpsObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set the overall value of the Switch (manual mode)
|
|
|
+ *
|
|
|
+ * @param mode
|
|
|
+ */
|
|
|
public void setManualMode(boolean mode) {
|
|
|
manualMode = mode;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the value of the switch (manual mode)
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public boolean getManualMode() {
|
|
|
return manualMode;
|
|
|
}
|