diff --git a/healthdisplay/.idea/uiDesigner.xml b/healthdisplay/.idea/uiDesigner.xml
index 9a015a0..c312b7a 100644
--- a/healthdisplay/.idea/uiDesigner.xml
+++ b/healthdisplay/.idea/uiDesigner.xml
@@ -122,6 +122,9 @@
-
+ -
+
+
diff --git a/healthdisplay/src/main/java/de/psychose/ActorDisplay.form b/healthdisplay/src/main/java/de/psychose/ActorDisplay.form
index f990072..1884b4e 100644
--- a/healthdisplay/src/main/java/de/psychose/ActorDisplay.form
+++ b/healthdisplay/src/main/java/de/psychose/ActorDisplay.form
@@ -3,7 +3,7 @@
-
+
@@ -11,7 +11,7 @@
-
+
diff --git a/healthdisplay/src/main/java/de/psychose/ChaOSCclient.java b/healthdisplay/src/main/java/de/psychose/ChaOSCclient.java
index 18135a1..ec4fc9d 100644
--- a/healthdisplay/src/main/java/de/psychose/ChaOSCclient.java
+++ b/healthdisplay/src/main/java/de/psychose/ChaOSCclient.java
@@ -23,6 +23,7 @@ public class ChaOSCclient {
public ChaOSCclient(String host, int port) throws UnknownHostException, SocketException {
portOut = new OSCPortOut(InetAddress.getByName(host), port);
+ portIn = new OSCPortIn(OSC_CLIENT_PORT);
}
public void addListener(String address, OSCListener listener) {
@@ -35,17 +36,8 @@ public class ChaOSCclient {
}
public boolean startReceiver() {
- try {
- portIn = new OSCPortIn(OSC_CLIENT_PORT);
- portIn.startListening();
-
- return changeChaoscSubscription(true);
- } catch (SocketException e) {
- System.out.println("could not create listening socket");
- e.printStackTrace();
- }
-
- return false;
+ portIn.startListening();
+ return changeChaoscSubscription(true);
}
private boolean changeChaoscSubscription(boolean subscribe) {
diff --git a/healthdisplay/src/main/java/de/psychose/MainForm.form b/healthdisplay/src/main/java/de/psychose/MainForm.form
index a90c6e9..c3adf46 100644
--- a/healthdisplay/src/main/java/de/psychose/MainForm.form
+++ b/healthdisplay/src/main/java/de/psychose/MainForm.form
@@ -1,6 +1,6 @@
diff --git a/healthdisplay/src/main/java/de/psychose/MainForm.java b/healthdisplay/src/main/java/de/psychose/MainForm.java
index 729b905..d4cd4b1 100644
--- a/healthdisplay/src/main/java/de/psychose/MainForm.java
+++ b/healthdisplay/src/main/java/de/psychose/MainForm.java
@@ -4,6 +4,7 @@ import com.illposed.osc.OSCListener;
import com.illposed.osc.OSCMessage;
import javax.swing.*;
+import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.net.SocketException;
@@ -21,14 +22,30 @@ public class MainForm {
private ActorDisplay actor1;
private ActorDisplay actor2;
private ActorDisplay actor3;
+ private StatsDisplay statDisplay;
- public MainForm(ChaOSCclient client) {
- osCclient = client;
- osCclient.startReceiver();
+ private int totalMessageCount = 0;
+ private int messagesTempCounter = 0;
+
+ public MainForm(ChaOSCclient chaOSCclient) {
+ osCclient = chaOSCclient;
addActor("merle", "Proband 1", actor1);
addActor("uwe", "Proband 2", actor2);
addActor("bjoern", "Proband 3", actor3);
+
+ osCclient.startReceiver();
+
+ final Timer timer = new Timer(1000, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ statDisplay.setMessagesPerSec(String.valueOf(totalMessageCount - messagesTempCounter));
+ statDisplay.setMessageCount(String.valueOf(totalMessageCount));
+ messagesTempCounter = totalMessageCount;
+ }
+ });
+ timer.setRepeats(true);
+ timer.start();
}
@@ -38,6 +55,7 @@ public class MainForm {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 3) {
+ totalMessageCount++;
actorDisplay.setHeartbeat(message.getArguments()[0].toString());
actorDisplay.setPulse(message.getArguments()[1].toString());
actorDisplay.setOxy(message.getArguments()[2].toString());
@@ -49,6 +67,7 @@ public class MainForm {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
+ totalMessageCount++;
actorDisplay.setEkg(message.getArguments()[0].toString());
}
}
@@ -58,6 +77,7 @@ public class MainForm {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
+ totalMessageCount++;
actorDisplay.setEmg(message.getArguments()[0].toString());
}
}
@@ -67,6 +87,7 @@ public class MainForm {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
+ totalMessageCount++;
actorDisplay.setTemperature(message.getArguments()[0].toString());
}
}
@@ -76,6 +97,7 @@ public class MainForm {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
+ totalMessageCount++;
actorDisplay.setBreath(message.getArguments()[0].toString());
}
}
@@ -84,16 +106,16 @@ public class MainForm {
public static void main(String[] args) {
- String host = args.length > 0 ? args[0] : "chaosc";
+ final String host = args.length > 0 ? args[0] : "chaosc";
+ final int port = args.length > 1 ? Integer.parseInt(args[1]) : 7110;
try {
- final ChaOSCclient chaOSCclient = new ChaOSCclient(host, 7110);
-
+ final ChaOSCclient chaOSCclient = new ChaOSCclient(host, port);
final MainForm mainForm = new MainForm(chaOSCclient);
final JFrame frame = new JFrame("MainForm");
frame.setContentPane(mainForm.mainPanel);
frame.setResizable(false);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.addWindowListener(new WindowAdapter() {
@@ -108,9 +130,7 @@ public class MainForm {
new Streamer(8888, mainForm.mainPanel).run();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- } catch (SocketException e) {
+ } catch (UnknownHostException | SocketException e) {
e.printStackTrace();
}
}
diff --git a/healthdisplay/src/main/java/de/psychose/StatsDisplay.form b/healthdisplay/src/main/java/de/psychose/StatsDisplay.form
new file mode 100644
index 0000000..0dd0183
--- /dev/null
+++ b/healthdisplay/src/main/java/de/psychose/StatsDisplay.form
@@ -0,0 +1,92 @@
+
+
diff --git a/healthdisplay/src/main/java/de/psychose/StatsDisplay.java b/healthdisplay/src/main/java/de/psychose/StatsDisplay.java
new file mode 100644
index 0000000..4989777
--- /dev/null
+++ b/healthdisplay/src/main/java/de/psychose/StatsDisplay.java
@@ -0,0 +1,23 @@
+package de.psychose;
+
+import javax.swing.*;
+
+/**
+ * @author: lucas
+ * @date: 18.04.14 02:19
+ */
+public class StatsDisplay {
+ private JLabel lblCaption;
+ private JLabel lblMessageCount;
+ private JLabel lblMessagesPerSec;
+ private JPanel statPanel;
+
+ public void setMessageCount(String count) {
+ lblMessageCount.setText(count);
+ }
+
+ public void setMessagesPerSec(String messagesPerSec) {
+ lblMessagesPerSec.setText(messagesPerSec);
+ }
+
+}
diff --git a/healthdisplay/src/main/java/de/psychose/Test.java b/healthdisplay/src/main/java/de/psychose/Test.java
index 9c38158..deb48b6 100644
--- a/healthdisplay/src/main/java/de/psychose/Test.java
+++ b/healthdisplay/src/main/java/de/psychose/Test.java
@@ -2,6 +2,11 @@ package de.psychose;
import javax.sound.midi.*;
import java.io.File;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashSet;
public class Test {
@@ -9,17 +14,37 @@ public class Test {
public static final int NOTE_OFF = 0x80;
public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"};
+ private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
+ System.out.printf("Display name: %s%n", netint.getDisplayName());
+ System.out.printf("Name: %s%n", netint.getName());
+ Enumeration inetAddresses = netint.getInetAddresses();
+
+ for (InetAddress inetAddress : Collections.list(inetAddresses)) {
+ System.out.printf("InetAddress: %s%n", inetAddress);
+ }
+ System.out.printf("%n");
+ }
+
public static void main(String[] args) throws Exception {
+
+ Enumeration nets = NetworkInterface.getNetworkInterfaces();
+ for (NetworkInterface netint : Collections.list(nets)) {
+ displayInterfaceInformation(netint);
+ }
+
+
+ if(true) return;
+
Sequence sequence = MidiSystem.getSequence(new File("/home/lucas/jake-avril_14th.mid"));
HashSet notes = new HashSet();
int trackNumber = 0;
- for (Track track : sequence.getTracks()) {
+ for (Track track : sequence.getTracks()) {
trackNumber++;
System.out.println("Track " + trackNumber + ": size = " + track.size());
System.out.println();
- for (int i=0; i < track.size(); i++) {
+ for (int i = 0; i < track.size(); i++) {
MidiEvent event = track.get(i);
System.out.print("@" + event.getTick() + " ");
MidiMessage message = event.getMessage();
@@ -28,17 +53,17 @@ public class Test {
System.out.print("Channel: " + sm.getChannel() + " ");
if (sm.getCommand() == NOTE_ON) {
int key = sm.getData1();
- int octave = (key / 12)-1;
+ int octave = (key / 12) - 1;
int note = key % 12;
String noteName = NOTE_NAMES[note];
int velocity = sm.getData2();
System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity);
- notes.add(noteName+octave);
+ notes.add(noteName + octave);
} else if (sm.getCommand() == NOTE_OFF) {
int key = sm.getData1();
- int octave = (key / 12)-1;
+ int octave = (key / 12) - 1;
int note = key % 12;
String noteName = NOTE_NAMES[note];
int velocity = sm.getData2();
@@ -57,7 +82,6 @@ public class Test {
}
-
System.out.println(notes);
}
}
\ No newline at end of file