Commit d5f14c8f authored by winckel's avatar winckel

Added instances filter support.

Instances filter settings are not saved in the filters files!

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4380 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent e63f6c79
...@@ -104,7 +104,7 @@ char *task_id_to_string(uint32_t task_id_value, types_t *task_id_type) { ...@@ -104,7 +104,7 @@ char *task_id_to_string(uint32_t task_id_value, types_t *task_id_type) {
if (task_id_value < ((uint32_t) ~0)) if (task_id_value < ((uint32_t) ~0))
{ {
/* Search task id name */ /* Search task id name */
task_id = enum_type_get_name_from_value (task_id_type->child, task_id_value); task_id = enum_type_get_name_from_value (task_id_type->child, task_id_value);
} }
......
...@@ -113,6 +113,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) ...@@ -113,6 +113,7 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data)
GtkTreeViewColumn *focus_column; GtkTreeViewColumn *focus_column;
uint32_t origin_task_id; uint32_t origin_task_id;
uint32_t destination_task_id; uint32_t destination_task_id;
uint32_t instance;
gtk_tree_view_get_cursor (GTK_TREE_VIEW(ui_main_data.signalslist), &path, &focus_column); gtk_tree_view_get_cursor (GTK_TREE_VIEW(ui_main_data.signalslist), &path, &focus_column);
...@@ -121,11 +122,12 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data) ...@@ -121,11 +122,12 @@ void ui_signal_add_to_list(gpointer data, gpointer user_data)
get_message_id (root, signal_buffer, &signal_buffer->message_id); get_message_id (root, signal_buffer, &signal_buffer->message_id);
origin_task_id = get_task_id (signal_buffer, origin_task_id_type); origin_task_id = get_task_id (signal_buffer, origin_task_id_type);
destination_task_id = get_task_id (signal_buffer, destination_task_id_type); destination_task_id = get_task_id (signal_buffer, destination_task_id_type);
instance = get_instance (signal_buffer);
ui_tree_view_new_signal_ind (signal_buffer->message_number, signal_buffer->message_id, message_id_to_string (signal_buffer->message_id), ui_tree_view_new_signal_ind (signal_buffer->message_number, signal_buffer->message_id, message_id_to_string (signal_buffer->message_id),
origin_task_id, task_id_to_string (origin_task_id, origin_task_id_type), origin_task_id, task_id_to_string (origin_task_id, origin_task_id_type),
destination_task_id, task_id_to_string (destination_task_id, destination_task_id_type), destination_task_id, task_id_to_string (destination_task_id, destination_task_id_type),
get_instance (signal_buffer), data); instance, data);
/* Increment number of messages */ /* Increment number of messages */
ui_main_data.nb_message_received++; ui_main_data.nb_message_received++;
...@@ -411,6 +413,10 @@ gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer dat ...@@ -411,6 +413,10 @@ gboolean ui_callback_on_tree_column_header_click(GtkWidget *widget, gpointer dat
ui_show_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks); ui_show_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks);
break; break;
case COL_INSTANCE:
ui_show_filter_menu (&ui_main_data.menu_filter_instances, &ui_filters.instances);
break;
default: default:
g_warning("Unknown column filter %d in call to ui_callback_on_tree_column_header_click", col); g_warning("Unknown column filter %d in call to ui_callback_on_tree_column_header_click", col);
return FALSE; return FALSE;
......
...@@ -54,6 +54,7 @@ int ui_init_filters(int reset, int clear_ids) ...@@ -54,6 +54,7 @@ int ui_init_filters(int reset, int clear_ids)
ui_init_filter (&ui_filters.messages, reset, clear_ids, "messages"); ui_init_filter (&ui_filters.messages, reset, clear_ids, "messages");
ui_init_filter (&ui_filters.origin_tasks, reset, clear_ids, "origin_tasks"); ui_init_filter (&ui_filters.origin_tasks, reset, clear_ids, "origin_tasks");
ui_init_filter (&ui_filters.destination_tasks, reset, clear_ids, "destination_tasks"); ui_init_filter (&ui_filters.destination_tasks, reset, clear_ids, "destination_tasks");
ui_init_filter (&ui_filters.instances, reset, clear_ids, "instances");
ui_destroy_filter_menus (); ui_destroy_filter_menus ();
...@@ -140,6 +141,8 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name, ...@@ -140,6 +141,8 @@ static int ui_filter_add(ui_filter_t *filter, uint32_t value, const char *name,
ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, FALSE); ui_filter_set_enabled (&filter->items[item].enabled, entry_enabled, FALSE);
} }
g_debug("filter \"%s\" add %d \"%s\" %d", filter->name, value, name, entry_enabled);
return (item); return (item);
} }
...@@ -159,6 +162,10 @@ void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_ent ...@@ -159,6 +162,10 @@ void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_ent
ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled); ui_filter_add (&ui_filters.destination_tasks, value, name, entry_enabled);
break; break;
case FILTER_INSTANCES:
ui_filter_add (&ui_filters.instances, value, name, entry_enabled);
break;
default: default:
g_warning("unknown filter type %d", filter); g_warning("unknown filter type %d", filter);
break; break;
...@@ -181,12 +188,12 @@ static gboolean ui_item_enabled(ui_filter_t *filter, const uint32_t value) ...@@ -181,12 +188,12 @@ static gboolean ui_item_enabled(ui_filter_t *filter, const uint32_t value)
return (FALSE); return (FALSE);
} }
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task) gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance)
{ {
gboolean result; gboolean result;
result = ui_item_enabled (&ui_filters.messages, message) && ui_item_enabled (&ui_filters.origin_tasks, origin_task) result = ui_item_enabled (&ui_filters.messages, message) && ui_item_enabled (&ui_filters.origin_tasks, origin_task)
&& ui_item_enabled (&ui_filters.destination_tasks, destination_task); && ui_item_enabled (&ui_filters.destination_tasks, destination_task) && ui_item_enabled (&ui_filters.instances, instance);
return result; return result;
} }
...@@ -205,6 +212,10 @@ static ui_filter_e ui_filter_from_name(const char *name) ...@@ -205,6 +212,10 @@ static ui_filter_e ui_filter_from_name(const char *name)
{ {
return FILTER_DESTINATION_TASKS; return FILTER_DESTINATION_TASKS;
} }
if (strcmp (name, ui_filters.instances.name) == 0)
{
return FILTER_INSTANCES;
}
return FILTER_UNKNOWN; return FILTER_UNKNOWN;
} }
...@@ -447,7 +458,7 @@ static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data) ...@@ -447,7 +458,7 @@ static void ui_destroy_filter_menu_item(GtkWidget *widget, gpointer data)
} }
} }
static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter) static void ui_destroy_filter_menu_widget(GtkWidget **menu)
{ {
if (*menu != NULL) if (*menu != NULL)
{ {
...@@ -460,9 +471,36 @@ static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter) ...@@ -460,9 +471,36 @@ static void ui_destroy_filter_menu(GtkWidget **menu, ui_filter_t *filter)
void ui_destroy_filter_menus(void) void ui_destroy_filter_menus(void)
{ {
ui_destroy_filter_menu (&ui_main_data.menu_filter_messages, &ui_filters.messages); ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_messages);
ui_destroy_filter_menu (&ui_main_data.menu_filter_origin_tasks, &ui_filters.origin_tasks); ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_origin_tasks);
ui_destroy_filter_menu (&ui_main_data.menu_filter_destination_tasks, &ui_filters.destination_tasks); ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_destination_tasks);
ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_instances);
}
void ui_destroy_filter_menu(ui_filter_e filter)
{
switch (filter)
{
case FILTER_MESSAGES:
ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_messages);
break;
case FILTER_ORIGIN_TASKS:
ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_origin_tasks);
break;
case FILTER_DESTINATION_TASKS:
ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_destination_tasks);
break;
case FILTER_INSTANCES:
ui_destroy_filter_menu_widget (&ui_main_data.menu_filter_instances);
break;
default:
g_warning("unknown filter type %d", filter);
break;
}
} }
void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter) void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
typedef enum typedef enum
{ {
FILTER_UNKNOWN, FILTER_MESSAGES, FILTER_ORIGIN_TASKS, FILTER_DESTINATION_TASKS, FILTER_UNKNOWN, FILTER_MESSAGES, FILTER_ORIGIN_TASKS, FILTER_DESTINATION_TASKS, FILTER_INSTANCES,
} ui_filter_e; } ui_filter_e;
typedef enum typedef enum
...@@ -35,6 +35,7 @@ typedef struct ...@@ -35,6 +35,7 @@ typedef struct
ui_filter_t messages; ui_filter_t messages;
ui_filter_t origin_tasks; ui_filter_t origin_tasks;
ui_filter_t destination_tasks; ui_filter_t destination_tasks;
ui_filter_t instances;
} ui_filters_t; } ui_filters_t;
extern ui_filters_t ui_filters; extern ui_filters_t ui_filters;
...@@ -43,7 +44,7 @@ int ui_init_filters(int reset, int clear_ids); ...@@ -43,7 +44,7 @@ int ui_init_filters(int reset, int clear_ids);
void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled); void ui_filters_add(ui_filter_e filter, uint32_t value, const char *name, ui_entry_enabled_e entry_enabled);
gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task); gboolean ui_filters_message_enabled(const uint32_t message, const uint32_t origin_task, const uint32_t destination_task, const uint32_t instance);
int ui_filters_read(const char *file_name); int ui_filters_read(const char *file_name);
...@@ -51,6 +52,8 @@ int ui_filters_file_write(const char *file_name); ...@@ -51,6 +52,8 @@ int ui_filters_file_write(const char *file_name);
void ui_destroy_filter_menus(void); void ui_destroy_filter_menus(void);
void ui_destroy_filter_menu(ui_filter_e filter);
void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter); void ui_show_filter_menu(GtkWidget **menu, ui_filter_t *filter);
#endif /* UI_FILTERS_H_ */ #endif /* UI_FILTERS_H_ */
...@@ -45,6 +45,7 @@ typedef struct { ...@@ -45,6 +45,7 @@ typedef struct {
GtkWidget *menu_filter_messages; GtkWidget *menu_filter_messages;
GtkWidget *menu_filter_origin_tasks; GtkWidget *menu_filter_origin_tasks;
GtkWidget *menu_filter_destination_tasks; GtkWidget *menu_filter_destination_tasks;
GtkWidget *menu_filter_instances;
int pipe_fd[2]; int pipe_fd[2];
} ui_main_data_t; } ui_main_data_t;
......
...@@ -20,6 +20,7 @@ typedef struct ...@@ -20,6 +20,7 @@ typedef struct
GtkTreeModelFilter *filtered; GtkTreeModelFilter *filtered;
uint32_t filtered_last_msg; uint32_t filtered_last_msg;
uint32_t filtered_msg_number; uint32_t filtered_msg_number;
uint32_t instance_number;
} ui_store_t; } ui_store_t;
static ui_store_t ui_store; static ui_store_t ui_store;
...@@ -30,20 +31,22 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter, ...@@ -30,20 +31,22 @@ static gboolean ui_tree_filter_messages(GtkTreeModel *model, GtkTreeIter *iter,
uint32_t message_id; uint32_t message_id;
uint32_t origin_task_id; uint32_t origin_task_id;
uint32_t destination_task_id; uint32_t destination_task_id;
uint32_t instance;
gboolean enabled = FALSE; gboolean enabled = FALSE;
gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id, gtk_tree_model_get (model, iter, COL_MSG_NUM, &msg_number, COL_MESSAGE_ID, &message_id, COL_FROM_TASK_ID, &origin_task_id,
COL_TO_TASK_ID, &destination_task_id, -1); COL_TO_TASK_ID, &destination_task_id, COL_INSTANCE, &instance, -1);
if (msg_number != 0) if (msg_number != 0)
{ {
enabled = ui_filters_message_enabled (message_id, origin_task_id, destination_task_id); enabled = ui_filters_message_enabled (message_id, origin_task_id, destination_task_id, instance);
if ((enabled) && (ui_store.filtered_last_msg < msg_number)) if ((enabled) && (ui_store.filtered_last_msg < msg_number))
{ {
ui_store.filtered_last_msg = msg_number; ui_store.filtered_last_msg = msg_number;
ui_store.filtered_msg_number++; ui_store.filtered_msg_number++;
} }
g_debug("%p %p %d %d %d %d %d %d", model, iter, msg_number, message_id, origin_task_id, destination_task_id, enabled, ui_store.filtered_msg_number); g_debug("%p %p %d m:%d o:%d d:%d i:%d %d %d", model, iter, msg_number, message_id, origin_task_id, destination_task_id, instance, enabled, ui_store.filtered_msg_number);
} }
return enabled; return enabled;
...@@ -81,6 +84,8 @@ ui_tree_view_init_list(GtkWidget *list) ...@@ -81,6 +84,8 @@ ui_tree_view_init_list(GtkWidget *list)
column = gtk_tree_view_column_new_with_attributes( column = gtk_tree_view_column_new_with_attributes(
"Ins", renderer, "text", COL_INSTANCE, NULL); "Ins", renderer, "text", COL_INSTANCE, NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(list), column); gtk_tree_view_append_column(GTK_TREE_VIEW(list), column);
g_signal_connect(G_OBJECT(column), "clicked",
G_CALLBACK(ui_callback_on_tree_column_header_click), (gpointer) COL_INSTANCE);
ui_store.store = gtk_list_store_new(NUM_COLS, ui_store.store = gtk_list_store_new(NUM_COLS,
G_TYPE_UINT, // COL_MSG_NUM G_TYPE_UINT, // COL_MSG_NUM
...@@ -143,6 +148,7 @@ void ui_tree_view_destroy_list(GtkWidget *list) ...@@ -143,6 +148,7 @@ void ui_tree_view_destroy_list(GtkWidget *list)
gtk_list_store_clear(ui_store.store); gtk_list_store_clear(ui_store.store);
ui_store.filtered_last_msg = 0; ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0; ui_store.filtered_msg_number = 0;
ui_store.instance_number = 0;
/* Reset number of messages */ /* Reset number of messages */
ui_main_data.nb_message_received = 0; ui_main_data.nb_message_received = 0;
...@@ -185,6 +191,10 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox) ...@@ -185,6 +191,10 @@ int ui_tree_view_create(GtkWidget *window, GtkWidget *vbox)
gtk_tree_selection_set_select_function(selection, ui_callback_on_select_signal, gtk_tree_selection_set_select_function(selection, ui_callback_on_select_signal,
ui_main_data.text_view, NULL); ui_main_data.text_view, NULL);
ui_store.filtered_last_msg = 0;
ui_store.filtered_msg_number = 0;
ui_store.instance_number = 0;
ui_main_data.selection = selection; ui_main_data.selection = selection;
return 0; return 0;
...@@ -196,6 +206,20 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number, ...@@ -196,6 +206,20 @@ int ui_tree_view_new_signal_ind(const uint32_t message_number,
const uint32_t destination_task_id, const char *destination_task, const uint32_t destination_task_id, const char *destination_task,
uint32_t instance, gpointer buffer) uint32_t instance, gpointer buffer)
{ {
if(ui_store.instance_number < (instance + 1))
{
int i;
char name[10];
for (i = ui_store.instance_number; i <= instance; i++)
{
sprintf (name, "%d", i);
ui_filters_add (FILTER_INSTANCES, i, name, ENTRY_ENABLED_TRUE);
}
ui_store.instance_number = (instance + 1);
ui_destroy_filter_menu(FILTER_INSTANCES);
}
ui_tree_view_add_to_list(ui_main_data.signalslist, message_number, message_id, message_name, ui_tree_view_add_to_list(ui_main_data.signalslist, message_number, message_id, message_name,
origin_task_id, origin_task, destination_task_id, destination_task, instance, (buffer_t *)buffer); origin_task_id, origin_task, destination_task_id, destination_task, instance, (buffer_t *)buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment