-void __TRACE_surf_update_action_state_resource (double now, double delta, const char *variable, const char *resource, double value)
-{
- char valuestr[100];
- char nowstr[100], nowdeltastr[100];
- char timekey[100], valuekey[100], variablekey[100];
- char *lastvariable = NULL;
- char *lasttime = NULL;
- char *lastvalue = NULL;
- char *nowdeltastr_cpy = NULL;
- char *valuestr_cpy = NULL;
- char *variable_cpy = NULL;
-
- if (!IS_TRACING_PLATFORM) return;
-
- snprintf (valuestr, 100, "%f", value);
-
- /*
- //fprintf (stderr, "resource = %s variable = %s (%f -> %f) value = %s\n", resource, variable, now, now+delta, valuestr);
- if (1){
- __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
- if (IS_TRACING_PLATFORM) pajeAddVariable (now, variable, resource, valuestr);
- if (IS_TRACING_PLATFORM) pajeSubVariable (now+delta, variable, resource, valuestr);
- return;
- }
- */
-
- /*
- * The following code replaces the code above with the objective
- * to decrease the size of file because of unnecessary add/sub on
- * variables. It should be re-checked before put in production.
- */
-
- snprintf (nowstr, 100, "%.15f", now);
- snprintf (nowdeltastr, 100, "%.15f", now+delta);
-
- snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
- snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
- snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
-
- lastvariable = xbt_dict_get_or_null (last_platform_variables, variablekey);
- if (lastvariable == NULL){
- __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
- pajeAddVariable (now, variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- variable_cpy = xbt_strdup (variable);
- xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
- xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
- }else{
- lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
- lastvalue = xbt_dict_get_or_null (last_platform_variables, valuekey);
-
- /* check if it is the same variable */
- if (strcmp(lastvariable, variable) == 0){ /* same variable */
- /* check if lasttime equals now */
- if (atof(lasttime) == now){ /* lastime == now */
- /* check if lastvalue equals valuestr */
- if (atof(lastvalue) == value){ /* lastvalue == value (good, just advance time) */
- char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
- }else{ /* value has changed */
- /* value has changed, subtract previous value, add new one */
- pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
- pajeAddVariable (atof(nowstr), variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
- }
- }else{ /* lasttime != now */
- /* the last time is different from new starting time, subtract to lasttime and add from nowstr */
- pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
- pajeAddVariable (atof(nowstr), variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
- }
- }else{ /* variable has changed */
- pajeSubVariable (atof(lasttime), lastvariable, resource, lastvalue);
- __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
- pajeAddVariable (now, variable, resource, valuestr);
- nowdeltastr_cpy = xbt_strdup (nowdeltastr);
- valuestr_cpy = xbt_strdup (valuestr);
- variable_cpy = xbt_strdup (variable);
- xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
- xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
- xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
- }
- }
- return;
-}
-