bug fixes
This commit is contained in:
		
							parent
							
								
									04af82224d
								
							
						
					
					
						commit
						ad4af0adac
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
 | 
			
		||||
/*pavan changes*/
 | 
			
		||||
void DTWfreqDistance(struct data_frame *df);
 | 
			
		||||
int DTWfreqDistance(struct data_frame *df);
 | 
			
		||||
 | 
			
		||||
void DTWvolDistance(struct data_frame *df);
 | 
			
		||||
int DTWvolDistance(struct data_frame *df);
 | 
			
		||||
| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
#include <gtk/gtk.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
struct DTWfreqlist
 | 
			
		||||
{
 | 
			
		||||
    int idcode;
 | 
			
		||||
    long double *freq1;
 | 
			
		||||
| 
						 | 
				
			
			@ -14,10 +14,10 @@ typedef struct
 | 
			
		|||
    int count_track2;
 | 
			
		||||
    int flag;
 | 
			
		||||
    int result;
 | 
			
		||||
    DTWfreqlist *next;
 | 
			
		||||
} DTWfreqlist;
 | 
			
		||||
    struct DTWfreqlist *next;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
struct DTWvollist
 | 
			
		||||
{
 | 
			
		||||
    int idcode;
 | 
			
		||||
    long double *vol1;
 | 
			
		||||
| 
						 | 
				
			
			@ -26,18 +26,18 @@ typedef struct
 | 
			
		|||
    int count_track2;
 | 
			
		||||
    int flag;
 | 
			
		||||
    int result;
 | 
			
		||||
    DTWvollist *next;
 | 
			
		||||
} DTWvollist;
 | 
			
		||||
    struct DTWvollist *next;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DTWfreqlist *head = NULL;
 | 
			
		||||
DTWvollist *headvol = NULL;
 | 
			
		||||
struct DTWfreqlist *head = NULL;
 | 
			
		||||
struct DTWvollist *headvol = NULL;
 | 
			
		||||
 | 
			
		||||
void DTWfreqDistance(struct data_frame *df)
 | 
			
		||||
