Commit 97fa91c6 authored by Michael Ott's avatar Michael Ott
Browse files

Provide DCDB::delta() function for uint64_t

parent 3831fea4
......@@ -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);
......
......@@ -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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment