System Management code

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Profile.h Source File

Profile.h

00001 #ifndef _Profile_H
00002 #define _Profile_H
00003 
00004 // The defines below are used to create change functions
00005 // The change functions allow changing things in the Profile with limits on allowed values
00006 #define CHANGE_FUNC(NAME, LLIM, ULIM)               \
00007 template<class T>                                   \
00008 bool change_##NAME(T data) {                        \
00009     if (data > ULIM || data < LLIM) return false;   \
00010     if (data == NAME) return false;                 \
00011     NAME = data;                                    \
00012     return true;                                    \
00013 }
00014 
00015 // Stores configurable parameters like limits, constants, etc.
00016 // NOTE there are no mutexes/protection mechanisms! Ensure single producer (inCommands.cpp - main thread), single consumer
00017 // To change a member of class Profile, use the change functions defined.  They will enforce limits on the changes.
00018 class Profile
00019 {
00020 public:
00021     // GLV Battery
00022     float chargeCurrent;
00023     float dischargeCurrent;
00024     float nominalCapacity;
00025     unsigned int glvBat_taps;
00026     CHANGE_FUNC(chargeCurrent,    -10, 0)
00027     CHANGE_FUNC(dischargeCurrent,   0, 10)
00028     CHANGE_FUNC(nominalCapacity,    0, 10)
00029     CHANGE_FUNC(glvBat_taps,        1, 1000)
00030 
00031     // DC-DC converter
00032     float dcdcThreshold;
00033     float dcdcOverCurrent;
00034     float dcdcStartDelay;
00035     float dcdcStopDelay;
00036     unsigned int dcdc_taps;
00037     CHANGE_FUNC(dcdcThreshold,      0, 10)
00038     CHANGE_FUNC(dcdcOverCurrent,    0, 100)
00039     CHANGE_FUNC(dcdcStartDelay,     0, 10)
00040     CHANGE_FUNC(dcdcStopDelay,      0, 10)
00041     CHANGE_FUNC(dcdc_taps,          1, 1000)
00042 
00043     // Latch Circuits
00044     float imdStartDelay;
00045     float amsStartDelay;
00046     CHANGE_FUNC(imdStartDelay,      0, 100)
00047     CHANGE_FUNC(amsStartDelay,      0, 100)
00048 
00049     // Over-temp
00050     float internalOverTemp;
00051     CHANGE_FUNC(internalOverTemp,   0, 100)
00052 
00053     // Boolean states / modes
00054     bool CANnoAck;                      // Is noAck mode on?
00055     bool extendedSerial;
00056     CHANGE_FUNC(CANnoAck,           0, 1)
00057     CHANGE_FUNC(extendedSerial,     0, 1)
00058 
00059     // Buffer sizes
00060     unsigned int CANtxSize;             // Size of CAN TX buffer
00061     unsigned int CANrxSize;             // Size of CAN RX buffer
00062     unsigned int SerialBaud;            // Serial port baudrate
00063     unsigned int SerialTxSize;          // Serial TX buffer size
00064     CHANGE_FUNC(CANtxSize,          1,    1000)
00065     CHANGE_FUNC(CANrxSize,          1,    1000)
00066     CHANGE_FUNC(SerialBaud,         9600, 921600)
00067     CHANGE_FUNC(SerialTxSize,       1,    10000)
00068 
00069     // Load / store / fetch functions
00070     static bool loadProfile(int index);                     // Load profile from flash into the current RAM object, 0=default, -1=freeze frame
00071     static bool saveProfile(int index);                     // Save the current RAM profile into flash to index, 0=default
00072     static bool getProfile(Profile **ptr, int index);       // Retrieve the handle to a profile
00073     static bool loadStartUp();                              // Load the profile on startup
00074     static int  usingProfile();                             // Return the last profile loaded into RAM, 0=default, -1=freeze frame
00075 };
00076 class Profile_checkSum
00077 {
00078 public:
00079     Profile param;
00080     uint32_t BSDchecksum;
00081 };
00082 #endif