diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py
index 249e540..37a0009 100644
--- a/ekgplotter/ekgplotter/main.py
+++ b/ekgplotter/ekgplotter/main.py
@@ -119,7 +119,6 @@ class OSCThread(threading.Thread):
except Exception, e:
logging.info(e)
-
self.unsubscribe_me()
self.osc_sock.close()
logging.info("OSCThread is going down")
diff --git a/healthdisplay/.idea/libraries/Maven__log4j_log4j_1_2_9.xml b/healthdisplay/.idea/libraries/Maven__log4j_log4j_1_2_9.xml
new file mode 100644
index 0000000..37a2238
--- /dev/null
+++ b/healthdisplay/.idea/libraries/Maven__log4j_log4j_1_2_9.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/healthdisplay/.idea/libraries/Maven__org_snmp4j_snmp4j_1_9_1f.xml b/healthdisplay/.idea/libraries/Maven__org_snmp4j_snmp4j_1_9_1f.xml
new file mode 100644
index 0000000..31252ff
--- /dev/null
+++ b/healthdisplay/.idea/libraries/Maven__org_snmp4j_snmp4j_1_9_1f.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/healthdisplay/healthdisplay.iml b/healthdisplay/healthdisplay.iml
index 8a76843..d987de2 100644
--- a/healthdisplay/healthdisplay.iml
+++ b/healthdisplay/healthdisplay.iml
@@ -17,6 +17,8 @@
+
+
diff --git a/healthdisplay/pom.xml b/healthdisplay/pom.xml
index 30de015..53cfc74 100644
--- a/healthdisplay/pom.xml
+++ b/healthdisplay/pom.xml
@@ -25,6 +25,11 @@
forms_rt
7.0.3
+
+ org.snmp4j
+ snmp4j
+ 1.9.1f
+
diff --git a/healthdisplay/src/main/java/de/psychose/ActorDisplay.form b/healthdisplay/src/main/java/de/psychose/ActorDisplay.form
index 1884b4e..d72dc0a 100644
--- a/healthdisplay/src/main/java/de/psychose/ActorDisplay.form
+++ b/healthdisplay/src/main/java/de/psychose/ActorDisplay.form
@@ -140,16 +140,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -170,6 +160,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/healthdisplay/src/main/java/de/psychose/ActorDisplay.java b/healthdisplay/src/main/java/de/psychose/ActorDisplay.java
index 542cd83..efe1d63 100644
--- a/healthdisplay/src/main/java/de/psychose/ActorDisplay.java
+++ b/healthdisplay/src/main/java/de/psychose/ActorDisplay.java
@@ -3,7 +3,6 @@ package de.psychose;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
-import java.util.Random;
/**
* @author: lucas
@@ -12,6 +11,7 @@ import java.util.Random;
public class ActorDisplay {
private final static Color onColor = Color.WHITE;
private final static Color offColor = Color.RED;
+ private final static String offText = "no data";
private JPanel actorPanel;
private JLabel lblCaption;
@@ -73,56 +73,58 @@ public class ActorDisplay {
}
public ActorDisplay() {
- final Random r = new Random();
-
final Timer timer = new Timer(100, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
-// actorPanel.setBackground(new Color(r.nextInt(), false));
-
if (++counterTemperature > timeout) {
lblTemperature.setForeground(offColor);
+ lblTemperature.setText(offText);
} else {
lblTemperature.setForeground(onColor);
}
if (++counterPulse > timeout) {
lblPulse.setForeground(offColor);
+ lblPulse.setText(offText);
} else {
lblPulse.setForeground(onColor);
}
if (++counterOxy > timeout) {
lblOxy.setForeground(offColor);
+ lblOxy.setText(offText);
} else {
lblOxy.setForeground(onColor);
}
if (++counterEkg > timeout) {
lblEkg.setForeground(offColor);
+ lblEkg.setText(offText);
} else {
lblEkg.setForeground(onColor);
}
if (++counterEmg > timeout) {
lblEmg.setForeground(offColor);
+ lblEmg.setText(offText);
} else {
lblEmg.setForeground(onColor);
}
if (++counterHeartbeat > timeout) {
lblHeartbeat.setForeground(offColor);
+ lblHeartbeat.setText(offText);
} else {
lblHeartbeat.setForeground(onColor);
}
if (++counterBreath > timeout) {
lblBreath.setForeground(offColor);
+ lblBreath.setText(offText);
} else {
lblBreath.setForeground(onColor);
}
-
}
});
timer.setRepeats(true);
diff --git a/healthdisplay/src/main/java/de/psychose/MainForm.java b/healthdisplay/src/main/java/de/psychose/MainForm.java
index d4cd4b1..45fe384 100644
--- a/healthdisplay/src/main/java/de/psychose/MainForm.java
+++ b/healthdisplay/src/main/java/de/psychose/MainForm.java
@@ -17,6 +17,7 @@ import java.util.Date;
*/
public class MainForm {
private ChaOSCclient osCclient;
+ private SnmpStatClient snmpStatClient;
private JPanel mainPanel;
private ActorDisplay actor1;
@@ -27,8 +28,12 @@ public class MainForm {
private int totalMessageCount = 0;
private int messagesTempCounter = 0;
- public MainForm(ChaOSCclient chaOSCclient) {
- osCclient = chaOSCclient;
+ private long totalTraffic = 0;
+ private long lastTraffic = 0;
+
+ public MainForm(final ChaOSCclient chaOSCclient, final SnmpStatClient snmpStatClient) {
+ this.osCclient = chaOSCclient;
+ this.snmpStatClient = snmpStatClient;
addActor("merle", "Proband 1", actor1);
addActor("uwe", "Proband 2", actor2);
@@ -46,6 +51,18 @@ public class MainForm {
});
timer.setRepeats(true);
timer.start();
+
+ final Timer snmpTimer = new Timer(5000, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ totalTraffic = snmpStatClient.getTrafficSum();
+ statDisplay.setTotalTraffic(String.valueOf(totalTraffic / 1024));
+ statDisplay.setBandwidth(String.valueOf((totalTraffic - lastTraffic) / 1024 / 5));
+ lastTraffic = totalTraffic;
+ }
+ });
+ snmpTimer.setRepeats(true);
+ snmpTimer.start();
}
@@ -56,7 +73,7 @@ public class MainForm {
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 3) {
totalMessageCount++;
- actorDisplay.setHeartbeat(message.getArguments()[0].toString());
+ actorDisplay.setHeartbeat(message.getArguments()[0].toString().equals("0") ? "Systole" : "Diastole");
actorDisplay.setPulse(message.getArguments()[1].toString());
actorDisplay.setOxy(message.getArguments()[2].toString());
}
@@ -111,7 +128,8 @@ public class MainForm {
try {
final ChaOSCclient chaOSCclient = new ChaOSCclient(host, port);
- final MainForm mainForm = new MainForm(chaOSCclient);
+ final SnmpStatClient snmp = new SnmpStatClient("switch/161");
+ final MainForm mainForm = new MainForm(chaOSCclient, snmp);
final JFrame frame = new JFrame("MainForm");
frame.setContentPane(mainForm.mainPanel);
frame.setResizable(false);
diff --git a/healthdisplay/src/main/java/de/psychose/SnmpStatClient.java b/healthdisplay/src/main/java/de/psychose/SnmpStatClient.java
new file mode 100644
index 0000000..a523318
--- /dev/null
+++ b/healthdisplay/src/main/java/de/psychose/SnmpStatClient.java
@@ -0,0 +1,83 @@
+package de.psychose;
+
+import org.snmp4j.CommunityTarget;
+import org.snmp4j.Snmp;
+import org.snmp4j.TransportMapping;
+import org.snmp4j.mp.SnmpConstants;
+import org.snmp4j.smi.OID;
+import org.snmp4j.smi.OctetString;
+import org.snmp4j.smi.UdpAddress;
+import org.snmp4j.smi.VariableBinding;
+import org.snmp4j.transport.DefaultUdpTransportMapping;
+import org.snmp4j.util.DefaultPDUFactory;
+import org.snmp4j.util.TreeEvent;
+import org.snmp4j.util.TreeUtils;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author: lucas
+ * @date: 18.04.14 12:10
+ */
+public class SnmpStatClient {
+ public static final String OID_COUNTER = "1.3.6.1.2.1.2.2.1.10";
+ private final String host;
+ private HashMap lastPorts = new HashMap<>();
+ private HashMap sumPorts = new HashMap<>();
+
+ private CommunityTarget getCommunityTarget() {
+ CommunityTarget communityTarget = new CommunityTarget();
+ communityTarget.setCommunity(new OctetString("public"));
+ communityTarget.setVersion(SnmpConstants.version2c);
+ communityTarget.setAddress(new UdpAddress(host));
+ communityTarget.setTimeout(500);
+ return communityTarget;
+ }
+
+ public SnmpStatClient(String host) {
+ this.host = host;
+ }
+
+ public long getTrafficSum() {
+
+ long sum = 0;
+
+ try {
+ final TransportMapping transportMapping = new DefaultUdpTransportMapping();
+ transportMapping.listen();
+
+ final Snmp snmp = new Snmp(transportMapping);
+ final TreeUtils treeUtils = new TreeUtils(snmp, new DefaultPDUFactory());
+ final List treeEventList = treeUtils.getSubtree(getCommunityTarget(), new OID(OID_COUNTER));
+
+ for (TreeEvent treeEvent : treeEventList) {
+ if (treeEvent.getStatus() == TreeEvent.STATUS_OK) {
+ for (VariableBinding binding : treeEvent.getVariableBindings()) {
+ int oid = binding.getOid().last();
+ long value = binding.getVariable().toLong();
+ long lastValue = 0;
+ if(lastPorts.containsKey(oid)) lastValue = lastPorts.get(oid);
+ long diff = value - lastValue;
+
+ if(diff > 0) {
+ sumPorts.put(oid, lastValue + diff);
+ }
+ }
+ }
+ }
+
+ snmp.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ for(long port: sumPorts.values()) {
+ sum+=port;
+ }
+
+ return sum;
+ }
+
+}
diff --git a/healthdisplay/src/main/java/de/psychose/StatsDisplay.form b/healthdisplay/src/main/java/de/psychose/StatsDisplay.form
index 0dd0183..0ea389a 100644
--- a/healthdisplay/src/main/java/de/psychose/StatsDisplay.form
+++ b/healthdisplay/src/main/java/de/psychose/StatsDisplay.form
@@ -1,6 +1,6 @@
diff --git a/healthdisplay/src/main/java/de/psychose/StatsDisplay.java b/healthdisplay/src/main/java/de/psychose/StatsDisplay.java
index 4989777..7b3c76c 100644
--- a/healthdisplay/src/main/java/de/psychose/StatsDisplay.java
+++ b/healthdisplay/src/main/java/de/psychose/StatsDisplay.java
@@ -11,6 +11,8 @@ public class StatsDisplay {
private JLabel lblMessageCount;
private JLabel lblMessagesPerSec;
private JPanel statPanel;
+ private JLabel lblTraffic;
+ private JLabel lblBandwidth;
public void setMessageCount(String count) {
lblMessageCount.setText(count);
@@ -20,4 +22,12 @@ public class StatsDisplay {
lblMessagesPerSec.setText(messagesPerSec);
}
+ public void setTotalTraffic(String totalTraffic) {
+ lblTraffic.setText(totalTraffic);
+ }
+
+ public void setBandwidth(String bandwidth) {
+ lblBandwidth.setText(bandwidth);
+ }
+
}
diff --git a/healthdisplay/src/main/java/de/psychose/Test.java b/healthdisplay/src/main/java/de/psychose/Test.java
index deb48b6..6a1e54c 100644
--- a/healthdisplay/src/main/java/de/psychose/Test.java
+++ b/healthdisplay/src/main/java/de/psychose/Test.java
@@ -27,6 +27,13 @@ public class Test {
public static void main(String[] args) throws Exception {
+ SnmpStatClient snmpStatClient = new SnmpStatClient("switch/161");
+
+ System.out.println(snmpStatClient.getTrafficSum() / 1024 / 1024 + "MB");
+
+
+ if(true) return;
+
Enumeration nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets)) {
displayInterfaceInformation(netint);
diff --git a/texter/texter/main.py b/texter/texter/main.py
index b3b3f89..b2d4cca 100644
--- a/texter/texter/main.py
+++ b/texter/texter/main.py
@@ -109,6 +109,63 @@ class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog):
self.text_list.setCurrentIndex(index)
self.text_list.clicked.emit(index)
+class FadeAnimation(QtCore.QObject):
+ animation_started = QtCore.pyqtSignal()
+ animation_finished = QtCore.pyqtSignal()
+ animation_stopped = QtCore.pyqtSignal()
+
+ def __init__(self, live_text, fade_steps=6, parent=None):
+ super(FadeAnimation, self).__init__(parent)
+ self.live_text = live_text
+ self.fade_steps = fade_steps
+ self.current_alpha = 255
+ self.timer = None
+
+
+ def start_animation(self):
+ print "start_animation"
+ self.animation_started.emit()
+
+ if self.current_alpha == 255:
+ self.fade_delta = 255 / self.fade_steps
+ else:
+ self.fade_delta = -255 / self.fade_steps
+ self.timer = QtCore.QTimer(self)
+ self.timer.timeout.connect(self.slot_animate)
+ self.timer.start(100)
+
+
+ def slot_animate(self):
+ print "slot_animate"
+ print "current_alpha", self.current_alpha
+ if self.fade_delta > 0:
+ if self.current_alpha > 0:
+ self.live_text.setStyleSheet("color:%d, %d, %d;" % (self.current_alpha, self.current_alpha,self.current_alpha))
+ self.current_alpha -= self.fade_delta
+ else:
+ self.live_text.setStyleSheet("color:black;")
+ self.current_alpha = 0
+ self.timer.stop()
+ self.timer.timeout.disconnect(self.slot_animate)
+ self.timer.deleteLater()
+ self.timer = None
+ self.animation_finished.emit()
+ print "animation_finished"
+ else:
+ if self.current_alpha < 255:
+ self.live_text.setStyleSheet("color:%d,%d, %d;" % (self.current_alpha, self.current_alpha,self.current_alpha))
+ self.current_alpha -= self.fade_delta
+ else:
+ self.live_text.setStyleSheet("color:white")
+ self.current_alpha = 255
+ self.timer.stop()
+ self.timer.timeout.disconnect(self.slot_animate)
+ self.timer.deleteLater()
+ self.timer = None
+ self.animation_finished.emit()
+ print "animation_finished"
+
+
class TextAnimation(QtCore.QObject):
animation_started = QtCore.pyqtSignal()
@@ -229,10 +286,13 @@ class MainWindow(KMainWindow, Ui_MainWindow):
self.animation = TextAnimation(self)
self.db_dirty = False
self.is_animate = False
+ self.fade_animation = None
self.is_auto_publish = False
self.setupUi(self)
+
+ self.fade_animation = FadeAnimation(self.live_text, 6, self)
self.font = QtGui.QFont("monospace", self.default_size)
self.font.setStyleHint(QtGui.QFont.TypeWriter)
@@ -273,6 +333,7 @@ class MainWindow(KMainWindow, Ui_MainWindow):
self.preview_size_action.triggered[QtGui.QAction].connect(self.slot_preview_font_size)
self.live_size_action.triggered[QtGui.QAction].connect(self.slot_live_font_size)
+ self.fade_action.triggered.connect(self.slot_fade)
self.next_action.triggered.connect(self.slot_next_item)
self.previous_action.triggered.connect(self.slot_previous_item)
@@ -432,6 +493,12 @@ class MainWindow(KMainWindow, Ui_MainWindow):
spacer = KToolBarSpacerAction(self.action_collection)
self.action_collection.addAction("1_spacer", spacer)
+
+ self.fade_action = self.action_collection.addAction("fade_action")
+ #icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page"))
+ #self.fade_action.setIcon(icon)
+ self.fade_action.setIconText("fade")
+ self.fade_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut))
self.previous_action = self.action_collection.addAction("previous_action")
icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page"))
@@ -587,6 +654,10 @@ class MainWindow(KMainWindow, Ui_MainWindow):
def slot_clear_preview(self):
self.preview_text.clear()
self.slot_set_preview_defaults()
+
+ def slot_fade(self):
+ if self.fade_animation.timer is None:
+ self.fade_animation.start_animation()
def fill_combo_box(self):