-
Notifications
You must be signed in to change notification settings - Fork 0
/
Store_Controller.h
97 lines (78 loc) · 2.78 KB
/
Store_Controller.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef STORE_CONTROLLER_H
#define STORE_CONTROLLER_H
#include <Arduino.h>
class Store_Controller {
public:
static Store_Controller& readInstance();
// Directions for typechecking
enum Wheel {FrontRightWheel, FrontLeftWheel, RearRightWheel, RearLeftWheel, WHEEL_LENGTH};
enum Motor {LeftMotor, RightMotor, MOTOR_LENGTH};
void logHasFault(bool hasFault);
bool readHasFault();
// Can node readings
void logAnalogThrottle(uint8_t throttle);
uint8_t readAnalogThrottle();
void logAnalogBrake(uint8_t brake);
uint8_t readAnalogBrake();
void logBrakeThrottleConflict(bool conflict);
bool readBrakeThrottleConflict();
// Speeds
void logSpeed(Wheel wheel, int16_t wheel_rpm);
int16_t readSpeed(Wheel wheel);
// Motor controller states
void logMotorResponse(Motor dir);
bool readMotorResponse(Motor dir);
void logMotorErrors(Motor dir, uint16_t error_string);
bool readMotorErrors(Motor dir);
void logMotorWarnings(Motor dir, uint16_t warning_string);
void logMotorState(Motor dir, uint32_t state_string);
// Motor controller readings
void logMotorTorqueCommand(Motor dir, int16_t torqueCommand);
int16_t readMotorTorqueCommand(Motor dir);
void logMotorRpm(Motor dir, int16_t motor_rpm);
int16_t readMotorRpm(Motor dir);
void logMotorCurrent(Motor dir, int16_t motor_current);
void logMotorAirTemp(Motor dir, int16_t motor_temp);
void logMotorIgbtTemp(Motor dir, int16_t motor_temp);
void logMotorCurrentLimit(Motor dir, int16_t limit);
void logMotorCurrentCommand(Motor dir, int16_t limit);
void logMotorCurrentAfterFilter(Motor dir, int16_t limit);
// Convenience methods for enum access
Motor toMotor(uint16_t id);
Motor otherMotor(Motor thisMotor);
// BMS state
void logBmsFaults(uint8_t fault_string);
void logBmsWarnings(uint8_t warning_string);
// BMS readings
void logBmsTemp(int16_t temp);
int16_t readBmsTemp();
void logBmsVoltage(int16_t volts);
int16_t readBmsVoltage();
void logBmsSoc(int16_t percent);
int16_t readBmsSoc();
private:
Store_Controller();
static Store_Controller *instance;
// Fault logging
bool hasFault;
// Can node logging
uint8_t analogThrottle;
uint8_t analogBrake;
bool brakeThrottleConflict;
// Wheel logging
int16_t speeds[WHEEL_LENGTH];
// Motor controller states
bool responses[MOTOR_LENGTH];
bool errors[MOTOR_LENGTH];
int16_t motorRpm[MOTOR_LENGTH];
// Motor controller readings
int16_t torqueCommands[MOTOR_LENGTH];
// BMS logging
int16_t bmsTemp;
int16_t bmsVoltage;
int16_t soc;
};
Store_Controller& Store();
typedef enum Store_Controller::Motor Motor;
typedef enum Store_Controller::Wheel Wheel;
#endif // STORE_CONTROLLER_H