Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnConfigFrame.h@1:e392595b4b76, 2012-07-20 (annotated)
- Committer:
- uci1
- Date:
- Fri Jul 20 19:04:02 2012 +0000
- Revision:
- 1:e392595b4b76
- Parent:
- 0:664899e0b988
- Child:
- 3:24c5f0f50bf1
many features checked and working. afar implemented. sending of data not yet tested. contains many debug prints
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 0:664899e0b988 | 1 | #ifndef SN_SnConfigFrame |
uci1 | 0:664899e0b988 | 2 | #define SN_SnConfigFrame |
uci1 | 0:664899e0b988 | 3 | |
uci1 | 0:664899e0b988 | 4 | #include <stdint.h> |
uci1 | 0:664899e0b988 | 5 | #include "SnConstants.h" |
uci1 | 0:664899e0b988 | 6 | #include "SnBitUtils.h" |
uci1 | 0:664899e0b988 | 7 | |
uci1 | 0:664899e0b988 | 8 | class SnConfigFrame { |
uci1 | 0:664899e0b988 | 9 | public: |
uci1 | 1:e392595b4b76 | 10 | static const uint32_t kMinCommWinPrdLowPwr; // exclusive min low power comm win period (s) |
uci1 | 1:e392595b4b76 | 11 | static const uint32_t kMaxCommWinPrdLowPwr; // exclusive max low power comm win period (s) |
uci1 | 1:e392595b4b76 | 12 | static const uint32_t kMinCommWinDurLowPwr; // exclusive min low power comm win duration (s) |
uci1 | 1:e392595b4b76 | 13 | static const uint32_t kMaxCommWinDurLowPwr; // exclusive max low power comm win duration (s) |
uci1 | 1:e392595b4b76 | 14 | static const uint8_t kConfLblLen=64; // length of configuration label char array (63+'\0') |
uci1 | 0:664899e0b988 | 15 | |
uci1 | 1:e392595b4b76 | 16 | static const char* const kDefConfFile; // default configuration file |
uci1 | 0:664899e0b988 | 17 | |
uci1 | 0:664899e0b988 | 18 | static const uint32_t kMaxSizeOf = |
uci1 | 1:e392595b4b76 | 19 | + (9u*sizeof(uint32_t)) + (6u*sizeof(uint16_t)) |
uci1 | 1:e392595b4b76 | 20 | + (10u*sizeof(uint8_t)) + (3u*kNplas*sizeof(uint16_t)) |
uci1 | 1:e392595b4b76 | 21 | + (kTotDacs*sizeof(uint16_t)) |
uci1 | 0:664899e0b988 | 22 | + (kConfLblLen*sizeof(uint8_t)); |
uci1 | 0:664899e0b988 | 23 | |
uci1 | 0:664899e0b988 | 24 | |
uci1 | 0:664899e0b988 | 25 | enum EDatPackBit { |
uci1 | 0:664899e0b988 | 26 | kSDcard = BIT(0), |
uci1 | 0:664899e0b988 | 27 | kIrid = BIT(1), |
uci1 | 0:664899e0b988 | 28 | kAfar = BIT(2), |
uci1 | 0:664899e0b988 | 29 | kUSB = BIT(3) |
uci1 | 0:664899e0b988 | 30 | }; |
uci1 | 0:664899e0b988 | 31 | |
uci1 | 0:664899e0b988 | 32 | enum ESendDataBit { |
uci1 | 0:664899e0b988 | 33 | // can't use BIT(0)! (-0 = 0 => send nothing) |
uci1 | 1:e392595b4b76 | 34 | kAllFiles = BIT(1), // if bit=0 => send most recent file |
uci1 | 1:e392595b4b76 | 35 | kTimeout = BIT(2), // if bit=0 => ignore timeout |
uci1 | 1:e392595b4b76 | 36 | kDelete = BIT(3), // if bit=0 => do not delete sent files |
uci1 | 1:e392595b4b76 | 37 | kUseBits = -BIT(10) // useful to initialize fCommSendData as a bit word |
uci1 | 0:664899e0b988 | 38 | }; |
uci1 | 0:664899e0b988 | 39 | |
uci1 | 0:664899e0b988 | 40 | // i/o version |
uci1 | 1:e392595b4b76 | 41 | static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) |
uci1 | 0:664899e0b988 | 42 | |
uci1 | 0:664899e0b988 | 43 | private: |
uci1 | 0:664899e0b988 | 44 | // !! |
uci1 | 0:664899e0b988 | 45 | // !! If any member variables change, update: SizeOf function and kIOVers value! (also if kNchans, etc. change!) |
uci1 | 0:664899e0b988 | 46 | // !! |
uci1 | 0:664899e0b988 | 47 | |
uci1 | 0:664899e0b988 | 48 | // mbed mac address |
uci1 | 0:664899e0b988 | 49 | static uint64_t fgMacAdr; // mbed mac address |
uci1 | 0:664899e0b988 | 50 | // conf header |
uci1 | 0:664899e0b988 | 51 | char fLabel[kConfLblLen]; // configuration label |
uci1 | 0:664899e0b988 | 52 | uint32_t fConfTime; // cpu config time |
uci1 | 0:664899e0b988 | 53 | uint32_t fRun; // run number |
uci1 | 0:664899e0b988 | 54 | uint32_t fFirstEvt; // starting event number |
uci1 | 0:664899e0b988 | 55 | uint8_t fStreamHiLoPlas; // (1byte bool) if true, add the separated hi/lo thresh PLA patterns to the i/o |
uci1 | 0:664899e0b988 | 56 | // data packing |
uci1 | 0:664899e0b988 | 57 | uint8_t fWvLoseLSB; // number of least significant bits to lose when packing waveform data |
uci1 | 0:664899e0b988 | 58 | uint8_t fWvLoseMSB; // number of most significant bits to lose when packing waveform data |
uci1 | 0:664899e0b988 | 59 | uint16_t fWvBaseline; // global baseline to use when packing data (useful to reduce clipping on the high end) |
uci1 | 0:664899e0b988 | 60 | uint8_t fDatPackType; // type of data packing. OR'd bitword: if bit 1, will pack for writing. see EDatPackBit. default: always pack (all 1's) |
uci1 | 0:664899e0b988 | 61 | // trigger setup |
uci1 | 0:664899e0b988 | 62 | uint16_t fDAC[kNchans][kNfpgaDacs]; //[card id][dac id] values should be 0-4095 here (not checked tho) |
uci1 | 0:664899e0b988 | 63 | uint8_t fNumPlas; // number of patterns to use. must be <= kNplas. |
uci1 | 0:664899e0b988 | 64 | uint16_t fPLA[kNplas]; //[pattern id] (same for each card) |
uci1 | 0:664899e0b988 | 65 | uint8_t fNumCardsMajLog; // number of cards participating in the MajLogic trigger (1 to 4) |
uci1 | 0:664899e0b988 | 66 | uint8_t fEnableThermTrig; // (1byte bool) whether or not to allow thermal triggers |
uci1 | 0:664899e0b988 | 67 | uint16_t fForceTrigPeriod; // number of seconds between force triggers (0=none) |
uci1 | 0:664899e0b988 | 68 | uint16_t fHeartBeatPeriod; // number of seconds between heartbeats (0=none) |
uci1 | 0:664899e0b988 | 69 | uint8_t fAmpsOn; // which amps are on (bit word. uint8_t => 8 amps max) |
uci1 | 0:664899e0b988 | 70 | uint16_t fEvtThrtlPeriodMs; // throttle period to write events (ms) |
uci1 | 0:664899e0b988 | 71 | // power |
uci1 | 0:664899e0b988 | 72 | uint8_t fPowerMode; // power mode bit word |
uci1 | 0:664899e0b988 | 73 | int16_t fBatVoltLowPwr; // battery level at which to switch to low power (not used?) |
uci1 | 0:664899e0b988 | 74 | // communication |
uci1 | 0:664899e0b988 | 75 | uint32_t fCommWinPeriod; // seconds between communication window startup (0=always on) |
uci1 | 0:664899e0b988 | 76 | uint32_t fCommWinDuration; // seconds that communication window stays open (0=always open) |
uci1 | 0:664899e0b988 | 77 | int16_t fCommSendData; // data to send during comm win (=0: none, >0=send up to x events from last file until comm win closes, <0=see ESendDataBit) |
uci1 | 0:664899e0b988 | 78 | uint32_t fCommWinPrdLowPwr; // low power communication window period (seconds) (range enforced) |
uci1 | 0:664899e0b988 | 79 | uint32_t fCommWinDurLowPwr; // low power communication window duration (seconds) (range enforced) |
uci1 | 0:664899e0b988 | 80 | // watchdog |
uci1 | 0:664899e0b988 | 81 | uint32_t fWatchDogPeriod; // number of seconds of inactivity for watchdog to issue a reset |
uci1 | 0:664899e0b988 | 82 | |
uci1 | 0:664899e0b988 | 83 | void SetHardDefaults(); |
uci1 | 0:664899e0b988 | 84 | |
uci1 | 0:664899e0b988 | 85 | static |
uci1 | 1:e392595b4b76 | 86 | uint32_t SizeOf(const bool streamHiLoPlas, |
uci1 | 1:e392595b4b76 | 87 | const uint8_t nplas, |
uci1 | 1:e392595b4b76 | 88 | const uint8_t lblLen) { |
uci1 | 0:664899e0b988 | 89 | // private because it cannot be used to read from a buffer |
uci1 | 0:664899e0b988 | 90 | // (the label length and fStreamHiLoPlas are not known a priori) |
uci1 | 0:664899e0b988 | 91 | // returns the num of bytes needed to stream this object |
uci1 | 0:664899e0b988 | 92 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 0:664899e0b988 | 93 | uint32_t sz = kMaxSizeOf - kConfLblLen + lblLen; |
uci1 | 1:e392595b4b76 | 94 | static const uint32_t mhlp = 2u*kNplas*sizeof(uint16_t); |
uci1 | 1:e392595b4b76 | 95 | const int32_t dp = (nplas-kNplas)*sizeof(uint16_t); |
uci1 | 1:e392595b4b76 | 96 | const uint8_t fac = (streamHiLoPlas) ? 3u : 1u; |
uci1 | 1:e392595b4b76 | 97 | sz -= (fac*dp); |
uci1 | 0:664899e0b988 | 98 | if (streamHiLoPlas==false) { |
uci1 | 1:e392595b4b76 | 99 | sz -= mhlp; |
uci1 | 0:664899e0b988 | 100 | } |
uci1 | 0:664899e0b988 | 101 | return sz; |
uci1 | 0:664899e0b988 | 102 | } |
uci1 | 0:664899e0b988 | 103 | |
uci1 | 0:664899e0b988 | 104 | public: |
uci1 | 0:664899e0b988 | 105 | SnConfigFrame() { Reset(); } |
uci1 | 0:664899e0b988 | 106 | virtual ~SnConfigFrame() {} |
uci1 | 0:664899e0b988 | 107 | |
uci1 | 0:664899e0b988 | 108 | const char* GetLabel() const { return fLabel; } |
uci1 | 0:664899e0b988 | 109 | uint32_t GetLabelStrLen() const { return strlen(fLabel); } |
uci1 | 0:664899e0b988 | 110 | uint32_t GetRun() const { return fRun; } |
uci1 | 0:664899e0b988 | 111 | uint32_t GetFirstEvt() const { return fFirstEvt; } |
uci1 | 0:664899e0b988 | 112 | uint16_t GetEvtThrtlPeriodMs() const { return fEvtThrtlPeriodMs; } |
uci1 | 0:664899e0b988 | 113 | uint16_t GetForceTrigPeriod() const { return fForceTrigPeriod; } |
uci1 | 0:664899e0b988 | 114 | uint32_t GetWatchdogPeriod() const { return fWatchDogPeriod; } |
uci1 | 0:664899e0b988 | 115 | uint16_t GetDac(const uint8_t ch, const uint8_t dn) const { return fDAC[ch][dn]; } |
uci1 | 0:664899e0b988 | 116 | uint8_t GetNumPlas() const { return fNumPlas; } |
uci1 | 0:664899e0b988 | 117 | uint16_t GetPla(const uint8_t pn) const { return fPLA[pn]; } |
uci1 | 0:664899e0b988 | 118 | uint8_t GetNumCardsMajLog() const { return fNumCardsMajLog; } |
uci1 | 0:664899e0b988 | 119 | bool IsThermTrigEnabled() const { return fEnableThermTrig!=0; } |
uci1 | 0:664899e0b988 | 120 | bool IsEachAmpOn() const { |
uci1 | 0:664899e0b988 | 121 | bool allon=true; |
uci1 | 0:664899e0b988 | 122 | for (uint8_t i=0; (i<kNchans) && allon; i++) { |
uci1 | 0:664899e0b988 | 123 | allon = (fAmpsOn & BIT(i))!=0; |
uci1 | 0:664899e0b988 | 124 | } |
uci1 | 0:664899e0b988 | 125 | return allon; |
uci1 | 0:664899e0b988 | 126 | } |
uci1 | 0:664899e0b988 | 127 | // TODO: allow check for individual amps, when they can be turned on individually |
uci1 | 0:664899e0b988 | 128 | |
uci1 | 0:664899e0b988 | 129 | uint32_t GetCommWinPeriod() const { return fCommWinPeriod; } |
uci1 | 0:664899e0b988 | 130 | uint32_t GetCommWinDuration() const { return fCommWinDuration; } |
uci1 | 0:664899e0b988 | 131 | int16_t GetCommSendData() const { return fCommSendData; } |
uci1 | 0:664899e0b988 | 132 | |
uci1 | 0:664899e0b988 | 133 | bool IsSendingAllFiles() const |
uci1 | 0:664899e0b988 | 134 | { return (fCommSendData<0) && ((fCommSendData & kAllFiles)!=0); } |
uci1 | 0:664899e0b988 | 135 | bool IsObeyingTimeout() const |
uci1 | 0:664899e0b988 | 136 | { return (fCommSendData<0) && ((fCommSendData & kTimeout)!=0); } |
uci1 | 0:664899e0b988 | 137 | bool IsDeletingFiles() const |
uci1 | 0:664899e0b988 | 138 | { return (fCommSendData<0) && ((fCommSendData & kDelete)!=0); } |
uci1 | 0:664899e0b988 | 139 | |
uci1 | 0:664899e0b988 | 140 | |
uci1 | 0:664899e0b988 | 141 | const char* GetOutFileName(const char* dir) const; |
uci1 | 0:664899e0b988 | 142 | |
uci1 | 0:664899e0b988 | 143 | // waveform packing info |
uci1 | 0:664899e0b988 | 144 | uint16_t GetWvBaseline() const { return fWvBaseline; } |
uci1 | 0:664899e0b988 | 145 | uint8_t GetWvLoseLSB() const { return fWvLoseLSB; } |
uci1 | 0:664899e0b988 | 146 | uint8_t GetWvLoseMSB() const { return fWvLoseMSB; } |
uci1 | 0:664899e0b988 | 147 | bool IsDatPackedFor(const EDatPackBit d) const { return (fDatPackType & d)!=0; } |
uci1 | 0:664899e0b988 | 148 | void GetPackParsFor(const EDatPackBit d, |
uci1 | 0:664899e0b988 | 149 | uint8_t& loseLSB, uint8_t& loseMSB, |
uci1 | 0:664899e0b988 | 150 | uint16_t& wvBase) const; |
uci1 | 0:664899e0b988 | 151 | |
uci1 | 0:664899e0b988 | 152 | // i/o |
uci1 | 0:664899e0b988 | 153 | template<class T> |
uci1 | 0:664899e0b988 | 154 | void ReadFrom(T& b) { |
uci1 | 0:664899e0b988 | 155 | // no check on the length of buf is done here |
uci1 | 0:664899e0b988 | 156 | // that should be been done already |
uci1 | 0:664899e0b988 | 157 | // |
uci1 | 0:664899e0b988 | 158 | // must match WriteTo |
uci1 | 0:664899e0b988 | 159 | |
uci1 | 1:e392595b4b76 | 160 | uint8_t Rv=0; |
uci1 | 0:664899e0b988 | 161 | b = SnBitUtils::ReadFrom(b, Rv); // i/o version |
uci1 | 0:664899e0b988 | 162 | if (Rv>0) { |
uci1 | 0:664899e0b988 | 163 | uint32_t llen=kConfLblLen; |
uci1 | 0:664899e0b988 | 164 | b = SnBitUtils::ReadFrom(b, llen); |
uci1 | 0:664899e0b988 | 165 | b = SnBitUtils::ReadFrom(b, fLabel, llen); |
uci1 | 0:664899e0b988 | 166 | b = SnBitUtils::ReadFrom(b, fConfTime); |
uci1 | 0:664899e0b988 | 167 | b = SnBitUtils::ReadFrom(b, fRun); |
uci1 | 0:664899e0b988 | 168 | b = SnBitUtils::ReadFrom(b, fFirstEvt); |
uci1 | 0:664899e0b988 | 169 | b = SnBitUtils::ReadFrom(b, fStreamHiLoPlas); |
uci1 | 0:664899e0b988 | 170 | b = SnBitUtils::ReadFrom(b, fWvLoseLSB); |
uci1 | 0:664899e0b988 | 171 | b = SnBitUtils::ReadFrom(b, fWvLoseMSB); |
uci1 | 0:664899e0b988 | 172 | b = SnBitUtils::ReadFrom(b, fWvBaseline); |
uci1 | 0:664899e0b988 | 173 | b = SnBitUtils::ReadFrom(b, fDatPackType); |
uci1 | 0:664899e0b988 | 174 | uint16_t* dc = &(fDAC[0][0]); |
uci1 | 0:664899e0b988 | 175 | for (uint16_t i=0; i<kTotDacs; i++, dc++) { |
uci1 | 0:664899e0b988 | 176 | b = SnBitUtils::ReadFrom(b, *dc); |
uci1 | 0:664899e0b988 | 177 | } |
uci1 | 0:664899e0b988 | 178 | b = SnBitUtils::ReadFrom(b, fNumPlas); |
uci1 | 0:664899e0b988 | 179 | uint16_t* pl = &(fPLA[0]); |
uci1 | 0:664899e0b988 | 180 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 0:664899e0b988 | 181 | b = SnBitUtils::ReadFrom(b, *pl); |
uci1 | 0:664899e0b988 | 182 | } |
uci1 | 0:664899e0b988 | 183 | b = SnBitUtils::ReadFrom(b, fNumCardsMajLog); |
uci1 | 0:664899e0b988 | 184 | b = SnBitUtils::ReadFrom(b, fEnableThermTrig); |
uci1 | 0:664899e0b988 | 185 | b = SnBitUtils::ReadFrom(b, fForceTrigPeriod); |
uci1 | 0:664899e0b988 | 186 | b = SnBitUtils::ReadFrom(b, fHeartBeatPeriod); |
uci1 | 0:664899e0b988 | 187 | b = SnBitUtils::ReadFrom(b, fAmpsOn); |
uci1 | 0:664899e0b988 | 188 | b = SnBitUtils::ReadFrom(b, fEvtThrtlPeriodMs); |
uci1 | 0:664899e0b988 | 189 | b = SnBitUtils::ReadFrom(b, fPowerMode); |
uci1 | 0:664899e0b988 | 190 | b = SnBitUtils::ReadFrom(b, fBatVoltLowPwr); |
uci1 | 0:664899e0b988 | 191 | b = SnBitUtils::ReadFrom(b, fCommWinPeriod); |
uci1 | 0:664899e0b988 | 192 | b = SnBitUtils::ReadFrom(b, fCommWinDuration); |
uci1 | 0:664899e0b988 | 193 | b = SnBitUtils::ReadFrom(b, fCommSendData); |
uci1 | 0:664899e0b988 | 194 | b = SnBitUtils::ReadFrom(b, fCommWinPrdLowPwr); |
uci1 | 0:664899e0b988 | 195 | b = SnBitUtils::ReadFrom(b, fCommWinDurLowPwr); |
uci1 | 0:664899e0b988 | 196 | b = SnBitUtils::ReadFrom(b, fWatchDogPeriod); |
uci1 | 0:664899e0b988 | 197 | if (fStreamHiLoPlas!=0) { |
uci1 | 0:664899e0b988 | 198 | uint16_t hi, lo; |
uci1 | 1:e392595b4b76 | 199 | for (uint8_t j=0; j<fNumPlas; j++) { |
uci1 | 0:664899e0b988 | 200 | b = SnBitUtils::ReadFrom(b, hi); |
uci1 | 0:664899e0b988 | 201 | b = SnBitUtils::ReadFrom(b, lo); |
uci1 | 1:e392595b4b76 | 202 | // don't save these |
uci1 | 0:664899e0b988 | 203 | } |
uci1 | 0:664899e0b988 | 204 | } |
uci1 | 0:664899e0b988 | 205 | } |
uci1 | 0:664899e0b988 | 206 | } |
uci1 | 0:664899e0b988 | 207 | |
uci1 | 0:664899e0b988 | 208 | template <class T> |
uci1 | 0:664899e0b988 | 209 | void WriteTo(T& b) const { |
uci1 | 0:664899e0b988 | 210 | // no check on the length of the buf is done here |
uci1 | 0:664899e0b988 | 211 | // that should be done already |
uci1 | 0:664899e0b988 | 212 | // |
uci1 | 0:664899e0b988 | 213 | // must match ReadFromBuf |
uci1 | 0:664899e0b988 | 214 | // |
uci1 | 0:664899e0b988 | 215 | // intentionally not writing mac address here, so we don't have to read it in |
uci1 | 0:664899e0b988 | 216 | |
uci1 | 0:664899e0b988 | 217 | const uint32_t llen = strlen(fLabel); |
uci1 | 0:664899e0b988 | 218 | |
uci1 | 0:664899e0b988 | 219 | b = SnBitUtils::WriteTo(b, kIOVers); // i/o version |
uci1 | 0:664899e0b988 | 220 | b = SnBitUtils::WriteTo(b, llen); |
uci1 | 0:664899e0b988 | 221 | b = SnBitUtils::WriteTo(b, fLabel, llen); |
uci1 | 0:664899e0b988 | 222 | b = SnBitUtils::WriteTo(b, fConfTime); |
uci1 | 0:664899e0b988 | 223 | b = SnBitUtils::WriteTo(b, fRun); |
uci1 | 0:664899e0b988 | 224 | b = SnBitUtils::WriteTo(b, fFirstEvt); |
uci1 | 0:664899e0b988 | 225 | b = SnBitUtils::WriteTo(b, fStreamHiLoPlas); |
uci1 | 0:664899e0b988 | 226 | b = SnBitUtils::WriteTo(b, fWvLoseLSB); |
uci1 | 0:664899e0b988 | 227 | b = SnBitUtils::WriteTo(b, fWvLoseMSB); |
uci1 | 0:664899e0b988 | 228 | b = SnBitUtils::WriteTo(b, fWvBaseline); |
uci1 | 0:664899e0b988 | 229 | b = SnBitUtils::WriteTo(b, fDatPackType); |
uci1 | 0:664899e0b988 | 230 | const uint16_t* dc = &(fDAC[0][0]); |
uci1 | 0:664899e0b988 | 231 | for (uint16_t i=0; i<kTotDacs; i++, dc++) { |
uci1 | 0:664899e0b988 | 232 | b = SnBitUtils::WriteTo(b, *dc); |
uci1 | 0:664899e0b988 | 233 | } |
uci1 | 0:664899e0b988 | 234 | b = SnBitUtils::WriteTo(b, fNumPlas); |
uci1 | 0:664899e0b988 | 235 | const uint16_t* pl = &(fPLA[0]); |
uci1 | 0:664899e0b988 | 236 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 0:664899e0b988 | 237 | b = SnBitUtils::WriteTo(b, *pl); |
uci1 | 0:664899e0b988 | 238 | } |
uci1 | 0:664899e0b988 | 239 | b = SnBitUtils::WriteTo(b, fNumCardsMajLog); |
uci1 | 0:664899e0b988 | 240 | b = SnBitUtils::WriteTo(b, fEnableThermTrig); |
uci1 | 0:664899e0b988 | 241 | b = SnBitUtils::WriteTo(b, fForceTrigPeriod); |
uci1 | 0:664899e0b988 | 242 | b = SnBitUtils::WriteTo(b, fHeartBeatPeriod); |
uci1 | 0:664899e0b988 | 243 | b = SnBitUtils::WriteTo(b, fAmpsOn); |
uci1 | 0:664899e0b988 | 244 | b = SnBitUtils::WriteTo(b, fEvtThrtlPeriodMs); |
uci1 | 0:664899e0b988 | 245 | b = SnBitUtils::WriteTo(b, fPowerMode); |
uci1 | 0:664899e0b988 | 246 | b = SnBitUtils::WriteTo(b, fBatVoltLowPwr); |
uci1 | 0:664899e0b988 | 247 | b = SnBitUtils::WriteTo(b, fCommWinPeriod); |
uci1 | 0:664899e0b988 | 248 | b = SnBitUtils::WriteTo(b, fCommWinDuration); |
uci1 | 0:664899e0b988 | 249 | b = SnBitUtils::WriteTo(b, fCommSendData); |
uci1 | 0:664899e0b988 | 250 | b = SnBitUtils::WriteTo(b, fCommWinPrdLowPwr); |
uci1 | 0:664899e0b988 | 251 | b = SnBitUtils::WriteTo(b, fCommWinDurLowPwr); |
uci1 | 0:664899e0b988 | 252 | b = SnBitUtils::WriteTo(b, fWatchDogPeriod); |
uci1 | 0:664899e0b988 | 253 | if (fStreamHiLoPlas!=0) { |
uci1 | 0:664899e0b988 | 254 | pl = fPLA; |
uci1 | 0:664899e0b988 | 255 | uint16_t hi, lo; |
uci1 | 0:664899e0b988 | 256 | for (uint8_t j=0; j<fNumPlas; j++, pl++) { |
uci1 | 0:664899e0b988 | 257 | GetHiLoPlas(*pl, hi, lo); |
uci1 | 0:664899e0b988 | 258 | b = SnBitUtils::WriteTo(b, hi); |
uci1 | 0:664899e0b988 | 259 | b = SnBitUtils::WriteTo(b, lo); |
uci1 | 0:664899e0b988 | 260 | } |
uci1 | 0:664899e0b988 | 261 | } |
uci1 | 0:664899e0b988 | 262 | } |
uci1 | 0:664899e0b988 | 263 | |
uci1 | 0:664899e0b988 | 264 | bool ReadFromFile(const char* cfile); |
uci1 | 0:664899e0b988 | 265 | bool WriteToFile(const char* cfile) const; |
uci1 | 0:664899e0b988 | 266 | |
uci1 | 0:664899e0b988 | 267 | void Reset() { |
uci1 | 0:664899e0b988 | 268 | memset(fLabel, 0, sizeof(char)*kConfLblLen); |
uci1 | 0:664899e0b988 | 269 | if (ReadFromFile(kDefConfFile)==false) { |
uci1 | 0:664899e0b988 | 270 | // couldn't get default. use hardcoded version. |
uci1 | 0:664899e0b988 | 271 | SetHardDefaults(); |
uci1 | 0:664899e0b988 | 272 | } |
uci1 | 0:664899e0b988 | 273 | } |
uci1 | 0:664899e0b988 | 274 | |
uci1 | 0:664899e0b988 | 275 | uint32_t SizeOf() const { |
uci1 | 0:664899e0b988 | 276 | // returns the num of bytes needed to stream this object |
uci1 | 0:664899e0b988 | 277 | // = size of member vars + 1 for i/o version + extra PLA strings (maybe) |
uci1 | 0:664899e0b988 | 278 | // + length of label string |
uci1 | 1:e392595b4b76 | 279 | return SizeOf(fStreamHiLoPlas!=0, fNumPlas, strlen(fLabel)); |
uci1 | 0:664899e0b988 | 280 | } |
uci1 | 0:664899e0b988 | 281 | |
uci1 | 0:664899e0b988 | 282 | static void SetMacAddress(); |
uci1 | 0:664899e0b988 | 283 | static uint64_t GetMacAddress() { |
uci1 | 0:664899e0b988 | 284 | if (fgMacAdr==0) { |
uci1 | 0:664899e0b988 | 285 | SetMacAddress(); |
uci1 | 0:664899e0b988 | 286 | } |
uci1 | 0:664899e0b988 | 287 | return fgMacAdr; |
uci1 | 0:664899e0b988 | 288 | } |
uci1 | 0:664899e0b988 | 289 | |
uci1 | 0:664899e0b988 | 290 | static uint32_t GetLabelMaxLen() { return kConfLblLen; } |
uci1 | 0:664899e0b988 | 291 | |
uci1 | 0:664899e0b988 | 292 | static void GetHiLoPlas(const uint16_t pla, |
uci1 | 0:664899e0b988 | 293 | uint16_t& hiPla, |
uci1 | 0:664899e0b988 | 294 | uint16_t& loPla, |
uci1 | 0:664899e0b988 | 295 | const bool r2l=false); |
uci1 | 0:664899e0b988 | 296 | }; |
uci1 | 0:664899e0b988 | 297 | |
uci1 | 0:664899e0b988 | 298 | #endif // SN_SnConfigFrame |