Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnTempFrame.h@110:d1da040a0cf2, 2015-11-24 (annotated)
- Committer:
- uci1
- Date:
- Tue Nov 24 21:52:27 2015 +0000
- Revision:
- 110:d1da040a0cf2
- Parent:
- 60:fb02f02804af
Stn32 (slow) with conf name. SD stall fix. No interface chip. Safety nets.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
uci1 | 56:0bba0ef15697 | 1 | #ifndef SN_SnTempFrame |
uci1 | 56:0bba0ef15697 | 2 | #define SN_SnTempFrame |
uci1 | 56:0bba0ef15697 | 3 | |
uci1 | 56:0bba0ef15697 | 4 | #include <stdint.h> |
uci1 | 56:0bba0ef15697 | 5 | |
uci1 | 56:0bba0ef15697 | 6 | #include "SnCommWin.h" |
uci1 | 56:0bba0ef15697 | 7 | |
uci1 | 56:0bba0ef15697 | 8 | |
uci1 | 56:0bba0ef15697 | 9 | class SnTempFrame { |
uci1 | 56:0bba0ef15697 | 10 | public: |
uci1 | 56:0bba0ef15697 | 11 | // i/o version |
uci1 | 56:0bba0ef15697 | 12 | static const uint8_t kIOvers; // MUST BE INCREASED if any member var changes |
uci1 | 60:fb02f02804af | 13 | static const uint32_t kMaxSizeOfV1 = sizeof(float) + sizeof(uint32_t); // DO NOT USE! forgot the byte for i/o version |
uci1 | 60:fb02f02804af | 14 | static const uint32_t kMaxSizeOfV2 = kMaxSizeOfV1 + sizeof(uint8_t); // add i/o version |
uci1 | 60:fb02f02804af | 15 | static const uint32_t kMaxSizeOf = kMaxSizeOfV2; |
uci1 | 56:0bba0ef15697 | 16 | |
uci1 | 56:0bba0ef15697 | 17 | private: |
uci1 | 56:0bba0ef15697 | 18 | float fTemp; // the temperature |
uci1 | 56:0bba0ef15697 | 19 | uint32_t fTime; // time of temp check |
uci1 | 56:0bba0ef15697 | 20 | |
uci1 | 56:0bba0ef15697 | 21 | public: |
uci1 | 56:0bba0ef15697 | 22 | SnTempFrame(const float tmp=0, const uint32_t tim=0) : |
uci1 | 56:0bba0ef15697 | 23 | fTemp(tmp), fTime(tim) { |
uci1 | 56:0bba0ef15697 | 24 | } |
uci1 | 56:0bba0ef15697 | 25 | virtual ~SnTempFrame() {} |
uci1 | 56:0bba0ef15697 | 26 | |
uci1 | 56:0bba0ef15697 | 27 | static |
uci1 | 56:0bba0ef15697 | 28 | uint32_t SizeOf(const uint8_t rv=SnTempFrame::kIOvers) { |
uci1 | 56:0bba0ef15697 | 29 | if (rv==1) { |
uci1 | 56:0bba0ef15697 | 30 | return kMaxSizeOfV1; |
uci1 | 60:fb02f02804af | 31 | } else if (rv==2) { |
uci1 | 60:fb02f02804af | 32 | return kMaxSizeOfV2; |
uci1 | 56:0bba0ef15697 | 33 | } else { |
uci1 | 56:0bba0ef15697 | 34 | return kMaxSizeOf; |
uci1 | 56:0bba0ef15697 | 35 | } |
uci1 | 56:0bba0ef15697 | 36 | } |
uci1 | 56:0bba0ef15697 | 37 | |
uci1 | 56:0bba0ef15697 | 38 | float GetTemperature() const { return fTemp; } |
uci1 | 56:0bba0ef15697 | 39 | uint32_t GetTime() const { return fTime; } |
uci1 | 56:0bba0ef15697 | 40 | |
uci1 | 56:0bba0ef15697 | 41 | void SetTempOnly(const float tmp) { fTemp = tmp; } |
uci1 | 56:0bba0ef15697 | 42 | void SetTime(const uint32_t t) { fTime = t; } |
uci1 | 56:0bba0ef15697 | 43 | |
uci1 | 56:0bba0ef15697 | 44 | void SetTempAndTime(const float tmp, const uint32_t tim) { |
uci1 | 56:0bba0ef15697 | 45 | fTemp = tmp; |
uci1 | 56:0bba0ef15697 | 46 | fTime = tim; |
uci1 | 56:0bba0ef15697 | 47 | } |
uci1 | 56:0bba0ef15697 | 48 | |
uci1 | 56:0bba0ef15697 | 49 | template<class T> |
uci1 | 56:0bba0ef15697 | 50 | SnCommWin::ECommWinResult WriteTo(T& x) const { |
uci1 | 56:0bba0ef15697 | 51 | x = SnBitUtils::WriteTo(x, kIOvers); |
uci1 | 56:0bba0ef15697 | 52 | x = SnBitUtils::WriteTo(x, fTemp); |
uci1 | 56:0bba0ef15697 | 53 | x = SnBitUtils::WriteTo(x, fTime); |
uci1 | 56:0bba0ef15697 | 54 | return SnCommWin::kOkWithMsg; |
uci1 | 56:0bba0ef15697 | 55 | } |
uci1 | 56:0bba0ef15697 | 56 | |
uci1 | 56:0bba0ef15697 | 57 | template<class T> |
uci1 | 56:0bba0ef15697 | 58 | SnCommWin::ECommWinResult ReadFrom(T& b) { |
uci1 | 56:0bba0ef15697 | 59 | uint8_t Rv=0; |
uci1 | 56:0bba0ef15697 | 60 | b = SnBitUtils::ReadFrom(b, Rv); |
uci1 | 56:0bba0ef15697 | 61 | b = SnBitUtils::ReadFrom(b, fTemp); |
uci1 | 56:0bba0ef15697 | 62 | b = SnBitUtils::ReadFrom(b, fTime); |
uci1 | 56:0bba0ef15697 | 63 | return SnCommWin::kOkWithMsg; |
uci1 | 56:0bba0ef15697 | 64 | } |
uci1 | 56:0bba0ef15697 | 65 | |
uci1 | 56:0bba0ef15697 | 66 | }; |
uci1 | 56:0bba0ef15697 | 67 | |
uci1 | 56:0bba0ef15697 | 68 | #endif // SN_SnTempFrame |