Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Explicit cast to double (sonar).
[simgrid.git] / src / plugins / link_energy_wifi.cpp
index 76bc939..60d067b 100644 (file)
@@ -105,10 +105,11 @@ void LinkEnergyWifi::update_destroy()
   dur_idle_ += duration;
 
   // add IDLE energy usage, as well as beacons consumption since previous update
-  eDyn_ += duration * control_duration_ * wifi_link->get_host_count() * pRx_;
-  eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (wifi_link->get_host_count() + 1);
+  const auto host_count = static_cast<double>(wifi_link->get_host_count());
+  eDyn_ += duration * control_duration_ * host_count * pRx_;
+  eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (host_count + 1);
 
-  XBT_DEBUG("finish eStat_ += %f * %f * (%zu+1) | eStat = %f", duration, pIdle_, wifi_link->get_host_count(), eStat_);
+  XBT_DEBUG("finish eStat_ += %f * %f * (%f+1) | eStat = %f", duration, pIdle_, host_count, eStat_);
 }
 
 void LinkEnergyWifi::update()
@@ -177,7 +178,8 @@ void LinkEnergyWifi::update()
   XBT_DEBUG("durUsage: %f", durUsage);
 
   // beacons cost
-  eDyn_ += duration * control_duration_ * wifi_link->get_host_count() * pRx_;
+  const auto host_count = static_cast<double>(wifi_link->get_host_count());
+  eDyn_ += duration * control_duration_ * host_count * pRx_;
 
   /**
    * Same principle as ns3:
@@ -186,17 +188,17 @@ void LinkEnergyWifi::update()
    * P_{tot} = P_{dyn}+P_{stat}
    */
   if (link_->get_usage() != 0.0) {
-    eDyn_ += /*duration * */ durUsage * ((wifi_link->get_host_count() * pRx_) + pTx_);
-    eStat_ += (duration - durUsage) * pIdle_ * (wifi_link->get_host_count() + 1);
-    XBT_DEBUG("eDyn +=  %f * ((%zu * %f) + %f) | eDyn = %f (durusage =%f)", durUsage, wifi_link->get_host_count(), pRx_,
-              pTx_, eDyn_, durUsage);
+    eDyn_ += /*duration * */ durUsage * ((host_count * pRx_) + pTx_);
+    eStat_ += (duration - durUsage) * pIdle_ * (host_count + 1);
+    XBT_DEBUG("eDyn +=  %f * ((%f * %f) + %f) | eDyn = %f (durusage =%f)", durUsage, host_count, pRx_, pTx_, eDyn_,
+              durUsage);
     dur_TxRx_ += duration;
   } else {
     dur_idle_ += duration;
-    eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (wifi_link->get_host_count() + 1);
+    eStat_ += (duration - (duration * control_duration_)) * pIdle_ * (host_count + 1);
   }
 
-  XBT_DEBUG("eStat_ += %f * %f * (%zu+1) | eStat = %f", duration, pIdle_, wifi_link->get_host_count(), eStat_);
+  XBT_DEBUG("eStat_ += %f * %f * (%f+1) | eStat = %f", duration, pIdle_, host_count, eStat_);
 }
 
 void LinkEnergyWifi::init_watts_range_list()