From c995e1f0c0a7942bf89750a3ed65b34225b8c647 Mon Sep 17 00:00:00 2001 From: karthikmurakonda Date: Fri, 11 Nov 2022 21:34:16 +0530 Subject: [PATCH] graph legend --- iPDC/assets/utility_tools.ui | 2 +- iPDC/assets/utility_tools.ui~ | 102 +--------------------------------- iPDC/src/map_vis.c | 9 --- iPDC/src/utility_tools.c | 23 +++++++- 4 files changed, 25 insertions(+), 111 deletions(-) diff --git a/iPDC/assets/utility_tools.ui b/iPDC/assets/utility_tools.ui index bb9d77f..e14a489 100644 --- a/iPDC/assets/utility_tools.ui +++ b/iPDC/assets/utility_tools.ui @@ -211,7 +211,7 @@ - Attack Detection + Event Detection True True True diff --git a/iPDC/assets/utility_tools.ui~ b/iPDC/assets/utility_tools.ui~ index 2d15355..bb9d77f 100644 --- a/iPDC/assets/utility_tools.ui~ +++ b/iPDC/assets/utility_tools.ui~ @@ -898,39 +898,7 @@ - - - True - False - - - True - True - True - rgb(253,0,0) - - - 0 - 0 - - - - - True - False - IITdh - - - 1 - 0 - - - - - False - True - 1 - + @@ -968,39 +936,7 @@ - - - True - False - - - True - True - True - rgb(253,0,0) - - - 0 - 0 - - - - - True - False - IITdh - - - 1 - 0 - - - - - False - True - 1 - + @@ -1044,39 +980,7 @@ - - - True - False - - - True - True - True - rgb(253,0,0) - - - 0 - 0 - - - - - True - False - IITdh - - - 1 - 0 - - - - - False - True - 1 - + diff --git a/iPDC/src/map_vis.c b/iPDC/src/map_vis.c index 518176d..564d5fa 100644 --- a/iPDC/src/map_vis.c +++ b/iPDC/src/map_vis.c @@ -33,10 +33,6 @@ gboolean update_images(gpointer* pars){ pthread_mutex_unlock(&mutex_on_TSB); return TRUE; } - //int freq = to_intconvertor(df->dpmu[0]->freq); - //gboolean green =attack_detect(df); - //printf("map_vis A: %Lf, B: %Lf,C: %Lf\n",A,B,C); - //gboolean green = kmeans(df); int i = 0, k = 0; float freq,vol_magnitude,angle, dfreq; @@ -45,17 +41,12 @@ gboolean update_images(gpointer* pars){ float lat; float lon; loops++; - // printf("loops: %d\n", loops); - id = to_intconvertor(df->idcode); - // printf("id = %d\n",id); pthread_mutex_lock(&mutex_cfg); temp_cfg = cfgfirst; - // Check for the IDCODE in Configuration Frame while(temp_cfg != NULL){ if(id == to_intconvertor(temp_cfg->idcode)){ cfg_match = 1; - // printf("Matched - id : %d\n",id); freq_fmt = temp_cfg->pmu[0]->fmt->freq; anal_fmt = temp_cfg->pmu[0]->fmt->analog; phas_fmt = temp_cfg->pmu[0]->fmt->phasor; diff --git a/iPDC/src/utility_tools.c b/iPDC/src/utility_tools.c index 8af4d40..3f0829c 100644 --- a/iPDC/src/utility_tools.c +++ b/iPDC/src/utility_tools.c @@ -351,6 +351,7 @@ void utility_tools(GtkButton *but, gpointer udata) dimmension = 0; myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_grey_image, g_last_image}; gpointer data = (gpointer)¶meters; + struct cfg_frame* temp_cfg = cfgfirst; gtk_widget_set_size_request(GTK_WIDGET(utdata->util_map), 600, 500); @@ -391,11 +392,26 @@ void utility_tools(GtkButton *but, gpointer udata) int index = 0; while (llptr != NULL) { - printf("\ncat\n"); temp_visptr->id = llptr->pmuid; temp_visptr->lat = llptr->latitude; temp_visptr->lon = llptr->longitude; - temp_visptr->last_image = osm_gps_map_image_add(utdata->util_map, llptr->latitude, llptr->longitude, g_grey_image); // TODO: change the image + temp_visptr->last_image = osm_gps_map_image_add(utdata->util_map, llptr->latitude, llptr->longitude, g_grey_image); + // declare tooltip + gchar *tooltiptext; + + + // iterate through the cfg frame and find the corresponding cfg frame + while (temp_cfg != NULL) + { + tooltiptext = g_strdup_printf("unknown"); + if ( to_intconvertor(temp_cfg->idcode) == llptr->pmuid) + { + // set the tooltip text + tooltiptext = cfgfirst->pmu[0]->stn; + break; + } + temp_cfg = temp_cfg->cfgnext; + } temp_visptr->serie_freq = live_chart_serie_new(llptr->ip, (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000))); GdkRGBA color = getIndexColor(index); @@ -415,6 +431,7 @@ void utility_tools(GtkButton *but, gpointer udata) GtkWidget *color_button = gtk_color_button_new_with_rgba(&color); gtk_grid_attach(GTK_GRID(grid), color_button, 0, 0, 1, 1); gchar *label_text = g_strdup_printf("%d", llptr->pmuid); + gtk_widget_set_tooltip_text(grid, tooltiptext); gtk_grid_attach(GTK_GRID(grid), gtk_label_new(label_text), 1, 0, 1, 1); // TODO: customise the line color gtk_box_pack_start(GTK_BOX(utdata->gl1), grid, FALSE, FALSE, 0); @@ -422,11 +439,13 @@ void utility_tools(GtkButton *but, gpointer udata) GtkWidget *color_button2 = gtk_color_button_new_with_rgba(&color); gtk_grid_attach(GTK_GRID(grid2), color_button2, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid2), gtk_label_new(label_text), 1, 0, 1, 1); + gtk_widget_set_tooltip_text(color_button2, tooltiptext); gtk_box_pack_start(GTK_BOX(utdata->gl2), grid2, FALSE, FALSE, 0); GtkWidget *grid3 = gtk_grid_new(); GtkWidget *color_button3 = gtk_color_button_new_with_rgba(&color); gtk_grid_attach(GTK_GRID(grid3), color_button3, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid3), gtk_label_new(label_text), 1, 0, 1, 1); + gtk_widget_set_tooltip_text(grid3, tooltiptext); gtk_box_pack_start(GTK_BOX(utdata->gl3), grid3, FALSE, FALSE, 0); temp_visptr->next = (struct vis_data *)malloc(sizeof(struct vis_data));