| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include "Receiver.h" | ||
| 8 | |||
| 9 | /// Default constructor of Receiver | ||
| 10 | 1 | Receiver::Receiver(){ | |
| 11 | 1 | initialisationReceiver(); | |
| 12 | // Do NOT addDataCallableMethod here! Inherited Daemon is not fully initialized yet (because we can't initialize it fully in its constructor and handle errors) | ||
| 13 | 1 | } | |
| 14 | |||
| 15 | /// Destructor of Receiver | ||
| 16 | 1 | Receiver::~Receiver(){} | |
| 17 | |||
| 18 | /// Initialisation function of the class Receiver | ||
| 19 | 1 | void Receiver::initialisationReceiver(){ | |
| 20 | 1 | p_nb_msg = 0lu; | |
| 21 | 1 | } | |
| 22 | |||
| 23 | 1 | void Receiver::addCallMethod(){ | |
| 24 | 1 | addDataCallableMethod(SWARM_SLOT(processShadok), *this, 10, 0, 1e6); | |
| 25 | 1 | } | |
| 26 | |||
| 27 | /// @brief Wait that the Receiver has received the confirmation of sent Stats | ||
| 28 | 1 | void Receiver::executeOnStop(){ | |
| 29 |
2/2✓ Branch 0 (20→3) taken 17 times.
✓ Branch 1 (20→21) taken 1 times.
|
18 | while(!getMapMessageToBeConfirmed().empty()){ |
| 30 |
4/4✓ Branch 0 (3→4) taken 17 times.
✓ Branch 2 (4→5) taken 17 times.
✓ Branch 4 (5→6) taken 17 times.
✓ Branch 6 (6→7) taken 17 times.
|
17 | getLog().getLogDebug() << "Sender::executeOnStop() : Waiting for confirmation of StatDaemon..." << std::endl; |
| 31 |
1/1✓ Branch 0 (7→8) taken 17 times.
|
17 | Message msgToCheck; |
| 32 |
3/3✓ Branch 0 (8→9) taken 17 times.
✓ Branch 2 (9→10) taken 17 times.
✓ Branch 4 (10→11) taken 17 times.
|
17 | PRecvStatus::PRecvStatus recvStatus = checkRecvStatus(p_backend.socketManager.recvData("pull", msgToCheck, p_mainConfig.recvFlag)); |
| 33 |
2/2✓ Branch 0 (12→13) taken 1 times.
✓ Branch 1 (12→14) taken 16 times.
|
17 | if(recvStatus == PRecvStatus::OK){ |
| 34 |
1/1✓ Branch 0 (13→14) taken 1 times.
|
1 | processInputMessage(msgToCheck); |
| 35 | } | ||
| 36 |
1/1✓ Branch 0 (15→16) taken 17 times.
|
17 | std::this_thread::sleep_for(std::chrono::milliseconds(10)); // Sleep to avoid CPU consumption |
| 37 | 17 | } | |
| 38 | 1 | getLog().getLogDebug() << "Sender::executeOnStop() : Sender stopping after receiving confirmation for Stats!" << std::endl; | |
| 39 | 1 | } | |
| 40 | |||
| 41 | /// @brief Receive DL1FileReady Events and stop after 5 | ||
| 42 | /// @param shadok : received Shadok | ||
| 43 | /// @return true on success | ||
| 44 | 5 | PUncastableBool Receiver::processShadok(const Shadok & shadok){ | |
| 45 | 5 | p_nb_msg++; | |
| 46 | 5 | getLog().getLogInfo() << "*** RECEIVED Shadok " << p_nb_msg << std::endl; | |
| 47 |
2/2✓ Branch 0 (7→8) taken 1 times.
✓ Branch 1 (7→13) taken 4 times.
|
5 | if(p_nb_msg >= 5){ |
| 48 | 1 | getLog().getLogInfo() << "Received 5 Shadoks, stopping Receiver Daemon." << std::endl; | |
| 49 | 1 | stop(); | |
| 50 | } | ||
| 51 | 5 | return UNCASTABLE_TRUE; | |
| 52 | } | ||
| 53 |