1 /* Copyright (c) 2003-2023. The SimGrid Team. All rights reserved. */
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. */
6 #include "simgrid/plugins/battery.hpp"
7 #include "simgrid/s4u.hpp"
9 XBT_LOG_NEW_DEFAULT_CATEGORY(battery_degradation, "Messages specific for this s4u example");
13 auto battery = simgrid::s4u::this_actor::get_host();
15 while (sg_battery_get_state_of_health(battery) > 0) {
16 XBT_INFO("%f,%f,SoC", simgrid::s4u::Engine::get_clock(), sg_battery_get_state_of_charge(battery));
17 XBT_INFO("%f,%f,SoH", simgrid::s4u::Engine::get_clock(), sg_battery_get_state_of_health(battery));
18 sg_battery_set_power(battery, power);
19 simgrid::s4u::this_actor::sleep_until(sg_battery_get_next_event_date(battery));
24 int main(int argc, char* argv[])
26 simgrid::s4u::Engine e(&argc, argv);
27 e.load_platform(argv[1]);
29 sg_battery_plugin_init();
31 simgrid::s4u::Actor::create("manager", e.get_all_hosts()[0], manager);