- 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;
- int flag = 0;
- xbt_dynar_foreach(array, i, cat) {
- if (strcmp(variable, cat) == 0) {
- flag = 1;
- }
- }
- if (flag == 0) {
- char *var_cpy = xbt_strdup(variable);
- xbt_dynar_push(array, &var_cpy);
- if (TRACE_categorized ()){
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSetVariable (now, container, type, 0);
- }
- }
- }
- /* end of check */
-}
-
-#define A_METHOD
-//A
-static void __TRACE_A_alloc(void)
-{
-}
-
-static void __TRACE_A_release(void)
-{
-}
-
-static void __TRACE_A_start(smx_action_t action)
-{
-}
-
-static void __TRACE_A_event(smx_action_t action, double now, double delta,
- const char *variable, const char *resource,
- double value)
-{
- char valuestr[100];
- snprintf(valuestr, 100, "%f", value);
-
- __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeAddVariable(now, container, type, value);
- new_pajeSubVariable(now + delta, container, type, value);
-}
-
-static void __TRACE_A_end(smx_action_t action)
-{
-}
-
-#define B_METHOD
-//B
-
-static void __TRACE_B_alloc(void)
-{
- method_b_dict = xbt_dict_new();
-}
-
-static void __TRACE_B_release(void)
-{
- char *key, *time;
- xbt_dict_cursor_t cursor = NULL;
- xbt_dict_foreach(method_b_dict, cursor, key, time) {
- char resource[INSTR_DEFAULT_STR_SIZE];
- char variable[INSTR_DEFAULT_STR_SIZE];
- char what[INSTR_DEFAULT_STR_SIZE];
- sscanf (key, "%s %s %s", resource, variable, what);
- if (strcmp(what, "time")==0){
- char key_value[INSTR_DEFAULT_STR_SIZE];
- snprintf (key_value, INSTR_DEFAULT_STR_SIZE, "%s %s value", resource, variable);
- char *value = xbt_dict_get_or_null (method_b_dict, key_value);
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSubVariable(atof(time), container, type, atof(value));
- }
- }
- xbt_dict_free(&method_b_dict);
-}
-
-static void __TRACE_B_start(smx_action_t action)
-{
-}
-
-static void __TRACE_B_event(smx_action_t action, double now, double delta,
- const char *variable, const char *resource,
- double value)
-{
- char key_time[INSTR_DEFAULT_STR_SIZE];
- char key_value[INSTR_DEFAULT_STR_SIZE];
- char nowstr[INSTR_DEFAULT_STR_SIZE];
- char valuestr[INSTR_DEFAULT_STR_SIZE];
- char nowdeltastr[INSTR_DEFAULT_STR_SIZE];
-
- snprintf (key_time, INSTR_DEFAULT_STR_SIZE, "%s %s time", resource, variable);
- snprintf (key_value, INSTR_DEFAULT_STR_SIZE, "%s %s value", resource, variable);
- snprintf (nowstr, INSTR_DEFAULT_STR_SIZE, "%f", now);
- snprintf (valuestr, INSTR_DEFAULT_STR_SIZE, "%f", value);
- snprintf (nowdeltastr, INSTR_DEFAULT_STR_SIZE, "%f", now+delta);
-
- char *lasttimestr = xbt_dict_get_or_null(method_b_dict, key_time);
- char *lastvaluestr = xbt_dict_get_or_null(method_b_dict, key_value);
- if (lasttimestr == NULL){
- __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeAddVariable(now, container, type, value);
- xbt_dict_set(method_b_dict, key_time, xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set(method_b_dict, key_value, xbt_strdup(valuestr), xbt_free);
- }else{
- double lasttime = atof (lasttimestr);
- double lastvalue = atof (lastvaluestr);
-
- if (lastvalue == value){
- double dif = fabs(now - lasttime);
- if (dif < 0.000001){
- //perfect, just go on
- }else{
- //time changed, have to update
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSubVariable(lasttime, container, type, lastvalue);
- new_pajeAddVariable(now, container, type, value);
- }
- }else{
- //value changed, have to update
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSubVariable(lasttime, container, type, lastvalue);
- new_pajeAddVariable(now, container, type, value);
- }
- xbt_dict_set(method_b_dict, key_time, xbt_strdup(nowdeltastr), xbt_free);
- xbt_dict_set(method_b_dict, key_value, xbt_strdup(valuestr), xbt_free);