-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStructures.h
58 lines (48 loc) · 1.3 KB
/
Structures.h
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
#ifndef STRUCTURES_H
#define STRUCTURES_H
#include <QObject>
#include <QString>
#include <cstdint>
#include <string>
namespace Structures {
enum WeightUnit { Gram, KiloGram, Tonne };
static QString wUnittoString(Structures::WeightUnit const unit) {
switch (unit) {
case Structures::WeightUnit::Gram:
return "Gram";
case Structures::WeightUnit::KiloGram:
return "KiloGram";
case Structures::WeightUnit::Tonne:
return "Tonne";
}
return "Error";
}
struct Bucket {
std::uint_fast32_t weight; // default in KiloGram(TODO: be sure)
std::string description;
public:
bool operator<(Bucket const& other) const { return weight < other.weight; }
bool operator==(Bucket const& other) const { return weight == other.weight; }
std::string toString() const {
return std::to_string(weight) + ",\"" + description + "\"";
}
inline double convert(WeightUnit const unit) const {
switch (unit) {
case Structures::WeightUnit::Gram:
return weight * 1e3;
case Structures::WeightUnit::Tonne:
return weight / 1e3;
default:
return weight;
}
}
};
struct DataOverSerial {
bool cameraOn; // 4
bool newBucket; // 3
float rawPump; // 2
float s2; // 1
float s1; // 0
};
} // namespace Structures
#endif // STRUCTURES_H