Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
Diff: SnCommWin.h
- Revision:
- 0:664899e0b988
- Child:
- 1:e392595b4b76
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SnCommWin.h Sat Jun 30 02:03:51 2012 +0000 @@ -0,0 +1,83 @@ +#ifndef SN_SnCommWin +#define SN_SnCommWin + +#include "mbed.h" +#include <stdint.h> + +class SnConfigFrame; +class SnEventFrame; + +// ABC for communication types + +class SnCommWin { + public: + enum ECommWinResult { + kUndefFail, // undefined fail type + kCanNotConnect, // unable to connect to port + kFailTimeout, // timed out but message required + kFailPartSent, // only part of the message sent + kAllFails, // to be used for "if (ret > kAllFails) ==> success" + // only successes should go below + kConnected, // connection established, no messaging attempted + kOkMsgSent, // message sent without waiting for "received" handshake + kOkNoMsg, // timed out with no message, but that is ok + kOkWithMsg // successfully received message + }; + + private: + //bool fWinOpen; // whether this comm should listen + + ECommWinResult SendData(const char* infn, + const SnConfigFrame& curConf, + SnEventFrame& evt, + char* const evtBuf, + char* const confBuf, + const uint32_t nevts=0, + const uint32_t firstEvt=0); + + protected: + virtual ECommWinResult SendConfAndEvents(FILE* inf, + const SnConfigFrame& curConf, + SnEventFrame& evt, + char* const evtBuf, + char* const confBuf, + const uint32_t nevts, + const uint32_t firstEvt=0)=0; + public: + virtual ~SnCommWin() {} + + /* + void SetCommWinOpen(const bool o) { fWinOpen = o; } + bool IsCommWinOpen() const { return fWinOpen; } + */ + + virtual ECommWinResult OpenWindow(Timer& timer, + const uint32_t timeout, + const bool sendStatus, + const SnConfigFrame& conf, + const SnEventFrame& evt, + char* const evtBuf, + char* const statBuf)=0; + + virtual bool Connect(Timer& timer, const uint32_t timeout)=0; + + virtual ECommWinResult GetConfig(SnConfigFrame& conf, + Timer& timer, + const uint32_t timeOut, + char* const confBuf)=0; + + virtual ECommWinResult SendStatus(const SnConfigFrame& conf, + const SnEventFrame& evt, + char* const evtBuf, + char* const statBuf)=0; + + ECommWinResult SendData(SnConfigFrame& conf, + SnEventFrame& evt, + char* const evtBuf, + char* const confBuf); + + virtual ECommWinResult SendData(FILE* inf)=0; + +}; + +#endif // SN_SnCommWin