Merge branch 'master' of repos.ctdo.de:psychose

This commit is contained in:
Stefan Kögl 2014-04-20 11:37:45 +02:00
commit 0086d0fd8f
20 changed files with 448 additions and 71 deletions

View File

@ -25,6 +25,9 @@
<module name="healthdisplay" /> <module name="healthdisplay" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel>
<module name="healthdisplay" target="1.7" />
</bytecodeTargetLevel>
</component> </component>
</project> </project>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: asm:asm:3.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm/3.0/asm-3.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm/3.0/asm-3.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm/3.0/asm-3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: asm:asm-commons:3.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm-commons/3.0/asm-commons-3.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm-commons/3.0/asm-commons-3.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm-commons/3.0/asm-commons-3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: asm:asm-tree:3.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm-tree/3.0/asm-tree-3.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm-tree/3.0/asm-tree-3.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/asm/asm-tree/3.0/asm-tree-3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.intellij:forms_rt:7.0.3">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/intellij/forms_rt/7.0.3/forms_rt-7.0.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/intellij/forms_rt/7.0.3/forms_rt-7.0.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/intellij/forms_rt/7.0.3/forms_rt-7.0.3-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.jgoodies:forms:1.1-preview">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/jgoodies/forms/1.1-preview/forms-1.1-preview.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/jgoodies/forms/1.1-preview/forms-1.1-preview-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/jgoodies/forms/1.1-preview/forms-1.1-preview-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: jdom:jdom:1.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/jdom/jdom/1.0/jdom-1.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/jdom/jdom/1.0/jdom-1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/jdom/jdom/1.0/jdom-1.0-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -119,7 +119,10 @@
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false"> <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" /> <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item> </item>
<item class="ActorDisplay" icon="" removable="true" auto-create-binding="false" can-attach-label="false"> <item class="main.java.de.psychose.ActorDisplay" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item>
<item class="de.psychose.StatsDisplay" icon="" removable="true" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" /> <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="0" />
</item> </item>
</group> </group>

5
healthdisplay/README Normal file
View File

@ -0,0 +1,5 @@
compile with
mvn clean compile ideauidesigner:javac2 assembly:single

View File

@ -1,16 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false"> <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" /> <output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" /> <output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.illposed.osc:javaosc-core:0.2" level="project" /> <orderEntry type="library" name="Maven: com.illposed.osc:javaosc-core:0.2" level="project" />
<orderEntry type="library" name="Maven: org.jboss.netty:netty:3.2.7.Final" level="project" /> <orderEntry type="library" name="Maven: org.jboss.netty:netty:3.2.7.Final" level="project" />
<orderEntry type="library" name="Maven: com.intellij:forms_rt:7.0.3" level="project" />
<orderEntry type="library" name="Maven: asm:asm-commons:3.0" level="project" />
<orderEntry type="library" name="Maven: asm:asm-tree:3.0" level="project" />
<orderEntry type="library" name="Maven: asm:asm:3.0" level="project" />
<orderEntry type="library" name="Maven: com.jgoodies:forms:1.1-preview" level="project" />
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
</component> </component>
</module> </module>

View File

