-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.hpp
More file actions
44 lines (36 loc) · 1018 Bytes
/
Copy pathController.hpp
File metadata and controls
44 lines (36 loc) · 1018 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
35
36
37
38
39
40
41
42
43
44
#pragma once
#include <string_view>
namespace factoryflow {
// Input process image: sampled once at the beginning of each PLC scan.
struct Inputs {
bool entrySensor = false;
bool sortingSensor = false;
bool emergencyStop = false;
bool motorFault = false;
bool laneBSensor = false;
};
struct Outputs {
bool conveyorMotor = false;
bool diverterA = false;
bool diverterB = false;
bool diverterC = false;
};
enum class State { IDLE, TRANSPORTING, SORTING, COMPLETE, FAULT };
constexpr std::string_view toString(State state) {
switch (state) {
case State::IDLE: return "IDLE";
case State::TRANSPORTING: return "TRANSPORTING";
case State::SORTING: return "SORTING";
case State::COMPLETE: return "COMPLETE";
case State::FAULT: return "FAULT";
}
return "UNKNOWN";
}
class Controller {
public:
[[nodiscard]] Outputs scan(const Inputs& inputs);
[[nodiscard]] State state() const { return state_; }
private:
State state_ = State::IDLE;
};
}