|
@@ -3,7 +3,19 @@ package classes;
|
|
import java.awt.Point;
|
|
import java.awt.Point;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
public class HolonSwitch extends AbstractCpsObject {
|
|
public class HolonSwitch extends AbstractCpsObject {
|
|
|
|
+=======
|
|
|
|
+
|
|
|
|
+ * 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 {
|
|
|
|
+>>>>>>> branch 'Ohne_Drag_and_Drop' of https:
|
|
|
|
|
|
* manual state True, if this wire is working (capable of carrying
|
|
* manual state True, if this wire is working (capable of carrying
|
|
* electricity), else false
|
|
* electricity), else false
|
|
@@ -29,6 +41,13 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
|
|
|
|
LinkedList<Point> graphPoints = new LinkedList<>();
|
|
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) {
|
|
public HolonSwitch(String ObjName) {
|
|
super(ObjName);
|
|
super(ObjName);
|
|
setManualState(true);
|
|
setManualState(true);
|
|
@@ -37,6 +56,15 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
setManualMode(false);
|
|
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) {
|
|
public HolonSwitch(String ObjName, String obj) {
|
|
super(ObjName);
|
|
super(ObjName);
|
|
super.setName(obj);
|
|
super.setName(obj);
|
|
@@ -46,7 +74,16 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
setManualMode(false);
|
|
setManualMode(false);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
public HolonSwitch(AbstractCpsObject obj) {
|
|
public HolonSwitch(AbstractCpsObject obj) {
|
|
|
|
+=======
|
|
|
|
+
|
|
|
|
+ * Create a copy of an existing HolonSwitch.
|
|
|
|
+ *
|
|
|
|
+ * @param obj
|
|
|
|
+ */
|
|
|
|
+ public HolonSwitch(CpsObject obj) {
|
|
|
|
+>>>>>>> branch 'Ohne_Drag_and_Drop' of https:
|
|
super(obj);
|
|
super(obj);
|
|
super.setName(obj.getName());
|
|
super.setName(obj.getName());
|
|
setManualState(true);
|
|
setManualState(true);
|
|
@@ -55,6 +92,9 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
setManualMode(false);
|
|
setManualMode(false);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Calculates the state of the Switch
|
|
|
|
+ */
|
|
public void switchState() {
|
|
public void switchState() {
|
|
if (manualMode) {
|
|
if (manualMode) {
|
|
if (this.manualActive == true) {
|
|
if (this.manualActive == true) {
|
|
@@ -65,15 +105,27 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
this.manualActive = !manualActive;
|
|
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;
|
|
return this.manualActive;
|
|
} else {
|
|
} else {
|
|
return getActiveAt()[timeStep];
|
|
return getActiveAt()[timeStep];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Overall status of the switch (manual or automatic mode)
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
public boolean getState() {
|
|
public boolean getState() {
|
|
if (manualMode) {
|
|
if (manualMode) {
|
|
return this.manualActive;
|
|
return this.manualActive;
|
|
@@ -83,16 +135,29 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Change the state of the Switch to manual
|
|
|
|
+ *
|
|
|
|
+ * @param state
|
|
|
|
+ */
|
|
public void setManualState(boolean state) {
|
|
public void setManualState(boolean state) {
|
|
this.manualActive = state;
|
|
this.manualActive = state;
|
|
setImage();
|
|
setImage();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Set the state of the Switch to automatic
|
|
|
|
+ *
|
|
|
|
+ * @param state
|
|
|
|
+ */
|
|
public void setAutoState(boolean state) {
|
|
public void setAutoState(boolean state) {
|
|
this.autoActive = state;
|
|
this.autoActive = state;
|
|
setImage();
|
|
setImage();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Set Image of the Switch
|
|
|
|
+ */
|
|
private void setImage() {
|
|
private void setImage() {
|
|
if (manualMode) {
|
|
if (manualMode) {
|
|
if (this.manualActive == false) {
|
|
if (this.manualActive == false) {
|
|
@@ -110,6 +175,8 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ * For automatic use only (throught the graph)
|
|
|
|
+ *
|
|
* @return the Graph Points
|
|
* @return the Graph Points
|
|
*/
|
|
*/
|
|
public LinkedList<Point> getGraphPoints() {
|
|
public LinkedList<Point> getGraphPoints() {
|
|
@@ -117,6 +184,8 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ * Set the values of the switch in the graph (auto. mode only)
|
|
|
|
+ *
|
|
* @param points,
|
|
* @param points,
|
|
* the Graph points
|
|
* the Graph points
|
|
*/
|
|
*/
|
|
@@ -125,17 +194,25 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- * get the activeAt Array
|
|
+ * All values of the graph for the selected Switch (only auto-Mode) get the
|
|
|
|
+ * activeAt Array
|
|
*/
|
|
*/
|
|
public boolean[] getActiveAt() {
|
|
public boolean[] getActiveAt() {
|
|
return activeAt;
|
|
return activeAt;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Overall value of the Swtich (only manual-Mode)
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
public boolean getActiveManual() {
|
|
public boolean getActiveManual() {
|
|
return this.manualActive;
|
|
return this.manualActive;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ * Set the value of the Switch
|
|
|
|
+ *
|
|
* @param active,
|
|
* @param active,
|
|
* the default value
|
|
* the default value
|
|
*/
|
|
*/
|
|
@@ -145,10 +222,20 @@ public class HolonSwitch extends AbstractCpsObject {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Set the overall value of the Switch (manual mode)
|
|
|
|
+ *
|
|
|
|
+ * @param mode
|
|
|
|
+ */
|
|
public void setManualMode(boolean mode) {
|
|
public void setManualMode(boolean mode) {
|
|
manualMode = mode;
|
|
manualMode = mode;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * Get the value of the switch (manual mode)
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
public boolean getManualMode() {
|
|
public boolean getManualMode() {
|
|
return manualMode;
|
|
return manualMode;
|
|
}
|
|
}
|