Skip to content
Snippets Groups Projects
Commit 46119ea9 authored by NTUMBA WA NTUMBA Patient's avatar NTUMBA WA NTUMBA Patient
Browse files

synchronization

parent 8d5e321f
No related branches found
No related tags found
No related merge requests found
...@@ -91,7 +91,7 @@ public class MeasureAgent { ...@@ -91,7 +91,7 @@ public class MeasureAgent {
long localTimestamp_1 = clockSync.getAdjustedTime(); long localTimestamp_1 = clockSync.getAdjustedTime();
long ntpTimestamps = getTimestamp(); long ntpTimestamps = getTimestamp();
long localTimestamp_2 = clockSync.getAdjustedTime(); long localTimestamp_2 = clockSync.getAdjustedTime();
long deltaLocalTime = Math.round((localTimestamp_2 -localTimestamp_2)/2); long deltaLocalTime = Math.round((localTimestamp_2 -localTimestamp_1)/2);
setDeltaTime(ntpTimestamps - ( localTimestamp_1 + deltaLocalTime)); setDeltaTime(ntpTimestamps - ( localTimestamp_1 + deltaLocalTime));
} }
......
...@@ -48,7 +48,7 @@ public class LocalTimeServer extends Thread{ ...@@ -48,7 +48,7 @@ public class LocalTimeServer extends Thread{
String sentence = new String( receivePacket.getData()); String sentence = new String( receivePacket.getData());
InetAddress IPAddress = receivePacket.getAddress(); InetAddress IPAddress = receivePacket.getAddress();
int port = receivePacket.getPort(); int port = receivePacket.getPort();
String timestamp = ""+clockSync.getAdjustedTime()+""; String timestamp = ""+System.currentTimeMillis()+"";
response = timestamp.getBytes(); response = timestamp.getBytes();
System.out.println(" Receive request from "+IPAddress.getHostAddress()); System.out.println(" Receive request from "+IPAddress.getHostAddress());
DatagramPacket sendPacket = new DatagramPacket(response, response.length, IPAddress, port); DatagramPacket sendPacket = new DatagramPacket(response, response.length, IPAddress, port);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment