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] 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