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
4d3650d6
Commit
4d3650d6
authored
Dec 01, 2018
by
Micha Mueller
Browse files
Tiny improvements
parent
276cc675
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/HttpsServer.cpp
View file @
4d3650d6
...
...
@@ -196,7 +196,7 @@ void HttpsServer::requestHandler::operator()(server::request const &request, ser
for
(
const
auto
&
g
:
p
.
configurator
->
getSensorGroups
())
{
for
(
const
auto
&
s
:
g
->
getSensors
())
{
if
(
s
->
getName
()
==
sensor
)
{
response
=
pathStrs
[
0
]
+
"::"
+
sensor
+
_httpsServer
.
calcAvg
(
*
s
,
s
->
getCacheSize
(),
time
);
response
=
pathStrs
[
0
]
+
"::"
+
sensor
+
_httpsServer
.
calcAvg
(
*
s
,
time
);
connection
->
set_status
(
server
::
connection
::
ok
);
break
;
}
...
...
@@ -321,12 +321,12 @@ HttpsServer::~HttpsServer() {
delete
_server
;
}
std
::
string
HttpsServer
::
calcAvg
(
SensorBase
&
s
,
unsigned
cacheSize
,
uint64_t
time
)
{
std
::
string
HttpsServer
::
calcAvg
(
SensorBase
&
s
,
uint64_t
time
)
{
uint64_t
avg
=
0
;
const
reading_t
*
const
cache
=
s
.
getCache
();
unsigned
count
=
0
;
for
(
unsigned
i
=
0
;
i
<
c
acheSize
;
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
s
.
getC
acheSize
()
;
i
++
)
{
if
(
cache
[
i
].
timestamp
>
time
)
{
avg
+=
cache
[
i
].
value
;
count
++
;
...
...
src/HttpsServer.h
View file @
4d3650d6
...
...
@@ -94,7 +94,7 @@ private:
*
* @return Response message of the form " Average of last *count* values is *avg*"
*/
std
::
string
calcAvg
(
SensorBase
&
s
,
unsigned
cacheSize
,
uint64_t
time
);
std
::
string
calcAvg
(
SensorBase
&
s
,
uint64_t
time
);
/*
* Check if the authkey is valid and has the permission requiredPerm associated
...
...
src/includes/SensorBase.h
View file @
4d3650d6
...
...
@@ -74,7 +74,7 @@ public:
const
std
::
string
&
getMqtt
()
const
{
return
_mqtt
;
}
unsigned
getCacheSize
()
const
{
return
_cacheSize
;
}
const
reading_t
*
const
getCache
()
const
{
return
_cache
.
get
();
}
const
reading_t
getLatestValue
()
const
{
return
_latestValue
;
}
/*TODO return reference*/
const
reading_t
&
getLatestValue
()
const
{
return
_latestValue
;
}
void
setDelta
(
const
bool
delta
)
{
_delta
=
delta
;
}
void
setName
(
const
std
::
string
&
name
,
int
cpuID
=-
1
)
{
_name
=
formatName
(
name
,
cpuID
);
}
...
...
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