From f9cdb4a5b63329b570c43ef65f96418e0c88234c Mon Sep 17 00:00:00 2001 From: karthikmurakonda Date: Fri, 28 Oct 2022 18:18:01 +0530 Subject: [PATCH] updated utility tools(unrefractored) --- iPDC/assets/utility_tools.ui | 252 +++++++++++++++++++++++++++++++++-- iPDC/inc/map_vis.h | 10 ++ iPDC/src/map_vis.c | 23 +++- iPDC/src/utility_tools.c | 3 + 4 files changed, 275 insertions(+), 13 deletions(-) diff --git a/iPDC/assets/utility_tools.ui b/iPDC/assets/utility_tools.ui index ce69fd8..153d59a 100644 --- a/iPDC/assets/utility_tools.ui +++ b/iPDC/assets/utility_tools.ui @@ -169,7 +169,7 @@ - + 100 80 @@ -179,7 +179,7 @@ 10 6 - + 80 True @@ -187,7 +187,7 @@ 35 - Voltage + Voltage Magnitude True True True @@ -218,7 +218,7 @@ 0 - 2 + 3 @@ -227,13 +227,14 @@ False 0 - kmeans - simple + Gaussian + kmeans + DTW 0 - 3 + 5 @@ -243,15 +244,52 @@ 0 frequency only - frequency,voltage - voltage + voltage only + frequency,voltage + + 0 + 7 + + + + + dfreq + True + True + True + + + 0 + 2 + + + + + True + False + Algorithm + 0 4 + + + True + False + Dimmensions + + + 0 + 6 + + + + + 0 @@ -281,6 +319,202 @@ 1 + + + True + False + vertical + + + True + False + Legend + True + + + False + True + 0 + + + + + + True + False + + + True + True + True + red + rgb(238,29,0) + + + 0 + 0 + + + + + True + False + Attack/Event + + + 1 + 0 + + + + + False + True + 1 + + + + + + True + False + + + True + True + True + rgb(0,255,0) + + + 0 + 0 + + + + + True + False + Normal + + + 1 + 0 + + + + + False + True + 2 + + + + + + + + + + + 2 + 0 + + + + + True + True + in + + + True + False + + + True + False + vertical + + + True + False + Graph Legend + + + False + True + 0 + + + + + + True + False + + + True + True + True + rgb(255,120,0) + + + 0 + 0 + + + + + True + False + Pmu + + + 1 + 0 + + + + + False + True + 1 + + + + + True + True + True + + + False + True + 2 + + + + + True + True + True + + + False + True + 3 + + + + + + + + + 2 + 1 + + diff --git a/iPDC/inc/map_vis.h b/iPDC/inc/map_vis.h index ec05f5e..0ae4ba2 100644 --- a/iPDC/inc/map_vis.h +++ b/iPDC/inc/map_vis.h @@ -8,5 +8,15 @@ typedef struct{ int current_selection; } myParameters; +struct vis_data{ + int id; + float lat; + float lon; + GdkPixbuf *last_image; + GTimeVal last_update_time; + struct vis_data *next; +}; + +struct vis_data *head; gboolean update_images(gpointer* pars); \ No newline at end of file diff --git a/iPDC/src/map_vis.c b/iPDC/src/map_vis.c index 6d947a4..1620e69 100644 --- a/iPDC/src/map_vis.c +++ b/iPDC/src/map_vis.c @@ -29,8 +29,8 @@ gboolean update_images(gpointer* pars){ if (curr_measurement==0) { int i = 0, k = 0; - float freq; - unsigned char fmt; + float freq,vol_magnitude,angle, dfreq; + unsigned char freq_fmt, anal_fmt, phas_fmt, polar_fmt; while (df!=NULL){ float lat; float lon; @@ -46,21 +46,36 @@ gboolean update_images(gpointer* pars){ if(id == to_intconvertor(temp_cfg->idcode)){ cfg_match = 1; printf("Matched - id : %d\n",id); - fmt = temp_cfg->pmu[0]->fmt->freq; + freq_fmt = temp_cfg->pmu[0]->fmt->freq; + anal_fmt = temp_cfg->pmu[0]->fmt->analog; + phas_fmt = temp_cfg->pmu[0]->fmt->phasor; + polar_fmt = temp_cfg->pmu[0]->fmt->polar; break; } else { temp_cfg = temp_cfg->cfgnext; } } pthread_mutex_unlock(&mutex_cfg); - if(fmt == '1'){ + + // get data from df. + if(freq_fmt == '1'){ freq = decode_ieee_single(df->dpmu[i]->freq); printf("freq = %f\n",freq); }else{ freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50; } + + unsigned char first2bytes[2]; + strncpy(first2bytes, df->dpmu[i]->phasors[0], 2); + unsigned char last2bytes[2]; + strncpy(last2bytes, df->dpmu[i]->phasors[0]+2, 2); + vol_magnitude = to_intconvertor(first2bytes); + float imaginary = to_intconvertor(last2bytes); + printf("vol = %f imag = %f\n",vol_magnitude, imaginary); + live_chart_serie_add(serie, freq); + // check lower layer details to get longitude and lattitude. pthread_mutex_lock(&mutex_Lower_Layer_Details); LLptr = LLfirst; match = 0; diff --git a/iPDC/src/utility_tools.c b/iPDC/src/utility_tools.c index bfd4db5..d74478d 100644 --- a/iPDC/src/utility_tools.c +++ b/iPDC/src/utility_tools.c @@ -105,12 +105,15 @@ void utility_tools(GtkButton *but, gpointer udata) "map-source", OSM_GPS_MAP_SOURCE_OSMC_TRAILS, "tile-cache", "/tmp/", NULL); + + // TODO: centering the map osm_gps_map_set_center_and_zoom(utdata->util_map, 15.4589, 75.0078, 10); // TODO: add the points to window. g_last_image = osm_gps_map_image_add(utdata->util_map, 15.4589, 75.0078, g_red_image); g_last_image = osm_gps_map_image_add(utdata->util_map, 15.518597, 74.925584, g_green_image); + curr_measurement = 0; algorithm = 0; dimmension = 0;