Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
All of the examples use now the StringHelp class to simplify the string manipulation.
[simgrid.git] / examples / cxx / ping_pong / Receiver.cxx
1 #include "Receiver.hpp"\r
2 #include "PingPongTask.hpp"\r
3 #include <Host.hpp>\r
4 #include <HostNotFoundException.hpp>\r
5 #include <Msg.hpp>\r
6 \r
7 #include <Msg.hpp>\r
8 \r
9 MSG_IMPLEMENT_DYNAMIC(Receiver, Process);\r
10 \r
11 const double commSizeLat = 1;\r
12 const double commSizeBw = 100000000;\r
13 \r
14 int Receiver::main(int argc, char** argv)\r
15 {\r
16         info("Hello");\r
17         double communicationTime=0;\r
18         double time = getClock();\r
19         StringHelper bw;\r
20         \r
21         info("Try to get a task");\r
22         \r
23         PingPongTask* task = reinterpret_cast<PingPongTask*>(Task::get(0));\r
24         \r
25         double timeGot = getClock();\r
26         double timeSent = task->getTime();\r
27         \r
28         delete task;\r
29         \r
30         info(TEXT_("Got at time ") + TEXT_(timeGot));\r
31         info(TEXT_("Was sent at time ") + TEXT_(timeSent));\r
32         \r
33         time = timeSent;\r
34         \r
35         communicationTime = timeGot - time;\r
36         \r
37         info(TEXT_( "Communication time : ") + TEXT_(communicationTime));\r
38         \r
39         info(TEXT_(" --- BW ") + bw.append(commSizeBw/communicationTime,"%07lf") + TEXT_(" ----"));\r
40         \r
41         info("Goodbye!");\r
42         \r
43         delete this;\r
44 \r
45         return 0;\r
46 }