-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuelSensor.h
More file actions
34 lines (27 loc) · 803 Bytes
/
Copy pathFuelSensor.h
File metadata and controls
34 lines (27 loc) · 803 Bytes
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
#ifndef FUELSENSOR_H
#define FUELSENSOR_H
#include "SensorBase.h"
#include "Rocket.h"
#include "Bus.h"
#include <thread>
#include <chrono>
#include <string>
#include <cstdlib>
#include <cmath>
class FuelSensor : public SensorBase{
private:
const Rocket& rocket;
public:
FuelSensor(const std::string& name_, Bus& bus_, const Rocket& rocket_)
: SensorBase(name_, bus_), rocket(rocket_) {}
void run() override {
auto cycleTime = std::chrono::milliseconds(1000); // 1Hz
while (!stopped) {
auto start = std::chrono::steady_clock::now();
bus.massChannel.write(static_cast<float>(voted(rocket.GetMass(), 0.01)));
bus.massChannel.swapBuffers();
std::this_thread::sleep_until(start + cycleTime);
}
}
};
#endif