Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
AcubeSat-OBC
ECSS Services
Commits
2e1df331
Commit
2e1df331
authored
6 years ago
by
thodkatz
Browse files
Options
Downloads
Patches
Plain Diff
Minor changes
parent
67456dd6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inc/Helpers/TimeHelper.hpp
+11
-7
11 additions, 7 deletions
inc/Helpers/TimeHelper.hpp
inc/Services/TimeManagementService.hpp
+3
-4
3 additions, 4 deletions
inc/Services/TimeManagementService.hpp
src/Helpers/TimeHelper.cpp
+11
-13
11 additions, 13 deletions
src/Helpers/TimeHelper.cpp
with
25 additions
and
24 deletions
inc/Helpers/TimeHelper.hpp
+
11
−
7
View file @
2e1df331
...
...
@@ -30,7 +30,8 @@ struct TimeAndDate {
*
* Note:
* Since this code is UTC-based, the leap second correction must be made. The leap seconds that
* have been occured between timestamps should be considered if a critical time-difference is needed
* have been occurred between timestamps should be considered if a critical time-difference is
* needed
*
*/
class
TimeHelper
{
...
...
@@ -54,10 +55,10 @@ private:
* @return the elapsed seconds between a given UTC date(after the Unix epoch) and Unix epoch
* @todo change the epoch for computer-efficiency
*/
uint32_t
mkUTCtime
(
struct
TimeAndDate
&
t
imeInfo
);
uint32_t
mkUTCtime
(
struct
TimeAndDate
&
T
imeInfo
);
/**
* Convert elapsed seconds since Unix epo
x
h to UTC date. This is a reimplemented gmtime() of
* Convert elapsed seconds since Unix epo
c
h to UTC date. This is a reimplemented gmtime() of
* <ctime> library in an embedded systems way
*
* @param seconds elapsed seconds since Unix epoch
...
...
@@ -88,13 +89,14 @@ public:
/**
* Parse the CDS time format(3.3 in CCSDS 301.0-B-4 standard)
*
* @param seconds elapsed seconds since Unix epoch
* @return the UTC date based on the /p
*/
static
struct
TimeAndDate
parseCDSTimeFormat
(
const
uint8_t
*
data
,
uint8_t
length
);
/**
* Dummy function created only to access mkUTCtime for testing
* Dummy function created only to access
`
mkUTCtime
`
for testing
*
* @todo Delete this function
*/
...
...
@@ -103,7 +105,7 @@ public:
}
/**
* Dummy function created only to access utcTime for testing
* Dummy function created only to access
`
utcTime
`
for testing
*
* @todo Delete this function
*/
...
...
@@ -112,8 +114,10 @@ public:
}
};
// used to access `mkgmtime` function and `gmtime` function in the static `implementCDSTimeFormat`
// and in the static `parseCDSTimeFormat functions
/**
* Used to access `mkgmtime` function and `gmtime` function in the static `implementCDSTimeFormat`
* and in the static `parseCDSTimeFormat` functions
*/
static
TimeHelper
Access
;
#endif //ECSS_SERVICES_TIMEHELPER_HPP
This diff is collapsed.
Click to expand it.
inc/Services/TimeManagementService.hpp
+
3
−
4
View file @
2e1df331
...
...
@@ -34,13 +34,13 @@ public:
serviceType
=
9
;
}
/**
/**
* TM[9,3] CDS time report
*
* This function sends reports with the spacecraft time that is formatted according to the CDS
* time code format(check class `TimeHelper` for the format)
*
* @param TimeInfo the time information/data from the RTC(UTC format)
* @param TimeInfo the time information/data from the RTC(UTC format)
* @todo check if we need spacecraft time reference status
* @todo ECSS standard claims: <<The time reports generated by the time reporting subservice
* are spacecraft time packets. A spacecraft time packet does not carry the message type,
...
...
@@ -58,8 +58,7 @@ public:
* time-management telecommand packet. This data is formatted according to the CDS time code
* format(check class `TimeHelper` for the format)
*
* @param timeData the data of the parsed space packet for the ST[09] time management
* @param length the size of the time data
* @param message the Message that will be parsed for its time-data
*/
struct
TimeAndDate
cdsTimeRequest
(
Message
&
message
);
};
...
...
This diff is collapsed.
Click to expand it.
src/Helpers/TimeHelper.cpp
+
11
−
13
View file @
2e1df331
...
...
@@ -10,26 +10,25 @@ bool TimeHelper::IsLeapYear(uint16_t year) {
return
(
year
%
400
)
==
0
;
}
uint32_t
TimeHelper
::
mkUTCtime
(
struct
TimeAndDate
&
t
imeInfo
)
{
uint32_t
TimeHelper
::
mkUTCtime
(
struct
TimeAndDate
&
T
imeInfo
)
{
uint32_t
secs
=
0
;
for
(
uint16_t
y
=
1970
;
y
<
t
imeInfo
.
year
;
++
y
)
{
for
(
uint16_t
y
=
1970
;
y
<
T
imeInfo
.
year
;
++
y
)
{
secs
+=
(
IsLeapYear
(
y
)
?
366
:
365
)
*
SecondsPerDay
;
}
for
(
uint16_t
m
=
1
;
m
<
t
imeInfo
.
month
;
++
m
)
{
for
(
uint16_t
m
=
1
;
m
<
T
imeInfo
.
month
;
++
m
)
{
secs
+=
DaysOfMonth
[
m
-
1
]
*
SecondsPerDay
;
if
(
m
==
2
&&
IsLeapYear
(
t
imeInfo
.
year
))
{
if
(
m
==
2
&&
IsLeapYear
(
T
imeInfo
.
year
))
{
secs
+=
SecondsPerDay
;
}
}
secs
+=
(
t
imeInfo
.
day
-
1
)
*
SecondsPerDay
;
secs
+=
t
imeInfo
.
hour
*
SecondsPerHour
;
secs
+=
t
imeInfo
.
minute
*
SecondsPerMinute
;
secs
+=
t
imeInfo
.
second
;
secs
+=
(
T
imeInfo
.
day
-
1
)
*
SecondsPerDay
;
secs
+=
T
imeInfo
.
hour
*
SecondsPerHour
;
secs
+=
T
imeInfo
.
minute
*
SecondsPerMinute
;
secs
+=
T
imeInfo
.
second
;
return
secs
;
}
struct
TimeAndDate
TimeHelper
::
utcTime
(
uint32_t
seconds
)
{
struct
TimeAndDate
TimeInfo
=
{
0
};
// Unix epoch 1/1/1970 00:00:00
TimeInfo
.
year
=
1970
;
...
...
@@ -92,15 +91,14 @@ uint64_t TimeHelper::implementCDSTimeFormat(struct TimeAndDate &TimeInfo) {
uint32_t
seconds
=
Access
.
mkUTCtime
(
TimeInfo
);
/**
* The `DAY` segment, 16 bits as defined from standard. Actually the days passed from an
* Agency-defined epoch,that it will be 1 January 1970(1/1/1970) 00:00:00(hours:minutes:seconds)
* This epoch is configured from the current implementation, using mktime() function
* The `DAY` segment, 16 bits as defined from standard. Actually the days passed since Unix
* epoch
*/
auto
elapsedDays
=
static_cast
<
uint16_t
>
(
seconds
/
86400
);
/**
* The `ms of day` segment, 32 bits as defined in standard. The `ms of the day` and DAY`
* should give the time passed
from the defined epoch (1/1/1970)
* should give the time passed
since Unix epoch
*/
auto
msOfDay
=
static_cast
<
uint32_t
>
((
seconds
%
86400
)
*
1000
);
...
...
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