bug fixes

This commit is contained in:
karthikmurakonda 2022-10-28 19:14:35 +05:30
parent 04af82224d
commit ad4af0adac
4 changed files with 41 additions and 41 deletions

View File

@ -1,5 +1,5 @@
/*pavan changes*/ /*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);

View File

@ -5,7 +5,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <stdlib.h> #include <stdlib.h>
typedef struct struct DTWfreqlist
{ {
int idcode; int idcode;
long double *freq1; long double *freq1;
@ -14,10 +14,10 @@ typedef struct
int count_track2; int count_track2;
int flag; int flag;
int result; int result;
DTWfreqlist *next; struct DTWfreqlist *next;
} DTWfreqlist; };
typedef struct struct DTWvollist
{ {
int idcode; int idcode;
long double *vol1; long double *vol1;
@ -26,18 +26,18 @@ typedef struct
int count_track2; int count_track2;
int flag; int flag;
int result; int result;
DTWvollist *next; struct DTWvollist *next;
} DTWvollist; };
DTWfreqlist *head = NULL; struct DTWfreqlist *head = NULL;
DTWvollist *headvol = NULL; struct DTWvollist *headvol = NULL;
void DTWfreqDistance(struct data_frame *df) int DTWfreqDistance(struct data_frame *df)
{ {
if (head == NULL) if (head == NULL)
{ {
head = (DTWfreqlist *)malloc(sizeof(DTWfreqlist)); head = (struct DTWfreqlist *)malloc(sizeof(struct DTWfreqlist));
head->count_track1 = 0; head->count_track1 = 0;
head->count_track2 = 0; head->count_track2 = 0;
head->flag = 0; head->flag = 0;
@ -48,8 +48,8 @@ void DTWfreqDistance(struct data_frame *df)
} }
else else
{ {
DTWfreqlist *temp = head; struct DTWfreqlist *temp = head;
DTWfreqlist *previous; struct DTWfreqlist *previous;
while (temp != NULL) while (temp != NULL)
{ {
if (to_intconvertor(df->idcode) == temp->idcode) if (to_intconvertor(df->idcode) == temp->idcode)
@ -68,7 +68,7 @@ void DTWfreqDistance(struct data_frame *df)
// printf("curr_freq: %f\n",CURR_FREQ); // printf("curr_freq: %f\n",CURR_FREQ);
if (temp->count_track1 == 0) if (temp->count_track1 == 0)
{ {
if (tmp->flag == 0) if (temp->flag == 0)
{ {
temp->flag = 1; temp->flag = 1;
temp->freq1 = (long double *)malloc(500 * sizeof(long double)); temp->freq1 = (long double *)malloc(500 * sizeof(long double));
@ -145,7 +145,7 @@ void DTWfreqDistance(struct data_frame *df)
} }
if (temp == NULL) if (temp == NULL)
{ {
DTWfreqlist *bring = (DTWfreqlist *)malloc(sizeof(DTWfreqlist)); struct DTWfreqlist *bring = (struct DTWfreqlist *)malloc(sizeof(struct DTWfreqlist));
bring->count_track1 = 0; bring->count_track1 = 0;
bring->count_track2 = 0; bring->count_track2 = 0;
bring->flag = 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) if (headvol == NULL)
{ {
headvol = (DTWvollist *)malloc(sizeof(DTWvollist)); headvol = (struct DTWvollist *)malloc(sizeof(struct DTWvollist));
headvol->count_track1 = 0; headvol->count_track1 = 0;
headvol->count_track2 = 0; headvol->count_track2 = 0;
headvol->flag = 0; headvol->flag = 0;
@ -174,8 +174,8 @@ void DTWvolDistance(struct data_frame *df)
} }
else else
{ {
DTWvollist *temp = headvol; struct DTWvollist *temp = headvol;
DTWvollist *previous; struct DTWvollist *previous;
while (temp != NULL) while (temp != NULL)
{ {
if (to_intconvertor(df->idcode) == temp->idcode) if (to_intconvertor(df->idcode) == temp->idcode)
@ -183,8 +183,8 @@ void DTWvolDistance(struct data_frame *df)
float CURR_vol; float CURR_vol;
if (df->dpmu[0]->fmt->phasor == '0') if (df->dpmu[0]->fmt->phasor == '0')
{ {
unsigned char* s1; unsigned char s1[2];
unsigned char* s2; unsigned char s2[2];
strncpy(s1,df->dpmu[0]->phasors[0],2); strncpy(s1,df->dpmu[0]->phasors[0],2);
strncpy(s2,df->dpmu[0]->phasors[0]+2,2); strncpy(s2,df->dpmu[0]->phasors[0]+2,2);
long double v1 = to_intconvertor(s1); long double v1 = to_intconvertor(s1);
@ -193,8 +193,8 @@ void DTWvolDistance(struct data_frame *df)
} }
else else
{ {
unsigned char* s1; unsigned char s1[4];
unsigned char* s2; unsigned char s2[4];
strncpy(s1,df->dpmu[0]->phasors[0],4); strncpy(s1,df->dpmu[0]->phasors[0],4);
strncpy(s2,df->dpmu[0]->phasors[0]+2,4); strncpy(s2,df->dpmu[0]->phasors[0]+2,4);
long double v1 = decode_ieee_single(s1); long double v1 = decode_ieee_single(s1);
@ -206,7 +206,7 @@ void DTWvolDistance(struct data_frame *df)
// printf("curr_vol: %f\n",CURR_vol); // printf("curr_vol: %f\n",CURR_vol);
if (temp->count_track1 == 0) if (temp->count_track1 == 0)
{ {
if (tmp->flag == 0) if (temp->flag == 0)
{ {
temp->flag = 1; temp->flag = 1;
temp->vol1 = (long double *)malloc(500 * sizeof(long double)); temp->vol1 = (long double *)malloc(500 * sizeof(long double));
@ -283,7 +283,7 @@ void DTWvolDistance(struct data_frame *df)
} }
if (temp == NULL) if (temp == NULL)
{ {
DTWvollist *bring = (DTWvollist *)malloc(sizeof(DTWvollist)); struct DTWvollist *bring = (struct DTWvollist *)malloc(sizeof(struct DTWvollist));
bring->count_track1 = 0; bring->count_track1 = 0;
bring->count_track2 = 0; bring->count_track2 = 0;
bring->flag = 0; bring->flag = 0;

View File

@ -44,17 +44,17 @@ gboolean update_images(gpointer* pars){
float lat; float lat;
float lon; float lon;
loops++; loops++;
printf("loops: %d\n", loops); // printf("loops: %d\n", loops);
id = to_intconvertor(df->idcode); id = to_intconvertor(df->idcode);
printf("id = %d\n",id); // printf("id = %d\n",id);
pthread_mutex_lock(&mutex_cfg); pthread_mutex_lock(&mutex_cfg);
temp_cfg = cfgfirst; temp_cfg = cfgfirst;
// Check for the IDCODE in Configuration Frame // Check for the IDCODE in Configuration Frame
while(temp_cfg != NULL){ while(temp_cfg != NULL){
if(id == to_intconvertor(temp_cfg->idcode)){ if(id == to_intconvertor(temp_cfg->idcode)){
cfg_match = 1; cfg_match = 1;
printf("Matched - id : %d\n",id); // printf("Matched - id : %d\n",id);
freq_fmt = temp_cfg->pmu[0]->fmt->freq; freq_fmt = temp_cfg->pmu[0]->fmt->freq;
anal_fmt = temp_cfg->pmu[0]->fmt->analog; anal_fmt = temp_cfg->pmu[0]->fmt->analog;
phas_fmt = temp_cfg->pmu[0]->fmt->phasor; phas_fmt = temp_cfg->pmu[0]->fmt->phasor;
@ -69,7 +69,7 @@ gboolean update_images(gpointer* pars){
// get data from df. // get data from df.
if(freq_fmt == '1'){ if(freq_fmt == '1'){
freq = decode_ieee_single(df->dpmu[i]->freq); freq = decode_ieee_single(df->dpmu[i]->freq);
printf("freq = %f\n",freq); // printf("freq = %f\n",freq);
}else{ }else{
freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50; 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); strncpy(last2bytes, df->dpmu[i]->phasors[0]+2, 2);
vol_magnitude = to_intconvertor(first2bytes); vol_magnitude = to_intconvertor(first2bytes);
float imaginary = to_intconvertor(last2bytes); 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); live_chart_serie_add(serie, freq);
@ -89,7 +89,7 @@ gboolean update_images(gpointer* pars){
LLptr = LLfirst; LLptr = LLfirst;
match = 0; match = 0;
while(LLptr != NULL){ while(LLptr != NULL){
printf("pmuid = %d\n",LLptr->pmuid); // printf("pmuid = %d\n",LLptr->pmuid);
if(LLptr->pmuid == id){ if(LLptr->pmuid == id){
match = 1; match = 1;
float lat = LLptr->latitude; float lat = LLptr->latitude;
@ -100,17 +100,17 @@ gboolean update_images(gpointer* pars){
} }
pthread_mutex_unlock(&mutex_Lower_Layer_Details); pthread_mutex_unlock(&mutex_Lower_Layer_Details);
if(match == 1 && cfg_match == 1){ // if(match == 1 && cfg_match == 1){
printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq); // printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
if(parameters->g_last_image != 0){ if(parameters->g_last_image != 0){
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image); 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); parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
}else{ }else{
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image); parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
} }
} // }
df = df->dnext; df = df->dnext;
// i++; // i++;
k++; k++;

View File

@ -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_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(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); // 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}; // myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_last_image};
gpointer data = (gpointer) &parameters; // gpointer data = (gpointer) &parameters;
guint pid = g_timeout_add(20, (GSourceFunc) update_images, data); // guint pid = g_timeout_add(20, (GSourceFunc) update_images, data);
// gtk_widget_set_vexpand(GTK_WIDGET(utdata->util_map), TRUE); // gtk_widget_set_vexpand(GTK_WIDGET(utdata->util_map), TRUE);
// gtk_widget_set_hexpand(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_show_all(utdata->util_window);