Bug fix: use getNodeTime() instead of getSystemTime()

This commit is contained in:
nifi 2010-09-14 11:27:23 +00:00
parent 87036b0089
commit 4b0ffb0739
2 changed files with 29 additions and 13 deletions

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: CollectServer.java,v 1.13 2010/09/14 10:38:12 nifi Exp $
* $Id: CollectServer.java,v 1.14 2010/09/14 11:27:23 nifi Exp $
*
* -----------------------------------------------------------------
*
@ -34,8 +34,8 @@
*
* Authors : Joakim Eriksson, Niclas Finne
* Created : 3 jul 2008
* Updated : $Date: 2010/09/14 10:38:12 $
* $Revision: 1.13 $
* Updated : $Date: 2010/09/14 11:27:23 $
* $Revision: 1.14 $
*/
package se.sics.contiki.collect;
@ -143,6 +143,8 @@ public class CollectServer {
private SerialConnection serialConnection;
private String initScript;
private long nodeTimeDelta;
@SuppressWarnings("serial")
public CollectServer(String comPort) {
loadConfig(config, CONFIG_FILE);
@ -399,10 +401,10 @@ public class CollectServer {
int dataCount = node.getSensorDataCount();
int packetCount = 0;
int duplicateCount = 0;
long earliestData = System.currentTimeMillis() - (5 * 60 * 60 * 1000);
long earliestData = getNodeTime() - (5 * 60 * 1000);
for(int index = dataCount - 1; index >= 0; index--) {
SensorData sd = node.getSensorData(index);
if (sd.getSystemTime() < earliestData) {
if (sd.getNodeTime() < earliestData) {
break;
}
if (sd.isDuplicate()) {
@ -943,6 +945,18 @@ public class CollectServer {
serialConsole.addSerialData(line);
}
// -------------------------------------------------------------------
// Node time estimation
// -------------------------------------------------------------------
public long getNodeTime() {
return System.currentTimeMillis() + nodeTimeDelta;
}
private void updateNodeTime(SensorData sensorData) {
this.nodeTimeDelta = sensorData.getNodeTime() - System.currentTimeMillis();
}
// -------------------------------------------------------------------
// SensorData handling
@ -959,6 +973,7 @@ public class CollectServer {
private void handleSensorData(final SensorData sensorData) {
System.out.println("SENSOR DATA: " + sensorData);
if (sensorData.getNode().addSensorData(sensorData)) {
updateNodeTime(sensorData);
sensorDataList.add(sensorData);
saveSensorData(sensorData);
handleLinks(sensorData);
@ -1005,6 +1020,7 @@ public class CollectServer {
SensorData data = SensorData.parseSensorData(this, line);
if (data != null) {
if (data.getNode().addSensorData(data)) {
updateNodeTime(data);
sensorDataList.add(data);
handleLinks(data);
}

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: PacketChartPanel.java,v 1.4 2010/09/14 10:44:07 adamdunkels Exp $
* $Id: PacketChartPanel.java,v 1.5 2010/09/14 11:27:24 nifi Exp $
*
* -----------------------------------------------------------------
*
@ -34,8 +34,8 @@
*
* Authors : Joakim Eriksson, Niclas Finne
* Created : 6 sep 2010
* Updated : $Date: 2010/09/14 10:44:07 $
* $Revision: 1.4 $
* Updated : $Date: 2010/09/14 11:27:24 $
* $Revision: 1.5 $
*/
package se.sics.contiki.collect.gui;
@ -146,7 +146,7 @@ public class PacketChartPanel extends JPanel implements Visualizer {
int total = 0;
series.clear();
if (this.selectedNodes != null && server.getSensorDataCount() > 0) {
long minute = server.getSensorData(0).getSystemTime() / 60000;
long minute = server.getSensorData(0).getNodeTime() / 60000;
long lastMinute = minute;
int count = 0;
for(int i = 0; i < server.getSensorDataCount(); i++) {
@ -158,12 +158,12 @@ public class PacketChartPanel extends JPanel implements Visualizer {
long min = sd.getNodeTime() / 60000;
if (min != minute) {
if (lastMinute < minute) {
series.addOrUpdate(new Minute(new Date(lastMinute * 60000L)), 0);
series.add(new Minute(new Date(lastMinute * 60000L)), 0);
if (lastMinute < minute - 1) {
series.addOrUpdate(new Minute(new Date((minute - 1) * 60000L)), 0);
series.add(new Minute(new Date((minute - 1) * 60000L)), 0);
}
}
series.addOrUpdate(new Minute(new Date(minute * 60000L)), count);
series.add(new Minute(new Date(minute * 60000L)), count);
count = 0;
lastMinute = minute + 1;
minute = min;
@ -174,7 +174,7 @@ public class PacketChartPanel extends JPanel implements Visualizer {
}
}
if (count > 0) {
series.addOrUpdate(new Minute(new Date(minute * 60000L)), count);
series.add(new Minute(new Date(minute * 60000L)), count);
}
}
int nodes = selectedMap.size();