-void __TRACE_surf_check_variable_set_to_zero (double now, const char *variable, const char *resource)
-{
- /* check if we have to set it to 0 */
- if (!xbt_dict_get_or_null (platform_variables, resource)){
- xbt_dynar_t array = xbt_dynar_new(100*sizeof(char), xbt_free);
- xbt_dynar_push (array, xbt_strdup(variable));
- if (IS_TRACING_PLATFORM) pajeSetVariable (now, variable, resource, "0");
- xbt_dict_set (platform_variables, resource, array, xbt_dynar_free_voidp);
- }else{
- xbt_dynar_t array = xbt_dict_get (platform_variables, resource);
- unsigned int i;
- char cat[100];
- int flag = 0;
- xbt_dynar_foreach (array, i, cat) {
- if (strcmp(variable, cat)==0){
- flag = 1;
- }
- }
- if (flag==0){
- xbt_dynar_push (array, strdup(variable));
- if (IS_TRACING_PLATFORM) pajeSetVariable (now, variable, resource, "0");
- }
- }
- /* end of check */
-}
-
-void __TRACE_surf_update_action_state_resource (double now, double delta, const char *variable, const char *resource, double value)
-{
- if (!IS_TRACING_PLATFORM) return;
-
- char valuestr[100];
- 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.
- */
-
- char nowstr[100], nowdeltastr[100];
- snprintf (nowstr, 100, "%.15f", now);
- snprintf (nowdeltastr, 100, "%.15f", now+delta);
-
- char timekey[100], valuekey[100], variablekey[100];
- snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
- snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
- snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
-
- char *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);
- xbt_dict_set (last_platform_variables, xbt_strdup (timekey), xbt_strdup (nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (valuekey), xbt_strdup (valuestr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (variablekey), xbt_strdup (variable), xbt_free);
- }else{
- char *lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
- char *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) */
- xbt_dict_set (last_platform_variables, xbt_strdup(timekey), xbt_strdup(nowdeltastr), 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);
- xbt_dict_set (last_platform_variables, xbt_strdup(timekey), xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup(valuekey), xbt_strdup(valuestr), 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);
- xbt_dict_set (last_platform_variables, xbt_strdup(timekey), xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup(valuekey), xbt_strdup(valuestr), 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);
- xbt_dict_set (last_platform_variables, xbt_strdup (timekey), xbt_strdup (nowdeltastr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (valuekey), xbt_strdup (valuestr), xbt_free);
- xbt_dict_set (last_platform_variables, xbt_strdup (variablekey), xbt_strdup (variable), xbt_free);
- }
- }
- return;
-}
-
-void __TRACE_surf_set_resource_variable (double date, const char *variable, const char *resource, double value)