From f396266715405167c3295873fc7c2e4728de2117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Thu, 17 Apr 2014 17:27:19 +0200 Subject: [PATCH 1/3] added airflow/breath --- healthdisplay/pom.xml | 21 ++++++++++++ healthdisplay/src/ActorDisplay.form | 52 ++++++++++++++++++++--------- healthdisplay/src/ActorDisplay.java | 13 ++++++++ healthdisplay/src/MainForm.java | 17 +++++++--- healthdisplay/src/Test.java | 14 +++++++- 5 files changed, 96 insertions(+), 21 deletions(-) diff --git a/healthdisplay/pom.xml b/healthdisplay/pom.xml index fe39b78..281e1a1 100644 --- a/healthdisplay/pom.xml +++ b/healthdisplay/pom.xml @@ -6,6 +6,8 @@ psychose psy + jar + com.illposed.osc @@ -33,4 +35,23 @@ + + + + + maven-assembly-plugin + + + + MainForm + + + + jar-with-dependencies + + + + + + \ No newline at end of file diff --git a/healthdisplay/src/ActorDisplay.form b/healthdisplay/src/ActorDisplay.form index 0506171..37cd41b 100644 --- a/healthdisplay/src/ActorDisplay.form +++ b/healthdisplay/src/ActorDisplay.form @@ -1,14 +1,14 @@
- + - + - + @@ -22,12 +22,12 @@ - + - + @@ -77,7 +77,7 @@ - + @@ -120,16 +120,6 @@ - - - - - - - - - - @@ -150,6 +140,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/healthdisplay/src/ActorDisplay.java b/healthdisplay/src/ActorDisplay.java index cfcd95a..e5a8637 100644 --- a/healthdisplay/src/ActorDisplay.java +++ b/healthdisplay/src/ActorDisplay.java @@ -19,6 +19,7 @@ public class ActorDisplay { private JLabel lblEkg; private JLabel lblEmg; private JLabel lblTemperature; + private JLabel lblBreath; private int counterHeartbeat = 0; private int counterPulse = 0; @@ -26,6 +27,7 @@ public class ActorDisplay { private int counterEkg = 0; private int counterEmg = 0; private int counterTemperature = 0; + private int counterBreath = 0; private int timeout = 20; // 20 * 100ms @@ -33,6 +35,11 @@ public class ActorDisplay { lblCaption.setText(caption); } + public void setBreath(String breath) { + lblBreath.setText(breath); + counterBreath = 0; + } + public void setTemperature(String temperature) { lblTemperature.setText(temperature); counterTemperature = 0; @@ -108,6 +115,12 @@ public class ActorDisplay { lblHeartbeat.setForeground(onColor); } + if(++counterBreath > timeout) { + lblBreath.setForeground(offColor); + } else { + lblBreath.setForeground(onColor); + } + } }); timer.setRepeats(true); diff --git a/healthdisplay/src/MainForm.java b/healthdisplay/src/MainForm.java index c5f52db..2db7409 100644 --- a/healthdisplay/src/MainForm.java +++ b/healthdisplay/src/MainForm.java @@ -24,9 +24,9 @@ public class MainForm { osCclient = client; osCclient.startReceiver(); - addActor("merle", "Merle", actor1); - addActor("uwe", "Uwe", actor2); - addActor("bjoern", "Björn", actor3); + addActor("merle", "Proband 1", actor1); + addActor("uwe", "Proband 2", actor2); + addActor("bjoern", "Proband 3", actor3); } @@ -69,12 +69,21 @@ public class MainForm { } } }); + + osCclient.addListener("/" + actor.toLowerCase() + "/airFlow", new OSCListener() { + @Override + public void acceptMessage(Date time, OSCMessage message) { + if (message.getArguments().length == 1) { + actorDisplay.setBreath(message.getArguments()[0].toString()); + } + } + }); } public static void main(String[] args) { try { - final ChaOSCclient chaOSCclient = new ChaOSCclient("localhost", 7110); + final ChaOSCclient chaOSCclient = new ChaOSCclient("chaosc", 7110); final MainForm mainForm = new MainForm(chaOSCclient); final JFrame frame = new JFrame("MainForm"); diff --git a/healthdisplay/src/Test.java b/healthdisplay/src/Test.java index 2aec3a5..c4ea4d4 100644 --- a/healthdisplay/src/Test.java +++ b/healthdisplay/src/Test.java @@ -1,14 +1,17 @@ import javax.sound.midi.*; import java.io.File; +import java.util.HashSet; public class Test { public static final int NOTE_ON = 0x90; public static final int NOTE_OFF = 0x80; - public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; + public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"}; public static void main(String[] args) throws Exception { Sequence sequence = MidiSystem.getSequence(new File("/home/lucas/jake-avril_14th.mid")); + HashSet notes = new HashSet(); + int trackNumber = 0; for (Track track : sequence.getTracks()) { trackNumber++; @@ -28,6 +31,9 @@ public class Test { String noteName = NOTE_NAMES[note]; int velocity = sm.getData2(); System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity); + + notes.add(noteName+octave); + } else if (sm.getCommand() == NOTE_OFF) { int key = sm.getData1(); int octave = (key / 12)-1; @@ -44,6 +50,12 @@ public class Test { } System.out.println(); + + } + + + + System.out.println(notes); } } \ No newline at end of file From a6a3666c155126f9fe5e8dee01685d913de2fc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Thu, 17 Apr 2014 19:03:45 +0200 Subject: [PATCH 2/3] moved code into package, added complete maven support for intellij UI Designer and JAR packaging --- healthdisplay/.idea/compiler.xml | 3 ++ .../.idea/libraries/Maven__asm_asm_3_0.xml | 13 +++++++ .../libraries/Maven__asm_asm_commons_3_0.xml | 13 +++++++ .../libraries/Maven__asm_asm_tree_3_0.xml | 13 +++++++ .../Maven__com_intellij_forms_rt_7_0_3.xml | 13 +++++++ .../Maven__com_jgoodies_forms_1_1_preview.xml | 13 +++++++ .../.idea/libraries/Maven__jdom_jdom_1_0.xml | 13 +++++++ healthdisplay/.idea/uiDesigner.xml | 2 +- healthdisplay/README | 5 +++ healthdisplay/healthdisplay.iml | 10 ++++- healthdisplay/pom.xml | 37 ++++++++++++++++++- .../java/de/psychose}/ActorDisplay.form | 2 +- .../java/de/psychose}/ActorDisplay.java | 17 +++++---- .../java/de/psychose}/ChaOSCclient.java | 2 + .../{ => main/java/de/psychose}/MainForm.form | 19 ++++++---- .../{ => main/java/de/psychose}/MainForm.java | 6 ++- .../{ => main/java/de/psychose}/Streamer.java | 2 + .../src/{ => main/java/de/psychose}/Test.java | 2 + 18 files changed, 164 insertions(+), 21 deletions(-) create mode 100644 healthdisplay/.idea/libraries/Maven__asm_asm_3_0.xml create mode 100644 healthdisplay/.idea/libraries/Maven__asm_asm_commons_3_0.xml create mode 100644 healthdisplay/.idea/libraries/Maven__asm_asm_tree_3_0.xml create mode 100644 healthdisplay/.idea/libraries/Maven__com_intellij_forms_rt_7_0_3.xml create mode 100644 healthdisplay/.idea/libraries/Maven__com_jgoodies_forms_1_1_preview.xml create mode 100644 healthdisplay/.idea/libraries/Maven__jdom_jdom_1_0.xml create mode 100644 healthdisplay/README rename healthdisplay/src/{ => main/java/de/psychose}/ActorDisplay.form (99%) rename healthdisplay/src/{ => main/java/de/psychose}/ActorDisplay.java (89%) rename healthdisplay/src/{ => main/java/de/psychose}/ChaOSCclient.java (99%) rename healthdisplay/src/{ => main/java/de/psychose}/MainForm.form (76%) rename healthdisplay/src/{ => main/java/de/psychose}/MainForm.java (95%) rename healthdisplay/src/{ => main/java/de/psychose}/Streamer.java (99%) rename healthdisplay/src/{ => main/java/de/psychose}/Test.java (99%) diff --git a/healthdisplay/.idea/compiler.xml b/healthdisplay/.idea/compiler.xml index fa7a277..2e11072 100644 --- a/healthdisplay/.idea/compiler.xml +++ b/healthdisplay/.idea/compiler.xml @@ -25,6 +25,9 @@ + + + diff --git a/healthdisplay/.idea/libraries/Maven__asm_asm_3_0.xml b/healthdisplay/.idea/libraries/Maven__asm_asm_3_0.xml new file mode 100644 index 0000000..7967610 --- /dev/null +++ b/healthdisplay/.idea/libraries/Maven__asm_asm_3_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/healthdisplay/.idea/libraries/Maven__asm_asm_commons_3_0.xml b/healthdisplay/.idea/libraries/Maven__asm_asm_commons_3_0.xml new file mode 100644 index 0000000..3cef17f --- /dev/null +++ b/healthdisplay/.idea/libraries/Maven__asm_asm_commons_3_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/healthdisplay/.idea/libraries/Maven__asm_asm_tree_3_0.xml b/healthdisplay/.idea/libraries/Maven__asm_asm_tree_3_0.xml new file mode 100644 index 0000000..967bfbd --- /dev/null +++ b/healthdisplay/.idea/libraries/Maven__asm_asm_tree_3_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/healthdisplay/.idea/libraries/Maven__com_intellij_forms_rt_7_0_3.xml b/healthdisplay/.idea/libraries/Maven__com_intellij_forms_rt_7_0_3.xml new file mode 100644 index 0000000..7c63da5 --- /dev/null +++ b/healthdisplay/.idea/libraries/Maven__com_intellij_forms_rt_7_0_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/healthdisplay/.idea/libraries/Maven__com_jgoodies_forms_1_1_preview.xml b/healthdisplay/.idea/libraries/Maven__com_jgoodies_forms_1_1_preview.xml new file mode 100644 index 0000000..230ff65 --- /dev/null +++ b/healthdisplay/.idea/libraries/Maven__com_jgoodies_forms_1_1_preview.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/healthdisplay/.idea/libraries/Maven__jdom_jdom_1_0.xml b/healthdisplay/.idea/libraries/Maven__jdom_jdom_1_0.xml new file mode 100644 index 0000000..3349d67 --- /dev/null +++ b/healthdisplay/.idea/libraries/Maven__jdom_jdom_1_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/healthdisplay/.idea/uiDesigner.xml b/healthdisplay/.idea/uiDesigner.xml index fbab987..9a015a0 100644 --- a/healthdisplay/.idea/uiDesigner.xml +++ b/healthdisplay/.idea/uiDesigner.xml @@ -119,7 +119,7 @@ - + diff --git a/healthdisplay/README b/healthdisplay/README new file mode 100644 index 0000000..4a3b245 --- /dev/null +++ b/healthdisplay/README @@ -0,0 +1,5 @@ + + +compile with + +mvn clean compile ideauidesigner:javac2 assembly:single diff --git a/healthdisplay/healthdisplay.iml b/healthdisplay/healthdisplay.iml index e6e4b05..8a76843 100644 --- a/healthdisplay/healthdisplay.iml +++ b/healthdisplay/healthdisplay.iml @@ -1,16 +1,22 @@ - + - + + + + + + + diff --git a/healthdisplay/pom.xml b/healthdisplay/pom.xml index 281e1a1..30de015 100644 --- a/healthdisplay/pom.xml +++ b/healthdisplay/pom.xml @@ -20,6 +20,12 @@ netty 3.2.7.Final
+ + com.intellij + forms_rt + 7.0.3 + +
@@ -36,14 +42,23 @@ - + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.7 + 1.7 + UTF-8 + + maven-assembly-plugin - MainForm + de.psychose.MainForm @@ -51,6 +66,24 @@ + + org.codehaus.mojo + ideauidesigner-maven-plugin + + + + javac2 + + + + + + true + true + true + + + diff --git a/healthdisplay/src/ActorDisplay.form b/healthdisplay/src/main/java/de/psychose/ActorDisplay.form similarity index 99% rename from healthdisplay/src/ActorDisplay.form rename to healthdisplay/src/main/java/de/psychose/ActorDisplay.form index 37cd41b..f990072 100644 --- a/healthdisplay/src/ActorDisplay.form +++ b/healthdisplay/src/main/java/de/psychose/ActorDisplay.form @@ -1,5 +1,5 @@ -
+ diff --git a/healthdisplay/src/ActorDisplay.java b/healthdisplay/src/main/java/de/psychose/ActorDisplay.java similarity index 89% rename from healthdisplay/src/ActorDisplay.java rename to healthdisplay/src/main/java/de/psychose/ActorDisplay.java index e5a8637..542cd83 100644 --- a/healthdisplay/src/ActorDisplay.java +++ b/healthdisplay/src/main/java/de/psychose/ActorDisplay.java @@ -1,3 +1,5 @@ +package de.psychose; + import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; @@ -79,43 +81,43 @@ public class ActorDisplay { // actorPanel.setBackground(new Color(r.nextInt(), false)); - if(++counterTemperature > timeout) { + if (++counterTemperature > timeout) { lblTemperature.setForeground(offColor); } else { lblTemperature.setForeground(onColor); } - if(++counterPulse > timeout) { + if (++counterPulse > timeout) { lblPulse.setForeground(offColor); } else { lblPulse.setForeground(onColor); } - if(++counterOxy > timeout) { + if (++counterOxy > timeout) { lblOxy.setForeground(offColor); } else { lblOxy.setForeground(onColor); } - if(++counterEkg > timeout) { + if (++counterEkg > timeout) { lblEkg.setForeground(offColor); } else { lblEkg.setForeground(onColor); } - if(++counterEmg > timeout) { + if (++counterEmg > timeout) { lblEmg.setForeground(offColor); } else { lblEmg.setForeground(onColor); } - if(++counterHeartbeat > timeout) { + if (++counterHeartbeat > timeout) { lblHeartbeat.setForeground(offColor); } else { lblHeartbeat.setForeground(onColor); } - if(++counterBreath > timeout) { + if (++counterBreath > timeout) { lblBreath.setForeground(offColor); } else { lblBreath.setForeground(onColor); @@ -126,5 +128,6 @@ public class ActorDisplay { timer.setRepeats(true); timer.start(); } + } diff --git a/healthdisplay/src/ChaOSCclient.java b/healthdisplay/src/main/java/de/psychose/ChaOSCclient.java similarity index 99% rename from healthdisplay/src/ChaOSCclient.java rename to healthdisplay/src/main/java/de/psychose/ChaOSCclient.java index a277421..18135a1 100644 --- a/healthdisplay/src/ChaOSCclient.java +++ b/healthdisplay/src/main/java/de/psychose/ChaOSCclient.java @@ -1,3 +1,5 @@ +package de.psychose; + import com.illposed.osc.OSCListener; import com.illposed.osc.OSCMessage; import com.illposed.osc.OSCPortIn; diff --git a/healthdisplay/src/MainForm.form b/healthdisplay/src/main/java/de/psychose/MainForm.form similarity index 76% rename from healthdisplay/src/MainForm.form rename to healthdisplay/src/main/java/de/psychose/MainForm.form index aa1bed6..a90c6e9 100644 --- a/healthdisplay/src/MainForm.form +++ b/healthdisplay/src/main/java/de/psychose/MainForm.form @@ -1,6 +1,6 @@ - - + + @@ -19,27 +19,32 @@ - + + + + + + - + - + - + - + diff --git a/healthdisplay/src/MainForm.java b/healthdisplay/src/main/java/de/psychose/MainForm.java similarity index 95% rename from healthdisplay/src/MainForm.java rename to healthdisplay/src/main/java/de/psychose/MainForm.java index 2db7409..729b905 100644 --- a/healthdisplay/src/MainForm.java +++ b/healthdisplay/src/main/java/de/psychose/MainForm.java @@ -1,3 +1,5 @@ +package de.psychose; + import com.illposed.osc.OSCListener; import com.illposed.osc.OSCMessage; @@ -82,8 +84,10 @@ public class MainForm { public static void main(String[] args) { + String host = args.length > 0 ? args[0] : "chaosc"; + try { - final ChaOSCclient chaOSCclient = new ChaOSCclient("chaosc", 7110); + final ChaOSCclient chaOSCclient = new ChaOSCclient(host, 7110); final MainForm mainForm = new MainForm(chaOSCclient); final JFrame frame = new JFrame("MainForm"); diff --git a/healthdisplay/src/Streamer.java b/healthdisplay/src/main/java/de/psychose/Streamer.java similarity index 99% rename from healthdisplay/src/Streamer.java rename to healthdisplay/src/main/java/de/psychose/Streamer.java index 1796b55..deea16a 100644 --- a/healthdisplay/src/Streamer.java +++ b/healthdisplay/src/main/java/de/psychose/Streamer.java @@ -1,3 +1,5 @@ +package de.psychose; + import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.*; diff --git a/healthdisplay/src/Test.java b/healthdisplay/src/main/java/de/psychose/Test.java similarity index 99% rename from healthdisplay/src/Test.java rename to healthdisplay/src/main/java/de/psychose/Test.java index c4ea4d4..9c38158 100644 --- a/healthdisplay/src/Test.java +++ b/healthdisplay/src/main/java/de/psychose/Test.java @@ -1,3 +1,5 @@ +package de.psychose; + import javax.sound.midi.*; import java.io.File; import java.util.HashSet; From a53cf435de873507122e33de9b3e04c753ce512e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Fri, 18 Apr 2014 03:06:41 +0200 Subject: [PATCH 3/3] added stats display, removed border from actor display --- healthdisplay/.idea/uiDesigner.xml | 3 + .../main/java/de/psychose/ActorDisplay.form | 4 +- .../main/java/de/psychose/ChaOSCclient.java | 14 +-- .../src/main/java/de/psychose/MainForm.form | 39 ++++---- .../src/main/java/de/psychose/MainForm.java | 40 ++++++-- .../main/java/de/psychose/StatsDisplay.form | 92 +++++++++++++++++++ .../main/java/de/psychose/StatsDisplay.java | 23 +++++ .../src/main/java/de/psychose/Test.java | 36 ++++++-- 8 files changed, 205 insertions(+), 46 deletions(-) create mode 100644 healthdisplay/src/main/java/de/psychose/StatsDisplay.form create mode 100644 healthdisplay/src/main/java/de/psychose/StatsDisplay.java 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 @@ - + @@ -14,21 +14,31 @@ - - - - - - + - + - + + + + + + + + + + + + + + + + @@ -39,16 +49,11 @@ - + - + - - - - - - + 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