Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qthing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
qthing
Commits
8a8199b6
Commit
8a8199b6
authored
6 years ago
by
fxk8y
Browse files
Options
Downloads
Patches
Plain Diff
going functional
parent
d2b5f3c4
No related branches found
No related tags found
2 merge requests
!8
Updating bme280-qthing
,
!5
Measured: A measuring daemon
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main/measured.cpp
+4
-5
4 additions, 5 deletions
main/measured.cpp
main/measured.h
+5
-11
5 additions, 11 deletions
main/measured.h
with
9 additions
and
16 deletions
main/measured.cpp
+
4
−
5
View file @
8a8199b6
...
@@ -8,10 +8,9 @@ typedef struct {
...
@@ -8,10 +8,9 @@ typedef struct {
std
::
string
name
;
std
::
string
name
;
std
::
string
type
;
std
::
string
type
;
std
::
string
unit
;
std
::
string
unit
;
qthing
::
measured
::
Producer
produce
r
;
qthing
::
measured
::
sensor_t
senso
r
;
}
sensor_t
;
}
sensor_
data_
t
;
typedef
qthing
::
measured
::
Consumer
backend_t
;
// TODO: declare backend/sensor vectors!
// TODO: declare backend/sensor vectors!
...
@@ -30,12 +29,12 @@ static void start_measured() {
...
@@ -30,12 +29,12 @@ static void start_measured() {
}
}
}
}
void
registerSensor
(
std
::
string
name
,
std
::
string
type
,
std
::
string
unit
,
qthing
::
measured
::
Producer
p
)
{
void
registerSensor
(
std
::
string
name
,
std
::
string
type
,
std
::
string
unit
,
qthing
::
measured
::
sensor_t
sensor
)
{
// do stuff!
// do stuff!
start_measured
();
start_measured
();
}
}
void
registerBackend
(
qthing
::
measured
::
Consumer
c
)
{
void
registerBackend
(
qthing
::
measured
::
backend_t
backend
)
{
// do stuff!
// do stuff!
start_measured
();
start_measured
();
}
}
This diff is collapsed.
Click to expand it.
main/measured.h
+
5
−
11
View file @
8a8199b6
#pragma once
#pragma once
#include
<string>
#include
<string>
#include
<functional>
namespace
qthing
{
namespace
qthing
{
namespace
measured
{
namespace
measured
{
class
Producer
{
typedef
std
::
function
<
float
()
>
sensor_t
;
public:
typedef
std
::
function
<
void
(
std
::
string
name
,
std
::
string
type
,
std
::
string
unit
,
float
value
)
>
backend_t
;
// name, type, unit, value
float
getValue
();
};
class
Consumer
{
void
registerBackend
(
sensor_t
sensor
);
public:
void
registerSensor
(
std
::
string
name
,
std
::
string
type
,
std
::
string
unit
,
backend_t
);
void
processValue
(
std
::
string
name
,
std
::
string
type
,
std
::
string
unit
,
float
value
);
};
void
registerBackend
(
Consumer
c
);
void
registerSensor
(
std
::
string
name
,
std
::
string
type
,
std
::
string
unit
,
Producer
p
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment