Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Rosjava Core Gradle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CeTI
ROS
ROS Java Packages
Rosjava Core Gradle
Commits
c3b095b4
Commit
c3b095b4
authored
Feb 20, 2015
by
Daniel Stonier
Browse files
Options
Downloads
Patches
Plain Diff
patch version bump, readying for release.
parent
4237745c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rosjava/src/main/java/org/ros/time/NtpTimeProvider.java
+10
-2
10 additions, 2 deletions
rosjava/src/main/java/org/ros/time/NtpTimeProvider.java
rosjava/src/test/java/org/ros/time/NtpTimeProviderTest.java
+4
-3
4 additions, 3 deletions
rosjava/src/test/java/org/ros/time/NtpTimeProviderTest.java
with
14 additions
and
5 deletions
rosjava/src/main/java/org/ros/time/NtpTimeProvider.java
+
10
−
2
View file @
c3b095b4
...
...
@@ -63,6 +63,7 @@ public class NtpTimeProvider implements TimeProvider {
this
.
scheduledExecutorService
=
scheduledExecutorService
;
wallTimeProvider
=
new
WallTimeProvider
();
ntpClient
=
new
NTPUDPClient
();
ntpClient
.
setDefaultTimeout
(
500
);
// timeout to 500ms
offset
=
0
;
scheduledFuture
=
null
;
}
...
...
@@ -70,12 +71,19 @@ public class NtpTimeProvider implements TimeProvider {
/**
* Update the current time offset from the configured NTP host.
*
* @throws IOException
* @throws IOException
: if ntpClient.getTime() fails too often.
*/
public
void
updateTime
()
throws
IOException
{
List
<
Long
>
offsets
=
Lists
.
newArrayList
();
int
failures
=
0
;
for
(
int
i
=
0
;
i
<
SAMPLE_SIZE
;
i
++)
{
try
{
offsets
.
add
(
computeOffset
());
}
catch
(
IOException
e
)
{
if
(
++
failures
>
SAMPLE_SIZE
/
2
)
{
throw
e
;
}
}
}
offset
=
CollectionMath
.
median
(
offsets
);
log
.
info
(
String
.
format
(
"NTP time offset: %d ms"
,
offset
));
...
...
This diff is collapsed.
Click to expand it.
rosjava/src/test/java/org/ros/time/NtpTimeProviderTest.java
+
4
−
3
View file @
c3b095b4
...
...
@@ -45,7 +45,7 @@ public class NtpTimeProviderTest extends RosTest {
nodeMainExecutor
.
execute
(
new
AbstractNodeMain
()
{
@Override
public
GraphName
getDefaultNodeName
()
{
return
GraphName
.
of
(
"n
o
de"
);
return
GraphName
.
of
(
"n
tp_time_provi
de
r
"
);
}
@Override
...
...
@@ -53,7 +53,6 @@ public class NtpTimeProviderTest extends RosTest {
try
{
ntpTimeProvider
.
updateTime
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"Dude"
);
// Ignored. This is only a sanity check.
}
ntpTimeProvider
.
getCurrentTime
();
...
...
@@ -62,6 +61,8 @@ public class NtpTimeProviderTest extends RosTest {
latch
.
countDown
();
}
},
nodeConfiguration
);
assertTrue
(
latch
.
await
(
1
,
TimeUnit
.
SECONDS
));
boolean
result
=
latch
.
await
(
10
,
TimeUnit
.
SECONDS
);
//System.out.println("Latch waiting : " + latch.getCount() + " " + result + " [" + System.currentTimeMillis() + "]");
assertTrue
(
result
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment