Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
dcdb
dcdb
Commits
97fa91c6
Commit
97fa91c6
authored
Nov 27, 2018
by
Michael Ott
Browse files
Provide DCDB::delta() function for uint64_t
parent
3831fea4
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/include/dcdb/sensoroperations.h
View file @
97fa91c6
...
...
@@ -29,6 +29,7 @@ namespace DCDB {
DCDB_OP_RESULT
safeMult
(
double
lh
,
double
rh
,
int64_t
*
result
);
DCDB_OP_RESULT
scale
(
int64_t
*
result
,
double
scalingFactor
,
double
baseScalingFactor
);
DCDB_OP_RESULT
delta
(
int64_t
lh
,
int64_t
rh
,
int64_t
*
result
);
DCDB_OP_RESULT
delta
(
uint64_t
lh
,
uint64_t
rh
,
int64_t
*
result
);
DCDB_OP_RESULT
derivative
(
int64_t
lhx
,
int64_t
rhx
,
uint64_t
lht
,
uint64_t
rht
,
int64_t
*
result
);
DCDB_OP_RESULT
integral
(
int64_t
lhx
,
int64_t
rhx
,
uint64_t
lht
,
uint64_t
rht
,
int64_t
*
result
);
...
...
lib/src/sensoroperations.cpp
View file @
97fa91c6
...
...
@@ -99,6 +99,17 @@ DCDB_OP_RESULT delta(int64_t lh, int64_t rh, int64_t* result) {
return
DCDB_OP_SUCCESS
;
};
DCDB_OP_RESULT
delta
(
uint64_t
lh
,
uint64_t
rh
,
int64_t
*
result
)
{
//TODO: Need to address overflow for monotonic sensor data, e.g., energy reaching max value.
//Maybe need to add another field to sensorconfig ("monotonic")?
//Or need to pass the maximum value detectable by the sensor?
*
result
=
lh
-
rh
;
return
DCDB_OP_SUCCESS
;
};
/* Safe implementation of a derivative */
DCDB_OP_RESULT
derivative
(
int64_t
lhx
,
int64_t
rhx
,
uint64_t
lht
,
uint64_t
rht
,
int64_t
*
result
)
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment