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
3ec2f885
Commit
3ec2f885
authored
Nov 03, 2018
by
Micha Mueller
Browse files
Add skipConstVal flag: Enable or disable if constant values should be stored
parent
9783db2e
Changes
3
Hide whitespace changes
Inline
Side-by-side
config/sysfs.conf
View file @
3ec2f885
...
...
@@ -28,8 +28,9 @@ group temp {
default
def1
path
/
sys
/
devices
/
virtual
/
thermal
/
thermal_zone1
/
temp
sensor
temp1
{
mqttsuffix
01
sensor
temp1
{
skipConstVal
on
mqttsuffix
01
}
}
...
...
src/includes/ConfiguratorTemplate.h
View file @
3ec2f885
...
...
@@ -340,6 +340,8 @@ protected:
BOOST_FOREACH
(
boost
::
property_tree
::
iptree
::
value_type
&
val
,
config
)
{
if
(
boost
::
iequals
(
val
.
first
,
"mqttsuffix"
))
{
sBase
.
setMqtt
(
val
.
second
.
data
());
}
else
if
(
boost
::
iequals
(
val
.
first
,
"skipConstVal"
))
{
sBase
.
setSkipConstVal
(
val
.
second
.
data
());
}
}
sensorBase
(
sBase
,
config
);
...
...
src/includes/SensorBase.h
View file @
3ec2f885
...
...
@@ -22,6 +22,7 @@ public:
SensorBase
(
const
std
::
string
&
name
)
:
_name
(
name
),
_mqtt
(
""
),
_skipConstVal
(
false
),
_cache
(
nullptr
),
_readingQueue
(
nullptr
)
{
...
...
@@ -32,6 +33,7 @@ public:
SensorBase
(
const
SensorBase
&
other
)
:
_name
(
other
.
_name
),
_mqtt
(
other
.
_mqtt
),
_skipConstVal
(
other
.
_skipConstVal
),
_cache
(
nullptr
),
_latestValue
(
other
.
_latestValue
),
_readingQueue
(
nullptr
)
{}
...
...
@@ -51,11 +53,19 @@ public:
const
std
::
string
&
getName
()
const
{
return
_name
;
}
const
std
::
string
&
getMqtt
()
const
{
return
_mqtt
;
}
bool
getSkipConstVal
()
const
{
return
_skipConstVal
;
}
const
reading_t
*
const
getCache
()
const
{
return
_cache
.
get
();
}
const
reading_t
getLatestValue
()
const
{
return
_latestValue
;
}
void
setName
(
const
std
::
string
&
name
)
{
_name
=
name
;
}
void
setMqtt
(
const
std
::
string
&
mqtt
)
{
_mqtt
=
mqtt
;
}
void
setName
(
const
std
::
string
&
name
)
{
_name
=
name
;
}
void
setMqtt
(
const
std
::
string
&
mqtt
)
{
_mqtt
=
mqtt
;
}
void
setSkipConstVal
(
const
std
::
string
&
skipConstVal
)
{
if
(
skipConstVal
==
"on"
)
{
_skipConstVal
=
true
;
}
else
{
_skipConstVal
=
false
;
}
}
const
std
::
size_t
getSizeOfReadingQueue
()
const
{
return
_readingQueue
->
read_available
();
}
std
::
size_t
popReadingQueue
(
reading_t
*
reads
,
std
::
size_t
max
)
const
{
return
_readingQueue
->
pop
(
reads
,
max
);
}
...
...
@@ -74,7 +84,9 @@ public:
}
virtual
void
storeReading
(
reading_t
reading
,
unsigned
cacheIndex
)
{
_readingQueue
->
push
(
reading
);
if
(
!
(
_skipConstVal
&&
(
reading
.
value
==
_latestValue
.
value
)))
{
_readingQueue
->
push
(
reading
);
}
_cache
[
cacheIndex
]
=
reading
;
_latestValue
.
value
=
reading
.
value
;
_latestValue
.
timestamp
=
reading
.
timestamp
;
...
...
@@ -84,6 +96,7 @@ protected:
std
::
string
_name
;
std
::
string
_mqtt
;
bool
_skipConstVal
;
std
::
unique_ptr
<
reading_t
[]
>
_cache
;
reading_t
_latestValue
;
std
::
unique_ptr
<
boost
::
lockfree
::
spsc_queue
<
reading_t
>>
_readingQueue
;
...
...
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