int DTWfreqDistance(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (head == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        head = (DTWfreqlist *)malloc(sizeof(DTWfreqlist));
 | 
			
		||||
        head = (struct DTWfreqlist *)malloc(sizeof(struct DTWfreqlist));
 | 
			
		||||
        head->count_track1 = 0;
 | 
			
		||||
        head->count_track2 = 0;
 | 
			
		||||
        head->flag = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -48,8 +48,8 @@ void DTWfreqDistance(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        DTWfreqlist *temp = head;
 | 
			
		||||
        DTWfreqlist *previous;
 | 
			
		||||
        struct DTWfreqlist *temp = head;
 | 
			
		||||
        struct DTWfreqlist *previous;
 | 
			
		||||
        while (temp != NULL)
 | 
			
		||||
        {
 | 
			
		||||
            if (to_intconvertor(df->idcode) == temp->idcode)
 | 
			
		||||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ void DTWfreqDistance(struct data_frame *df)
 | 
			
		|||
                // printf("curr_freq: %f\n",CURR_FREQ);
 | 
			
		||||
                if (temp->count_track1 == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    if (tmp->flag == 0)
 | 
			
		||||
                    if (temp->flag == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        temp->flag = 1;
 | 
			
		||||
                        temp->freq1 = (long double *)malloc(500 * sizeof(long double));
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ void DTWfreqDistance(struct data_frame *df)
 | 
			
		|||
        }
 | 
			
		||||
        if (temp == NULL)
 | 
			
		||||
        {
 | 
			
		||||
            DTWfreqlist *bring = (DTWfreqlist *)malloc(sizeof(DTWfreqlist));
 | 
			
		||||
            struct DTWfreqlist *bring = (struct DTWfreqlist *)malloc(sizeof(struct DTWfreqlist));
 | 
			
		||||
            bring->count_track1 = 0;
 | 
			
		||||
            bring->count_track2 = 0;
 | 
			
		||||
            bring->flag = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -159,11 +159,11 @@ void DTWfreqDistance(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DTWvolDistance(struct data_frame *df)
 | 
			
		||||
int DTWvolDistance(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (headvol == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        headvol = (DTWvollist *)malloc(sizeof(DTWvollist));
 | 
			
		||||
        headvol = (struct DTWvollist *)malloc(sizeof(struct DTWvollist));
 | 
			
		||||
        headvol->count_track1 = 0;
 | 
			
		||||
        headvol->count_track2 = 0;
 | 
			
		||||
        headvol->flag = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -174,8 +174,8 @@ void DTWvolDistance(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        DTWvollist *temp = headvol;
 | 
			
		||||
        DTWvollist *previous;
 | 
			
		||||
        struct DTWvollist *temp = headvol;
 | 
			
		||||
        struct DTWvollist *previous;
 | 
			
		||||
        while (temp != NULL)
 | 
			
		||||
        {
 | 
			
		||||
            if (to_intconvertor(df->idcode) == temp->idcode)
 | 
			
		||||
| 
						 | 
				
			
			@ -183,8 +183,8 @@ void DTWvolDistance(struct data_frame *df)
 | 
			
		|||
                float CURR_vol;
 | 
			
		||||
                if (df->dpmu[0]->fmt->phasor == '0')
 | 
			
		||||
                {
 | 
			
		||||
                    unsigned char* s1;
 | 
			
		||||
                    unsigned char* s2;
 | 
			
		||||
                    unsigned char s1[2];
 | 
			
		||||
                    unsigned char s2[2];
 | 
			
		||||
                    strncpy(s1,df->dpmu[0]->phasors[0],2);
 | 
			
		||||
                    strncpy(s2,df->dpmu[0]->phasors[0]+2,2);
 | 
			
		||||
                    long double v1 = to_intconvertor(s1);
 | 
			
		||||
| 
						 | 
				
			
			@ -193,8 +193,8 @@ void DTWvolDistance(struct data_frame *df)
 | 
			
		|||
                }
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    unsigned char* s1;
 | 
			
		||||
                    unsigned char* s2;
 | 
			
		||||
                    unsigned char s1[4];
 | 
			
		||||
                    unsigned char s2[4];
 | 
			
		||||
                    strncpy(s1,df->dpmu[0]->phasors[0],4);
 | 
			
		||||
                    strncpy(s2,df->dpmu[0]->phasors[0]+2,4);
 | 
			
		||||
                    long double v1 = decode_ieee_single(s1);
 | 
			
		||||
| 
						 | 
				
			
			@ -206,7 +206,7 @@ void DTWvolDistance(struct data_frame *df)
 | 
			
		|||
                // printf("curr_vol: %f\n",CURR_vol);
 | 
			
		||||
                if (temp->count_track1 == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    if (tmp->flag == 0)
 | 
			
		||||
                    if (temp->flag == 0)
 | 
			
		||||
                    {
 | 
			
		||||
                        temp->flag = 1;
 | 
			
		||||
                        temp->vol1 = (long double *)malloc(500 * sizeof(long double));
 | 
			
		||||
| 
						 | 
				
			
			@ -283,7 +283,7 @@ void DTWvolDistance(struct data_frame *df)
 | 
			
		|||
        }
 | 
			
		||||
        if (temp == NULL)
 | 
			
		||||
        {
 | 
			
		||||
            DTWvollist *bring = (DTWvollist *)malloc(sizeof(DTWvollist));
 | 
			
		||||
            struct DTWvollist *bring = (struct DTWvollist *)malloc(sizeof(struct DTWvollist));
 | 
			
		||||
            bring->count_track1 = 0;
 | 
			
		||||
            bring->count_track2 = 0;
 | 
			
		||||
            bring->flag = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,17 +44,17 @@ gboolean update_images(gpointer* pars){
 | 
			
		|||
            float lat;
 | 
			
		||||
            float lon;
 | 
			
		||||
            loops++;
 | 
			
		||||
            printf("loops: %d\n", loops);
 | 
			
		||||
            // printf("loops: %d\n", loops);
 | 
			
		||||
            
 | 
			
		||||
            id = to_intconvertor(df->idcode);
 | 
			
		||||
            printf("id = %d\n",id);
 | 
			
		||||
            // 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);
 | 
			
		||||
                    // 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;
 | 
			
		||||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ gboolean update_images(gpointer* pars){
 | 
			
		|||
            // get data from df.
 | 
			
		||||
            if(freq_fmt == '1'){
 | 
			
		||||
                freq = decode_ieee_single(df->dpmu[i]->freq);
 | 
			
		||||
                printf("freq = %f\n",freq);
 | 
			
		||||
                // printf("freq = %f\n",freq);
 | 
			
		||||
            }else{
 | 
			
		||||
                freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ gboolean update_images(gpointer* pars){
 | 
			
		|||
            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);
 | 
			
		||||
            // printf("vol = %f imag = %f\n",vol_magnitude, imaginary);
 | 
			
		||||
 | 
			
		||||
            live_chart_serie_add(serie, freq);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ gboolean update_images(gpointer* pars){
 | 
			
		|||
            LLptr = LLfirst;
 | 
			
		||||
            match = 0;
 | 
			
		||||
            while(LLptr != NULL){
 | 
			
		||||
                printf("pmuid = %d\n",LLptr->pmuid);
 | 
			
		||||
                // printf("pmuid = %d\n",LLptr->pmuid);
 | 
			
		||||
                if(LLptr->pmuid == id){
 | 
			
		||||
                    match = 1;
 | 
			
		||||
                    float lat = LLptr->latitude;
 | 
			
		||||
| 
						 | 
				
			
			@ -100,17 +100,17 @@ gboolean update_images(gpointer* pars){
 | 
			
		|||
            }
 | 
			
		||||
            pthread_mutex_unlock(&mutex_Lower_Layer_Details);
 | 
			
		||||
 | 
			
		||||
            if(match == 1 && cfg_match == 1){
 | 
			
		||||
                printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
 | 
			
		||||
            // if(match == 1 && cfg_match == 1){
 | 
			
		||||
                // printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
 | 
			
		||||
                if(parameters->g_last_image != 0){
 | 
			
		||||
                    osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
 | 
			
		||||
                }
 | 
			
		||||
                if (freq > 50.300){
 | 
			
		||||
                if (DTWvolDistance(df)){
 | 
			
		||||
                    parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
 | 
			
		||||
                }else{
 | 
			
		||||
                    parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            // }
 | 
			
		||||
            df = df->dnext;
 | 
			
		||||
            // i++;
 | 
			
		||||
            k++;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -156,11 +156,11 @@ void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		|||
 | 
			
		||||
    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) ¶meters;
 | 
			
		||||
    guint pid = g_timeout_add(20, (GSourceFunc) update_images, data);
 | 
			
		||||
    // //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) ¶meters;
 | 
			
		||||
    // 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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue