Arianna autonomous DAQ firmware
Dependencies: mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW
SnCommWin.cpp@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 | 0:664899e0b988 | 1 | #include "SnCommWin.h" |
uci1 | 0:664899e0b988 | 2 | |
uci1 | 0:664899e0b988 | 3 | #include "SnConfigFrame.h" |
uci1 | 0:664899e0b988 | 4 | #include "SnSDUtils.h" |
uci1 | 0:664899e0b988 | 5 | |
uci1 | 0:664899e0b988 | 6 | /* |
uci1 | 0:664899e0b988 | 7 | bool SnCommWin::fgCommEst = false; |
uci1 | 0:664899e0b988 | 8 | bool SnCommWin::fgWinOpen = false; |
uci1 | 0:664899e0b988 | 9 | */ |
uci1 | 0:664899e0b988 | 10 | |
uci1 | 0:664899e0b988 | 11 | SnCommWin::ECommWinResult SnCommWin::SendData(SnConfigFrame& conf, |
uci1 | 0:664899e0b988 | 12 | SnEventFrame& evt, |
uci1 | 0:664899e0b988 | 13 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 14 | char* const confBuf, |
uci1 | 1:e392595b4b76 | 15 | const uint32_t timeout) { |
uci1 | 0:664899e0b988 | 16 | ECommWinResult res = kUndefFail; |
uci1 | 0:664899e0b988 | 17 | if (conf.IsSendingAllFiles()) { |
uci1 | 0:664899e0b988 | 18 | res = SnSDUtils::SendAllFiles(this, conf.IsDeletingFiles()); |
uci1 | 0:664899e0b988 | 19 | } else { |
uci1 | 0:664899e0b988 | 20 | if (conf.GetCommSendData()==0) { |
uci1 | 0:664899e0b988 | 21 | res = kOkNoMsg; |
uci1 | 0:664899e0b988 | 22 | } else { |
uci1 | 1:e392595b4b76 | 23 | const uint32_t nev = (conf.GetCommSendData()>0) ? |
uci1 | 1:e392595b4b76 | 24 | conf.GetCommSendData() |
uci1 | 1:e392595b4b76 | 25 | : 0u; // send all events in file |
uci1 | 1:e392595b4b76 | 26 | res = SendData(SnSDUtils::GetCurFile(), SnSDUtils::GetCurFileName(), |
uci1 | 1:e392595b4b76 | 27 | conf, evt, evtBuf, confBuf, nev); |
uci1 | 0:664899e0b988 | 28 | } |
uci1 | 0:664899e0b988 | 29 | } |
uci1 | 0:664899e0b988 | 30 | return res; |
uci1 | 0:664899e0b988 | 31 | } |
uci1 | 0:664899e0b988 | 32 | |
uci1 | 1:e392595b4b76 | 33 | SnCommWin::ECommWinResult SnCommWin::SendData(FILE* inf, const char* infn, |
uci1 | 0:664899e0b988 | 34 | const SnConfigFrame& curConf, |
uci1 | 0:664899e0b988 | 35 | SnEventFrame& evt, |
uci1 | 0:664899e0b988 | 36 | char* const evtBuf, |
uci1 | 0:664899e0b988 | 37 | char* const confBuf, |
uci1 | 0:664899e0b988 | 38 | const uint32_t nevts, |
uci1 | 0:664899e0b988 | 39 | const uint32_t firstEvt) { |
uci1 | 0:664899e0b988 | 40 | // nevts==0 ==> send all events |
uci1 | 0:664899e0b988 | 41 | // evtBuf should be 0 only if nevts==0 |
uci1 | 1:e392595b4b76 | 42 | // |
uci1 | 1:e392595b4b76 | 43 | // this version should be used to send the current file (avoid fopen/fclose) |
uci1 | 0:664899e0b988 | 44 | |
uci1 | 0:664899e0b988 | 45 | ECommWinResult res = kUndefFail; |
uci1 | 0:664899e0b988 | 46 | if (inf!=0) { |
uci1 | 0:664899e0b988 | 47 | if (nevts==0) { |
uci1 | 0:664899e0b988 | 48 | res = SendData(inf); |
uci1 | 0:664899e0b988 | 49 | if (curConf.IsDeletingFiles() && res>=kOkMsgSent) { |
uci1 | 0:664899e0b988 | 50 | SnSDUtilsWhisperer::DeleteFile(inf, infn); |
uci1 | 0:664899e0b988 | 51 | } |
uci1 | 0:664899e0b988 | 52 | } else { |
uci1 | 0:664899e0b988 | 53 | if (evtBuf!=0) { |
uci1 | 0:664899e0b988 | 54 | res = SendConfAndEvents(inf, curConf, evt, evtBuf, confBuf, nevts, firstEvt); |
uci1 | 0:664899e0b988 | 55 | } |
uci1 | 0:664899e0b988 | 56 | } |
uci1 | 1:e392595b4b76 | 57 | } |
uci1 | 1:e392595b4b76 | 58 | return res; |
uci1 | 1:e392595b4b76 | 59 | } |
uci1 | 1:e392595b4b76 | 60 | |
uci1 | 1:e392595b4b76 | 61 | |
uci1 | 1:e392595b4b76 | 62 | SnCommWin::ECommWinResult SnCommWin::SendData(const char* infn, |
uci1 | 1:e392595b4b76 | 63 | const SnConfigFrame& curConf, |
uci1 | 1:e392595b4b76 | 64 | SnEventFrame& evt, |
uci1 | 1:e392595b4b76 | 65 | char* const evtBuf, |
uci1 | 1:e392595b4b76 | 66 | char* const confBuf, |
uci1 | 1:e392595b4b76 | 67 | const uint32_t nevts, |
uci1 | 1:e392595b4b76 | 68 | const uint32_t firstEvt) { |
uci1 | 1:e392595b4b76 | 69 | // nevts==0 ==> send all events |
uci1 | 1:e392595b4b76 | 70 | // evtBuf should be 0 only if nevts==0 |
uci1 | 1:e392595b4b76 | 71 | // |
uci1 | 1:e392595b4b76 | 72 | // this version can send existing files that were previous closed |
uci1 | 1:e392595b4b76 | 73 | |
uci1 | 1:e392595b4b76 | 74 | ECommWinResult res = kUndefFail; |
uci1 | 1:e392595b4b76 | 75 | FILE* inf = fopen(infn, "rb"); |
uci1 | 1:e392595b4b76 | 76 | if (inf!=0) { |
uci1 | 1:e392595b4b76 | 77 | SendData(inf, infn, curConf, evt, evtBuf, confBuf, nevts, firstEvt); |
uci1 | 0:664899e0b988 | 78 | if (inf!=0) { |
uci1 | 0:664899e0b988 | 79 | fclose(inf); |
uci1 | 0:664899e0b988 | 80 | } |
uci1 | 0:664899e0b988 | 81 | } |
uci1 | 0:664899e0b988 | 82 | return res; |
uci1 | 0:664899e0b988 | 83 | } |