-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicrologger.cpp
More file actions
71 lines (64 loc) · 2.59 KB
/
Copy pathmicrologger.cpp
File metadata and controls
71 lines (64 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// #define SDDS_PARTICLE_DEBUG 1
// self-describing data structure (SDDS) tree
#include "uMicroLogger.h"
TmicroLogger micrologger;
// serial spike for communication via serial (with baud rate)
#include "uSerialSpike.h"
TserialSpike serialSpike(micrologger, 115200);
// particle spike for particle communication (with sdds name and version)
#include "uParticleSpike.h"
static TparticleSpike particleSpike(
micrologger, // SDDS tree
"micrologger", // device type
"microloggerData", // data event
10501 // device version (1.0.0= 10000, 2.23.2 = 22302)
);
// logging
SerialLogHandler logHandler(
LOG_LEVEL_WARN, // WARN for non-app messages
{
{"app",
#ifdef SDDS_PARTICLE_DEBUG
LOG_LEVEL_TRACE
#else
LOG_LEVEL_INFO
#endif
}});
// setup
void setup()
{
// setup particle communication
using publish = TparticleSpike::publish;
particleSpike.setup(
{// set default publishing intervals for anything that should be different from publish::OFF
// --> all variables that are stored in EEPROM (saveeval option) should report all changes
{publish::EACH, sdds::opt::saveval},
// --> last save should always be reported
{publish::ALWAYS, &particleSystem().state.lastSave_dt},
// --> device connect/disconnect should be published immediately
{publish::EACH, µlogger.device},
// --> top level errors should always be published
{publish::EACH, µlogger.stirrer.error},
{publish::EACH, µlogger.lights.error},
{publish::EACH, µlogger.sensor.error},
{publish::EACH, µlogger.environment.error},
// --> all floats should inherit from the globalInterval
{publish::AVG_GLOBAL, {sdds::Ttype::FLOAT32, sdds::Ttype::FLOAT64}},
// --> motor speed is an integer but should still inherit from the globalInterval
{publish::AVG_GLOBAL, µlogger.stirrer.speed_rpm},
// --> don't report transmittance, and power, and standard devs by default
{publish::OFF, µlogger.environment.power_V},
{publish::OFF, µlogger.environment.powerReq_V},
{publish::OFF, µlogger.sensor.reading.transmittance},
{publish::OFF, µlogger.sensor.reading.transmittanceSd},
{publish::OFF, µlogger.sensor.reading.ODSd}});
// add hardware menu after the particle spike so it does not have publish options
micrologger.addDescr(hardware());
}
// loop: task handler
#include "uMultask.h"
void loop()
{
// handle all events
TtaskHandler::handleEvents();
}