Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Few more CI tesh fixing
[simgrid.git] / examples / cpp / photovoltaic-simple / s4u-photovoltaic-simple.cpp
1 /* Copyright (c) 2003-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/plugins/photovoltaic.hpp"
7 #include "simgrid/s4u.hpp"
8
9 XBT_LOG_NEW_DEFAULT_CATEGORY(photovoltaic_simple, "Messages specific for this s4u example");
10
11 static void manager()
12 {
13   auto pv_panel = simgrid::s4u::Engine::get_instance()->host_by_name("pv_panel");
14   std::vector<std::pair<double, double>> solar_irradiance = {{1, 10}, {100, 5}, {200, 20}};
15   for (auto [t, s] : solar_irradiance) {
16     simgrid::s4u::this_actor::sleep_until(t);
17     sg_photovoltaic_set_solar_irradiance(pv_panel, s);
18     XBT_INFO("%s power: %f", pv_panel->get_cname(), sg_photovoltaic_get_power(pv_panel));
19   }
20 }
21
22 int main(int argc, char* argv[])
23 {
24   simgrid::s4u::Engine e(&argc, argv);
25   e.load_platform(argv[1]);
26   sg_photovoltaic_plugin_init();
27   simgrid::s4u::Actor::create("manager", e.host_by_name("pv_panel"), manager);
28   e.run();
29   return 0;
30 }