storing gps coordinates of source devices

This commit is contained in:
karthikmurakonda 2022-11-10 10:34:46 +05:30
parent e077810a72
commit a8faacf61f
6 changed files with 40 additions and 52 deletions

View File

@ -1315,12 +1315,12 @@ void add_pmu (GtkButton *but, gpointer udata)
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
gtk_widget_show (label);
label = gtk_label_new ("x-co-ordinate");
label = gtk_label_new ("lattitude");
gtk_misc_set_alignment (GTK_MISC(label),0,0);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6);
gtk_widget_show (label);
label = gtk_label_new ("y-co-ordinate");
label = gtk_label_new ("longitude");
gtk_misc_set_alignment (GTK_MISC(label),0,0);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 6, 7);
gtk_widget_show (label);
@ -2339,7 +2339,7 @@ void view_setup_file (char *filename)
/* Create a table of ? by 2 squares */
rowCount = dDevices + sDevices + 15;
table = gtk_table_new (rowCount, 5, FALSE);
table = gtk_table_new (rowCount, 7, FALSE);
/* set the spacing to 10 on x and 10 on y */
gtk_table_set_row_spacings (GTK_TABLE (table), 8);
@ -2441,7 +2441,7 @@ void view_setup_file (char *filename)
sprintf(buff, "Measurement Received From Total : %d Devices", sDevices);
label = gtk_label_new (buff);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 5, 8, 9 );
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 7, 8, 9 );
gtk_widget_show (label);
rowi = 9;
@ -2463,11 +2463,20 @@ void view_setup_file (char *filename)
gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, rowi, rowi+1);
gtk_widget_show (label);
label = gtk_label_new ("Lattitude");
gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 5, rowi, rowi+1);
gtk_widget_show (label);
label = gtk_label_new ("Longitude");
gtk_table_attach_defaults (GTK_TABLE (table), label, 5, 6, rowi, rowi+1);
gtk_widget_show (label);
rowi = rowi+1;
}
label = gtk_hseparator_new();
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 5, rowi, rowi+1);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 7, rowi, rowi+1);
gtk_widget_show (label);
rowi = rowi+1;
@ -2493,16 +2502,26 @@ void view_setup_file (char *filename)
gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, rowi, rowi+1);
gtk_widget_show (label);
d1 = strtok (NULL,"\n");
d1 = strtok (NULL,",");
label = gtk_label_new (d1);
gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, rowi, rowi+1);
gtk_widget_show (label);
d1 = strtok (NULL,",");
label = gtk_label_new (d1);
gtk_table_attach_defaults (GTK_TABLE (table), label, 4, 5, rowi, rowi+1);
gtk_widget_show (label);
d1 = strtok (NULL,"\n");
label = gtk_label_new (d1);
gtk_table_attach_defaults (GTK_TABLE (table), label, 5, 6, rowi, rowi+1);
gtk_widget_show (label);
rowi = rowi + 1;
}
label = gtk_hseparator_new();
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 5, rowi, rowi+1);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 7, rowi, rowi+1);
gtk_widget_show (label);
rowi = rowi+1;
@ -2511,7 +2530,7 @@ void view_setup_file (char *filename)
label = gtk_label_new (" ");
markup = g_markup_printf_escaped ("<span foreground=\"#0000FF\" font='11'>Destination Devices</span>");
gtk_label_set_markup (GTK_LABEL (label), markup);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 5, rowi, rowi+1);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 7, rowi, rowi+1);
gtk_widget_show (label);
g_free (markup);

View File

