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

Trainingskontrolle verbessert

parent eebfb798
No preview for this file type
......@@ -92,6 +92,19 @@ public class EmotivController implements ActionListener, WindowListener{
Edk.INSTANCE.IEE_EngineClearEventQueue(0x0040);
this.emotivThread.continueWorking();
}
else if(buttonName == "<html><span color='green'>Accept Training</span></html>"){
this.emotivThread.stopWorking();
Edk.INSTANCE.IEE_MentalCommandSetTrainingControl(0, Edk.IEE_MentalCommandTrainingControl_t.MC_ACCEPT.getType());
Edk.INSTANCE.IEE_EngineClearEventQueue(0x0040);
this.emotivThread.continueWorking();
}
else if(buttonName == "<html><span color='red'>Decline Training</span></html>"){
this.emotivThread.stopWorking();
Edk.INSTANCE.IEE_MentalCommandSetTrainingControl(0, Edk.IEE_MentalCommandTrainingControl_t.MC_REJECT.getType());
Edk.INSTANCE.IEE_EngineClearEventQueue(0x0040);
this.emotivThread.continueWorking();
}
((JButton)e.getSource()).setEnabled(true);
}
catch(Exception ex){
......
......@@ -87,4 +87,8 @@ public abstract class AbstractEmostateUpdatedComponent extends AbstractEmotiv {
public void deactivateWebsocketConnection() {
this.nextEmotivComponent.deactivateWebsocketConnection();
}
public String getMaxBatteryCharge() {
return this.nextEmotivComponent.getMaxBatteryCharge();
}
}
......@@ -55,4 +55,6 @@ public abstract class AbstractEmotiv {
public abstract void deactivateWebsocketConnection();
public abstract String getMaxBatteryCharge();
}
......@@ -87,5 +87,9 @@ public abstract class AbstractWebSocketComponent extends AbstractEmotiv {
public void deactivateWebsocketConnection() {
this.nextEmotivComponent.deactivateWebsocketConnection();
}
public String getMaxBatteryCharge() {
return this.nextEmotivComponent.getMaxBatteryCharge();
}
}
......@@ -37,6 +37,10 @@ public class BatteryComponent extends AbstractEmostateUpdatedComponent {
}
public String getBattery(){
return Integer.toString(this.chargeLevel) + "von " + Integer.toString(this.maxChargeLevel);
return Integer.toString(this.chargeLevel);
}
public String getMaxBatteryCharge() {
return Integer.toString(this.maxChargeLevel);
}
}
......@@ -222,6 +222,10 @@ public class EmotivInit extends AbstractEmotiv {
return this.webSocketLeader;
}
}
public String getMaxBatteryCharge() {
return "";
}
//-----------------------------------------------------------------------------------------------------
//Behandelt generell die Auslese
......
......@@ -28,12 +28,10 @@ public class MentalCommandEventInit {
getView().updateEmotivMentalCommandType();
if(this.mentalCommandType == 2){
Edk.INSTANCE.IEE_MentalCommandSetTrainingControl(0, Edk.IEE_MentalCommandTrainingControl_t.MC_ACCEPT.getType());
this.getView().setTrainingPanelVisibility(true);
}
else if(this.mentalCommandType == 4){
NativeLongByReference in = new NativeLongByReference();
Edk.INSTANCE.IEE_MentalCommandGetTrainedSignatureActions(0, in);
System.out.println(in.getValue());
this.getView().setTrainingPanelVisibility(false);
}
}
}
......@@ -49,19 +47,19 @@ public class MentalCommandEventInit {
public String getMentalCommandTypeString(){
switch(this.mentalCommandType){
case 0:
return "IEE_MentalCommandNoEvent";
return "Kein Event";
case 1:
return "IEE_MentalCommandTrainingStarted";
return "<html><span color='#ffa500'>training started</span></html>";
case 2:
return "IEE_MentalCommandTrainingSucceeded";
return "<html><span color='green'>training succeeded</span></html>";
case 3:
return "IEE_MentalCommandTrainingFailed";
return "<html><span color='red'>training failed</span></html>";
case 4:
return "IEE_MentalCommandTrainingCompleted";
return "<html><span color='green'>training completed</span></html>";
case 5:
return "IEE_MentalCommandTrainingDataErased";
case 6:
return "IEE_MentalCommandTrainingRejected";
return "<html><span color='red'>training rejectcted</span></html>";
case 7:
return "IEE_MentalCommandTrainingReset";
case 8:
......
......@@ -27,6 +27,9 @@ public class EmotivGUI extends JFrame implements ActionListener{
private JLabel batteryLabel = new JLabel("");
private JLabel timeLabel = new JLabel("");
private JPanel contentPanel;
private JLabel maxBatteryLabel = new JLabel("");
private JLabel trainingStateLabel = new JLabel();
private JPanel buttonPanel = new JPanel();
public EmotivGUI(EmotivController emotivController, AbstractEmotiv modell){
this.emotivController = emotivController;
......@@ -129,21 +132,42 @@ public class EmotivGUI extends JFrame implements ActionListener{
private void createTrainingWorkPanel() {
Dimension panelSize = new Dimension(340, 20);
Dimension buttonPanelSize = new Dimension(340, 34);
JPanel jPanel = new JPanel(new FlowLayout(0,0,0));
jPanel.setPreferredSize(new Dimension(340, 110));
JPanel batteriePanel = new JPanel(new FlowLayout(0,0,0));
batteriePanel.add(new JLabel("Batterie: "));
JPanel batteriePanel = new JPanel(new FlowLayout(0,3,0));
batteriePanel.add(new JLabel("Batterie:"));
batteriePanel.add(this.batteryLabel);
batteriePanel.add(new JLabel("von"));
batteriePanel.add(this.maxBatteryLabel);
batteriePanel.setPreferredSize(panelSize);
jPanel.add(batteriePanel);
JPanel timePanel = new JPanel(new FlowLayout(0,0,0));
timePanel.add(new JLabel("Zeit: "));
JPanel timePanel = new JPanel(new FlowLayout(0,3,0));
timePanel.add(new JLabel("Zeit:"));
timePanel.add(this.timeLabel);
timePanel.setPreferredSize(panelSize);
jPanel.add(timePanel);
JPanel trainingsPanel = new JPanel(new FlowLayout(0,3,0));
trainingsPanel.add(new JLabel("Trainingsstatus:"));
trainingsPanel.add(this.trainingStateLabel);
trainingsPanel.setPreferredSize(panelSize);
jPanel.add(trainingsPanel);
this.buttonPanel.removeAll();
JButton acceptTrainingButton = new JButton("<html><span color='green'>Accept Training</span></html>");
acceptTrainingButton.addActionListener(this);
acceptTrainingButton.addActionListener(this.emotivController);
this.buttonPanel.add(acceptTrainingButton);
JButton declineTrainingButton = new JButton("<html><span color='red'>Decline Training</span></html>");
declineTrainingButton.addActionListener(this);
declineTrainingButton.addActionListener(this.emotivController);
this.buttonPanel.add(declineTrainingButton);
this.buttonPanel.setVisible(false);
jPanel.add(buttonPanel);
this.contentPanel.add(jPanel);
}
......@@ -181,16 +205,16 @@ public class EmotivGUI extends JFrame implements ActionListener{
}
public void updateEmotivMentalCommandType(){
String mentalCommandType = Float.toString(this.runningTime) + ": " + this.modell.getMentalCommandTypeString()+"\n";
String mentalCommandType = this.modell.getMentalCommandTypeString();
this.emotivMentalCommandType += mentalCommandType;
if(this.emotivMentalCommandTypeGUI != null){
this.emotivMentalCommandTypeGUI.addText(mentalCommandType);
}
this.trainingStateLabel.setText(mentalCommandType);
}
public void updateHardware(){
String battery = this.modell.getBattery();
String maxBattery = this.modell.getMaxBatteryCharge();
this.batteryLabel.setText(battery);
this.maxBatteryLabel.setText(maxBattery);
}
public void updateTime(){
......@@ -198,6 +222,10 @@ public class EmotivGUI extends JFrame implements ActionListener{
this.timeLabel.setText(Float.toString(this.runningTime));
}
public void setTrainingPanelVisibility(boolean bool) {
this.buttonPanel.setVisible(bool);
}
//--------------------------------------------------------------------------------------------------
//ActionEvents
......@@ -230,17 +258,29 @@ public class EmotivGUI extends JFrame implements ActionListener{
}
this.emotivEventTypeGUI.setVisible(true);
}
else if(buttonName=="Mentalcommands"){
}
else if(buttonName=="Hardwareinformationen"){
}
else if(buttonName=="Training") {
this.createTrainingContent();
}
else if(buttonName == "Verbindung") {
this.createWebsocketConnectionPanel();
}
else if(buttonName=="<html><span color='green'>Accept Training</span></html>") {
this.setTrainingPanelVisibility(false);
}
else if(buttonName == "<html><span color='red'>Decline Training</span></html>") {
this.setTrainingPanelVisibility(false);
}
}
}
\ No newline at end of file
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