Commit 91b20c8e authored by Matthias Möller's avatar Matthias Möller

neue Struktur

parent 42f28c5e
......@@ -12,7 +12,7 @@ public abstract class AbstractEmostateUpdatedComponent extends AbstractEmotiv {
//Wenn eine neue Komponente dem Dekorator hinzugefgt wird, wird der Leader der Grundeinheit EmotivInit aktualisiert
public AbstractEmostateUpdatedComponent(AbstractEmotiv emo){
this.nextEmotivComponent = emo;
setLeader(this);
setGUILeader(this);
}
public void initialize() {
......@@ -34,8 +34,13 @@ public abstract class AbstractEmostateUpdatedComponent extends AbstractEmotiv {
//Soll den leader der Grundeinheit aktualisieren durch delegation
public void setLeader(AbstractEmostateUpdatedComponent leader){
this.nextEmotivComponent.setLeader(leader);
public void setGUILeader(AbstractEmostateUpdatedComponent leader){
this.nextEmotivComponent.setGUILeader(leader);
}
@Override
public void setWebSocketLeader(AbstractWebSocketComponent webSocketLeader) {
}
public void destroy(){
......
......@@ -31,7 +31,9 @@ public abstract class AbstractEmotiv {
public abstract void actualizeComponents();
public abstract void setLeader(AbstractEmostateUpdatedComponent leader);
public abstract void setGUILeader(AbstractEmostateUpdatedComponent leader);
public abstract void setWebSocketLeader(AbstractWebSocketComponent leader);
public abstract void login(EmotivGUI emotivGUI);
......
......@@ -16,12 +16,14 @@ import View.EmotivGUI;
public class EmotivInit extends AbstractEmotiv {
Pointer eEvent = null;
Pointer eState = null;
AbstractEmotiv leader = this;
AbstractEmotiv guiLeader = this;
AbstractEmotiv webSocketLeader = this;
MentalCommandEventInit mentalCommandEventInit;
EmotivGUI view;
int state;
float runningTime = 0;
int emotivEventType;
boolean isGUIActive = true; // this boolean describes, if we send data or let the GUI actualize
//Konstruktor wird option mitgegeben. Bei option=1 wird ein EmotivGert bei initialisierung angeschlosen.
......@@ -86,11 +88,16 @@ public class EmotivInit extends AbstractEmotiv {
@Override
public void setLeader(AbstractEmostateUpdatedComponent leader) {
this.leader = leader;
public void setGUILeader(AbstractEmostateUpdatedComponent guiLeader) {
this.guiLeader = guiLeader;
}
@Override
public void setWebSocketLeader(AbstractWebSocketComponent webSocketLeader) {
this.webSocketLeader = webSocketLeader;
}
//Behandelt den Edk_ERROR Code und handelt dementsprechen
public void emotivErrorCode(int state){
//Listet Vernderungen im Edk-Error-Code auf und gibt diese aus
......@@ -115,7 +122,7 @@ public class EmotivInit extends AbstractEmotiv {
case 0x040: //gibt an dass die Emostate geupdaetet wurde
this.runningTime = EmoState.INSTANCE.IS_GetTimeFromStart(getEmoState());
getView().updateTime();
this.leader.actualizeComponents();
this.getCurrentLeader().actualizeComponents();
break;
case 0x100 : //Gibt an dass ein MentalCommandEvent vorliegt
this.mentalCommandEventInit.actualizeMentalCommandEvent();
......@@ -139,7 +146,8 @@ public class EmotivInit extends AbstractEmotiv {
//Lscht den Zugriff auf die einzelnen Pointer und logt die EmoEngine aus
@Override
public void destroy() {
this.leader = null;
this.guiLeader = null;
this.webSocketLeader = null;
if(Edk.INSTANCE.IEE_EngineDisconnect() == 0){
System.out.println("EmoEngine Logout succeeded!");
}
......@@ -195,6 +203,14 @@ public class EmotivInit extends AbstractEmotiv {
public Pointer getEmoState(){
return this.eState;
}
public AbstractEmotiv getCurrentLeader() {
if(this.isGUIActive) {
return this.guiLeader;
}else {
return this.webSocketLeader;
}
}
//-----------------------------------------------------------------------------------------------------
//Behandelt generell die Auslese
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment