Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / src / plugins / link_energy_wifi.cpp
index 954a54f7825ed295fb1672f38fd4b4b266357c5b..0eb9cf0cae0026956b61fc0076b68b724b48d015 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -10,6 +10,7 @@
 #include "src/kernel/activity/CommImpl.hpp"
 #include "src/kernel/resource/StandardLinkImpl.hpp"
 #include "src/kernel/resource/WifiLinkImpl.hpp"
+#include "src/simgrid/module.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
@@ -22,8 +23,7 @@ SIMGRID_REGISTER_PLUGIN(link_energy_wifi, "Energy wifi test", &sg_wifi_energy_pl
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(link_energy_wifi, kernel, "Logging specific to the link energy wifi plugin");
 
-namespace simgrid {
-namespace plugin {
+namespace simgrid::plugin {
 
 class XBT_PRIVATE LinkEnergyWifi {
   // associative array keeping size of data already sent for a given flow (required for interleaved actions)
@@ -187,7 +187,7 @@ void LinkEnergyWifi::update()
    *  - if idle i.e. get_usage = 0, update P_{stat}
    * P_{tot} = P_{dyn}+P_{stat}
    */
-  if (link_->get_usage() != 0.0) {
+  if (link_->get_load() != 0.0) {
     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_,
@@ -215,7 +215,7 @@ void LinkEnergyWifi::init_watts_range_list()
     try {
       control_duration_ = std::stod(beacons_factor);
     } catch (const std::invalid_argument&) {
-      throw std::invalid_argument(std::string("Invalid beacons factor value for link ") + this->link_->get_cname());
+      throw std::invalid_argument("Invalid beacons factor value for link " + this->link_->get_name());
     }
   }
 
@@ -238,22 +238,22 @@ void LinkEnergyWifi::init_watts_range_list()
       try {
         pSleep_ = std::stod(current_power_values.at(3));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
       }
       try {
         pRx_ = std::stod(current_power_values.at(2));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
       }
       try {
         pTx_ = std::stod(current_power_values.at(1));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid idle power value for link " + this->link_->get_name());
       }
       try {
         pIdle_ = std::stod(current_power_values.at(0));
       } catch (const std::invalid_argument&) {
-        throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname());
+        throw std::invalid_argument("Invalid busy power value for link " + this->link_->get_name());
       }
 
       XBT_DEBUG("Values aa initialized with: pSleep=%f pIdle=%f pTx=%f pRx=%f", pSleep_, pIdle_, pTx_, pRx_);
@@ -261,8 +261,7 @@ void LinkEnergyWifi::init_watts_range_list()
   }
 }
 
-} // namespace plugin
-} // namespace simgrid
+} // namespace simgrid::plugin
 
 using simgrid::plugin::LinkEnergyWifi;
 /* **************************** events  callback *************************** */