Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.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:
- 2:e67f7c158087
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 | 1:e392595b4b76 | 1 | #ifndef SN_SnCommWin |
uci1 | 1:e392595b4b76 | 2 | #define SN_SnCommWin |
uci1 | 1:e392595b4b76 | 3 | |
uci1 | 1:e392595b4b76 | 4 | #include "mbed.h" |
uci1 | 1:e392595b4b76 | 5 | #include <stdint.h> |
uci1 | 1:e392595b4b76 | 6 | |
uci1 | 1:e392595b4b76 | 7 | class SnConfigFrame; |
uci1 | 1:e392595b4b76 | 8 | class SnEventFrame; |
uci1 | 1:e392595b4b76 | 9 | |
uci1 | 1:e392595b4b76 | 10 | // ABC for communication types |
uci1 | 1:e392595b4b76 | 11 | |
uci1 | 1:e392595b4b76 | 12 | class SnCommWin { |
uci1 | 1:e392595b4b76 | 13 | public: |
uci1 | 1:e392595b4b76 | 14 | enum ECommWinResult { |
uci1 | 1:e392595b4b76 | 15 | kUndefFail, // undefined fail type |
uci1 | 1:e392595b4b76 | 16 | kCanNotConnect, // unable to connect to port |
uci1 | 1:e392595b4b76 | 17 | kFailTimeout, // timed out but message required |
uci1 | 1:e392595b4b76 | 18 | kFailPartSent, // only part of the message sent |
uci1 | 1:e392595b4b76 | 19 | kAllFails, // to be used for "if (ret > kAllFails) ==> success" |
uci1 | 1:e392595b4b76 | 20 | // only successes should go below |
uci1 | 1:e392595b4b76 | 21 | kConnected, // connection established, no messaging attempted |
uci1 | 1:e392595b4b76 | 22 | kOkMsgSent, // message sent without waiting for "received" handshake |
uci1 | 1:e392595b4b76 | 23 | kOkNoMsg, // timed out with no message, but that is ok |
uci1 | 1:e392595b4b76 | 24 | kOkWithMsg // successfully received message |
uci1 | 1:e392595b4b76 | 25 | }; |
uci1 | 1:e392595b4b76 | 26 | |
uci1 | 1:e392595b4b76 | 27 | private: |
uci1 | 1:e392595b4b76 | 28 | //bool fWinOpen; // whether this comm should listen |
uci1 | 1:e392595b4b76 | 29 | |
uci1 | 1:e392595b4b76 | 30 | ECommWinResult SendData(FILE* inf, const char* infn, |
uci1 | 1:e392595b4b76 | 31 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 32 | SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 33 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 34 | char* const confBuf, |
uci1 | 1:e392595b4b76 | 35 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 36 | const uint32_t firstEvt=0); |
uci1 | 1:e392595b4b76 | 37 | ECommWinResult SendData(const char* infn, |
uci1 | 1:e392595b4b76 | 38 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 39 | SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 40 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 41 | char* const confBuf, |
uci1 | 1:e392595b4b76 | 42 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 43 | const uint32_t firstEvt=0); |
uci1 | 1:e392595b4b76 | 44 | |
uci1 | 1:e392595b4b76 | 45 | protected: |
uci1 | 1:e392595b4b76 | 46 | virtual ECommWinResult SendConfAndEvents(FILE* inf, |
uci1 | 1:e392595b4b76 | 47 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 48 | SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 49 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 50 | char* const confBuf, |
uci1 | 1:e392595b4b76 | 51 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 52 | const uint32_t firstEvt=0)=0; |
uci1 | 1:e392595b4b76 | 53 | public: |
uci1 | 1:e392595b4b76 | 54 | virtual ~SnCommWin() {} |
uci1 | 1:e392595b4b76 | 55 | |
uci1 | 1:e392595b4b76 | 56 | virtual ECommWinResult OpenWindow(const uint32_t timeout, |
uci1 | 1:e392595b4b76 | 57 | const bool sendStatus, |
uci1 | 1:e392595b4b76 | 58 | const SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 59 | const SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 60 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 61 | char* const statBuf)=0; |
uci1 | 1:e392595b4b76 | 62 | |
uci1 | 1:e392595b4b76 | 63 | virtual bool Connect(const uint32_t timeout)=0; |
uci1 | 1:e392595b4b76 | 64 | |
uci1 | 1:e392595b4b76 | 65 | virtual ECommWinResult GetConfig(SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 66 | const uint32_t timeOut, |
uci1 | 1:e392595b4b76 | 67 | char* const confBuf)=0; |
uci1 | 1:e392595b4b76 | 68 | |
uci1 | 1:e392595b4b76 | 69 | virtual ECommWinResult SendStatus(const SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 70 | const SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 71 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 72 | char* const statBuf)=0; |
uci1 | 1:e392595b4b76 | 73 | |
uci1 | 1:e392595b4b76 | 74 | ECommWinResult SendData(SnConfigFrame& conf, |
uci1 | 1:e392595b4b76 | 75 | SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 76 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 77 | char* const confBuf, |
uci1 | 1:e392595b4b76 | 78 | const uint32_t timeout); |
uci1 | 1:e392595b4b76 | 79 | |
uci1 | 1:e392595b4b76 | 80 | virtual ECommWinResult SendData(FILE* inf)=0; |
uci1 | 1:e392595b4b76 | 81 | |
uci1 | 1:e392595b4b76 | 82 | }; |
uci1 | 1:e392595b4b76 | 83 | |
uci1 | 1:e392595b4b76 | 84 | #endif // SN_SnCommWin |