Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnPowerFrame.h@110:d1da040a0cf2, 2015-11-24 (annotated)
- Committer:
- uci1
- Date:
- Tue Nov 24 21:52:27 2015 +0000
- Revision:
- 110:d1da040a0cf2
- Parent:
- 84:80b15993944e
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 | 4:a91682e19d6b | 1 | #ifndef SN_SnPowerFrame |
uci1 | 4:a91682e19d6b | 2 | #define SN_SnPowerFrame |
uci1 | 4:a91682e19d6b | 3 | |
uci1 | 4:a91682e19d6b | 4 | #include <stdint.h> |
uci1 | 4:a91682e19d6b | 5 | |
uci1 | 4:a91682e19d6b | 6 | #include "SnCommWin.h" |
uci1 | 4:a91682e19d6b | 7 | |
uci1 | 4:a91682e19d6b | 8 | class SnPowerFrame { |
uci1 | 4:a91682e19d6b | 9 | public: |
uci1 | 4:a91682e19d6b | 10 | static const uint8_t kIOvers; // MUST BE INCREASED if any member var changes (==> also if kNchans, etc. change!) |
uci1 | 8:95a325df1f6b | 11 | static const uint32_t kMaxSizeOf = sizeof(uint8_t) + (4u*sizeof(float)) + sizeof(uint32_t); |
uci1 | 4:a91682e19d6b | 12 | |
uci1 | 4:a91682e19d6b | 13 | private: |
uci1 | 8:95a325df1f6b | 14 | float faveV1; |
uci1 | 8:95a325df1f6b | 15 | float faveV2; |
uci1 | 8:95a325df1f6b | 16 | float frmsV1; |
uci1 | 8:95a325df1f6b | 17 | float frmsV2; |
uci1 | 8:95a325df1f6b | 18 | uint32_t fTime; |
uci1 | 8:95a325df1f6b | 19 | |
uci1 | 4:a91682e19d6b | 20 | public: |
uci1 | 8:95a325df1f6b | 21 | SnPowerFrame(const float av1=0, const float av2=0, |
uci1 | 8:95a325df1f6b | 22 | const float rv1=0, const float rv2=0, |
uci1 | 8:95a325df1f6b | 23 | const uint32_t time=0) |
uci1 | 8:95a325df1f6b | 24 | : faveV1(av1), faveV2(av2), frmsV1(rv1), frmsV2(rv2), fTime(time) {} |
uci1 | 4:a91682e19d6b | 25 | virtual ~SnPowerFrame() {} |
uci1 | 4:a91682e19d6b | 26 | |
uci1 | 8:95a325df1f6b | 27 | float GetAveV1() const { return faveV1; } |
uci1 | 8:95a325df1f6b | 28 | float GetAveV2() const { return faveV2; } |
uci1 | 8:95a325df1f6b | 29 | float GetRmsV1() const { return frmsV1; } |
uci1 | 8:95a325df1f6b | 30 | float GetRmsV2() const { return frmsV2; } |
uci1 | 8:95a325df1f6b | 31 | uint32_t GetTime() const { return fTime; } |
uci1 | 4:a91682e19d6b | 32 | |
uci1 | 8:95a325df1f6b | 33 | void SetAveV1(const float av) { faveV1 = av; } |
uci1 | 8:95a325df1f6b | 34 | void SetAveV2(const float av) { faveV2 = av; } |
uci1 | 8:95a325df1f6b | 35 | void SetRmsV1(const float rm) { frmsV1 = rm; } |
uci1 | 8:95a325df1f6b | 36 | void SetRmsV2(const float rm) { frmsV2 = rm; } |
uci1 | 8:95a325df1f6b | 37 | void SetTime(const uint32_t t) { fTime = t; } |
uci1 | 8:95a325df1f6b | 38 | void Set(const float av1, const float av2, |
uci1 | 8:95a325df1f6b | 39 | const float rm1, const float rm2, |
uci1 | 8:95a325df1f6b | 40 | const uint32_t time) { |
uci1 | 8:95a325df1f6b | 41 | faveV1 = av1; faveV2 = av2; |
uci1 | 8:95a325df1f6b | 42 | frmsV1 = rm1; frmsV2 = rm2; |
uci1 | 8:95a325df1f6b | 43 | fTime = time; |
uci1 | 8:95a325df1f6b | 44 | } |
uci1 | 4:a91682e19d6b | 45 | |
uci1 | 4:a91682e19d6b | 46 | static |
uci1 | 84:80b15993944e | 47 | uint32_t SizeOf(const uint8_t rv=SnPowerFrame::kIOvers) { |
uci1 | 8:95a325df1f6b | 48 | if (rv==1) { |
uci1 | 8:95a325df1f6b | 49 | return sizeof(uint8_t) + (2u*sizeof(uint16_t)); |
uci1 | 8:95a325df1f6b | 50 | } else { |
uci1 | 8:95a325df1f6b | 51 | return kMaxSizeOf; |
uci1 | 8:95a325df1f6b | 52 | } |
uci1 | 4:a91682e19d6b | 53 | } |
uci1 | 4:a91682e19d6b | 54 | |
uci1 | 4:a91682e19d6b | 55 | template<class T> |
uci1 | 8:95a325df1f6b | 56 | SnCommWin::ECommWinResult WriteTo(T& x) const { |
uci1 | 8:95a325df1f6b | 57 | x = SnBitUtils::WriteTo(x, kIOvers); |
uci1 | 8:95a325df1f6b | 58 | x = SnBitUtils::WriteTo(x, faveV1); |
uci1 | 8:95a325df1f6b | 59 | x = SnBitUtils::WriteTo(x, faveV2); |
uci1 | 8:95a325df1f6b | 60 | x = SnBitUtils::WriteTo(x, frmsV1); |
uci1 | 8:95a325df1f6b | 61 | x = SnBitUtils::WriteTo(x, frmsV2); |
uci1 | 8:95a325df1f6b | 62 | x = SnBitUtils::WriteTo(x, fTime); |
uci1 | 8:95a325df1f6b | 63 | return SnCommWin::kOkWithMsg; |
uci1 | 8:95a325df1f6b | 64 | } |
uci1 | 8:95a325df1f6b | 65 | |
uci1 | 8:95a325df1f6b | 66 | template<class T> |
uci1 | 8:95a325df1f6b | 67 | SnCommWin::ECommWinResult ReadFrom(T& b) { |
uci1 | 4:a91682e19d6b | 68 | uint8_t Rv=0; |
uci1 | 4:a91682e19d6b | 69 | b = SnBitUtils::ReadFrom(b, Rv); |
uci1 | 8:95a325df1f6b | 70 | if (Rv==1) { |
uci1 | 8:95a325df1f6b | 71 | uint16_t v1, v2; |
uci1 | 4:a91682e19d6b | 72 | b = SnBitUtils::ReadFrom(b, v1); |
uci1 | 4:a91682e19d6b | 73 | b = SnBitUtils::ReadFrom(b, v2); |
uci1 | 8:95a325df1f6b | 74 | faveV1 = v1; |
uci1 | 8:95a325df1f6b | 75 | faveV2 = v2; |
uci1 | 8:95a325df1f6b | 76 | frmsV1 = frmsV2 = 0; |
uci1 | 8:95a325df1f6b | 77 | fTime = 0; |
uci1 | 8:95a325df1f6b | 78 | } else if (Rv>1) { |
uci1 | 8:95a325df1f6b | 79 | b = SnBitUtils::ReadFrom(b, faveV1); |
uci1 | 8:95a325df1f6b | 80 | b = SnBitUtils::ReadFrom(b, faveV2); |
uci1 | 8:95a325df1f6b | 81 | b = SnBitUtils::ReadFrom(b, frmsV1); |
uci1 | 8:95a325df1f6b | 82 | b = SnBitUtils::ReadFrom(b, frmsV2); |
uci1 | 8:95a325df1f6b | 83 | b = SnBitUtils::ReadFrom(b, fTime); |
uci1 | 4:a91682e19d6b | 84 | } |
uci1 | 4:a91682e19d6b | 85 | return SnCommWin::kOkWithMsg; |
uci1 | 4:a91682e19d6b | 86 | } |
uci1 | 4:a91682e19d6b | 87 | |
uci1 | 4:a91682e19d6b | 88 | }; |
uci1 | 4:a91682e19d6b | 89 | |
uci1 | 4:a91682e19d6b | 90 | #endif // SN_SnPowerFrame |