@ -17,7 +17,6 @@
#include "Kmeans2.h"
// debug
int loops = 0;
gboolean update_images(gpointer* pars){
@ -73,7 +72,7 @@ gboolean update_images(gpointer* pars){
freq = decode_ieee_single(df->dpmu[i]->freq);
// printf("freq = %f\n",freq);
}else{
freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50;
freq = to_intconvertor(df->dpmu[i]->freq)*1e-3+50;
}
unsigned char first2bytes[2];

View File

@ -163,7 +163,6 @@ int add_PMU(char pmuid[], char ip[], char port[], char protocol[], char latitude
temp_pmu->request_cfg_frame = 0;
temp_pmu->latitude = atof(latitude);
temp_pmu->longitude = atof(longitude);
printf(" lat = %f long = %f\n",temp_pmu->latitude,temp_pmu->longitude);
temp_pmu->next = NULL;
temp_pmu->prev = NULL;

View File

@ -689,6 +689,10 @@ void write_cfg_to_file()
fprintf(fp1,"%d",temp_pmu->port);
fputc(',',fp1);
fprintf(fp1,"%s",temp_pmu->protocol);
fputc(',',fp1);
fprintf(fp1,"%f",temp_pmu->latitude);
fputc(',',fp1);
fprintf(fp1,"%f",temp_pmu->longitude);
fputc('\n',fp1);
temp_pmu = temp_pmu->next;

View File

@ -632,7 +632,7 @@ void init_cfgparser(unsigned char st[]){
void recreate_Connection_Table() {
char line[40],*ip,*port,*protocol,*id;
char line[40],*ip,*port,*protocol,*id, *latitude, *longitude;
char *rline = NULL, *d1;
int err, tempi;
FILE *f;
@ -689,7 +689,9 @@ void recreate_Connection_Table() {
id = strtok (rline,",");
ip = strtok (NULL,",");
port = strtok (NULL,",");
protocol = strtok (NULL,"\n");
protocol = strtok (NULL,",");
latitude = strtok (NULL,",");
longitude = strtok (NULL,"\n");
protocol[3] = '\0';
printf("|\t%d\t|%s\t|\t%d\t|\t%s\t|\n",atoi(id),ip,atoi(port),protocol);
@ -706,6 +708,8 @@ void recreate_Connection_Table() {
strcpy(temp_pmu->ip,ip);
temp_pmu->port = atoi(port);
strcpy(temp_pmu->protocol,protocol);
temp_pmu->latitude = atof(latitude);
temp_pmu->longitude = atof(longitude);
temp_pmu->data_transmission_off = 0;
temp_pmu->pmu_remove = 0;
temp_pmu->request_cfg_frame = 0;

View File

@ -16,14 +16,6 @@
#define GREY_IMAGE "./assets/grey.png"
#define PINK_IMAGE "./assets/pink.png"
// void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image)
// {
// if (g_last_image)
// osm_gps_map_image_remove(map, g_last_image);
// osm_gps_map_image_add(map, lat, lon, image);
// }
// on closing the window kill the g_timeout_add
GdkRGBA getIndexColor(int index){
GdkRGBA color;
@ -306,7 +298,6 @@ void utility_tools(GtkButton *but, gpointer udata)
utdata->attack_detection = GTK_WIDGET(gtk_builder_get_object(builder, "attack_detection"));
utdata->algorithm = GTK_WIDGET(gtk_builder_get_object(builder, "algorithm"));
utdata->dimmension = GTK_WIDGET(gtk_builder_get_object(builder, "dimmension"));
// utdata->util_map = GTK_WIDGET(gtk_builder_get_object(builder, "util_map"));
utdata->map_layout = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
utdata->graph_layoutvol = GTK_CONTAINER(gtk_builder_get_object(builder, "graph_layoutvol"));
utdata->graph_layoutfreq = GTK_CONTAINER(gtk_builder_get_object(builder, "graph_layoutfreq"));
@ -350,9 +341,6 @@ void utility_tools(GtkButton *but, gpointer udata)
// 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;
@ -365,15 +353,6 @@ void utility_tools(GtkButton *but, gpointer udata)
gtk_container_add(utdata->map_layout, GTK_WIDGET(utdata->util_map));
// add live chart
// serie = live_chart_serie_new("IIT", (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000)));
// // live_chart set color to the serie
// GdkRGBA color = getIndexColor(0);
// live_chart_path_set_color(live_chart_serie_get_line(serie), &color);
// iterate over llptr and load the map_vis_head structure
// vis_data_head = (struct map_vis_head *)malloc(sizeof(struct vis_data));
LiveChartConfig *config_vol = live_chart_config_new();
live_chart_yaxis_set_unit(config_vol->y_axis, "V");
@ -403,11 +382,6 @@ void utility_tools(GtkButton *but, gpointer udata)
LiveChartChart *chart_dfreq = live_chart_chart_new(config_dfreq);
// live_chart_chart_add_serie(chart, serie);
struct Lower_Layer_Details *llptr = LLfirst;
vis_data_head = (struct vis_data *)malloc(sizeof(struct vis_data));
struct vis_data * temp_visptr = vis_data_head;
@ -445,6 +419,7 @@ void utility_tools(GtkButton *but, gpointer udata)
// gtk_widget_set_hexpand(GTK_WIDGET(chart), TRUE);
// gtk_widget_set_vexpand(GTK_WIDGET(chart), TRUE);
gtk_widget_set_size_request(GTK_WIDGET(chart_freq), 600, 150);
gtk_widget_set_size_request(GTK_WIDGET(chart_vol), 600, 150);
gtk_widget_set_size_request(GTK_WIDGET(chart_dfreq), 600, 150);
@ -453,20 +428,8 @@ void utility_tools(GtkButton *but, gpointer udata)
gtk_container_add(utdata->graph_layoutfreq, GTK_WIDGET(chart_freq));
gtk_container_add(utdata->graph_layoutdfreq, GTK_WIDGET(chart_dfreq));
g_signal_connect(utdata->util_window, "destroy", G_CALLBACK(on_window_destroy), GUINT_TO_POINTER(pid));
// //g_last_image = osm_gps_map_image_add(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);
// myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_last_image};
// gpointer data = (gpointer) &parameters;
// guint pid = g_timeout_add(20, (GSourceFunc) update_images, data);
// gtk_widget_set_vexpand(GTK_WIDGET(utdata->util_map), TRUE);
// gtk_widget_set_hexpand(GTK_WIDGET(utdata->util_map), TRUE);
gtk_widget_show_all(utdata->util_window);
gtk_widget_hide(utdata->algorithm);