Compare commits
	
		
			6 Commits
		
	
	
		
			efdc4d6a6c
			...
			4ce18420ac
		
	
	| Author | SHA1 | Date | 
|---|---|---|
| 
							
							
								 | 
						4ce18420ac | |
| 
							
							
								 | 
						74c683321e | |
| 
							
							
								 | 
						dca636ce18 | |
| 
							
							
								 | 
						4f5cc8455e | |
| 
							
							
								 | 
						650eb23d30 | |
| 
							
							
								 | 
						bfa0b35d86 | 
| 
						 | 
				
			
			@ -1,9 +0,0 @@
 | 
			
		|||
/* pavan changes */
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
/* variables declared of attack_detect function */
 | 
			
		||||
 | 
			
		||||
/* function declared  */
 | 
			
		||||
gboolean attack_detect_freq(struct data_frame *df);
 | 
			
		||||
gboolean attack_detect_vol(struct data_frame *df);
 | 
			
		||||
gboolean attack_detect_freq_vol(struct data_frame *df);
 | 
			
		||||
/* pavan changes */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,33 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Dynamic_time_warping.h
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
/*pavan changes*/
 | 
			
		||||
int DTWfreqDistance(struct data_frame *df);
 | 
			
		||||
 | 
			
		||||
int DTWvolDistance(struct data_frame *df);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Event_detect.h
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
gboolean attack_detect_freq(struct data_frame *df);
 | 
			
		||||
gboolean attack_detect_vol(struct data_frame *df);
 | 
			
		||||
gboolean attack_detect_freq_vol(struct data_frame *df);
 | 
			
		||||
| 
						 | 
				
			
			@ -1,10 +1,33 @@
 | 
			
		|||
/*Pavan Changes*/
 | 
			
		||||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Kmeans.h
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
// intial variables
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//function declaration
 | 
			
		||||
gboolean kmeans(struct data_frame *df);
 | 
			
		||||
 | 
			
		||||
/*Pavan Changes*/
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +1,33 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Kmeans2.h
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
int *getRandoms(int lower, int upper, int count);
 | 
			
		||||
long double distance(struct Point *A, struct Point *B);
 | 
			
		||||
bool Kmeans2(struct data_frame *df);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,39 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * data_vis.h
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
#include <osm-gps-map.h>
 | 
			
		||||
#include "livechart.h"
 | 
			
		||||
 | 
			
		||||
