System Management code
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
DataStructures/Headers/OperatingInfo.h@39:ddf38df9699e, 2015-02-11 (annotated)
- Committer:
- pspatel321
- Date:
- Wed Feb 11 23:09:57 2015 +0000
- Revision:
- 39:ddf38df9699e
- Parent:
- 38:8efacce315ae
Updated CAN IDs for datalogging. Changed profile encoding.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pspatel321 | 38:8efacce315ae | 1 | #ifndef OPERATING_INFO_H |
pspatel321 | 38:8efacce315ae | 2 | #define OPERATING_INFO_H |
pspatel321 | 38:8efacce315ae | 3 | |
pspatel321 | 38:8efacce315ae | 4 | #include "Constants.h" |
pspatel321 | 38:8efacce315ae | 5 | #include <stdint.h> |
pspatel321 | 38:8efacce315ae | 6 | #include <time.h> |
pspatel321 | 38:8efacce315ae | 7 | |
pspatel321 | 38:8efacce315ae | 8 | enum OperatingMode { |
pspatel321 | 38:8efacce315ae | 9 | // MODES |
pspatel321 | 39:ddf38df9699e | 10 | OKAY=1<<0, |
pspatel321 | 39:ddf38df9699e | 11 | FAULT=1<<1, |
pspatel321 | 38:8efacce315ae | 12 | }; |
pspatel321 | 38:8efacce315ae | 13 | |
pspatel321 | 38:8efacce315ae | 14 | // Items here will prevent moving from STANDBY to IDLE |
pspatel321 | 38:8efacce315ae | 15 | enum TopLevelFaults { |
pspatel321 | 38:8efacce315ae | 16 | WATCHDOG = 1<<0, // Last reset caused by WDT |
pspatel321 | 38:8efacce315ae | 17 | BROWNOUT = 1<<1, // Last reset caused by Brownout |
pspatel321 | 38:8efacce315ae | 18 | CAN_FAULT = 1<<2, // CAN buffer overflow |
pspatel321 | 38:8efacce315ae | 19 | |
pspatel321 | 38:8efacce315ae | 20 | INT_OVER_TEMP = 1<<3, // Temp. sensor on Charge FET is over limit |
pspatel321 | 38:8efacce315ae | 21 | IMD_LATCH = 1<<4, // Fault detected on the IMD latch circuit |
pspatel321 | 38:8efacce315ae | 22 | AMS_LATCH = 1<<5, // Fault detected on the AMS latch circuit |
pspatel321 | 38:8efacce315ae | 23 | IMD_FAULT = 1<<6, // IMD not okay or not running |
pspatel321 | 38:8efacce315ae | 24 | DCDC_FAULT = 1<<7, |
pspatel321 | 38:8efacce315ae | 25 | GLVBAT_FAULT = 1<<8, |
pspatel321 | 38:8efacce315ae | 26 | FREEZE_FRAME = 1<<9, // There is an error freeze frame captured, waiting to be inspected by user |
pspatel321 | 38:8efacce315ae | 27 | }; |
pspatel321 | 38:8efacce315ae | 28 | |
pspatel321 | 38:8efacce315ae | 29 | enum SignalFlags { |
pspatel321 | 38:8efacce315ae | 30 | SHUTDOWN_CLOSED = 1<<0, // Shutdown circuit ready (closed) |
pspatel321 | 38:8efacce315ae | 31 | AIRS_CLOSED = 1<<1, // AIRs Closed (CAN) |
pspatel321 | 38:8efacce315ae | 32 | CHARGER_DET = 1<<2, // Charger detected (CAN) |
pspatel321 | 38:8efacce315ae | 33 | }; |
pspatel321 | 38:8efacce315ae | 34 | |
pspatel321 | 38:8efacce315ae | 35 | // Contains all of the relevant operating data gathered from sensors and the prcoessed outputs |
pspatel321 | 38:8efacce315ae | 36 | // NOTE there are no mutexes/protection mechanisms here! Ensure single producer, single consumer for every item |
pspatel321 | 38:8efacce315ae | 37 | class OperatingInfo |
pspatel321 | 38:8efacce315ae | 38 | { |
pspatel321 | 38:8efacce315ae | 39 | public: |
pspatel321 | 38:8efacce315ae | 40 | // Diagnostic data |
pspatel321 | 38:8efacce315ae | 41 | char mode; |
pspatel321 | 38:8efacce315ae | 42 | char signals; |
pspatel321 | 38:8efacce315ae | 43 | uint16_t faultCode; |
pspatel321 | 38:8efacce315ae | 44 | time_t SysTime; |
pspatel321 | 38:8efacce315ae | 45 | time_t startTime; |
pspatel321 | 38:8efacce315ae | 46 | signed char profileIndex; |
pspatel321 | 38:8efacce315ae | 47 | bool profileModded; |
pspatel321 | 38:8efacce315ae | 48 | |
pspatel321 | 38:8efacce315ae | 49 | struct { // GLV-Battery related |
pspatel321 | 38:8efacce315ae | 50 | float current; |
pspatel321 | 38:8efacce315ae | 51 | float SOC; |
pspatel321 | 38:8efacce315ae | 52 | float Ah; |
pspatel321 | 38:8efacce315ae | 53 | float capacity; |
pspatel321 | 38:8efacce315ae | 54 | char error; |
pspatel321 | 38:8efacce315ae | 55 | } glvBat; |
pspatel321 | 38:8efacce315ae | 56 | |
pspatel321 | 38:8efacce315ae | 57 | struct { // DC-DC converter and PWM channels |
pspatel321 | 38:8efacce315ae | 58 | char status; |
pspatel321 | 38:8efacce315ae | 59 | float current; |
pspatel321 | 38:8efacce315ae | 60 | struct { |
pspatel321 | 38:8efacce315ae | 61 | float pump1; |
pspatel321 | 38:8efacce315ae | 62 | float pump2; |
pspatel321 | 38:8efacce315ae | 63 | float fan1; |
pspatel321 | 38:8efacce315ae | 64 | float fan2; |
pspatel321 | 38:8efacce315ae | 65 | } request; |
pspatel321 | 38:8efacce315ae | 66 | struct { |
pspatel321 | 38:8efacce315ae | 67 | float pump1; |
pspatel321 | 38:8efacce315ae | 68 | float pump2; |
pspatel321 | 38:8efacce315ae | 69 | float fan1; |
pspatel321 | 38:8efacce315ae | 70 | float fan2; |
pspatel321 | 38:8efacce315ae | 71 | } actual; |
pspatel321 | 38:8efacce315ae | 72 | } dcdc; |
pspatel321 | 38:8efacce315ae | 73 | |
pspatel321 | 38:8efacce315ae | 74 | struct { // IMD |
pspatel321 | 38:8efacce315ae | 75 | char status; |
pspatel321 | 38:8efacce315ae | 76 | float resistance; |
pspatel321 | 38:8efacce315ae | 77 | char error; |
pspatel321 | 38:8efacce315ae | 78 | } imd; |
pspatel321 | 38:8efacce315ae | 79 | |
pspatel321 | 38:8efacce315ae | 80 | struct { // Latch circuit supervisor |
pspatel321 | 38:8efacce315ae | 81 | char imd; |
pspatel321 | 38:8efacce315ae | 82 | char ams; |
pspatel321 | 38:8efacce315ae | 83 | } latch; |
pspatel321 | 39:ddf38df9699e | 84 | |
pspatel321 | 38:8efacce315ae | 85 | char switchState; |
pspatel321 | 38:8efacce315ae | 86 | float internalTemp; |
pspatel321 | 38:8efacce315ae | 87 | }; |
pspatel321 | 38:8efacce315ae | 88 | class OperatingInfo_checkSum |
pspatel321 | 38:8efacce315ae | 89 | { |
pspatel321 | 38:8efacce315ae | 90 | public: |
pspatel321 | 38:8efacce315ae | 91 | OperatingInfo op; |
pspatel321 | 38:8efacce315ae | 92 | uint32_t BSDchecksum; |
pspatel321 | 38:8efacce315ae | 93 | }; |
pspatel321 | 38:8efacce315ae | 94 | #endif |