Merge branch 'master' of repos.ctdo.de:psychose
Conflicts: ekgplotter/ekgplotter/main.py
This commit is contained in:
commit
12138a9f57
|
@ -119,7 +119,6 @@ class OSCThread(threading.Thread):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logging.info(e)
|
logging.info(e)
|
||||||
|
|
||||||
|
|
||||||
self.unsubscribe_me()
|
self.unsubscribe_me()
|
||||||
self.osc_sock.close()
|
self.osc_sock.close()
|
||||||
logging.info("OSCThread is going down")
|
logging.info("OSCThread is going down")
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: log4j:log4j:1.2.9">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.9/log4j-1.2.9.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.9/log4j-1.2.9-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/log4j/log4j/1.2.9/log4j-1.2.9-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.snmp4j:snmp4j:1.9.1f">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/snmp4j/snmp4j/1.9.1f/snmp4j-1.9.1f.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/snmp4j/snmp4j/1.9.1f/snmp4j-1.9.1f-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/snmp4j/snmp4j/1.9.1f/snmp4j-1.9.1f-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
|
@ -17,6 +17,8 @@
|
||||||
<orderEntry type="library" name="Maven: asm:asm: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: com.jgoodies:forms:1.1-preview" level="project" />
|
||||||
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
<orderEntry type="library" name="Maven: jdom:jdom:1.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.snmp4j:snmp4j:1.9.1f" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: log4j:log4j:1.2.9" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
<artifactId>forms_rt</artifactId>
|
<artifactId>forms_rt</artifactId>
|
||||||
<version>7.0.3</version>
|
<version>7.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.snmp4j</groupId>
|
||||||
|
<artifactId>snmp4j</artifactId>
|
||||||
|
<version>1.9.1f</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -140,16 +140,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="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">
|
<component id="29a78" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<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"/>
|
<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"/>
|
||||||
|
@ -170,6 +160,16 @@
|
||||||
<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="0" 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>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -3,7 +3,6 @@ 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;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: lucas
|
* @author: lucas
|
||||||
|
@ -12,6 +11,7 @@ import java.util.Random;
|
||||||
public class ActorDisplay {
|
public class ActorDisplay {
|
||||||
private final static Color onColor = Color.WHITE;
|
private final static Color onColor = Color.WHITE;
|
||||||
private final static Color offColor = Color.RED;
|
private final static Color offColor = Color.RED;
|
||||||
|
private final static String offText = "no data";
|
||||||
|
|
||||||
private JPanel actorPanel;
|
private JPanel actorPanel;
|
||||||
private JLabel lblCaption;
|
private JLabel lblCaption;
|
||||||
|
@ -73,56 +73,58 @@ public class ActorDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActorDisplay() {
|
public ActorDisplay() {
|
||||||
final Random r = new Random();
|
|
||||||
|
|
||||||
final Timer timer = new Timer(100, new AbstractAction() {
|
final Timer timer = new Timer(100, new AbstractAction() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
// actorPanel.setBackground(new Color(r.nextInt(), false));
|
|
||||||
|
|
||||||
if (++counterTemperature > timeout) {
|
if (++counterTemperature > timeout) {
|
||||||
lblTemperature.setForeground(offColor);
|
lblTemperature.setForeground(offColor);
|
||||||
|
lblTemperature.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblTemperature.setForeground(onColor);
|
lblTemperature.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counterPulse > timeout) {
|
if (++counterPulse > timeout) {
|
||||||
lblPulse.setForeground(offColor);
|
lblPulse.setForeground(offColor);
|
||||||
|
lblPulse.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblPulse.setForeground(onColor);
|
lblPulse.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counterOxy > timeout) {
|
if (++counterOxy > timeout) {
|
||||||
lblOxy.setForeground(offColor);
|
lblOxy.setForeground(offColor);
|
||||||
|
lblOxy.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblOxy.setForeground(onColor);
|
lblOxy.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counterEkg > timeout) {
|
if (++counterEkg > timeout) {
|
||||||
lblEkg.setForeground(offColor);
|
lblEkg.setForeground(offColor);
|
||||||
|
lblEkg.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblEkg.setForeground(onColor);
|
lblEkg.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counterEmg > timeout) {
|
if (++counterEmg > timeout) {
|
||||||
lblEmg.setForeground(offColor);
|
lblEmg.setForeground(offColor);
|
||||||
|
lblEmg.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblEmg.setForeground(onColor);
|
lblEmg.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counterHeartbeat > timeout) {
|
if (++counterHeartbeat > timeout) {
|
||||||
lblHeartbeat.setForeground(offColor);
|
lblHeartbeat.setForeground(offColor);
|
||||||
|
lblHeartbeat.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblHeartbeat.setForeground(onColor);
|
lblHeartbeat.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counterBreath > timeout) {
|
if (++counterBreath > timeout) {
|
||||||
lblBreath.setForeground(offColor);
|
lblBreath.setForeground(offColor);
|
||||||
|
lblBreath.setText(offText);
|
||||||
} else {
|
} else {
|
||||||
lblBreath.setForeground(onColor);
|
lblBreath.setForeground(onColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
timer.setRepeats(true);
|
timer.setRepeats(true);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public class MainForm {
|
public class MainForm {
|
||||||
private ChaOSCclient osCclient;
|
private ChaOSCclient osCclient;
|
||||||
|
private SnmpStatClient snmpStatClient;
|
||||||
|
|
||||||
private JPanel mainPanel;
|
private JPanel mainPanel;
|
||||||
private ActorDisplay actor1;
|
private ActorDisplay actor1;
|
||||||
|
@ -27,8 +28,12 @@ public class MainForm {
|
||||||
private int totalMessageCount = 0;
|
private int totalMessageCount = 0;
|
||||||
private int messagesTempCounter = 0;
|
private int messagesTempCounter = 0;
|
||||||
|
|
||||||
public MainForm(ChaOSCclient chaOSCclient) {
|
private long totalTraffic = 0;
|
||||||
osCclient = chaOSCclient;
|
private long lastTraffic = 0;
|
||||||
|
|
||||||
|
public MainForm(final ChaOSCclient chaOSCclient, final SnmpStatClient snmpStatClient) {
|
||||||
|
this.osCclient = chaOSCclient;
|
||||||
|
this.snmpStatClient = snmpStatClient;
|
||||||
|
|
||||||
addActor("merle", "Proband 1", actor1);
|
addActor("merle", "Proband 1", actor1);
|
||||||
addActor("uwe", "Proband 2", actor2);
|
addActor("uwe", "Proband 2", actor2);
|
||||||
|
@ -46,6 +51,18 @@ public class MainForm {
|
||||||
});
|
});
|
||||||
timer.setRepeats(true);
|
timer.setRepeats(true);
|
||||||
timer.start();
|
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) {
|
public void acceptMessage(Date time, OSCMessage message) {
|
||||||
if (message.getArguments().length == 3) {
|
if (message.getArguments().length == 3) {
|
||||||
totalMessageCount++;
|
totalMessageCount++;
|
||||||
actorDisplay.setHeartbeat(message.getArguments()[0].toString());
|
actorDisplay.setHeartbeat(message.getArguments()[0].toString().equals("0") ? "Systole" : "Diastole");
|
||||||
actorDisplay.setPulse(message.getArguments()[1].toString());
|
actorDisplay.setPulse(message.getArguments()[1].toString());
|
||||||
actorDisplay.setOxy(message.getArguments()[2].toString());
|
actorDisplay.setOxy(message.getArguments()[2].toString());
|
||||||
}
|
}
|
||||||
|
@ -111,7 +128,8 @@ public class MainForm {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final ChaOSCclient chaOSCclient = new ChaOSCclient(host, port);
|
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");
|
final JFrame frame = new JFrame("MainForm");
|
||||||
frame.setContentPane(mainForm.mainPanel);
|
frame.setContentPane(mainForm.mainPanel);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
|
|
|
@ -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<Integer, Long> lastPorts = new HashMap<>();
|
||||||
|
private HashMap<Integer, Long> 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<TreeEvent> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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="de.psychose.StatsDisplay">
|
<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">
|
<grid id="27dc6" binding="statPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="20" y="20" width="248" height="180"/>
|
<xy x="20" y="20" width="248" height="180"/>
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
</component>
|
</component>
|
||||||
<vspacer id="9a59f">
|
<vspacer id="9a59f">
|
||||||
<constraints>
|
<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"/>
|
<grid row="5" 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="1d950" class="javax.swing.JLabel">
|
<component id="1d950" class="javax.swing.JLabel">
|
||||||
|
@ -47,16 +47,6 @@
|
||||||
<text value="Ev/Sek"/>
|
<text value="Ev/Sek"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</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">
|
<component id="54c59" class="javax.swing.JLabel" binding="lblMessageCount">
|
||||||
<constraints>
|
<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"/>
|
<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"/>
|
||||||
|
@ -77,7 +67,27 @@
|
||||||
<text value="-"/>
|
<text value="-"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="a2840" class="javax.swing.JLabel">
|
<component id="95ca8" 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="kb"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="b1b4b" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" 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="kb/Sek"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="af868" class="javax.swing.JLabel" binding="lblTraffic">
|
||||||
<constraints>
|
<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"/>
|
<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>
|
</constraints>
|
||||||
|
@ -87,6 +97,16 @@
|
||||||
<text value="-"/>
|
<text value="-"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="88e99" class="javax.swing.JLabel" binding="lblBandwidth">
|
||||||
|
<constraints>
|
||||||
|
<grid row="4" 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>
|
||||||
|
|
|
@ -11,6 +11,8 @@ public class StatsDisplay {
|
||||||
private JLabel lblMessageCount;
|
private JLabel lblMessageCount;
|
||||||
private JLabel lblMessagesPerSec;
|
private JLabel lblMessagesPerSec;
|
||||||
private JPanel statPanel;
|
private JPanel statPanel;
|
||||||
|
private JLabel lblTraffic;
|
||||||
|
private JLabel lblBandwidth;
|
||||||
|
|
||||||
public void setMessageCount(String count) {
|
public void setMessageCount(String count) {
|
||||||
lblMessageCount.setText(count);
|
lblMessageCount.setText(count);
|
||||||
|
@ -20,4 +22,12 @@ public class StatsDisplay {
|
||||||
lblMessagesPerSec.setText(messagesPerSec);
|
lblMessagesPerSec.setText(messagesPerSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTotalTraffic(String totalTraffic) {
|
||||||
|
lblTraffic.setText(totalTraffic);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBandwidth(String bandwidth) {
|
||||||
|
lblBandwidth.setText(bandwidth);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,13 @@ public class Test {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
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<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
|
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
|
||||||
for (NetworkInterface netint : Collections.list(nets)) {
|
for (NetworkInterface netint : Collections.list(nets)) {
|
||||||
displayInterfaceInformation(netint);
|
displayInterfaceInformation(netint);
|
||||||
|
|
|
@ -109,6 +109,63 @@ class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog):
|
||||||
self.text_list.setCurrentIndex(index)
|
self.text_list.setCurrentIndex(index)
|
||||||
self.text_list.clicked.emit(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):
|
class TextAnimation(QtCore.QObject):
|
||||||
animation_started = QtCore.pyqtSignal()
|
animation_started = QtCore.pyqtSignal()
|
||||||
|
@ -229,11 +286,14 @@ class MainWindow(KMainWindow, Ui_MainWindow):
|
||||||
self.animation = TextAnimation(self)
|
self.animation = TextAnimation(self)
|
||||||
self.db_dirty = False
|
self.db_dirty = False
|
||||||
self.is_animate = False
|
self.is_animate = False
|
||||||
|
self.fade_animation = None
|
||||||
|
|
||||||
self.is_auto_publish = False
|
self.is_auto_publish = False
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
|
self.fade_animation = FadeAnimation(self.live_text, 6, self)
|
||||||
|
|
||||||
self.font = QtGui.QFont("monospace", self.default_size)
|
self.font = QtGui.QFont("monospace", self.default_size)
|
||||||
self.font.setStyleHint(QtGui.QFont.TypeWriter)
|
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.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.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.next_action.triggered.connect(self.slot_next_item)
|
||||||
self.previous_action.triggered.connect(self.slot_previous_item)
|
self.previous_action.triggered.connect(self.slot_previous_item)
|
||||||
|
|
||||||
|
@ -433,6 +494,12 @@ class MainWindow(KMainWindow, Ui_MainWindow):
|
||||||
spacer = KToolBarSpacerAction(self.action_collection)
|
spacer = KToolBarSpacerAction(self.action_collection)
|
||||||
self.action_collection.addAction("1_spacer", spacer)
|
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")
|
self.previous_action = self.action_collection.addAction("previous_action")
|
||||||
icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page"))
|
icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page"))
|
||||||
self.previous_action.setIcon(icon)
|
self.previous_action.setIcon(icon)
|
||||||
|
@ -588,6 +655,10 @@ class MainWindow(KMainWindow, Ui_MainWindow):
|
||||||
self.preview_text.clear()
|
self.preview_text.clear()
|
||||||
self.slot_set_preview_defaults()
|
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):
|
def fill_combo_box(self):
|
||||||
self.text_combo.clear()
|
self.text_combo.clear()
|
||||||
|
|
Loading…
Reference in New Issue