diff --git a/iPDC/inc/global.h b/iPDC/inc/global.h index baf5440..68ff3e8 100755 --- a/iPDC/inc/global.h +++ b/iPDC/inc/global.h @@ -43,6 +43,7 @@ pthread_mutex_t mutex_file; /* To lock PMU Setup File */ pthread_mutex_t mutex_Lower_Layer_Details; /* To lock objects of connection table that hold lower layer PMU/PDC ip and protocol */ pthread_mutex_t mutex_Upper_Layer_Details; /* To lock objects of connection table that hold upper layer PDC ip and protocol */ pthread_mutex_t mutex_status_change; +pthread_mutex_t mutex_on_TSB; unsigned char *cfgframe,*dataframe; diff --git a/iPDC/src/align_sort.c b/iPDC/src/align_sort.c index 9ad1197..8cf45cb 100755 --- a/iPDC/src/align_sort.c +++ b/iPDC/src/align_sort.c @@ -56,7 +56,7 @@ int i; int front = -1; int rear = -1; -pthread_mutex_t mutex_on_TSB = PTHREAD_MUTEX_INITIALIZER; + /* ---------------------------------------------------------------------------- */ diff --git a/iPDC/src/map_vis.c b/iPDC/src/map_vis.c index 334ef3a..5f0901c 100644 --- a/iPDC/src/map_vis.c +++ b/iPDC/src/map_vis.c @@ -1,4 +1,6 @@ #include +#include +#include "global.h" #include "align_sort.h" #include "map_vis.h" #include "parser.h" @@ -15,6 +17,8 @@ int loops = 0; gboolean update_images(gpointer* pars){ int match=0,id; myParameters* parameters = (myParameters*) pars; + + pthread_mutex_lock(&mutex_on_TSB); struct data_frame *df = TSB[0].first_data_frame; struct Lower_Layer_Details *LLptr; @@ -23,14 +27,15 @@ gboolean update_images(gpointer* pars){ } if (curr_measurement==0) { - int i = 0; + int i = 0, k = 0; float freq; while (df!=NULL){ freq = to_intconvertor(df->dpmu[i]->freq)*0.001+50; live_chart_serie_add(serie, freq*1e-1); loops++; printf("loops: %d\n", loops); - id = to_intconvertor(TSB[0].idlist[i].idcode); + + id = to_intconvertor(df->idcode); printf("id = %d\n",id); LLptr = LLfirst; @@ -50,9 +55,9 @@ gboolean update_images(gpointer* pars){ float freq = to_intconvertor(df->dpmu[i]->freq)*0.001+50; printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq); gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY); - if(parameters->g_last_image != 0){ - osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image); - } + // if(parameters->g_last_image != 0){ + // // osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image); + // } if (freq > 50.300){ parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image); }else{ @@ -68,9 +73,11 @@ gboolean update_images(gpointer* pars){ // } } df = df->dnext; - i++; + // i++; + k++; } } + pthread_mutex_unlock(&mutex_on_TSB); gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map)); return TRUE; diff --git a/iPDC/src/recreate.c b/iPDC/src/recreate.c index 4b6c27b..b3fe047 100755 --- a/iPDC/src/recreate.c +++ b/iPDC/src/recreate.c @@ -71,6 +71,7 @@ void recreate_cfg_objects(){ pthread_mutex_init(&mutex_status_change, NULL); pthread_mutex_init(&mutex_Lower_Layer_Details, NULL); pthread_mutex_init(&mutex_Upper_Layer_Details, NULL); + pthread_mutex_init(&mutex_on_TSB, NULL); CMDSYNC[0] = 0xaa; CMDSYNC[1] = 0x41;