aboutsummaryrefslogtreecommitdiff
path: root/src/simulator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulator.cc')
-rw-r--r--src/simulator.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/simulator.cc b/src/simulator.cc
index 5da125d..13bc711 100644
--- a/src/simulator.cc
+++ b/src/simulator.cc
@@ -11,8 +11,10 @@
#define PLATFORM_FILE "platform.xml"
-#define TURN_OFF() simgrid::s4u::this_actor::get_host()->set_pstate(0);
-#define TURN_ON() simgrid::s4u::this_actor::get_host()->set_pstate(1);
+#define MODE_OFF() simgrid::s4u::this_actor::get_host()->set_pstate(0);
+#define MODE_ON() simgrid::s4u::this_actor::get_host()->set_pstate(1);
+#define MODE_RX() simgrid::s4u::this_actor::get_host()->set_pstate(2);
+#define MODE_TX() simgrid::s4u::this_actor::get_host()->set_pstate(3);
/// @brief Required by SimGrid
XBT_LOG_NEW_DEFAULT_CATEGORY(simulator, "[DAO]");
@@ -92,9 +94,9 @@ static void obs_node(std::vector<std::string> args) {
u32 nRcvFail=0;
while(i.ShouldContinue()){
XBT_INFO("%s is spleeping",selfName.c_str());
- TURN_OFF();
+ MODE_OFF();
simgrid::s4u::this_actor::sleep_until(i.GetTS());
- TURN_ON();
+ MODE_ON();
XBT_INFO("%s wakes up",selfName.c_str());
// Doing wake up stuff
@@ -116,14 +118,14 @@ static void obs_node(std::vector<std::string> args) {
// channel (to avoid other receivers to get the message)
m->put(p,0,i.GetDuration());
simgrid::s4u::Mailbox *m_ext= simgrid::s4u::Mailbox::by_name("medium"+selfName);
+ MODE_TX();
m_ext->put(p,data_size);
}
else{
+ MODE_TX();
m->put(p,data_size,i.GetDuration());
}
XBT_INFO("%s sent data successfully",selfName.c_str());
- isObserver=true; // Do one send for now...
- isSender=false;
}
else if (!isObserver){
Payload* p;
@@ -133,9 +135,11 @@ static void obs_node(std::vector<std::string> args) {
// and then we use a mailbox specific to the sender (to have an exclusive channel)
p=m->get<Payload>(i.GetDuration());
simgrid::s4u::Mailbox *m_ext_sender = simgrid::s4u::Mailbox::by_name("medium"+p->node);
+ MODE_RX();
p=m_ext_sender->get<Payload>();
}
else{
+ MODE_RX();
p=m->get<Payload>(i.GetDuration());
}
nDataRcv++; // New data received
@@ -145,8 +149,8 @@ static void obs_node(std::vector<std::string> args) {
}
else{
XBT_INFO("%s received data successfully and switch to forwarding mode",selfName.c_str());
- isSender=!isSender; // Toggle isSender to start sending
}
+ isObserver=true; // Now we received the data we switch to observer
}
else {
XBT_INFO("%s is observing his environment...",selfName.c_str());
@@ -169,6 +173,6 @@ static void obs_node(std::vector<std::string> args) {
nWakeUp++; // Increase the number of wake up
}
// Done
- TURN_OFF()
+ MODE_OFF()
XBT_INFO("Observation node %s finished [LOG2PARSE](node:%s|nWakeUp:%d|nDataRcv:%d|nSendFail:%d|nRcvFail:%d)",selfName.c_str(),selfName.c_str(),nWakeUp,nDataRcv,nSendFail,nRcvFail);
} \ No newline at end of file