Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ph4r05/WirelessSensorNodeGeolocation
base: 404a2a3d43
...
head fork: ph4r05/WirelessSensorNodeGeolocation
compare: 50112ecde5
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 23, 2011
ph4r05 remove aged components from RSSI_IN_TIME and DISTANCE_IN_TIME graphs.…
… Only 5 minutes old records are left
83345cf
ph4r05 graph aging, log panel aging.
Logpanel:
	* aging of messages. Leaving only last 2000-3000 messages.
	* new features from menu: enable/disable autoscroll, enable/disable debug loging, delete debug messages, clear log
50112ec
View
11 src/rssi_graph/JPanelLogger.form
@@ -1,6 +1,17 @@
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+ <NonVisualComponents>
+ <Container class="javax.swing.JPopupMenu" name="jPopupMenu1">
+ <Properties>
+ <Property name="name" type="java.lang.String" value="jPopupMenu1" noResource="true"/>
+ </Properties>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout">
+ <Property name="useNullLayout" type="boolean" value="true"/>
+ </Layout>
+ </Container>
+ </NonVisualComponents>
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
View
81 src/rssi_graph/JPanelLogger.java
@@ -26,6 +26,9 @@
*/
public class JPanelLogger extends javax.swing.JPanel implements Cloneable {
+ public static final int MAX_LINES=2000;
+ public static final int MAX_LINES_THRESHOLD=3000;
+
/**
* Do auto scroll?
*/
@@ -62,6 +65,11 @@
* Log window to mirror sent log messages
*/
protected JPanelLogger logMirror = null;
+
+ /**
+ * log debug messages?
+ */
+ protected boolean logDebugMessages = true;
/** Creates new form JPanelLogger */
public JPanelLogger() {
@@ -125,6 +133,29 @@ public void clearArea(){
this.logMirror.clearArea();
}
}
+
+ /**
+ * Removes messages with given severity from log
+ * @param severity
+ */
+ public void removeSeverityFromLog(int severity){
+ Iterator<JPannelLoggerLogElement> iterator = this.lines.iterator();
+ while(iterator.hasNext()){
+ JPannelLoggerLogElement curElem = iterator.next();
+
+ // null
+ if (curElem==null || curElem.getSeverity() == severity){
+ iterator.remove();
+ continue;
+ }
+ }
+
+ this.rewrite();
+
+ if (this.logMirror!=null){
+ this.logMirror.removeSeverityFromLog(severity);
+ }
+ }
/**
* Rewrites log window according to parameters
@@ -154,6 +185,13 @@ public synchronized void appendLog(JPannelLoggerLogElement a){
// get date string from time
// this could call jPannelLoggerLogElement method to be polymorphic
// adding this class to linked list should be allowed
+
+ // add to buffer?
+ if (this.isLogDebugMessages()==false && a.getSeverity() == JPannelLoggerLogElement.SEVERITY_DEBUG){
+ // debug messages forbiden, skip this message
+ return;
+ }
+
this.date.setTime(a.getTime());
this.append("[" + this.dateFormat.format(this.date) + "; " + a.getSeverityLabel() + " ;" + a.getTypeString() + "]: " + a.getText());
}
@@ -163,7 +201,26 @@ public synchronized void appendLog(JPannelLoggerLogElement a){
* Add specified log entry to log window and to linked list
* @param a
*/
- public void addLogEntry(JPannelLoggerLogElement a){
+ public synchronized void addLogEntry(JPannelLoggerLogElement a){
+ // add to buffer?
+ if (this.isLogDebugMessages()==false && a.getSeverity() == JPannelLoggerLogElement.SEVERITY_DEBUG){
+ // debug messages forbiden, skip this message
+ return;
+ }
+
+ // size check
+ int curSize = this.lines.size();
+ if (curSize > MAX_LINES_THRESHOLD){
+ // prune list
+ for(int i=curSize - MAX_LINES; i>0; i--){
+ this.lines.removeFirst();
+ }
+
+ // force to rewrite log window
+ this.rewrite();
+ }
+
+
this.lines.offer(a);
this.appendLog(a);
this.jTextArea1.repaint();
@@ -244,6 +301,10 @@ public boolean isAutoscroll() {
public synchronized void setAutoscroll(boolean autoscroll) {
this.autoscroll = autoscroll;
+
+ if (this.logMirror!=null){
+ this.logMirror.setAutoscroll(autoscroll);
+ }
}
public String getDateFormatString() {
@@ -298,6 +359,20 @@ public void setLogMirror(JPanelLogger logMirror) {
this.logMirror = logMirror;
}
+ public boolean isLogDebugMessages() {
+ return logDebugMessages;
+ }
+
+ public void setLogDebugMessages(boolean logDebugMessages) {
+ this.logDebugMessages = logDebugMessages;
+
+ if (this.logMirror!=null){
+ this.logMirror.setLogDebugMessages(logDebugMessages);
+ }
+ }
+
+
+
/**
* =========================================================================
*
@@ -315,9 +390,12 @@ public void setLogMirror(JPanelLogger logMirror) {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
+ jPopupMenu1 = new javax.swing.JPopupMenu();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
+ jPopupMenu1.setName("jPopupMenu1"); // NOI18N
+
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(rssi_graph.RSSI_graphApp.class).getContext().getResourceMap(JPanelLogger.class);
setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("Form.border.title"))); // NOI18N
setName("Form"); // NOI18N
@@ -345,6 +423,7 @@ private void initComponents() {
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration//GEN-END:variables
View
46 src/rssi_graph/RSSI_graphView.form
@@ -1858,6 +1858,52 @@
</MenuItem>
</SubComponents>
</Menu>
+ <Menu class="javax.swing.JMenu" name="jMenu1">
+ <Properties>
+ <Property name="text" type="java.lang.String" resourceKey="jMenu1.text"/>
+ <Property name="name" type="java.lang.String" value="jMenu1" noResource="true"/>
+ </Properties>
+ <SubComponents>
+ <MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxLogDebugMessages">
+ <Properties>
+ <Property name="selected" type="boolean" value="true"/>
+ <Property name="text" type="java.lang.String" resourceKey="jCheckBoxLogDebugMessages.text"/>
+ <Property name="name" type="java.lang.String" value="jCheckBoxLogDebugMessages" noResource="true"/>
+ </Properties>
+ <Events>
+ <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jCheckBoxLogDebugMessagesItemStateChanged"/>
+ </Events>
+ </MenuItem>
+ <MenuItem class="javax.swing.JCheckBoxMenuItem" name="jCheckBoxLogAutoScroll">
+ <Properties>
+ <Property name="selected" type="boolean" value="true"/>
+ <Property name="text" type="java.lang.String" resourceKey="jCheckBoxLogAutoScroll.text"/>
+ <Property name="name" type="java.lang.String" value="jCheckBoxLogAutoScroll" noResource="true"/>
+ </Properties>
+ <Events>
+ <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jCheckBoxLogAutoScrollItemStateChanged"/>
+ </Events>
+ </MenuItem>
+ <MenuItem class="javax.swing.JMenuItem" name="jMenuItemLogDeleteDebug">
+ <Properties>
+ <Property name="text" type="java.lang.String" resourceKey="jMenuItemLogDeleteDebug.text"/>
+ <Property name="name" type="java.lang.String" value="jMenuItemLogDeleteDebug" noResource="true"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItemLogDeleteDebugActionPerformed"/>
+ </Events>
+ </MenuItem>
+ <MenuItem class="javax.swing.JMenuItem" name="jMenuItemLogClear">
+ <Properties>
+ <Property name="text" type="java.lang.String" resourceKey="jMenuItemLogClear.text"/>
+ <Property name="name" type="java.lang.String" value="jMenuItemLogClear" noResource="true"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItemLogClearActionPerformed"/>
+ </Events>
+ </MenuItem>
+ </SubComponents>
+ </Menu>
<Menu class="javax.swing.JMenu" name="helpMenu">
<Properties>
<Property name="text" type="java.lang.String" resourceKey="helpMenu.text"/>
View
76 src/rssi_graph/RSSI_graphView.java
@@ -35,6 +35,7 @@
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -679,6 +680,11 @@ private void initComponents() {
javax.swing.JMenu fileMenu = new javax.swing.JMenu();
javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
jCheckExternalLog = new javax.swing.JCheckBoxMenuItem();
+ jMenu1 = new javax.swing.JMenu();
+ jCheckBoxLogDebugMessages = new javax.swing.JCheckBoxMenuItem();
+ jCheckBoxLogAutoScroll = new javax.swing.JCheckBoxMenuItem();
+ jMenuItemLogDeleteDebug = new javax.swing.JMenuItem();
+ jMenuItemLogClear = new javax.swing.JMenuItem();
javax.swing.JMenu helpMenu = new javax.swing.JMenu();
javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
statusPanel = new javax.swing.JPanel();
@@ -1857,6 +1863,49 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
menuBar.add(fileMenu);
+ jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
+ jMenu1.setName("jMenu1"); // NOI18N
+
+ jCheckBoxLogDebugMessages.setSelected(true);
+ jCheckBoxLogDebugMessages.setText(resourceMap.getString("jCheckBoxLogDebugMessages.text")); // NOI18N
+ jCheckBoxLogDebugMessages.setName("jCheckBoxLogDebugMessages"); // NOI18N
+ jCheckBoxLogDebugMessages.addItemListener(new java.awt.event.ItemListener() {
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ jCheckBoxLogDebugMessagesItemStateChanged(evt);
+ }
+ });
+ jMenu1.add(jCheckBoxLogDebugMessages);
+
+ jCheckBoxLogAutoScroll.setSelected(true);
+ jCheckBoxLogAutoScroll.setText(resourceMap.getString("jCheckBoxLogAutoScroll.text")); // NOI18N
+ jCheckBoxLogAutoScroll.setName("jCheckBoxLogAutoScroll"); // NOI18N
+ jCheckBoxLogAutoScroll.addItemListener(new java.awt.event.ItemListener() {
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ jCheckBoxLogAutoScrollItemStateChanged(evt);
+ }
+ });
+ jMenu1.add(jCheckBoxLogAutoScroll);
+
+ jMenuItemLogDeleteDebug.setText(resourceMap.getString("jMenuItemLogDeleteDebug.text")); // NOI18N
+ jMenuItemLogDeleteDebug.setName("jMenuItemLogDeleteDebug"); // NOI18N
+ jMenuItemLogDeleteDebug.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jMenuItemLogDeleteDebugActionPerformed(evt);
+ }
+ });
+ jMenu1.add(jMenuItemLogDeleteDebug);
+
+ jMenuItemLogClear.setText(resourceMap.getString("jMenuItemLogClear.text")); // NOI18N
+ jMenuItemLogClear.setName("jMenuItemLogClear"); // NOI18N
+ jMenuItemLogClear.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jMenuItemLogClearActionPerformed(evt);
+ }
+ });
+ jMenu1.add(jMenuItemLogClear);
+
+ menuBar.add(jMenu1);
+
helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
helpMenu.setName("helpMenu"); // NOI18N
@@ -2051,6 +2100,28 @@ private void jButtonChangePacketSourceActionPerformed(java.awt.event.ActionEvent
RSSI_graphApp.getApplication().show(packetSource);
}//GEN-LAST:event_jButtonChangePacketSourceActionPerformed
+ private void jCheckBoxLogDebugMessagesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBoxLogDebugMessagesItemStateChanged
+ boolean logDebugMessages = evt.getStateChange() == ItemEvent.SELECTED;
+ this.jPanelLogger1.setLogDebugMessages(logDebugMessages);
+ }//GEN-LAST:event_jCheckBoxLogDebugMessagesItemStateChanged
+
+ private void jCheckBoxLogAutoScrollItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBoxLogAutoScrollItemStateChanged
+ // TODO add your handling code here:
+ boolean autoScroll = evt.getStateChange() == ItemEvent.SELECTED;
+ this.jPanelLogger1.setAutoscroll(autoScroll);
+ }//GEN-LAST:event_jCheckBoxLogAutoScrollItemStateChanged
+
+ private void jMenuItemLogDeleteDebugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLogDeleteDebugActionPerformed
+ // TODO add your handling code here:
+ this.jPanelLogger1.removeSeverityFromLog(JPannelLoggerLogElement.SEVERITY_DEBUG);
+ }//GEN-LAST:event_jMenuItemLogDeleteDebugActionPerformed
+
+ private void jMenuItemLogClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLogClearActionPerformed
+ // TODO add your handling code here:
+ this.jPanelLogger1.clearData();
+ this.jPanelLogger1.rewrite();
+ }//GEN-LAST:event_jMenuItemLogClearActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
@@ -2082,6 +2153,8 @@ private void jButtonChangePacketSourceActionPerformed(java.awt.event.ActionEvent
private javax.swing.JButton jButton_comm_setReportGap;
private javax.swing.JButton jButton_drop;
private javax.swing.JButton jButton_save;
+ private javax.swing.JCheckBoxMenuItem jCheckBoxLogAutoScroll;
+ private javax.swing.JCheckBoxMenuItem jCheckBoxLogDebugMessages;
private javax.swing.JCheckBoxMenuItem jCheckExternalLog;
private javax.swing.JCheckBox jCheckSampleSensorDataReadings;
private javax.swing.JCheckBox jCheckSensorReadingBroadcast;
@@ -2114,6 +2187,9 @@ private void jButtonChangePacketSourceActionPerformed(java.awt.event.ActionEvent
private javax.swing.JLabel jMarkerParameter;
private javax.swing.JLabel jMarkerSaveNext;
private javax.swing.JLabel jMarkerStart;
+ private javax.swing.JMenu jMenu1;
+ private javax.swing.JMenuItem jMenuItemLogClear;
+ private javax.swing.JMenuItem jMenuItemLogDeleteDebug;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel10;
private javax.swing.JPanel jPanel11;
View
2  src/rssi_graph/localization/JPanelDistanceInTime.java
@@ -157,6 +157,8 @@ protected void updateValues(){
ts = this.timeSeries.get(curTimeSerieKey);
}
+ // age items in time series
+ ts.removeAgedItems(300000, false);
ts.add(now, distanceFunction.getDistanceFromRSSI(floatingMean.get(curAnchor)));
this.timeSeries.put(curTimeSerieKey, ts);
}
View
8 src/rssi_graph/localization/JPanelRSSIInTime.java
@@ -51,6 +51,8 @@
*/
public class JPanelRSSIInTime extends javax.swing.JPanel implements ActionListener {
+ public static final int MAX_MEMORY_ELEMENTS=10000;
+
private Timer grabTimer = null;
private WorkerLocalization worker = null;
private Map<String, TimeSeries> timeSeries = null;
@@ -147,7 +149,7 @@ protected synchronized void updateValues(){
// generate key for time serie
String curTimeSerieKey = "T"+mn.getMobile_nodeID()+";R"+curAnchor;
TimeSeries ts = null;
-
+
// does time serie exist?
if (!this.timeSeries.containsKey(curTimeSerieKey)){
redrawGraphNeeded=true;
@@ -161,6 +163,8 @@ protected synchronized void updateValues(){
ts = this.timeSeries.get(curTimeSerieKey);
}
+ // age items in time series
+ ts.removeAgedItems(300, true);
ts.add(now, floatingMean.get(curAnchor));
this.timeSeries.put(curTimeSerieKey, ts);
}
@@ -287,7 +291,7 @@ protected void drawGraph(){
this.revalidate();
}
- public void actionPerformed(ActionEvent e) {
+ public synchronized void actionPerformed(ActionEvent e) {
if ("grabTimer".equals(e.getActionCommand())){
this.updateValues();
}
View
5 src/rssi_graph/resources/RSSI_graphView.properties
@@ -164,3 +164,8 @@ jButtonResetListener.text=[Reset listener]
jButtonResetSender.text=[Reset sender]
jButtonResetPacketSource.text=[Reset Packet Source]
jButtonChangePacketSource.text=[Change packet source]
+jMenu1.text=Logs
+jCheckBoxLogDebugMessages.text=Log debug messages
+jCheckBoxLogAutoScroll.text=Auto scroll
+jMenuItemLogDeleteDebug.text=Delete debug from log
+jMenuItemLogClear.text=Clear log

No commit comments for this range

Something went wrong with that request. Please try again.