typedef struct{
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
    OsmGpsMap *util_map;
 | 
			
		||||
    GdkPixbuf *g_red_image;
 | 
			
		||||
    GdkPixbuf *g_green_image;
 | 
			
		||||
| 
						 | 
				
			
			@ -10,7 +41,8 @@ typedef struct{
 | 
			
		|||
    int current_selection;
 | 
			
		||||
} myParameters;
 | 
			
		||||
 | 
			
		||||
struct vis_data{
 | 
			
		||||
struct vis_data
 | 
			
		||||
{
 | 
			
		||||
    int id;
 | 
			
		||||
    float lat;
 | 
			
		||||
    float lon;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,33 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * utility_tools.h
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
#include "osm-gps-map.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -53,6 +83,4 @@ int curr_measurement;
 | 
			
		|||
int algorithm;
 | 
			
		||||
int dimmension;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void utility_tools(GtkButton *but, gpointer udata);
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +1,31 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Dynamic_time_warping.c
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include "parser.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +60,13 @@ struct DTWvollist
 | 
			
		|||
struct DTWfreqlist *dtwhead = NULL;
 | 
			
		||||
struct DTWvollist *dtwheadvol = NULL;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Dynamic Time Warping using frequency
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return int
 | 
			
		||||
 */
 | 
			
		||||
int DTWfreqDistance(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (dtwhead == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -158,6 +193,13 @@ int DTWfreqDistance(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Dynamic Time Warping using voltage
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return int
 | 
			
		||||
 */
 | 
			
		||||
int DTWvolDistance(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (dtwheadvol == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -314,6 +356,13 @@ int DTWvolDistance(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Dynamic Time Warping using frequency and voltage
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return int
 | 
			
		||||
 */
 | 
			
		||||
int DTWfreqvolDistance(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    return DTWfreqDistance(df) && DTWfreqvolDistance(df);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,42 @@
 | 
			
		|||
/* pavan changes */
 | 
			
		||||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Event_detect.c
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <time.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include "parser.h"
 | 
			
		||||
#include "Attack_detect.h"
 | 
			
		||||
#include "Event_detect.h"
 | 
			
		||||
 | 
			
		||||
/*Used in maintaining Nodes for all PMUS*/
 | 
			
		||||
struct freqlist
 | 
			
		||||
{
 | 
			
		||||
    int idcode;
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +45,7 @@ struct freqlist
 | 
			
		|||
    struct freqlist *next;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*Used in maintaining Nodes for all PMUS*/
 | 
			
		||||
struct vollist
 | 
			
		||||
{
 | 
			
		||||
    int idcode;
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +57,13 @@ struct vollist
 | 
			
		|||
struct freqlist *head = NULL;
 | 
			
		||||
struct vollist *headvol = NULL;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Basic appraoch using freq
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return gboolean
 | 
			
		||||
 */
 | 
			
		||||
gboolean attack_detect_freq(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (head == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -95,6 +133,13 @@ gboolean attack_detect_freq(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Basic appraoch using voltage
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return gboolean
 | 
			
		||||
 */
 | 
			
		||||
gboolean attack_detect_vol(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    float CURR_vol;
 | 
			
		||||
| 
						 | 
				
			
			@ -194,9 +239,14 @@ gboolean attack_detect_vol(struct data_frame *df)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Basic appraoch using voltage and frequency
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return gboolean
 | 
			
		||||
 */
 | 
			
		||||
gboolean attack_detect_freq_vol(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    return attack_detect_freq(df) && attack_detect_vol(df);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* pavan changes */
 | 
			
		||||
| 
						 | 
				
			
			@ -1,4 +1,32 @@
 | 
			
		|||
/*Pavan Changes*/
 | 
			
		||||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Kmeans.c
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include "parser.h"
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -22,6 +50,13 @@ struct kmeans1
 | 
			
		|||
 | 
			
		||||
struct kmeans1 *headk = NULL;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Kmeans clustering using frequency
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return gboolean
 | 
			
		||||
 */
 | 
			
		||||
gboolean kmeans(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (headk == NULL)
 | 
			
		||||
| 
						 | 
				
			
			@ -99,5 +134,3 @@ gboolean kmeans(struct data_frame *df)
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*Pavan Changes*/
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +1,33 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * Kmeans2.c
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include "parser.h"
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -6,6 +36,7 @@
 | 
			
		|||
#include <string.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
/*Used for storing points*/
 | 
			
		||||
struct Point
 | 
			
		||||
{
 | 
			
		||||
    long double x, y;    // coordinates
 | 
			
		||||
| 
						 | 
				
			
			@ -13,6 +44,7 @@ struct Point
 | 
			
		|||
    long double minDist; // default infinite dist to nearest cluster
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*used for storing centroid of clusters formed*/
 | 
			
		||||
struct centroid
 | 
			
		||||
{
 | 
			
		||||
    long double x, y;
 | 
			
		||||
| 
						 | 
				
			
			@ -20,6 +52,7 @@ struct centroid
 | 
			
		|||
    unsigned long long int count;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*used to maintain nodes for all PMUs*/
 | 
			
		||||
struct Kmeans2
 | 
			
		||||
{
 | 
			
		||||
    int idcode;
 | 
			
		||||
| 
						 | 
				
			
			@ -34,11 +67,23 @@ struct Kmeans2
 | 
			
		|||
 | 
			
		||||
struct Kmeans2 *head_of_kmeans2 = NULL;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It finds data between point A and B
 | 
			
		||||
 *
 | 
			
		||||
 * @param  A,B
 | 
			
		||||
 * @return long double
 | 
			
		||||
 */
 | 
			
		||||
long double distance(struct Point *A, struct Point *B)
 | 
			
		||||
{
 | 
			
		||||
    return (((A->x - B->x) * (A->x - B->x)) + ((A->y - B->y) * (A->y - B->y)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It finds data between centroid A and point B
 | 
			
		||||
 *
 | 
			
		||||
 * @param  A,B
 | 
			
		||||
 * @return long double
 | 
			
		||||
 */
 | 
			
		||||
long double distance2(struct centroid *A, struct Point *B)
 | 
			
		||||
{
 | 
			
		||||
    return (((A->x - B->x) * (A->x - B->x)) + ((A->y - B->y) * (A->y - B->y)));
 | 
			
		||||
| 
						 | 
				
			
			@ -79,6 +124,13 @@ int *getRandoms(int lower, int upper, int count)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to check event detection using Kmeans clustering using voltage and frequency
 | 
			
		||||
 *        called in data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * @param df data frame
 | 
			
		||||
 * @return bool
 | 
			
		||||
 */
 | 
			
		||||
bool Kmeans2(struct data_frame *df)
 | 
			
		||||
{
 | 
			
		||||
    if (head_of_kmeans2 == NULL)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,33 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * data_vis.c
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -8,7 +38,7 @@
 | 
			
		|||
#include "data_vis.h"
 | 
			
		||||
#include "parser.h"
 | 
			
		||||
#include "osm-gps-map.h"
 | 
			
		||||
#include "Attack_detect.h"
 | 
			
		||||
#include "Event_detect.h"
 | 
			
		||||
#include "Kmeans.h"
 | 
			
		||||
#include "Dynamic_time_warping.h"
 | 
			
		||||
#include "connections.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -16,10 +46,17 @@
 | 
			
		|||
#include "utility_tools.h"
 | 
			
		||||
#include "Kmeans2.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int loops = 0;
 | 
			
		||||
 | 
			
		||||
gboolean update_vis(gpointer* pars){
 | 
			
		||||
/**
 | 
			
		||||
 * @brief It is used to update the data in the GUI.
 | 
			
		||||
 *        called in utility_tools.c with the help of g_timeout_add()
 | 
			
		||||
 * 
 | 
			
		||||
 * @param pars 
 | 
			
		||||
 * @return gboolean 
 | 
			
		||||
 */
 | 
			
		||||
gboolean update_vis(gpointer *pars)
 | 
			
		||||
{
 | 
			
		||||
    int match = 0, id, cfg_match = 0;
 | 
			
		||||
    myParameters *parameters = (myParameters *)pars;
 | 
			
		||||
    struct cfg_frame *temp_cfg;
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +66,8 @@ gboolean update_vis(gpointer* pars){
 | 
			
		|||
    struct Lower_Layer_Details *LLptr;
 | 
			
		||||
    struct vis_data *vis_ptr;
 | 
			
		||||
 | 
			
		||||
    if (df == NULL){
 | 
			
		||||
    if (df == NULL)
 | 
			
		||||
    {
 | 
			
		||||
        pthread_mutex_unlock(&mutex_on_TSB);
 | 
			
		||||
        return TRUE;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -37,32 +75,40 @@ gboolean update_vis(gpointer* pars){
 | 
			
		|||
    int i = 0, k = 0;
 | 
			
		||||
    float freq, vol_magnitude, angle, dfreq;
 | 
			
		||||
    unsigned char freq_fmt, anal_fmt, phas_fmt, polar_fmt;
 | 
			
		||||
    while (df!=NULL){
 | 
			
		||||
    while (df != NULL)
 | 
			
		||||
    {
 | 
			
		||||
        float lat;
 | 
			
		||||
        float lon;
 | 
			
		||||
        loops++;
 | 
			
		||||
        id = to_intconvertor(df->idcode);
 | 
			
		||||
        pthread_mutex_lock(&mutex_cfg);
 | 
			
		||||
        temp_cfg = cfgfirst;
 | 
			
		||||
        while(temp_cfg != NULL){
 | 
			
		||||
            if(id == to_intconvertor(temp_cfg->idcode)){
 | 
			
		||||
        while (temp_cfg != NULL)
 | 
			
		||||
        {
 | 
			
		||||
            if (id == to_intconvertor(temp_cfg->idcode))
 | 
			
		||||
            {
 | 
			
		||||
                cfg_match = 1;
 | 
			
		||||
                freq_fmt = temp_cfg->pmu[0]->fmt->freq;
 | 
			
		||||
                anal_fmt = temp_cfg->pmu[0]->fmt->analog;
 | 
			
		||||
                phas_fmt = temp_cfg->pmu[0]->fmt->phasor;
 | 
			
		||||
                polar_fmt = temp_cfg->pmu[0]->fmt->polar;
 | 
			
		||||
                break;
 | 
			
		||||
            } else {
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                temp_cfg = temp_cfg->cfgnext;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        pthread_mutex_unlock(&mutex_cfg);
 | 
			
		||||
 | 
			
		||||
        // get data from df.
 | 
			
		||||
        if(freq_fmt == '1'){
 | 
			
		||||
        if (freq_fmt == '1')
 | 
			
		||||
        {
 | 
			
		||||
            freq = decode_ieee_single(df->dpmu[i]->freq);
 | 
			
		||||
            printf("freq = %f\n", freq);
 | 
			
		||||
        }else{
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            freq = to_intconvertor(df->dpmu[i]->freq) * 1e-3 + 50;
 | 
			
		||||
            printf("freq = %f\n", freq);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -76,8 +122,10 @@ gboolean update_vis(gpointer* pars){
 | 
			
		|||
 | 
			
		||||
        vis_ptr = vis_data_head;
 | 
			
		||||
        match = 0;
 | 
			
		||||
        while(vis_ptr != NULL){
 | 
			
		||||
            if(vis_ptr->id == id){
 | 
			
		||||
        while (vis_ptr != NULL)
 | 
			
		||||
        {
 | 
			
		||||
            if (vis_ptr->id == id)
 | 
			
		||||
            {
 | 
			
		||||
                match = 1;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -91,78 +139,136 @@ gboolean update_vis(gpointer* pars){
 | 
			
		|||
        live_chart_serie_add(vis_ptr->serie_vol, vol_magnitude);
 | 
			
		||||
        live_chart_serie_add(vis_ptr->serie_dfreq, dfreq);
 | 
			
		||||
 | 
			
		||||
        if(match == 1 && cfg_match == 1){
 | 
			
		||||
            if(vis_ptr->last_image != 0){
 | 
			
		||||
        if (match == 1 && cfg_match == 1)
 | 
			
		||||
        {
 | 
			
		||||
            if (vis_ptr->last_image != 0)
 | 
			
		||||
            {
 | 
			
		||||
                osm_gps_map_image_remove(parameters->util_map, vis_ptr->last_image);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if(curr_measurement == 0){
 | 
			
		||||
                if(vol_magnitude > 65600 || vol_magnitude < 65300){
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                }else{
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                }
 | 
			
		||||
            }else if(curr_measurement == 1){
 | 
			
		||||
                if (freq > 50.3){
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
 | 
			
		||||
                }else{
 | 
			
		||||
            if (curr_measurement == 0)
 | 
			
		||||
            {
 | 
			
		||||
                if (vol_magnitude > 65600 || vol_magnitude < 65300)
 | 
			
		||||
                {
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                }
 | 
			
		||||
            }else if(curr_measurement == 2){
 | 
			
		||||
                if (dfreq < 0.5){
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
 | 
			
		||||
                }else{
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
 | 
			
		||||
                }
 | 
			
		||||
            }else if(curr_measurement == 3){
 | 
			
		||||
                if(algorithm==0 && dimmension == 0){
 | 
			
		||||
                    if (!attack_detect_freq(df)){
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                }
 | 
			
		||||
                }else if (algorithm==0 && dimmension == 1){
 | 
			
		||||
                    if (!attack_detect_vol(df)){
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
            }
 | 
			
		||||
            else if (curr_measurement == 1)
 | 
			
		||||
            {
 | 
			
		||||
                if (freq > 50.3)
 | 
			
		||||
                {
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                }
 | 
			
		||||
                }else if (algorithm==0 && dimmension == 2){
 | 
			
		||||
                    if (!attack_detect_freq_vol(df)){
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else if (curr_measurement == 2)
 | 
			
		||||
            {
 | 
			
		||||
                if (dfreq < 0.5)
 | 
			
		||||
                {
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                }
 | 
			
		||||
                }else if (algorithm==1 && dimmension == 0){
 | 
			
		||||
                    if(!kmeans(df)){
 | 
			
		||||
                else
 | 
			
		||||
                {
 | 
			
		||||
                    vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else if (curr_measurement == 3)
 | 
			
		||||
            {
 | 
			
		||||
                if (algorithm == 0 && dimmension == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!attack_detect_freq(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }else if (algorithm==1 && dimmension == 1){
 | 
			
		||||
 | 
			
		||||
                }else if (algorithm==1 && dimmension == 2){
 | 
			
		||||
                    if(!Kmeans2(df)){
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 0 && dimmension == 1)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!attack_detect_vol(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }else if (algorithm==2 && dimmension == 0){
 | 
			
		||||
                    if(!DTWfreqDistance(df)){
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 0 && dimmension == 2)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!attack_detect_freq_vol(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }else if (algorithm==2 && dimmension == 1){
 | 
			
		||||
                    if(!DTWvolDistance(df)){
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 1 && dimmension == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!kmeans(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }else if (algorithm==2 && dimmension == 2){
 | 
			
		||||
                    if(!DTWfreqvolDistance(df)){
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 1 && dimmension == 1)
 | 
			
		||||
                {
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 1 && dimmension == 2)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!Kmeans2(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }else{
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 2 && dimmension == 0)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!DTWfreqDistance(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 2 && dimmension == 1)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!DTWvolDistance(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                else if (algorithm == 2 && dimmension == 2)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!DTWfreqvolDistance(df))
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_green_image);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
| 
						 | 
				
			
			@ -176,4 +282,3 @@ gboolean update_vis(gpointer* pars){
 | 
			
		|||
    gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
 | 
			
		||||
    return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,33 @@
 | 
			
		|||
/* -----------------------------------------------------------------------------
 | 
			
		||||
 * utility_tools.c
 | 
			
		||||
 *
 | 
			
		||||
 * iPDC - Phasor Data Concentrator
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2022-2023 Nitesh Pandit
 | 
			
		||||
 * Copyright (C) 2022-2023 Kedar V. Khandeparkar
 | 
			
		||||
 * Copyright (C) 2022-2023 Pavan Kumar V Patil
 | 
			
		||||
 * Copyright (C) 2022-2023 Karthik Murakonda
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License
 | 
			
		||||
 * as published by the Free Software Foundation; either version 2
 | 
			
		||||
 * of the License, or (at your option) any later version.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program; if not, write to the Free Software
 | 
			
		||||
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 | 
			
		||||
 *
 | 
			
		||||
 * Authors:
 | 
			
		||||
 *		M V Karthik <karthik.murakonda14@gmail.com>
 | 
			
		||||
 *		Pavan Kumar V Patil <pavanvpatil01@gmail.com>
 | 
			
		||||
 *
 | 
			
		||||
 * ----------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
#include <gtk/gtk.h>
 | 
			
		||||
#include "align_sort.h"
 | 
			
		||||
#include "parser.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -14,11 +44,21 @@
 | 
			
		|||
#define GREY_IMAGE "/usr/local/share/iPDC/grey.png"
 | 
			
		||||
#define PINK_IMAGE "/usr/local/share/iPDC/pink.png"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Get the Index Color object
 | 
			
		||||
 * 
 | 
			
		||||
 * @param index 
 | 
			
		||||
 * @return GdkRGBA 
 | 
			
		||||
 * @note This function is used to get the color of the index mathematicallly 
 | 
			
		||||
 * by using the index value.
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
GdkRGBA getIndexColor(int index){
 | 
			
		||||
GdkRGBA getIndexColor(int index)
 | 
			
		||||
{
 | 
			
		||||
    GdkRGBA color;
 | 
			
		||||
    // get the color from the index mathematically
 | 
			
		||||
    switch(index){
 | 
			
		||||
    switch (index)
 | 
			
		||||
    {
 | 
			
		||||
    case 0:
 | 
			
		||||
        color.red = 1.0;
 | 
			
		||||
        color.green = 0.0;
 | 
			
		||||
| 
						 | 
				
			
			@ -113,14 +153,18 @@ GdkRGBA getIndexColor(int index){
 | 
			
		|||
    return color;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void on_window_destroy(GtkWidget *widget, gpointer data)
 | 
			
		||||
{
 | 
			
		||||
    g_source_remove(GPOINTER_TO_UINT(data));
 | 
			
		||||
    gtk_main_quit();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// on clicking the button voltage
 | 
			
		||||
/**
 | 
			
		||||
 * @brief handles the voltage magnitude button click event
 | 
			
		||||
 * 
 | 
			
		||||
 * @param but 
 | 
			
		||||
 * @param udata 
 | 
			
		||||
 */
 | 
			
		||||
void on_voltage_clicked(GtkButton *but, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    curr_measurement = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -152,7 +196,12 @@ void on_voltage_clicked(GtkButton *but, gpointer udata)
 | 
			
		|||
    printf("Voltage\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// on clicking the button frequency
 | 
			
		||||
/**
 | 
			
		||||
 * @brief handles the frequency magnitude button click event
 | 
			
		||||
 * 
 | 
			
		||||
 * @param but : button
 | 
			
		||||
 * @param udata : user data
 | 
			
		||||
 */
 | 
			
		||||
void on_frequency_clicked(GtkButton *but, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    curr_measurement = 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -173,7 +222,6 @@ void on_frequency_clicked(GtkButton *but, gpointer udata)
 | 
			
		|||
    gtk_widget_hide(utdata->graph_layoutdfreq);
 | 
			
		||||
    gtk_widget_hide(utdata->graph_layoutvol);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    gtk_widget_hide(utdata->algorithm);
 | 
			
		||||
    gtk_widget_hide(utdata->dimmension);
 | 
			
		||||
    gtk_widget_hide(utdata->algo_label);
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +234,12 @@ void on_frequency_clicked(GtkButton *but, gpointer udata)
 | 
			
		|||
    printf("Frequency\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// on clicking the button dfreq
 | 
			
		||||
/**
 | 
			
		||||
 * @brief handles the frequency derivative button click event
 | 
			
		||||
 * 
 | 
			
		||||
 * @param but : button
 | 
			
		||||
 * @param udata : user data
 | 
			
		||||
 */
 | 
			
		||||
void on_dfreq_clicked(GtkButton *but, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    curr_measurement = 2;
 | 
			
		||||
| 
						 | 
				
			
			@ -207,7 +260,6 @@ void on_dfreq_clicked(GtkButton *but, gpointer udata)
 | 
			
		|||
    gtk_widget_hide(utdata->swvol);
 | 
			
		||||
    gtk_widget_hide(utdata->swfreq);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    gtk_widget_hide(utdata->algorithm);
 | 
			
		||||
    gtk_widget_hide(utdata->dimmension);
 | 
			
		||||
    gtk_widget_hide(utdata->algo_label);
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +272,12 @@ void on_dfreq_clicked(GtkButton *but, gpointer udata)
 | 
			
		|||
    printf("dfreq\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// on clicking the button attack_detection
 | 
			
		||||
/**
 | 
			
		||||
 * @brief handles the attack detection button click event
 | 
			
		||||
 * 
 | 
			
		||||
 * @param but : button
 | 
			
		||||
 * @param udata : user data
 | 
			
		||||
 */
 | 
			
		||||
void on_attack_detection_clicked(GtkButton *but, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    curr_measurement = 3;
 | 
			
		||||
| 
						 | 
				
			
			@ -251,12 +308,24 @@ void on_attack_detection_clicked(GtkButton *but, gpointer udata)
 | 
			
		|||
    printf("Attack Detection\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Set the algo variable to the selected algorithm
 | 
			
		||||
 * 
 | 
			
		||||
 * @param combo : combo box
 | 
			
		||||
 * @param udata : user data
 | 
			
		||||
 */
 | 
			
		||||
void set_algo(GtkComboBox *combo, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    algorithm = gtk_combo_box_get_active(combo);
 | 
			
		||||
    printf("Algorithm: %d\n", algorithm);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Set the dimm variable to the selected dimmension
 | 
			
		||||
 * 
 | 
			
		||||
 * @param combo : combo box
 | 
			
		||||
 * @param udata : user data
 | 
			
		||||
 */
 | 
			
		||||
void set_dimm(GtkComboBox *combo, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    dimmension = gtk_combo_box_get_active(combo);
 | 
			
		||||
| 
						 | 
				
			
			@ -264,9 +333,13 @@ void set_dimm(GtkComboBox *combo, gpointer udata)
 | 
			
		|||
    printf("dimmension = %d\n", dimmension);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Initializes utility tools window.
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Main function for the utility tools window sets up the window and all the widgets
 | 
			
		||||
 *      and connects the signals to the callbacks.
 | 
			
		||||
 * 
 | 
			
		||||
 * @param but : button
 | 
			
		||||
 * @param udata : user data
 | 
			
		||||
 */
 | 
			
		||||
void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		||||
{
 | 
			
		||||
    GdkPixbuf *g_red_image;
 | 
			
		||||
| 
						 | 
				
			
			@ -322,7 +395,6 @@ void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		|||
    gtk_widget_set_visible(utdata->graph_layoutfreq, FALSE);
 | 
			
		||||
    gtk_widget_set_visible(utdata->graph_layoutdfreq, FALSE);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    g_signal_connect(utdata->voltage, "clicked", G_CALLBACK(on_voltage_clicked), NULL);
 | 
			
		||||
    g_signal_connect(utdata->frequency, "clicked", G_CALLBACK(on_frequency_clicked), NULL);
 | 
			
		||||
    g_signal_connect(utdata->dfreq, "clicked", G_CALLBACK(on_dfreq_clicked), NULL);
 | 
			
		||||
| 
						 | 
				
			
			@ -350,7 +422,6 @@ void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		|||
 | 
			
		||||
    gtk_container_add(utdata->map_layout, GTK_WIDGET(utdata->util_map));
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    LiveChartConfig *config_vol = live_chart_config_new();
 | 
			
		||||
    live_chart_yaxis_set_unit(config_vol->y_axis, "V");
 | 
			
		||||
    live_chart_xaxis_set_tick_interval(config_vol->x_axis, 20);
 | 
			
		||||
| 
						 | 
				
			
			@ -369,7 +440,6 @@ void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		|||
 | 
			
		||||
    LiveChartChart *chart_freq = live_chart_chart_new(config_freq);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    LiveChartConfig *config_dfreq = live_chart_config_new();
 | 
			
		||||
    live_chart_yaxis_set_unit(config_dfreq->y_axis, "mHz");
 | 
			
		||||
    live_chart_xaxis_set_tick_interval(config_dfreq->x_axis, 20);
 | 
			
		||||
| 
						 | 
				
			
			@ -396,7 +466,6 @@ void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		|||
        // declare tooltip
 | 
			
		||||
        gchar *tooltiptext;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // iterate through the cfg frame and find the corresponding cfg frame
 | 
			
		||||
        while (temp_cfg != NULL)
 | 
			
		||||
        {
 | 
			
		||||
| 
						 | 
				
			
			@ -453,10 +522,13 @@ void utility_tools(GtkButton *but, gpointer udata)
 | 
			
		|||
    temp_visptr->next = NULL;
 | 
			
		||||
 | 
			
		||||
    guint pid = g_timeout_add(20, (GSourceFunc)update_vis, data);
 | 
			
		||||
    if(index>0){
 | 
			
		||||
    if (index > 0)
 | 
			
		||||
    {
 | 
			
		||||
        centroid_latitude /= (index);
 | 
			
		||||
        centroid_longitude /= (index);
 | 
			
		||||
    }else{
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        centroid_latitude = 15;
 | 
			
		||||
        centroid_longitude = 74;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
		
		
			 Can't render this file because it is too large. 
		
	 | 
		Loading…
	
		Reference in New Issue