corrected phasor input data

This commit is contained in:
pavanvpatil 2022-10-30 00:59:41 +05:30
parent 5006efe082
commit 53c937a8e5
2 changed files with 81 additions and 47 deletions

View File

@ -23,7 +23,6 @@ struct vollist
struct vollist *next;
};
struct freqlist *head = NULL;
struct vollist *headvol = NULL;
@ -46,10 +45,12 @@ gboolean attack_detect_freq(struct data_frame *df)
if (to_intconvertor(df->idcode) == temp->idcode)
{
float CURR_FREQ;
if (df->dpmu[0]->fmt->freq == '0'){
if (df->dpmu[0]->fmt->freq == '0')
{
CURR_FREQ = 50 + to_intconvertor(df->dpmu[0]->freq) * 1e-3;
}
else{
else
{
CURR_FREQ = decode_ieee_single(df->dpmu[0]->freq);
}
printf("Current freq: %f\n", CURR_FREQ);
@ -95,6 +96,8 @@ gboolean attack_detect_vol(struct data_frame *df)
{
float CURR_vol;
if (df->dpmu[0]->fmt->phasor == '0')
{
if (df->dpmu[0]->fmt->polar == '0')
{
unsigned char s1[2];
unsigned char s2[2];
@ -107,13 +110,29 @@ gboolean attack_detect_vol(struct data_frame *df)
else
{
unsigned char s1[2];
unsigned char s2[2];
strncpy(s1, df->dpmu[0]->phasors[0], 2);
CURR_vol = to_intconvertor(s1);
}
}
else
{
if (df->dpmu[0]->fmt->polar == '0')
{
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);
long double v2 = decode_ieee_single(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[4];
strncpy(s1, df->dpmu[0]->phasors[0], 4);
CURR_vol = decode_ieee_single(s1);
}
}
if (headvol == NULL)
{
headvol = (struct vollist *)malloc(sizeof(struct vollist));
@ -174,6 +193,4 @@ gboolean attack_detect_freq_vol(struct data_frame *df)
return attack_detect_freq(df) && attack_detect_vol(df);
}
/* pavan changes */

View File

@ -29,7 +29,6 @@ struct DTWvollist
struct DTWvollist *next;
};
struct DTWfreqlist *dtwhead = NULL;
struct DTWvollist *dtwheadvol = NULL;
@ -182,6 +181,8 @@ int DTWvolDistance(struct data_frame *df)
{
float CURR_vol;
if (df->dpmu[0]->fmt->phasor == '0')
{
if (df->dpmu[0]->fmt->polar == '0')
{
unsigned char s1[2];
unsigned char s2[2];
@ -192,6 +193,15 @@ int DTWvolDistance(struct data_frame *df)
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[2];
strncpy(s1, df->dpmu[0]->phasors[0], 2);
CURR_vol = to_intconvertor(s1);
}
}
else
{
if (df->dpmu[0]->fmt->polar == '0')
{
unsigned char s1[4];
unsigned char s2[4];
@ -201,6 +211,13 @@ int DTWvolDistance(struct data_frame *df)
long double v2 = decode_ieee_single(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[4];
strncpy(s1, df->dpmu[0]->phasors[0], 4);
CURR_vol = decode_ieee_single(s1);
}
}
// printf("count1: %d\ncount2: %d\n",count_track1,count_track2);
// printf("curr_vol: %f\n",CURR_vol);