Commit ca47c7b9 authored by Matthias Möller's avatar Matthias Möller

Comments

parent 66e13829
......@@ -46,9 +46,7 @@ public class EmotivInit extends AbstractEmotiv {
}
System.out.println("Emotiv Engine start up suceeded.");
this.eEvent = Edk.INSTANCE.IEE_EmoEngineEventCreate();
this.eState = Edk.INSTANCE.IEE_EmoStateCreate();
// VERY IMPORTANT!
// Activates the two MentalCommands with
this.eState = Edk.INSTANCE.IEE_EmoStateCreate();
break;
}
case 2: {
......@@ -75,7 +73,7 @@ public class EmotivInit extends AbstractEmotiv {
}
//Den Inhalt des Handles und fordert das erste Objekt des Dekorators auf, sich zu aktualisieren.
//Den Inhalt des Handles und fordert das erste Objekt des Decorators auf, sich zu aktualisieren.
public void actualize(){
int state = Edk.INSTANCE.IEE_EngineGetNextEvent(this.eEvent);
Edk.INSTANCE.IEE_EmoEngineEventGetEmoState(this.eEvent, this.eState);
......@@ -237,7 +235,7 @@ public class EmotivInit extends AbstractEmotiv {
//Behandelt generell die Auslese
//Behandelt die Auslese des EmotivEvents
//Can be used to convert EmotivEvents in form of a number into their meaning
public String getEmotivEventTypeString(){
switch(this.emotivEventType){
case 0x0000:
......@@ -268,7 +266,7 @@ public class EmotivInit extends AbstractEmotiv {
//Behandelt die Darstellung der Adk-Error-Codes
//Can convert the Edk-Error-Codes in their actual meaning
public String edkErrorToString(){
switch(this.state){
case 0x0000:
......
......@@ -6,6 +6,7 @@ import com.sun.jna.ptr.FloatByReference;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
// This Decorator is a example showing how we can process the MentalCommands
public class MentalCommandDecorator extends AbstractEmostateUpdatedDecorator {
int lastMentalCommand;
float lastMentalCommandStrength;
......@@ -20,6 +21,7 @@ public class MentalCommandDecorator extends AbstractEmostateUpdatedDecorator {
this.nextEmotivComponent.show();
}
//shows the devices Mapping of a number and its decoding as mentalCommand
public String mentalCommandToString(int mentalCommand){
switch(mentalCommand){
case 1:
......@@ -49,7 +51,6 @@ public class MentalCommandDecorator extends AbstractEmostateUpdatedDecorator {
@Override
public void actualizeComponents() {
int lastMentalCommand = EmoState.INSTANCE.IS_MentalCommandGetCurrentAction(getEmoState());
float lastMentalCommandStrength = EmoState.INSTANCE.IS_MentalCommandGetCurrentActionPower(getEmoState());
int mentalCommandType = Edk.INSTANCE.IEE_MentalCommandEventGetType(getEmotivEvent());
......
......@@ -8,7 +8,8 @@ import Server.WebSocketServerSingleton;
public class WebSocketDecorator extends AbstractEmostateUpdatedDecorator{
public int actualMentalCommand;
public int iteratedTriggeredMentalCommand = 0;
public float MCPULLSensibility = new Float(0.45);
// Decides the triggerstrength needed to send MnetalCommand
public float MCPULLSensibility = new Float(0.45);
public float MCPUSHSensibility = new Float(0.45);
......@@ -44,6 +45,8 @@ public class WebSocketDecorator extends AbstractEmostateUpdatedDecorator{
}
@Override
//Our decorator has to trigger the MentalCommands in a row with a certein triggerStrength influenced
//by the user
public void actualizeComponents() {
int newMentalCommand = EmoState.INSTANCE.IS_MentalCommandGetCurrentAction(getEmoState());
float newMentalCommandStrength = EmoState.INSTANCE.IS_MentalCommandGetCurrentActionPower(getEmoState());
......@@ -53,7 +56,6 @@ public class WebSocketDecorator extends AbstractEmostateUpdatedDecorator{
this.iteratedTriggeredMentalCommand = 0;
}
switch(this.actualMentalCommand) {
case 2:
if(this.MCPUSHSensibility <= newMentalCommandStrength) {
......@@ -83,6 +85,7 @@ public class WebSocketDecorator extends AbstractEmostateUpdatedDecorator{
}
//Influenced by JSlider in the EmotivGUI
public void updateMentalCommandSensibility() {
this.MCPUSHSensibility = (float) (this.getView().getMCPUSHSensibilitiy() * 0.05 + 0.1);
this.MCPULLSensibility = (float) (this.getView().getMCPULLSenisibility() * 0.05 + 0.1);
......
......@@ -13,6 +13,7 @@ import org.java_websocket.framing.Framedata;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
//singleton class used for WebSocket connection
public class WebSocketServerSingleton extends WebSocketServer{
private static Boolean shallSend = false;
......@@ -66,7 +67,7 @@ public class WebSocketServerSingleton extends WebSocketServer{
System.out.println("Server started!");
}
//Builds JSON-Object out of String
public static void sendMentalCommand(int mentalCommand) {
if(shallSend){
System.out.println(mentalCommand);
......
......@@ -18,9 +18,6 @@ import Modell.AbstractEmotiv;
public class EmotivGUI extends JFrame implements ActionListener{
private EmotivController emotivController;
private AbstractEmotiv modell;
//private SubEmotivGUI edkErrorGUI;
//private SubEmotivGUI emotivMentalCommandTypeGUI;
//private SubEmotivGUI emotivEventTypeGUI;
private String edkErrorCode = "";
private float runningTime = 0; // Die RunningTime wird fr sehr viele Komponenten gebraucht!
private String emotivEventType = "";
......@@ -44,7 +41,6 @@ public class EmotivGUI extends JFrame implements ActionListener{
this.setTitle("ExplorViz BCI Plugin");
this.setVisible(true);
//this.createMenuBar();
this.createMenuPanel();
this.setLayout(new FlowLayout());
......@@ -62,6 +58,7 @@ public class EmotivGUI extends JFrame implements ActionListener{
}
// is only shown in the beginning, can be used to inform Users about furhter working processes
private void setupDefaultPanel() {
JPanel defaultPanel = new JPanel();
defaultPanel.setPreferredSize(this.contentPanel.getPreferredSize());
......@@ -71,7 +68,8 @@ public class EmotivGUI extends JFrame implements ActionListener{
this.contentPanel.add(defaultPanel);
}
//layout-functions
// not used anymore. This function can be used to implement in the menu bar the possibility to show SusEmotivGui
//We used these GUI to protocol the EmotivEvents. For further work we want to provide the opportunity
private void createMenuBar() {
JMenuBar jMenuBar = new JMenuBar();
......@@ -195,11 +193,18 @@ public class EmotivGUI extends JFrame implements ActionListener{
}
//WebSocketPanel providing Slider to influence the Sensitivty of our TriggerStrength
// in case of a high sensitivity our WebSocketDecorator sends the MentalCommand with less
//ActionPower required. The ActionPower is a value between 0 and 1 describing the similarity
//between the measured thought and the learnt MentalCommand
private void createWebsocketConnectionPanel() {
Hashtable<Integer, JLabel> hash = new Hashtable<Integer, JLabel>();
hash.put(new Integer(1), new JLabel("high"));
hash.put(new Integer(3), new JLabel("average"));
hash.put(new Integer(6), new JLabel("low"));
hash.put(new Integer(10), new JLabel("high"));
hash.put(new Integer(5), new JLabel("average"));
hash.put(new Integer(1), new JLabel("low"));
JPanel MC1JPanel = new JPanel();
JPanel MC2JPanel = new JPanel();
JSlider MC1Slider = new JSlider(JSlider.HORIZONTAL, 1, 10, 5);
MC1Slider.setMajorTickSpacing(1);
......@@ -209,7 +214,13 @@ public class EmotivGUI extends JFrame implements ActionListener{
MC1Slider.setPaintLabels(true);
MC1Slider.addChangeListener(this.emotivController);
this.MCPUSHSlider = MC1Slider;
this.websocketPanel.add(this.MCPUSHSlider);
MC1JPanel.setLayout(new FlowLayout(0, 0, 0));
MC1JPanel.add(new JLabel("MC_PUSH Sensitivity"));
MC1JPanel.add(MC1Slider);
MC1JPanel.setPreferredSize(new Dimension(250, 110));
this.websocketPanel.add(MC1JPanel);
JSlider MC2Slider = new JSlider(JSlider.HORIZONTAL, 1, 10, 5);
MC2Slider.setMajorTickSpacing(1);
......@@ -218,8 +229,13 @@ public class EmotivGUI extends JFrame implements ActionListener{
MC2Slider.setLabelTable(hash);
MC2Slider.setPaintLabels(true);
MC2Slider.addChangeListener(this.emotivController);
MC2JPanel.setLayout(new FlowLayout(0, 0, 0));
this.MCPULLSlider = MC2Slider;
this.websocketPanel.add(this.MCPULLSlider);
MC2JPanel.add(new JLabel("MCPULLSlider"));
MC2JPanel.add(MC2Slider);
MC2JPanel.setPreferredSize(new Dimension(220, 110));
this.websocketPanel.add(MC2JPanel);
}
......@@ -246,6 +262,7 @@ public class EmotivGUI extends JFrame implements ActionListener{
this.modell.login(this);
}
//actions not used anymore but neccessary to implement MenuBar again
public void updateErrorCode(){
/* this.runningTime = this.modell.getRunningTime();
String edkErrorCode = Float.toString(this.runningTime) + ": " + this.modell.edkErrorToString() + "\n";
......
package View;
//Class not used anymore, but can be used to provide User new UI to protocol data
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
......
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