Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iriutils
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
algorithms
iriutils
Commits
53831eea
Commit
53831eea
authored
13 years ago
by
Martí Morta Garriga
Browse files
Options
Downloads
Patches
Plain Diff
Added ref time function
parent
6196f725
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/time/ctime.cpp
+47
-11
47 additions, 11 deletions
src/time/ctime.cpp
src/time/ctime.h
+2
-0
2 additions, 0 deletions
src/time/ctime.h
with
49 additions
and
11 deletions
src/time/ctime.cpp
+
47
−
11
View file @
53831eea
...
@@ -128,8 +128,12 @@ void CTime::set(double milliseconds)
...
@@ -128,8 +128,12 @@ void CTime::set(double milliseconds)
this
->
nsec
=
time_temp
.
tv_nsec
;
this
->
nsec
=
time_temp
.
tv_nsec
;
if
(
this
->
use_zero
&&
milliseconds
<
0.0
)
if
(
this
->
use_zero
&&
milliseconds
<
0.0
)
{
{
this
->
sec
-=
this
->
zero
.
seconds
();
CTime
tmp
;
this
->
nsec
-=
this
->
zero
.
nanoseconds
();
tmp
.
sec
=
this
->
sec
;
tmp
.
nsec
=
this
->
nsec
;
tmp
=
diff
(
tmp
,
this
->
zero
);
this
->
sec
=
tmp
.
sec
;
this
->
nsec
=
tmp
.
nsec
;
}
}
}
}
...
@@ -153,6 +157,21 @@ void CTime::resetRef()
...
@@ -153,6 +157,21 @@ void CTime::resetRef()
void
CTime
::
useRef
(
bool
use
)
void
CTime
::
useRef
(
bool
use
)
{
{
this
->
use_zero
=
use
;
this
->
use_zero
=
use
;
CTime
tmp
;
tmp
.
sec
=
this
->
sec
;
tmp
.
nsec
=
this
->
nsec
;
tmp
=
diff
(
tmp
,
this
->
zero
);
this
->
sec
=
tmp
.
sec
;
this
->
nsec
=
tmp
.
nsec
;
/*
if ( (long)this->nsec - (long)this->zero.seconds() < 0 )
{
this->sec -= this->zero.seconds() - 1;
this->nsec += 1000000000 - this->zero.nanoseconds();
} else {
this->sec -= this->zero.seconds();
this->nsec -= this->zero.nanoseconds();
}*/
}
}
bool
CTime
::
isRefUsed
()
bool
CTime
::
isRefUsed
()
...
@@ -160,23 +179,40 @@ bool CTime::isRefUsed()
...
@@ -160,23 +179,40 @@ bool CTime::isRefUsed()
return
this
->
use_zero
;
return
this
->
use_zero
;
}
}
// OPERATIONS
CTime
CTime
::
diff
(
CTime
&
t0
,
CTime
&
t1
)
CTime
CTime
::
operator
-
(
CTime
&
t
)
{
{
CTime
tmp
;
CTime
tmp
;
tmp
=
t0
;
if
(
(
long
)
t
his
->
nsec
-
(
long
)
t
.
n
sec
<
0
)
if
(
(
long
)
t
0
.
nsec
-
(
long
)
t
1
.
sec
<
0
)
{
{
tmp
.
sec
=
this
->
sec
-
t
.
sec
-
1
;
tmp
.
sec
-
=
t
1
.
sec
-
1
;
tmp
.
nsec
=
1000000000
+
this
->
nsec
-
t
.
nsec
;
tmp
.
nsec
+
=
1000000000
-
t
1
.
nsec
;
}
else
{
}
else
{
tmp
.
sec
=
t
his
->
sec
-
t
.
sec
;
tmp
.
sec
-
=
t
1
.
sec
;
tmp
.
nsec
=
t
his
->
nsec
-
t
.
nsec
;
tmp
.
nsec
-
=
t
1
.
nsec
;
}
}
return
tmp
;
return
tmp
;
}
}
// OPERATIONS
CTime
CTime
::
operator
-
(
CTime
&
t
)
{
CTime
tmp
;
tmp
.
sec
=
this
->
sec
;
tmp
.
nsec
=
this
->
nsec
;
// if ( (long)this->nsec - (long)t.nsec < 0 )
// {
// tmp.sec = this->sec - t.sec - 1;
// tmp.nsec = 1000000000 + this->nsec - t.nsec;
// } else {
// tmp.sec = this->sec - t.sec;
// tmp.nsec = this->nsec - t.nsec;
// }
return
diff
(
tmp
,
t
);
}
CTime
CTime
::
operator
+
(
CTime
&
t
)
CTime
CTime
::
operator
+
(
CTime
&
t
)
{
{
CTime
tmp
;
CTime
tmp
;
...
...
This diff is collapsed.
Click to expand it.
src/time/ctime.h
+
2
−
0
View file @
53831eea
...
@@ -310,6 +310,8 @@ class CTime
...
@@ -310,6 +310,8 @@ class CTime
*/
*/
void
resetRef
();
void
resetRef
();
CTime
diff
(
CTime
&
t0
,
CTime
&
t1
);
///@}
///@}
/// @name Operators
/// @name Operators
...
...
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