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
8ef686cb
Unverified
Commit
8ef686cb
authored
5 years ago
by
Grigoris Pavlakis
Browse files
Options
Downloads
Patches
Plain Diff
Convert Parameter class to template
parent
807648b6
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
+5
-6
5 additions, 6 deletions
inc/Services/Parameter.hpp
src/Services/Parameter.cpp
+13
-7
13 additions, 7 deletions
src/Services/Parameter.cpp
with
18 additions
and
13 deletions
inc/Services/Parameter.hpp
+
5
−
6
View file @
8ef686cb
...
...
@@ -23,8 +23,7 @@
* @typedef Flags: container for the binary flags
*/
typedef
uint16_t
ParamId
;
typedef
uint32_t
ValueType
;
typedef
void
(
*
UpdatePtr
)(
ValueType
*
);
//typedef etl::variant<bool, uint8_t, int32_t, float> ValueType;
typedef
etl
::
bitset
<
NUM_OF_FLAGS
>
Flags
;
/**
...
...
@@ -55,17 +54,17 @@ typedef etl::bitset<NUM_OF_FLAGS> Flags;
* @public getCurrentValue(): Gets the current value of the parameter
* @public getPTC(), getPFC(): Returns the PFC and PTC of the parameter
*/
class
Parameter
{
template
<
typename
ValueType
>
class
Parameter
{
uint8_t
ptc
;
uint8_t
pfc
;
UpdatePtr
ptr
;
void
(
*
ptr
)(
ValueType
*
)
;
Flags
flags
;
ValueType
currentValue
=
0
;
public:
Parameter
(
uint8_t
newPtc
,
uint8_t
newPfc
,
uint32_t
initialValue
=
0
,
UpdatePtr
newPtr
=
nullptr
);
Parameter
<
ValueType
>
(
uint8_t
newPtc
,
uint8_t
newPfc
,
const
ValueType
&
initialValue
,
void
(
*
newPtr
)(
ValueType
*
)
);
void
setCurrentValue
(
ValueType
newVal
);
void
setCurrentValue
(
const
ValueType
&
newVal
);
void
setFlags
(
const
char
*
flags
);
ValueType
getCurrentValue
();
...
...
This diff is collapsed.
Click to expand it.
src/Services/Parameter.cpp
+
13
−
7
View file @
8ef686cb
#include
"Services/Parameter.hpp"
Parameter
::
Parameter
(
uint8_t
newPtc
,
uint8_t
newPfc
,
ValueType
initialValue
,
UpdatePtr
newPtr
)
{
template
<
typename
ValueType
>
Parameter
<
ValueType
>::
Parameter
(
uint8_t
newPtc
,
uint8_t
newPfc
,
const
ValueType
&
initialValue
,
void
(
*
newPtr
)(
ValueType
*
))
{
ptc
=
newPtc
;
pfc
=
newPfc
;
ptr
=
newPtr
;
...
...
@@ -15,25 +16,30 @@ Parameter::Parameter(uint8_t newPtc, uint8_t newPfc, ValueType initialValue, Upd
}
}
void
Parameter
::
setCurrentValue
(
ValueType
newVal
)
{
template
<
typename
ValueType
>
void
Parameter
<
ValueType
>::
setCurrentValue
(
const
ValueType
&
newVal
)
{
// set the value only if the parameter can be updated manually
if
(
flags
[
1
])
{
currentValue
=
newVal
;
}
}
ValueType
Parameter
::
getCurrentValue
()
{
template
<
typename
ValueType
>
ValueType
Parameter
<
ValueType
>::
getCurrentValue
()
{
return
currentValue
;
}
uint8_t
Parameter
::
getPTC
()
{
template
<
typename
ValueType
>
uint8_t
Parameter
<
ValueType
>
::
getPTC
()
{
return
ptc
;
}
uint8_t
Parameter
::
getPFC
()
{
template
<
typename
ValueType
>
uint8_t
Parameter
<
ValueType
>::
getPFC
()
{
return
pfc
;
}
void
Parameter
::
setFlags
(
const
char
*
flags
)
{
template
<
typename
ValueType
>
void
Parameter
<
ValueType
>::
setFlags
(
const
char
*
flags
)
{
this
->
flags
=
Flags
(
flags
);
}
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