@ -6,6 +6,8 @@
<artifactId>psychose</artifactId> <artifactId>psychose</artifactId>
<groupId>psy</groupId> <groupId>psy</groupId>
<packaging>jar</packaging>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.illposed.osc</groupId> <groupId>com.illposed.osc</groupId>
@ -18,6 +20,12 @@
<artifactId>netty</artifactId> <artifactId>netty</artifactId>
<version>3.2.7.Final</version> <version>3.2.7.Final</version>
</dependency> </dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>forms_rt</artifactId>
<version>7.0.3</version>
</dependency>
</dependencies> </dependencies>
@ -33,4 +41,50 @@
</repository> </repository>
</repositories> </repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>de.psychose.MainForm</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>ideauidesigner-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>javac2</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
<debug>true</debug>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ActorDisplay"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.ActorDisplay">
<grid id="27dc6" binding="actorPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="27dc6" binding="actorPanel" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="4" left="6" bottom="4" right="6"/> <margin top="4" left="6" bottom="4" right="6"/>
<constraints> <constraints>
<xy x="20" y="20" width="220" height="220"/> <xy x="20" y="20" width="316" height="302"/>
</constraints> </constraints>
<properties> <properties>
<background color="-16777216"/> <background color="-16777216"/>
<foreground color="-1"/> <foreground color="-1"/>
<minimumSize width="220" height="220"/> <minimumSize width="220" height="250"/>
<preferredSize width="0" height="0"/> <preferredSize width="0" height="0"/>
</properties> </properties>
<border type="line"> <border type="none">
<color color="-11447983"/> <color color="-11447983"/>
</border> </border>
<children> <children>
@ -22,12 +22,12 @@
<properties> <properties>
<font name="Droid Sans Mono" size="20"/> <font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/> <foreground color="-1"/>
<text value="Pulse"/> <text value="Puls"/>
</properties> </properties>
</component> </component>
<vspacer id="1290"> <vspacer id="1290">
<constraints> <constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> </vspacer>
<component id="d0a2" class="javax.swing.JLabel" binding="lblPulse"> <component id="d0a2" class="javax.swing.JLabel" binding="lblPulse">
@ -77,7 +77,7 @@
<properties> <properties>
<font name="Droid Sans Mono" size="20"/> <font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/> <foreground color="-1"/>
<text value="Heart"/> <text value="Herz"/>
</properties> </properties>
</component> </component>
<component id="e1c6d" class="javax.swing.JLabel" binding="lblOxy"> <component id="e1c6d" class="javax.swing.JLabel" binding="lblOxy">
@ -120,16 +120,6 @@
<text value="-"/> <text value="-"/>
</properties> </properties>
</component> </component>
<component id="9b787" class="javax.swing.JLabel" binding="lblCaption">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="28" style="1"/>
<foreground color="-1"/>
<text value="Label"/>
</properties>
</component>
<component id="4d72a" class="javax.swing.JLabel"> <component id="4d72a" class="javax.swing.JLabel">
<constraints> <constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@ -150,6 +140,36 @@
<text value="-"/> <text value="-"/>
</properties> </properties>
</component> </component>
<component id="9b787" class="javax.swing.JLabel" binding="lblCaption">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="28" style="1"/>
<foreground color="-1"/>
<text value="Label"/>
</properties>
</component>
<component id="29a78" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Atem"/>
</properties>
</component>
<component id="bb84f" class="javax.swing.JLabel" binding="lblBreath">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
</children> </children>
</grid> </grid>
</form> </form>

View File

@ -1,3 +1,5 @@
package de.psychose;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -19,6 +21,7 @@ public class ActorDisplay {
private JLabel lblEkg; private JLabel lblEkg;
private JLabel lblEmg; private JLabel lblEmg;
private JLabel lblTemperature; private JLabel lblTemperature;
private JLabel lblBreath;
private int counterHeartbeat = 0; private int counterHeartbeat = 0;
private int counterPulse = 0; private int counterPulse = 0;
@ -26,6 +29,7 @@ public class ActorDisplay {
private int counterEkg = 0; private int counterEkg = 0;
private int counterEmg = 0; private int counterEmg = 0;
private int counterTemperature = 0; private int counterTemperature = 0;
private int counterBreath = 0;
private int timeout = 20; // 20 * 100ms private int timeout = 20; // 20 * 100ms
@ -33,6 +37,11 @@ public class ActorDisplay {
lblCaption.setText(caption); lblCaption.setText(caption);
} }
public void setBreath(String breath) {
lblBreath.setText(breath);
counterBreath = 0;
}
public void setTemperature(String temperature) { public void setTemperature(String temperature) {
lblTemperature.setText(temperature); lblTemperature.setText(temperature);
counterTemperature = 0; counterTemperature = 0;
@ -108,10 +117,17 @@ public class ActorDisplay {
lblHeartbeat.setForeground(onColor); lblHeartbeat.setForeground(onColor);
} }
if (++counterBreath > timeout) {
lblBreath.setForeground(offColor);
} else {
lblBreath.setForeground(onColor);
}
} }
}); });
timer.setRepeats(true); timer.setRepeats(true);
timer.start(); timer.start();
} }
} }

View File

