Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Committer:
uci1
Date:
Fri Oct 30 04:49:40 2015 +0000
Revision:
84:80b15993944e
Parent:
40:1324da35afd4
Child:
97:9f3fe603e8b5
conf v11,12. ip to ints. write 64chr lbl. send status data packs. comm pwr as needed. comm each evt. conn/list TO separate afar, sbd. calc FFT, L1 trigger, L1 scaledown. pre-compl opts in own file. max comm fail 75. htbt and clock frames store vars.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uci1 40:1324da35afd4 1 #ifndef SNS_SnClockSetFrame
uci1 40:1324da35afd4 2 #define SNS_SnClockSetFrame
uci1 40:1324da35afd4 3
uci1 40:1324da35afd4 4 #include "mbed.h"
uci1 40:1324da35afd4 5 #include <stdint.h>
uci1 40:1324da35afd4 6
uci1 40:1324da35afd4 7 #include "SnCommWin.h"
uci1 40:1324da35afd4 8
uci1 40:1324da35afd4 9 class SnClockSetFrame {
uci1 40:1324da35afd4 10 public:
uci1 40:1324da35afd4 11 static const uint8_t kIOVers; // MUST BE INCREASED if any member var changes
uci1 40:1324da35afd4 12 static const uint32_t kMaxSizeOf = sizeof(uint8_t) + (3u*sizeof(uint32_t))
uci1 84:80b15993944e 13 + sizeof(int32_t);
uci1 40:1324da35afd4 14
uci1 40:1324da35afd4 15
uci1 40:1324da35afd4 16 private:
uci1 40:1324da35afd4 17 uint32_t fPrevTime;
uci1 40:1324da35afd4 18 uint32_t fSetTime;
uci1 84:80b15993944e 19 //Timer fSinceSet;
uci1 84:80b15993944e 20 uint32_t fCurTime;
uci1 84:80b15993944e 21 int32_t fUsSinceSet; // Timer for some reason givse an int instead of an unsigned int
uci1 40:1324da35afd4 22
uci1 84:80b15993944e 23 //void ResetCCtimer() { fSinceSet.reset(); fSinceSet.start(); }
uci1 40:1324da35afd4 24
uci1 40:1324da35afd4 25 public:
uci1 40:1324da35afd4 26 SnClockSetFrame() :
uci1 84:80b15993944e 27 fPrevTime(0), fSetTime(0),
uci1 84:80b15993944e 28 fCurTime(0), fUsSinceSet(0) {}
uci1 40:1324da35afd4 29 virtual ~SnClockSetFrame() {}
uci1 40:1324da35afd4 30
uci1 84:80b15993944e 31 uint32_t GetCurTime() const { return fCurTime; }
uci1 84:80b15993944e 32
uci1 84:80b15993944e 33 void SetClocks(const uint32_t prev, const uint32_t stim,
uci1 84:80b15993944e 34 const uint32_t ctime, const int32_t usss) {
uci1 84:80b15993944e 35 //ResetCCtimer();
uci1 84:80b15993944e 36 fPrevTime = prev;
uci1 84:80b15993944e 37 fSetTime = stim;
uci1 84:80b15993944e 38 fCurTime = ctime;
uci1 84:80b15993944e 39 fUsSinceSet = usss;
uci1 40:1324da35afd4 40 }
uci1 84:80b15993944e 41 /*
uci1 84:80b15993944e 42 int32_t GetUsSinceSet() {
uci1 84:80b15993944e 43 return static_cast<int32_t>(fUsSinceSet.read_us());
uci1 84:80b15993944e 44 }
uci1 84:80b15993944e 45 */
uci1 40:1324da35afd4 46 static
uci1 40:1324da35afd4 47 uint32_t SizeOf(const uint8_t rv=SnClockSetFrame::kIOVers)
uci1 40:1324da35afd4 48 { return kMaxSizeOf; }
uci1 40:1324da35afd4 49
uci1 40:1324da35afd4 50 template<class T>
uci1 84:80b15993944e 51 SnCommWin::ECommWinResult WriteTo(T& x) const {
uci1 40:1324da35afd4 52 // expect 'x' to be a MODSERIAL or a char const* or a FILE*
uci1 40:1324da35afd4 53 x = SnBitUtils::WriteTo(x, kIOVers);
uci1 40:1324da35afd4 54 x = SnBitUtils::WriteTo(x, fPrevTime);
uci1 40:1324da35afd4 55 x = SnBitUtils::WriteTo(x, fSetTime);
uci1 84:80b15993944e 56 x = SnBitUtils::WriteTo(x, fCurTime);
uci1 84:80b15993944e 57 x = SnBitUtils::WriteTo(x, fUsSinceSet);
uci1 40:1324da35afd4 58 // read_us returns a signed int for some reason. so we keep that
uci1 40:1324da35afd4 59 // convention and merely make the number of bits explicit via the
uci1 40:1324da35afd4 60 // cast. changing to an unsigned int is left for later.
uci1 40:1324da35afd4 61 return SnCommWin::kOkMsgSent;
uci1 40:1324da35afd4 62 }
uci1 40:1324da35afd4 63
uci1 84:80b15993944e 64
uci1 40:1324da35afd4 65 template<class T>
uci1 40:1324da35afd4 66 static
uci1 40:1324da35afd4 67 SnCommWin::ECommWinResult ReadFrom(T& b,
uci1 40:1324da35afd4 68 uint32_t& prev,
uci1 40:1324da35afd4 69 uint32_t& stim,
uci1 40:1324da35afd4 70 uint32_t& ctim,
uci1 40:1324da35afd4 71 int32_t& ss) {
uci1 40:1324da35afd4 72 uint8_t Rv=0;
uci1 40:1324da35afd4 73 b = SnBitUtils::ReadFrom(b, Rv);
uci1 40:1324da35afd4 74 b = SnBitUtils::ReadFrom(b, prev);
uci1 40:1324da35afd4 75 b = SnBitUtils::ReadFrom(b, stim);
uci1 40:1324da35afd4 76 b = SnBitUtils::ReadFrom(b, ctim);
uci1 40:1324da35afd4 77 b = SnBitUtils::ReadFrom(b, ss);
uci1 40:1324da35afd4 78 return SnCommWin::kOkWithMsg;
uci1 40:1324da35afd4 79 }
uci1 84:80b15993944e 80
uci1 84:80b15993944e 81 template<class T>
uci1 84:80b15993944e 82 SnCommWin::ECommWinResult ReadFrom(T& b) {
uci1 84:80b15993944e 83 return ReadFrom(b, fPrevTime, fSetTime, fCurTime, fUsSinceSet);
uci1 84:80b15993944e 84 }
uci1 40:1324da35afd4 85
uci1 40:1324da35afd4 86 };
uci1 40:1324da35afd4 87
uci1 40:1324da35afd4 88 #endif // SNS_SnClockSetFrame