SmartApp_Miun
AppUnit.cpp@0:3cd336aba723, 2017-04-12 (annotated)
- Committer:
- biwa1400
- Date:
- Wed Apr 12 05:28:25 2017 +0000
- Revision:
- 0:3cd336aba723
B
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
biwa1400 | 0:3cd336aba723 | 1 | #include "AppUnit.h" |
biwa1400 | 0:3cd336aba723 | 2 | |
biwa1400 | 0:3cd336aba723 | 3 | std::queue<MIUN::SendPayload> MIUN::AppUnit::payloadQueue; |
biwa1400 | 0:3cd336aba723 | 4 | |
biwa1400 | 0:3cd336aba723 | 5 | MIUN::AppUnit::AppUnit(uint8_t in_appNumber) |
biwa1400 | 0:3cd336aba723 | 6 | { |
biwa1400 | 0:3cd336aba723 | 7 | if(in_appNumber>220) |
biwa1400 | 0:3cd336aba723 | 8 | { |
biwa1400 | 0:3cd336aba723 | 9 | appNumber = 220; |
biwa1400 | 0:3cd336aba723 | 10 | } |
biwa1400 | 0:3cd336aba723 | 11 | else |
biwa1400 | 0:3cd336aba723 | 12 | { |
biwa1400 | 0:3cd336aba723 | 13 | appNumber = in_appNumber; |
biwa1400 | 0:3cd336aba723 | 14 | } |
biwa1400 | 0:3cd336aba723 | 15 | |
biwa1400 | 0:3cd336aba723 | 16 | } |
biwa1400 | 0:3cd336aba723 | 17 | |
biwa1400 | 0:3cd336aba723 | 18 | MIUN::AppUnit::~AppUnit() |
biwa1400 | 0:3cd336aba723 | 19 | { |
biwa1400 | 0:3cd336aba723 | 20 | } |
biwa1400 | 0:3cd336aba723 | 21 | |
biwa1400 | 0:3cd336aba723 | 22 | |
biwa1400 | 0:3cd336aba723 | 23 | uint8_t MIUN::AppUnit::getAppNumber() |
biwa1400 | 0:3cd336aba723 | 24 | { |
biwa1400 | 0:3cd336aba723 | 25 | return appNumber; |
biwa1400 | 0:3cd336aba723 | 26 | } |
biwa1400 | 0:3cd336aba723 | 27 | |
biwa1400 | 0:3cd336aba723 | 28 | |
biwa1400 | 0:3cd336aba723 | 29 | void MIUN::AppUnit::run(std::string payload) |
biwa1400 | 0:3cd336aba723 | 30 | { |
biwa1400 | 0:3cd336aba723 | 31 | logInfo("Receive Payload: %s in application %u. Please overload \'run(std::string payload)\' method to solve them.", payload.c_str(),appNumber); |
biwa1400 | 0:3cd336aba723 | 32 | } |
biwa1400 | 0:3cd336aba723 | 33 | |
biwa1400 | 0:3cd336aba723 | 34 | void MIUN::AppUnit::interrupt() |
biwa1400 | 0:3cd336aba723 | 35 | { |
biwa1400 | 0:3cd336aba723 | 36 | logInfo("Enter Interrupt"); |
biwa1400 | 0:3cd336aba723 | 37 | } |
biwa1400 | 0:3cd336aba723 | 38 | |
biwa1400 | 0:3cd336aba723 | 39 | void MIUN::AppUnit::send(std::string payload) |
biwa1400 | 0:3cd336aba723 | 40 | { |
biwa1400 | 0:3cd336aba723 | 41 | SendPayload sendPayload(payload,appNumber); |
biwa1400 | 0:3cd336aba723 | 42 | payloadQueue.push(sendPayload); |
biwa1400 | 0:3cd336aba723 | 43 | } |
biwa1400 | 0:3cd336aba723 | 44 | |
biwa1400 | 0:3cd336aba723 | 45 | |
biwa1400 | 0:3cd336aba723 | 46 | MIUN::SendPayload MIUN::AppUnit::getSendPayload() |
biwa1400 | 0:3cd336aba723 | 47 | { |
biwa1400 | 0:3cd336aba723 | 48 | SendPayload sendPayload = payloadQueue.front(); |
biwa1400 | 0:3cd336aba723 | 49 | payloadQueue.pop(); |
biwa1400 | 0:3cd336aba723 | 50 | return sendPayload; |
biwa1400 | 0:3cd336aba723 | 51 | } |
biwa1400 | 0:3cd336aba723 | 52 | |
biwa1400 | 0:3cd336aba723 | 53 | bool MIUN::AppUnit::hasSendPayload() |
biwa1400 | 0:3cd336aba723 | 54 | { |
biwa1400 | 0:3cd336aba723 | 55 | return !payloadQueue.empty(); |
biwa1400 | 0:3cd336aba723 | 56 | } |
biwa1400 | 0:3cd336aba723 | 57 |