@ -1,3 +1,5 @@
package de.psychose;
import com.illposed.osc.OSCListener; import com.illposed.osc.OSCListener;
import com.illposed.osc.OSCMessage; import com.illposed.osc.OSCMessage;
import com.illposed.osc.OSCPortIn; import com.illposed.osc.OSCPortIn;
@ -21,6 +23,7 @@ public class ChaOSCclient {
public ChaOSCclient(String host, int port) throws UnknownHostException, SocketException { public ChaOSCclient(String host, int port) throws UnknownHostException, SocketException {
portOut = new OSCPortOut(InetAddress.getByName(host), port); portOut = new OSCPortOut(InetAddress.getByName(host), port);
portIn = new OSCPortIn(OSC_CLIENT_PORT);
} }
public void addListener(String address, OSCListener listener) { public void addListener(String address, OSCListener listener) {
@ -33,17 +36,8 @@ public class ChaOSCclient {
} }
public boolean startReceiver() { public boolean startReceiver() {
try {
portIn = new OSCPortIn(OSC_CLIENT_PORT);
portIn.startListening(); portIn.startListening();
return changeChaoscSubscription(true); return changeChaoscSubscription(true);
} catch (SocketException e) {
System.out.println("could not create listening socket");
e.printStackTrace();
}
return false;
} }
private boolean changeChaoscSubscription(boolean subscribe) { private boolean changeChaoscSubscription(boolean subscribe) {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="MainForm"> <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.MainForm">
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="5" left="5" bottom="5" right="5"/> <margin top="5" left="5" bottom="5" right="5"/>
<constraints> <constraints>
<xy x="20" y="20" width="720" height="576"/> <xy x="20" y="20" width="720" height="576"/>
@ -14,36 +14,46 @@
</properties> </properties>
<border type="none"/> <border type="none"/>
<children> <children>
<vspacer id="b61d"> <hspacer id="f912c">
<constraints> <constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> <grid row="1" column="5" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</vspacer> </hspacer>
<nested-form id="71726" form-file="/ActorDisplay.form" binding="actor1"> <hspacer id="6a2b8">
<constraints> <constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/> <grid row="1" column="1" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<hspacer id="67192">
<constraints>
<grid row="1" column="3" row-span="2" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<nested-form id="5519b" form-file="de/psychose/StatsDisplay.form" binding="statDisplay">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</nested-form> </nested-form>
<nested-form id="a01e1" form-file="/ActorDisplay.form" binding="actor2"> <vspacer id="ad2ab">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<nested-form id="736bf" form-file="de/psychose/ActorDisplay.form" binding="actor2">
<constraints> <constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/> <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</nested-form> </nested-form>
<nested-form id="914d6" form-file="/ActorDisplay.form" binding="actor3"> <nested-form id="7fe82" form-file="de/psychose/ActorDisplay.form" binding="actor3">
<constraints> <constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/> <grid row="0" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</nested-form> </nested-form>
<hspacer id="8e2fe"> <nested-form id="bd9b" form-file="de/psychose/ActorDisplay.form" binding="actor1">
<constraints> <constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints> </constraints>
</hspacer> </nested-form>
<hspacer id="f912c">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children> </children>
</grid> </grid>
</form> </form>

View File

@ -1,7 +1,10 @@
package de.psychose;
import com.illposed.osc.OSCListener; import com.illposed.osc.OSCListener;
import com.illposed.osc.OSCMessage; import com.illposed.osc.OSCMessage;
import javax.swing.*; import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.net.SocketException; import java.net.SocketException;
@ -19,14 +22,30 @@ public class MainForm {
private ActorDisplay actor1; private ActorDisplay actor1;
private ActorDisplay actor2; private ActorDisplay actor2;
private ActorDisplay actor3; private ActorDisplay actor3;
private StatsDisplay statDisplay;
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);
public MainForm(ChaOSCclient client) {
osCclient = client;
osCclient.startReceiver(); osCclient.startReceiver();
addActor("merle", "Merle", actor1); final Timer timer = new Timer(1000, new AbstractAction() {
addActor("uwe", "Uwe", actor2); @Override
addActor("bjoern", "Björn", actor3); public void actionPerformed(ActionEvent e) {
statDisplay.setMessagesPerSec(String.valueOf(totalMessageCount - messagesTempCounter));
statDisplay.setMessageCount(String.valueOf(totalMessageCount));
messagesTempCounter = totalMessageCount;
}
});
timer.setRepeats(true);
timer.start();
} }
@ -36,6 +55,7 @@ public class MainForm {
@Override @Override
public void acceptMessage(Date time, OSCMessage message) { public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 3) { if (message.getArguments().length == 3) {
totalMessageCount++;
actorDisplay.setHeartbeat(message.getArguments()[0].toString()); actorDisplay.setHeartbeat(message.getArguments()[0].toString());
actorDisplay.setPulse(message.getArguments()[1].toString()); actorDisplay.setPulse(message.getArguments()[1].toString());
actorDisplay.setOxy(message.getArguments()[2].toString()); actorDisplay.setOxy(message.getArguments()[2].toString());
@ -47,6 +67,7 @@ public class MainForm {
@Override @Override
public void acceptMessage(Date time, OSCMessage message) { public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) { if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setEkg(message.getArguments()[0].toString()); actorDisplay.setEkg(message.getArguments()[0].toString());
} }
} }
@ -56,6 +77,7 @@ public class MainForm {
@Override @Override
public void acceptMessage(Date time, OSCMessage message) { public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) { if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setEmg(message.getArguments()[0].toString()); actorDisplay.setEmg(message.getArguments()[0].toString());
} }
} }
@ -65,22 +87,35 @@ public class MainForm {
@Override @Override
public void acceptMessage(Date time, OSCMessage message) { public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) { if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setTemperature(message.getArguments()[0].toString()); actorDisplay.setTemperature(message.getArguments()[0].toString());
} }
} }
}); });
osCclient.addListener("/" + actor.toLowerCase() + "/airFlow", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
totalMessageCount++;
actorDisplay.setBreath(message.getArguments()[0].toString());
}
}
});
} }
public static void main(String[] args) { public static void main(String[] args) {
try { final String host = args.length > 0 ? args[0] : "chaosc";
final ChaOSCclient chaOSCclient = new ChaOSCclient("localhost", 7110); final int port = args.length > 1 ? Integer.parseInt(args[1]) : 7110;
try {
final ChaOSCclient chaOSCclient = new ChaOSCclient(host, port);
final MainForm mainForm = new MainForm(chaOSCclient); final MainForm mainForm = new MainForm(chaOSCclient);
final JFrame frame = new JFrame("MainForm"); final JFrame frame = new JFrame("MainForm");
frame.setContentPane(mainForm.mainPanel); frame.setContentPane(mainForm.mainPanel);
frame.setResizable(false); frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack(); frame.pack();
frame.addWindowListener(new WindowAdapter() { frame.addWindowListener(new WindowAdapter() {
@ -95,9 +130,7 @@ public class MainForm {
new Streamer(8888, mainForm.mainPanel).run(); new Streamer(8888, mainForm.mainPanel).run();
} catch (UnknownHostException e) { } catch (UnknownHostException | SocketException e) {
e.printStackTrace();
} catch (SocketException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.psychose.StatsDisplay">
<grid id="27dc6" binding="statPanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="248" height="180"/>
</constraints>
<properties>
<background color="-16777216"/>
<foreground color="-1"/>
<minimumSize width="220" height="180"/>
</properties>
<border type="none"/>
<children>
<component id="69530" class="javax.swing.JLabel" binding="lblCaption">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="28" style="1"/>
<foreground color="-1"/>
<text value="Statistik"/>
</properties>
</component>
<vspacer id="9a59f">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="1d950" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Events"/>
</properties>
</component>
<component id="442f5" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Ev/Sek"/>
</properties>
</component>
<component id="4b993" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Herz"/>
</properties>
</component>
<component id="54c59" class="javax.swing.JLabel" binding="lblMessageCount">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
<component id="eaaf9" class="javax.swing.JLabel" binding="lblMessagesPerSec">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
<component id="a2840" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -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);
}
}

View File

@ -1,3 +1,5 @@
package de.psychose;
import org.jboss.netty.bootstrap.ServerBootstrap; import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.*; import org.jboss.netty.channel.*;

View File

@ -1,14 +1,44 @@
package de.psychose;
import javax.sound.midi.*; import javax.sound.midi.*;
import java.io.File; 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 { public class Test {
public static final int NOTE_ON = 0x90; public static final int NOTE_ON = 0x90;
public static final int NOTE_OFF = 0x80; 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"};
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<InetAddress> 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 { public static void main(String[] args) throws Exception {
Enumeration<NetworkInterface> 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")); Sequence sequence = MidiSystem.getSequence(new File("/home/lucas/jake-avril_14th.mid"));
HashSet<String> notes = new HashSet<String>();
int trackNumber = 0; int trackNumber = 0;
for (Track track : sequence.getTracks()) { for (Track track : sequence.getTracks()) {
trackNumber++; trackNumber++;
@ -28,6 +58,9 @@ public class Test {
String noteName = NOTE_NAMES[note]; String noteName = NOTE_NAMES[note];
int velocity = sm.getData2(); int velocity = sm.getData2();
System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity); System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity);
notes.add(noteName + octave);
} else if (sm.getCommand() == NOTE_OFF) { } else if (sm.getCommand() == NOTE_OFF) {
int key = sm.getData1(); int key = sm.getData1();
int octave = (key / 12) - 1; int octave = (key / 12) - 1;
@ -44,6 +77,11 @@ public class Test {
} }
System.out.println(); System.out.println();
}
}
System.out.println(notes);
} }
} }