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
a58307d6
Commit
a58307d6
authored
5 years ago
by
thodkatz
Browse files
Options
Downloads
Patches
Plain Diff
Added CUC time format
parent
28026622
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/Helpers/TimeHelper.hpp
+42
-8
42 additions, 8 deletions
inc/Helpers/TimeHelper.hpp
src/Helpers/TimeHelper.cpp
+11
-0
11 additions, 0 deletions
src/Helpers/TimeHelper.cpp
with
53 additions
and
8 deletions
inc/Helpers/TimeHelper.hpp
+
42
−
8
View file @
a58307d6
...
...
@@ -13,15 +13,22 @@
* This class formats the spacecraft time and cooperates closely with the ST[09] time management.
*
* The ECSS standard supports two time formats: the CUC and CSD that are described in CCSDS
* 301.0-B-4 standard. The chosen time format is CDS and it is UTC-based (UTC: Coordinated
* Universal Time). It consists of two main fields: the time code preamble field (P-field) and
* the time specification field (T-field). The P-Field is the metadata for the T-Field. The
* T-Field is consisted of two segments: 1) the `DAY` and the 2) `ms of day` segments.
* The P-field won't be included in the code, because as the ECSS standards claims, it can be
* just implicitly declared.
* 301.0-B-4 standard.
*
* @note
* Since this code is UTC-based, the leap second correction must be made. The leap seconds that
* The CDS is UTC-based (UTC: Coordinated Universal Time). It consists of two main fields: the
* time code preamble field (P-field) and the time specification field (T-field). The P-Field is the metadata for the
* T-Field. The T-Field is consisted of two segments: 1) the `DAY` and the 2) `ms of day` segments. The P-field won't
* be included in the code, because as the ECSS standards claims, it can be just implicitly declared.
*
* The CUC time format consists of two main fields: the time code preamble field (P-field) and the time specification
* field(T-field). The T-Field contains the value of the time unit and the designer decides what the time unit will
* be, so this is a subject for discussion. The recommended time unit from the standard is the second and it is
* probably the best solution for accuracy.
*
* @notes
* The defined epoch for both time formats is 1 January 1958 00:00:00
*
* Since CDS format is UTC-based, the leap second correction must be made. The leap seconds that
* have been occurred between timestamps should be considered if a critical time-difference is
* needed
*
...
...
@@ -89,6 +96,33 @@ public:
* @return the UTC date
*/
static
TimeAndDate
parseCDStimeFormat
(
const
uint8_t
*
data
);
/**
* Generate the CUC time format (3.3 in CCSDS 301.0-B-4 standard).
*
* Converts a UTC date to CUC time format.
*
* @note
* The T-field is specified for the seconds passed from the defined epoch 1 January 1958. We use 4 octets(32
* bits) for the time unit(seconds) because 32 bits for the seconds are enough to count 136 years! But if we use 24
* bits for the seconds then it will count 0,5 years and this isn't enough. Remember we can use only integers
* numbers of octets for the time unit(second)
*
* @param TimeInfo is the data provided from RTC (UTC)
* @return TimeFormat the CUC time format. More specific, 32 bits are used for the T-field (seconds since 1/1/1958)
* @todo time security for critical time operations
* @todo declare the implicit P-field
*/
static
uint32_t
generateCUCtimeFormat
(
struct
TimeAndDate
&
TimeInfo
);
/**
* Parse the CUC time format (3.3 in CCSDS 301.0-B-4 standard)
*
* @param data time information provided from the ground segment. The length of the data is a
* fixed size of 32 bits
* @return the UTC date
*/
static
TimeAndDate
parseCUCtimeFormat
(
const
uint8_t
*
data
);
};
#endif // ECSS_SERVICES_TIMEHELPER_HPP
This diff is collapsed.
Click to expand it.
src/Helpers/TimeHelper.cpp
+
11
−
0
View file @
a58307d6
...
...
@@ -125,3 +125,14 @@ TimeAndDate TimeHelper::parseCDStimeFormat(const uint8_t* data) {
return
secondsToUTC
(
seconds
);
}
uint32_t
TimeHelper
::
generateCUCtimeFormat
(
struct
TimeAndDate
&
TimeInfo
)
{
return
utcToSeconds
(
TimeInfo
);
}
TimeAndDate
TimeHelper
::
parseCUCtimeFormat
(
const
uint8_t
*
data
)
{
uint32_t
seconds
=
((
static_cast
<
uint32_t
>
(
data
[
0
]))
<<
24
)
|
((
static_cast
<
uint32_t
>
(
data
[
1
])))
<<
16
|
((
static_cast
<
uint32_t
>
(
data
[
2
])))
<<
8
|
(
static_cast
<
uint32_t
>
(
data
[
3
]));
return
secondsToUTC
(
seconds
);
}
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