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
7bcc4a9f
Unverified
Commit
7bcc4a9f
authored
5 years ago
by
Grigoris Pavlakis
Browse files
Options
Downloads
Patches
Plain Diff
Move template definitions in the header file to avoid link errors
parent
96afef6b
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/Services/Parameter.hpp
+45
-17
45 additions, 17 deletions
inc/Services/Parameter.hpp
src/Services/Parameter.cpp
+0
-32
0 additions, 32 deletions
src/Services/Parameter.cpp
with
45 additions
and
49 deletions
inc/Services/Parameter.hpp
+
45
−
17
View file @
7bcc4a9f
...
@@ -59,29 +59,57 @@ typedef etl::bitset<NUM_OF_FLAGS> Flags;
...
@@ -59,29 +59,57 @@ typedef etl::bitset<NUM_OF_FLAGS> Flags;
*/
*/
class
ParameterBase
{
class
ParameterBase
{
protected:
protected:
uint8_t
ptc
;
uint8_t
ptc
;
uint8_t
pfc
;
uint8_t
pfc
;
uint8_t
sizeInBytes
;
uint8_t
sizeInBytes
;
void
*
valuePtr
;
void
*
valuePtr
;
Flags
flags
;
Flags
flags
;
public:
public:
uint8_t
getPTC
();
uint8_t
getPTC
();
void
setFlags
(
const
char
*
flags
);
uint8_t
getPFC
();
void
setFlags
(
const
char
*
flags
);
virtual
String
<
MAX_STRING_LENGTH
>
getValueAsString
()
=
0
;
template
<
typename
ValueType
>
void
setCurrentValue
(
ValueType
newVal
);
uint8_t
getPFC
();
virtual
String
<
MAX_STRING_LENGTH
>
getValueAsString
()
=
0
;
template
<
typename
ValueType
>
void
setCurrentValue
(
ValueType
newVal
)
{
// set the value only if the parameter can be updated manually
if
(
flags
[
1
])
{
*
reinterpret_cast
<
ValueType
*>
(
valuePtr
)
=
newVal
;
}
}
};
};
template
<
typename
ValueType
>
template
<
typename
ValueType
>
class
Parameter
:
public
ParameterBase
{
class
Parameter
:
public
ParameterBase
{
void
(
*
ptr
)(
ValueType
*
);
void
(
*
ptr
)(
ValueType
*
);
ValueType
currentValue
;
ValueType
currentValue
;
public:
public:
Parameter
(
uint8_t
newPtc
,
uint8_t
newPfc
,
ValueType
initialValue
=
0
,
void
(
*
newPtr
)
Parameter
(
uint8_t
newPtc
,
uint8_t
newPfc
,
ValueType
initialValue
=
0
,
void
(
*
newPtr
)(
ValueType
*
)
=
nullptr
)
{
(
ValueType
*
)
=
nullptr
);
ptc
=
newPtc
;
String
<
MAX_STRING_LENGTH
>
getValueAsString
()
override
;
pfc
=
newPfc
;
ptr
=
newPtr
;
sizeInBytes
=
sizeof
(
initialValue
);
valuePtr
=
static_cast
<
void
*>
(
&
currentValue
);
// see Parameter.hpp for explanation on flags
// by default: no update priority, manual and automatic update available
if
(
ptr
!=
nullptr
)
{
(
*
ptr
)(
&
currentValue
);
// call the update function for the initial value
}
else
{
currentValue
=
initialValue
;
}
}
String
<
MAX_STRING_LENGTH
>
getValueAsString
()
override
{
String
<
MAX_STRING_LENGTH
>
contents
(
reinterpret_cast
<
uint8_t
*>
(
&
currentValue
),
sizeInBytes
);
return
contents
;
}
};
};
...
...
This diff is collapsed.
Click to expand it.
src/Services/Parameter.cpp
+
0
−
32
View file @
7bcc4a9f
#include
"Services/Parameter.hpp"
#include
"Services/Parameter.hpp"
template
<
typename
ValueType
>
Parameter
<
ValueType
>::
Parameter
(
uint8_t
newPtc
,
uint8_t
newPfc
,
ValueType
initialValue
,
void
(
*
newPtr
)(
ValueType
*
))
{
ptc
=
newPtc
;
pfc
=
newPfc
;
ptr
=
newPtr
;
sizeInBytes
=
sizeof
(
initialValue
);
valuePtr
=
static_cast
<
void
*>
(
&
currentValue
);
// see Parameter.hpp for explanation on flags
// by default: no update priority, manual and automatic update available
if
(
ptr
!=
nullptr
)
{
(
*
ptr
)(
&
currentValue
);
// call the update function for the initial value
}
else
{
currentValue
=
initialValue
;
}
}
template
<
typename
ValueType
>
void
ParameterBase
::
setCurrentValue
(
ValueType
newVal
)
{
// set the value only if the parameter can be updated manually
if
(
flags
[
1
])
{
*
reinterpret_cast
<
ValueType
>
(
valuePtr
)
=
newVal
;
}
}
template
<
typename
ValueType
>
String
<
MAX_STRING_LENGTH
>
Parameter
<
ValueType
>::
getValueAsString
()
{
String
<
MAX_STRING_LENGTH
>
contents
(
reinterpret_cast
<
uint8_t
*>
(
&
currentValue
),
sizeInBytes
);
return
contents
;
}
uint8_t
ParameterBase
::
getPTC
()
{
uint8_t
ParameterBase
::
getPTC
()
{
return
ptc
;
return
ptc
;
}
}
...
...
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