-xbt_dynar_t HostEnergy::getWattsRangeList()
-{
- xbt_dynar_t power_range_list;
- xbt_dynar_t power_tuple;
- int i = 0, pstate_nb=0;
- xbt_dynar_t current_power_values;
- double min_power, max_power;
-
- if (host->getProperties() == NULL)
- return NULL;
-
- char* all_power_values_str = (char*)xbt_dict_get_or_null(host->getProperties(), "watt_per_state");
-
- if (all_power_values_str == NULL)
- return NULL;
-
-
- power_range_list = xbt_dynar_new(sizeof(xbt_dynar_t), NULL);
- xbt_dynar_t all_power_values = xbt_str_split(all_power_values_str, ",");
-
- pstate_nb = xbt_dynar_length(all_power_values);
- for (i=0; i< pstate_nb; i++)
- {
- /* retrieve the power values associated with the current pstate */
- current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
- xbt_assert(xbt_dynar_length(current_power_values) > 1,
- "Power properties incorrectly defined - could not retrieve min and max power values for host %s",
- host->getName());
-
- /* min_power corresponds to the idle power (cpu load = 0) */
- /* max_power is the power consumed at 100% cpu load */
- min_power = atof(xbt_dynar_get_as(current_power_values, 0, char*));
- max_power = atof(xbt_dynar_get_as(current_power_values, 1, char*));
-
- power_tuple = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push_as(power_tuple, double, min_power);
- xbt_dynar_push_as(power_tuple, double, max_power);
-
- xbt_dynar_push_as(power_range_list, xbt_dynar_t, power_tuple);
- xbt_dynar_free(¤t_power_values);
- }
- xbt_dynar_free(&all_power_values);
- return power_range_list;
+/** @brief Returns the total energy consumed by the host so far (in Joules)
+ *
+ * See also @ref SURF_plugin_energy.
+ */
+double sg_host_get_consumed_energy(sg_host_t host) {
+ xbt_assert(HostEnergy::EXTENSION_ID.valid(),
+ "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
+ return host->extension<HostEnergy>()->getConsumedEnergy();