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
1d684738
Commit
1d684738
authored
Jan 10, 2019
by
Micha Mueller
Browse files
Skip first reading in delta plugins as it is not very meaningful
parent
f9322eec
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/includes/SensorBase.h
View file @
1d684738
...
...
@@ -35,6 +35,7 @@ public:
_cacheIndex
(
0
),
_cache
(
nullptr
),
_delta
(
false
),
_firstReading
(
true
),
_readingQueue
(
nullptr
),
_sinkFile
(
nullptr
)
{
...
...
@@ -58,6 +59,7 @@ public:
_cacheIndex
(
0
),
_cache
(
nullptr
),
_delta
(
other
.
_delta
),
_firstReading
(
true
),
_latestValue
(
other
.
_latestValue
),
_lastRawValue
(
other
.
_lastRawValue
),
_lastSentValue
(
other
.
_lastSentValue
),
...
...
@@ -78,6 +80,7 @@ public:
_cacheIndex
=
0
;
_cache
.
reset
(
nullptr
);
_delta
=
other
.
_delta
;
_firstReading
=
true
;
_latestValue
.
timestamp
=
other
.
_latestValue
.
timestamp
;
_latestValue
.
value
=
other
.
_latestValue
.
value
;
_lastRawValue
.
timestamp
=
other
.
_lastRawValue
.
timestamp
;
...
...
@@ -133,10 +136,16 @@ public:
void
storeReading
(
reading_t
rawReading
,
double
factor
=
1.0
,
unsigned
long
long
maxValue
=
ULLONG_MAX
)
{
reading_t
reading
=
rawReading
;
if
(
_delta
)
{
if
(
rawReading
.
value
<
_lastRawValue
.
value
)
reading
.
value
=
(
rawReading
.
value
+
(
maxValue
-
_lastRawValue
.
value
))
*
factor
;
else
reading
.
value
=
(
rawReading
.
value
-
_lastRawValue
.
value
)
*
factor
;
if
(
!
_firstReading
)
{
if
(
rawReading
.
value
<
_lastRawValue
.
value
)
reading
.
value
=
(
rawReading
.
value
+
(
maxValue
-
_lastRawValue
.
value
))
*
factor
;
else
reading
.
value
=
(
rawReading
.
value
-
_lastRawValue
.
value
)
*
factor
;
}
else
{
_firstReading
=
false
;
_lastRawValue
=
rawReading
;
return
;
}
_lastRawValue
=
rawReading
;
}
else
...
...
@@ -172,6 +181,7 @@ protected:
unsigned
int
_cacheIndex
;
std
::
unique_ptr
<
reading_t
[]
>
_cache
;
bool
_delta
;
bool
_firstReading
;
reading_t
_latestValue
;
reading_t
_lastRawValue
;
reading_t
_lastSentValue
;
...
...
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