Commit 66e13829 authored by Matthias Möller's avatar Matthias Möller

Deleted unneeded class

parent a47a3a10
......@@ -12,23 +12,23 @@ import com.emotiv.Iedk.EmoState;
import com.sun.jna.ptr.NativeLongByReference;
import Modell.*;
import Server.WebsocketServer2;
import Server.WebSocketServerSingleton;
import View.*;
public class EmotivController implements ActionListener, WindowListener, ChangeListener{
EmotivGUI emotivGUI;
EmotivThread emotivThread;
WebsocketServer2 emotivServer;
WebSocketServerSingleton emotivServer;
public EmotivController() throws UnknownHostException{
EmotivInit emo = new EmotivInit(2);
AbstractEmostateUpdatedComponent guiModel = new MentalCommandComponent(emo);
guiModel = new HardwareComponent(guiModel);
guiModel = new BatteryComponent(guiModel);
AbstractEmostateUpdatedDecorator guiModel = new MentalCommandDecorator(emo);
guiModel = new HardwareDecorator(guiModel);
guiModel = new BatteryDecorator(guiModel);
EmotivThread emotivThread = new EmotivThread(guiModel);
this.emotivThread = emotivThread;
this.emotivGUI = new EmotivGUI(this, guiModel);
WebsocketServer2.initialize(1313);
WebSocketServerSingleton.initialize(1313);
}
@Override
......
......@@ -6,11 +6,11 @@ import View.EmotivGUI;
//Dies ist Teil des Dekorator-Entwurfsmusters. Es ist die abstrakte Oberklasse der Komponenten
public abstract class AbstractEmostateUpdatedComponent extends AbstractEmotiv {
public abstract class AbstractEmostateUpdatedDecorator extends AbstractEmotiv {
AbstractEmotiv nextEmotivComponent;
//Wenn eine neue Komponente dem Dekorator hinzugefgt wird, wird der Leader der Grundeinheit EmotivInit aktualisiert
public AbstractEmostateUpdatedComponent(AbstractEmotiv emo){
public AbstractEmostateUpdatedDecorator(AbstractEmotiv emo){
this.nextEmotivComponent = emo;
setGUILeader(this);
}
......@@ -34,14 +34,10 @@ public abstract class AbstractEmostateUpdatedComponent extends AbstractEmotiv {
//Soll den leader der Grundeinheit aktualisieren durch delegation
public void setGUILeader(AbstractEmostateUpdatedComponent leader){
public void setGUILeader(AbstractEmostateUpdatedDecorator leader){
this.nextEmotivComponent.setGUILeader(leader);
}
@Override
public void setWebSocketLeader(AbstractWebSocketComponent webSocketLeader) {
}
public void destroy(){
this.nextEmotivComponent.destroy();
......
......@@ -31,9 +31,7 @@ public abstract class AbstractEmotiv {
public abstract void actualizeComponents();
public abstract void setGUILeader(AbstractEmostateUpdatedComponent leader);
public abstract void setWebSocketLeader(AbstractWebSocketComponent leader);
public abstract void setGUILeader(AbstractEmostateUpdatedDecorator leader);
public abstract void login(EmotivGUI emotivGUI);
......
package Modell;
import com.sun.jna.Pointer;
import View.EmotivGUI;
//This class describes the approach to process data before sending them
public abstract class AbstractWebSocketComponent extends AbstractEmotiv {
AbstractEmotiv nextEmotivComponent;
//Wenn eine neue Komponente dem Dekorator hinzugefgt wird, wird der Leader der Grundeinheit EmotivInit aktualisiert
public AbstractWebSocketComponent(AbstractEmotiv emo){
this.nextEmotivComponent = emo;
setWebSocketLeader(this);
}
@Override
public void initialize() {
this.nextEmotivComponent.initialize();
}
@Override
public void actualize() {
this.nextEmotivComponent.actualize();
}
public Pointer getEmotivEvent(){
return this.nextEmotivComponent.getEmotivEvent();
}
public Pointer getEmoState(){
return this.nextEmotivComponent.getEmoState();
}
//Soll den leader der Grundeinheit aktualisieren durch delegation
public void setGUILeader(AbstractEmostateUpdatedComponent leader){
}
@Override
public void setWebSocketLeader(AbstractWebSocketComponent webSocketLeader) {
}
public void destroy(){
this.nextEmotivComponent.destroy();
this.nextEmotivComponent = null;
}
public EmotivGUI getView(){
return this.nextEmotivComponent.getView();
}
public void login(EmotivGUI emotivGUI){
this.nextEmotivComponent.login(emotivGUI);
}
public void updateGUI(){
}
public String edkErrorToString(){
return this.nextEmotivComponent.edkErrorToString();
}
public Float getRunningTime(){
return this.nextEmotivComponent.getRunningTime();
}
public String getEmotivEventTypeString(){
return this.nextEmotivComponent.getEmotivEventTypeString();
}
public String getMentalCommandTypeString(){
return this.nextEmotivComponent.getMentalCommandTypeString();
}
public String getBattery(){
return this.nextEmotivComponent.getBattery();
}
public void activateWebsocketConnection() {
this.nextEmotivComponent.activateWebsocketConnection();
}
public void deactivateWebsocketConnection() {
this.nextEmotivComponent.deactivateWebsocketConnection();
}
public String getMaxBatteryCharge() {
return this.nextEmotivComponent.getMaxBatteryCharge();
}
}
......@@ -4,11 +4,11 @@ import com.emotiv.Iedk.Edk;
import com.emotiv.Iedk.EmoState;
import com.sun.jna.ptr.IntByReference;
public class BatteryComponent extends AbstractEmostateUpdatedComponent {
public class BatteryDecorator extends AbstractEmostateUpdatedDecorator {
private int chargeLevel;
public int maxChargeLevel;
public BatteryComponent(AbstractEmotiv emo){
public BatteryDecorator(AbstractEmotiv emo){
super(emo);
}
......
......@@ -31,7 +31,7 @@ public class EmotivInit extends AbstractEmotiv {
public EmotivInit(int option){
this.option= option;
this.mentalCommandEventInit = new MentalCommandEventInit(this);
this.webSocketLeader = new MentalCommandWebSocket(this);
this.webSocketLeader = new WebSocketDecorator(this);
}
......@@ -92,13 +92,12 @@ public class EmotivInit extends AbstractEmotiv {
@Override
public void setGUILeader(AbstractEmostateUpdatedComponent guiLeader) {
public void setGUILeader(AbstractEmostateUpdatedDecorator guiLeader) {
this.guiLeader = guiLeader;
}
@Override
public void setWebSocketLeader(AbstractWebSocketComponent webSocketLeader) {
public void setWebSocketLeader(AbstractEmostateUpdatedDecorator webSocketLeader) {
this.webSocketLeader = webSocketLeader;
}
......
......@@ -6,13 +6,13 @@ import com.sun.jna.NativeLong;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
public class HardwareComponent extends AbstractEmostateUpdatedComponent{
public class HardwareDecorator extends AbstractEmostateUpdatedDecorator{
int hardwareVersion; // has to be printed in a Hex-Dec-Code for better use
int signalStrength; //1 for bad Signal, 2 for good Signal
int chargeLevel;
int maxChargeLevel;
public HardwareComponent(AbstractEmotiv emo) {
public HardwareDecorator(AbstractEmotiv emo) {
super(emo);
// TODO Auto-generated constructor stub
}
......
......@@ -6,12 +6,12 @@ import com.sun.jna.ptr.FloatByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
public class MentalCommandComponent extends AbstractEmostateUpdatedComponent {
public class MentalCommandDecorator extends AbstractEmostateUpdatedDecorator {
int lastMentalCommand;
float lastMentalCommandStrength;
public MentalCommandComponent(AbstractEmotiv emo) {
public MentalCommandDecorator(AbstractEmotiv emo) {
super(emo);
}
......
......@@ -3,16 +3,16 @@ package Modell;
import com.emotiv.Iedk.Edk;
import com.emotiv.Iedk.EmoState;
import Server.WebsocketServer2;
import Server.WebSocketServerSingleton;
public class MentalCommandWebSocket extends AbstractWebSocketComponent{
public class WebSocketDecorator extends AbstractEmostateUpdatedDecorator{
public int actualMentalCommand;
public int iteratedTriggeredMentalCommand = 0;
public float MCPULLSensibility = new Float(0.45);
public float MCPUSHSensibility = new Float(0.45);
public MentalCommandWebSocket(AbstractEmotiv emo) {
public WebSocketDecorator(AbstractEmotiv emo) {
super(emo);
}
......@@ -68,7 +68,7 @@ public class MentalCommandWebSocket extends AbstractWebSocketComponent{
}
if(this.iteratedTriggeredMentalCommand >= 2) {
WebsocketServer2.sendMentalCommand(this.actualMentalCommand);
WebSocketServerSingleton.sendMentalCommand(this.actualMentalCommand);
this.iteratedTriggeredMentalCommand = 0;
}
......
......@@ -13,24 +13,24 @@ import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
public class WebsocketServer2 extends WebSocketServer{
public class WebSocketServerSingleton extends WebSocketServer{
private static Boolean shallSend = false;
public static WebsocketServer2 Singleton = null;
public static WebSocketServerSingleton Singleton = null;
public static void initialize(int addr) throws UnknownHostException {
if(Singleton == null) {
Singleton = new WebsocketServer2(addr);
Singleton = new WebSocketServerSingleton(addr);
Singleton.start();
}
}
private WebsocketServer2( int port ) throws UnknownHostException {
private WebSocketServerSingleton( int port ) throws UnknownHostException {
super( new InetSocketAddress( port ) );
}
public WebsocketServer2( InetSocketAddress address ) {
public WebSocketServerSingleton( InetSocketAddress address ) {
super(address);
}
......
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