RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
Common.h
Go to the documentation of this file.
1#pragma once
2#include <stdio.h>
3#include <stdlib.h>
4#include <fstream>
5#include <iostream>
6#include <string>
7#include <sstream>
8#include <unordered_map>
9#include <ctime>
10#include <cmath>
11#include <climits>
12#include <condition_variable>
13#include <thread>
14#include <atomic>
15#include <map>
16#include <queue>
17#include <cstdio>
18#include <functional>
19#include <mutex>
20#include <vector>
21
22extern "C"
23{
24 #include <wiringPi.h>
25 #include <wiringSerial.h>
26}
27#include "AceLinux.h"
28
29namespace RumPi
30{
31 //Constants
32 /* WiringPi pin 0 is BCM_GPIO 17. we have to use BCM numbering when initializing
33 with wiringPiSetupSys when choosing a different pin number please use
34 the BCM numbering, also update the Property Pages - Build Events - Remote
35 Post-Build Event command which uses gpio export for setup for wiringPiSetupSys */
36 constexpr unsigned int PIN_GPIO_5 = 5;
37 constexpr unsigned int PIN_GPIO_6 = 6;
38 constexpr unsigned int PIN_GPIO_12 = 12;
39 constexpr unsigned int PIN_GPIO_13 = 13;
40 constexpr unsigned int PIN_GPIO_14 = 14;
41 constexpr unsigned int PIN_GPIO_15 = 15;
42 constexpr unsigned int PIN_GPIO_16 = 16;
43 constexpr unsigned int PIN_GPIO_17 = 17;
44 constexpr unsigned int PIN_GPIO_18 = 18;
45 constexpr unsigned int PIN_GPIO_19 = 19;
46 constexpr unsigned int PIN_GPIO_20 = 20;
47 constexpr unsigned int PIN_GPIO_21 = 21;
48 constexpr unsigned int PIN_GPIO_22 = 22;
49 constexpr unsigned int PIN_GPIO_23 = 23;
50 constexpr unsigned int PIN_GPIO_24 = 24;
51 constexpr unsigned int PIN_GPIO_25 = 25;
52 constexpr unsigned int PIN_GPIO_26 = 26;
53 constexpr unsigned int PIN_GPIO_27 = 27;
54
55 constexpr unsigned int RUMPI_SINGLE_COMPONENT_BUFFER_SIZE = 2 << 9;
56 constexpr unsigned int RUMPI_MAX_BUFFER_SIZE = 2 << 15;
57 constexpr unsigned int RUMPI_MAX_PCF8591_PINS = 4;
58 constexpr unsigned int RUMPI_MAX_READ_ATTEMPTS = 2 << 15;
59 constexpr unsigned int RUMPI_MAX_NUM_SAMPLES = 5;
60
61 //Keep at most this many session log files in the log directory; older ones are pruned on startup.
62 constexpr size_t RUMPI_MAX_LOG_FILES_TO_KEEP = 20;
63
67
72
73 constexpr float THRESHOLD_DISKUSAGE_WARNING_PERCENT = 80.0f;
74 constexpr float THRESHOLD_DISKUSAGE_ALERT_PERCENT = 90.0f;
76
79 constexpr float THRESHOLD_MEMORY_WARNING_SWAP_PERCENT = 20.0f;
80 constexpr float THRESHOLD_MEMORY_ALERT_SWAP_PERCENT = 50.0f;
81
82 constexpr float THRESHOLD_WIFISIGNAL_WARNING_DBM = -70.0f;
83 constexpr float THRESHOLD_WIFISIGNAL_ALERT_DBM = -75.0f;
84 constexpr bool THRESHOLD_WIFISIGNAL_HIGHER_IS_WORSE = false;
85
86
94 {
97 Alert
98 };
99} // namespace RumPi
RumPi is the library's top-level facade.
Definition: AlertManager.h:6
constexpr unsigned int PIN_GPIO_14
BCM GPIO pin 14.
Definition: Common.h:40
constexpr bool THRESHOLD_SYSTEMTEMPERATURE_HIGHER_IS_WORSE
High system temperature is worse.
Definition: Common.h:66
constexpr unsigned int RUMPI_MAX_READ_ATTEMPTS
Maximum serial-read retry attempts before giving up.
Definition: Common.h:58
constexpr unsigned int PIN_GPIO_17
BCM GPIO pin 17.
Definition: Common.h:43
constexpr bool THRESHOLD_WIFISIGNAL_HIGHER_IS_WORSE
Low WiFi signal is worse (closer to 0 is stronger).
Definition: Common.h:84
constexpr unsigned int RUMPI_MAX_PCF8591_PINS
Number of ADC channels on a PCF8591.
Definition: Common.h:57
constexpr float THRESHOLD_EXTERNALFIVEVOLT_WARNING_HIGH_VOLTS
5V rail high-side warning threshold, in volts.
Definition: Common.h:70
constexpr unsigned int PIN_GPIO_18
BCM GPIO pin 18.
Definition: Common.h:44
constexpr unsigned int PIN_GPIO_19
BCM GPIO pin 19.
Definition: Common.h:45
constexpr unsigned int PIN_GPIO_20
BCM GPIO pin 20.
Definition: Common.h:46
constexpr unsigned int PIN_GPIO_13
BCM GPIO pin 13.
Definition: Common.h:39
constexpr float THRESHOLD_EXTERNALFIVEVOLT_WARNING_LOW_VOLTS
5V rail low-side warning threshold, in volts.
Definition: Common.h:68
constexpr unsigned int PIN_GPIO_26
BCM GPIO pin 26.
Definition: Common.h:52
constexpr unsigned int PIN_GPIO_12
BCM GPIO pin 12.
Definition: Common.h:38
constexpr unsigned int PIN_GPIO_21
BCM GPIO pin 21.
Definition: Common.h:47
constexpr float THRESHOLD_EXTERNALFIVEVOLT_ALERT_LOW_VOLTS
5V rail low-side alert threshold, in volts.
Definition: Common.h:69
constexpr unsigned int PIN_GPIO_16
BCM GPIO pin 16.
Definition: Common.h:42
constexpr float THRESHOLD_EXTERNALFIVEVOLT_ALERT_HIGH_VOLTS
5V rail high-side alert threshold, in volts.
Definition: Common.h:71
constexpr unsigned int PIN_GPIO_27
BCM GPIO pin 27.
Definition: Common.h:53
constexpr float THRESHOLD_WIFISIGNAL_WARNING_DBM
WiFi signal warning threshold, in dBm.
Definition: Common.h:82
constexpr unsigned int PIN_GPIO_23
BCM GPIO pin 23.
Definition: Common.h:49
constexpr unsigned int PIN_GPIO_6
BCM GPIO pin 6.
Definition: Common.h:37
EAlertLevel
Severity of a metric relative to its thresholds.
Definition: Common.h:94
@ Warning
The metric has crossed its warning threshold.
Definition: Common.h:96
@ OK
The metric is within acceptable limits.
Definition: Common.h:95
@ Alert
The metric has crossed its alert threshold.
Definition: Common.h:97
constexpr unsigned int PIN_GPIO_25
BCM GPIO pin 25.
Definition: Common.h:51
constexpr float THRESHOLD_SYSTEMTEMPERATURE_WARNING_CELSIUS
System temperature warning threshold, in Celsius.
Definition: Common.h:64
constexpr unsigned int PIN_GPIO_5
BCM GPIO pin 5.
Definition: Common.h:36
constexpr bool THRESHOLD_DISKUSAGE_HIGHER_IS_WORSE
High disk usage is worse.
Definition: Common.h:75
constexpr float THRESHOLD_DISKUSAGE_WARNING_PERCENT
Disk usage warning threshold, as a percent.
Definition: Common.h:73
constexpr float THRESHOLD_DISKUSAGE_ALERT_PERCENT
Disk usage alert threshold, as a percent.
Definition: Common.h:74
constexpr float THRESHOLD_MEMORY_WARNING_AVAILABLE_PERCENT
Available-memory warning threshold, as a percent.
Definition: Common.h:77
constexpr unsigned int PIN_GPIO_24
BCM GPIO pin 24.
Definition: Common.h:50
constexpr size_t RUMPI_MAX_LOG_FILES_TO_KEEP
Definition: Common.h:62
constexpr float THRESHOLD_MEMORY_ALERT_SWAP_PERCENT
Swap-usage alert threshold, as a percent (high swap is bad).
Definition: Common.h:80
constexpr float THRESHOLD_MEMORY_ALERT_AVAILABLE_PERCENT
Available-memory alert threshold, as a percent (low available is bad).
Definition: Common.h:78
constexpr float THRESHOLD_MEMORY_WARNING_SWAP_PERCENT
Swap-usage warning threshold, as a percent.
Definition: Common.h:79
constexpr unsigned int PIN_GPIO_15
BCM GPIO pin 15.
Definition: Common.h:41
constexpr float THRESHOLD_WIFISIGNAL_ALERT_DBM
WiFi signal alert threshold, in dBm.
Definition: Common.h:83
constexpr unsigned int RUMPI_MAX_NUM_SAMPLES
Default rolling-average window length.
Definition: Common.h:59
constexpr unsigned int PIN_GPIO_22
BCM GPIO pin 22.
Definition: Common.h:48
constexpr unsigned int RUMPI_MAX_BUFFER_SIZE
Maximum overall buffer size.
Definition: Common.h:56
constexpr float THRESHOLD_SYSTEMTEMPERATURE_ALERT_CELSIUS
System temperature alert threshold, in Celsius (Pi soft-throttles here).
Definition: Common.h:65
constexpr unsigned int RUMPI_SINGLE_COMPONENT_BUFFER_SIZE
Buffer size for a single component's serial reads.
Definition: Common.h:55