Bug fix: use getNodeTime() instead of getSystemTime()
This commit is contained in:
parent
87036b0089
commit
4b0ffb0739
2 changed files with 29 additions and 13 deletions
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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
|
* Authors : Joakim Eriksson, Niclas Finne
|
||||||
* Created : 3 jul 2008
|
* Created : 3 jul 2008
|
||||||
* Updated : $Date: 2010/09/14 10:38:12 $
|
* Updated : $Date: 2010/09/14 11:27:23 $
|
||||||
* $Revision: 1.13 $
|
* $Revision: 1.14 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.contiki.collect;
|
package se.sics.contiki.collect;
|
||||||
|
@ -143,6 +143,8 @@ public class CollectServer {
|
||||||
private SerialConnection serialConnection;
|
private SerialConnection serialConnection;
|
||||||
private String initScript;
|
private String initScript;
|
||||||
|
|
||||||
|
private long nodeTimeDelta;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public CollectServer(String comPort) {
|
public CollectServer(String comPort) {
|
||||||
loadConfig(config, CONFIG_FILE);
|
loadConfig(config, CONFIG_FILE);
|
||||||
|
@ -399,10 +401,10 @@ public class CollectServer {
|
||||||
int dataCount = node.getSensorDataCount();
|
int dataCount = node.getSensorDataCount();
|
||||||
int packetCount = 0;
|
int packetCount = 0;
|
||||||
int duplicateCount = 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--) {
|
for(int index = dataCount - 1; index >= 0; index--) {
|
||||||
SensorData sd = node.getSensorData(index);
|
SensorData sd = node.getSensorData(index);
|
||||||
if (sd.getSystemTime() < earliestData) {
|
if (sd.getNodeTime() < earliestData) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sd.isDuplicate()) {
|
if (sd.isDuplicate()) {
|
||||||
|
@ -943,6 +945,18 @@ public class CollectServer {
|
||||||
serialConsole.addSerialData(line);
|
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
|
// SensorData handling
|
||||||
|
@ -959,6 +973,7 @@ public class CollectServer {
|
||||||
private void handleSensorData(final SensorData sensorData) {
|
private void handleSensorData(final SensorData sensorData) {
|
||||||
System.out.println("SENSOR DATA: " + sensorData);
|
System.out.println("SENSOR DATA: " + sensorData);
|
||||||
if (sensorData.getNode().addSensorData(sensorData)) {
|
if (sensorData.getNode().addSensorData(sensorData)) {
|
||||||
|
updateNodeTime(sensorData);
|
||||||
sensorDataList.add(sensorData);
|
sensorDataList.add(sensorData);
|
||||||
saveSensorData(sensorData);
|
saveSensorData(sensorData);
|
||||||
handleLinks(sensorData);
|
handleLinks(sensorData);
|
||||||
|
@ -1005,6 +1020,7 @@ public class CollectServer {
|
||||||
SensorData data = SensorData.parseSensorData(this, line);
|
SensorData data = SensorData.parseSensorData(this, line);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
if (data.getNode().addSensorData(data)) {
|
if (data.getNode().addSensorData(data)) {
|
||||||
|
updateNodeTime(data);
|
||||||
sensorDataList.add(data);
|
sensorDataList.add(data);
|
||||||
handleLinks(data);
|
handleLinks(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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
|
* Authors : Joakim Eriksson, Niclas Finne
|
||||||
* Created : 6 sep 2010
|
* Created : 6 sep 2010
|
||||||
* Updated : $Date: 2010/09/14 10:44:07 $
|
* Updated : $Date: 2010/09/14 11:27:24 $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.contiki.collect.gui;
|
package se.sics.contiki.collect.gui;
|
||||||
|
@ -146,7 +146,7 @@ public class PacketChartPanel extends JPanel implements Visualizer {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
series.clear();
|
series.clear();
|
||||||
if (this.selectedNodes != null && server.getSensorDataCount() > 0) {
|
if (this.selectedNodes != null && server.getSensorDataCount() > 0) {
|
||||||
long minute = server.getSensorData(0).getSystemTime() / 60000;
|
long minute = server.getSensorData(0).getNodeTime() / 60000;
|
||||||
long lastMinute = minute;
|
long lastMinute = minute;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for(int i = 0; i < server.getSensorDataCount(); i++) {
|
for(int i = 0; i < server.getSensorDataCount(); i++) {
|
||||||
|
@ -158,12 +158,12 @@ public class PacketChartPanel extends JPanel implements Visualizer {
|
||||||
long min = sd.getNodeTime() / 60000;
|
long min = sd.getNodeTime() / 60000;
|
||||||
if (min != minute) {
|
if (min != minute) {
|
||||||
if (lastMinute < 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) {
|
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;
|
count = 0;
|
||||||
lastMinute = minute + 1;
|
lastMinute = minute + 1;
|
||||||
minute = min;
|
minute = min;
|
||||||
|
@ -174,7 +174,7 @@ public class PacketChartPanel extends JPanel implements Visualizer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
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();
|
int nodes = selectedMap.size();
|
||||||
|
|
Loading…
Reference in a new issue