Compare commits

...

2 Commits

Author SHA1 Message Date
karthikmurakonda 59bed77548 basic color changing working 2022-09-28 16:40:10 +05:30
karthikmurakonda eda4d763e5 deleted unnecessary files 2022-09-28 16:39:53 +05:30
10 changed files with 141 additions and 1218 deletions

View File

@ -2,9 +2,10 @@
#include<time.h> #include<time.h>
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
#include<gtk/gtk.h>
#include "parser.h" #include "parser.h"
void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY) gboolean attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY)
{ {
// printf("freq: %d\n",to_intconvertor(&(df->dpmu[0]->fmt->freq))); // printf("freq: %d\n",to_intconvertor(&(df->dpmu[0]->fmt->freq)));
// printf("analog: %d\n",to_intconvertor(&(df->dpmu[0]->fmt->analog))); // printf("analog: %d\n",to_intconvertor(&(df->dpmu[0]->fmt->analog)));
@ -16,18 +17,20 @@ void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_O
*SUM_OF_FREQUENCY+=CURR_FREQ; *SUM_OF_FREQUENCY+=CURR_FREQ;
float FREQ_AVG=*SUM_OF_FREQUENCY/(*COUNT*1.0f); float FREQ_AVG=*SUM_OF_FREQUENCY/(*COUNT*1.0f);
float DETECT_PERCENT=(abs(FREQ_AVG-CURR_FREQ)/(FREQ_AVG*1.0f))*100; float DETECT_PERCENT=(abs(FREQ_AVG-CURR_FREQ)/(FREQ_AVG*1.0f))*100;
gboolean detect;
/* detecting based on thershold */ /* detecting based on thershold */
float THRESHOLD=70; float THRESHOLD=60;
if(DETECT_PERCENT>THRESHOLD) if(DETECT_PERCENT>THRESHOLD)
{ {
detect=FALSE;
printf("\033[0;31m"); printf("\033[0;31m");
printf("ATTACK DETECTED!"); printf("ATTACK DETECTED!");
printf("\033[0m"); printf("\033[0m");
printf(" Detect_percent: %f\n",DETECT_PERCENT); // intf(" Detect_percent: %f\n",DETECT_PERCENT);
} }
else else
{ {
detect=TRUE;
printf("\033[0;32m"); printf("\033[0;32m");
printf("NO PROBLEM :)\n"); printf("NO PROBLEM :)\n");
printf("\033[0m"); printf("\033[0m");
@ -51,6 +54,7 @@ void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_O
*SUM_OF_FREQUENCY=CURR_FREQ; *SUM_OF_FREQUENCY=CURR_FREQ;
*COUNT=1; *COUNT=1;
} }
return detect;
} }
/* pavan changes */ /* pavan changes */

View File

@ -1,10 +1,11 @@
/* pavan changes */ /* pavan changes */
#include <time.h>
#include <gtk/gtk.h>
/* variables declared of attack_detect function */ /* variables declared of attack_detect function */
float SUM_OF_FREQUENCY=0; float SUM_OF_FREQUENCY=0;
float COUNT=0; float COUNT=0;
time_t START; time_t START;
/* function declared */ /* function declared */
void attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY); gboolean attack_detect(struct data_frame *df,time_t* START,float* COUNT,float* SUM_OF_FREQUENCY);
/* pavan changes */ /* pavan changes */

View File

@ -1,640 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkAccelGroup" id="accelgroup1"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-properties</property>
</object>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-go-up</property>
<property name="pixel_size">10</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-go-down</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-select-color</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-about</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-quit</property>
<property name="pixel_size">10</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-properties</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-sort-ascending</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-remove</property>
<property name="icon_size">1</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-media-stop</property>
<property name="icon_size">1</property>
</object>
<object class="GtkWindow" id="ipdc">
<property name="width_request">800</property>
<property name="height_request">600</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">iPDC - A Free Phasor Data Concentrator.
Supportive IEEE C37.118 Synchrophasor std.</property>
<property name="title" translatable="yes">iPDC - v1.3</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">710</property>
<property name="default_height">590</property>
<property name="icon_name">gnome-obex-server</property>
<property name="focus_on_map">False</property>
<property name="gravity">center</property>
<child type="titlebar">
<placeholder/>
</child>
<child>
<object class="GtkLayout" id="layout1">
<property name="width_request">800</property>
<property name="height_request">600</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkButton" id="add_pmu_button">
<property name="label" translatable="yes">Add a Source Device</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">PMU/PDC device from which configuration
and data frames would be received.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">180</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_pmu_button">
<property name="label" translatable="yes">Remove a Source Device</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Remove PMU/PDC device from which
data frames are being received.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">225</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmd_data_off_button">
<property name="label" translatable="yes">Turn OFF Data Transmission</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Turn OFF data transmission of PMU/PDC device from
which data frames are being received.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">270</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmd_data_on_button">
<property name="label" translatable="yes">Turn ON Data Transmission</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Turn ON data transmission of PMU/PDC device whose
data transmission is put OFF.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">315</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmd_cfg_button">
<property name="label" translatable="yes">Request Configuration Frame</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Send Command frame to PMU/PDC device
to get configuration frame.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">360</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_pdc_button">
<property name="label" translatable="yes">Add a Destination Device</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">PDC device to whom iPDC sends
configuration and data frames.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">405</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_pdc_button">
<property name="label" translatable="yes">Remove a Destination Device</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Remove PDC device to whom iPDC
sends data frames.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">449</property>
</packing>
</child>
<child>
<object class="GtkButton" id="display_conn_table_button">
<property name="label" translatable="yes">iPDC Connection Table</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Display source and destination devices connection tables.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">495</property>
</packing>
</child>
<child>
<object class="GtkButton" id="exit_button">
<property name="label" translatable="yes">EXIT</property>
<property name="width_request">0</property>
<property name="height_request">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Click to exit the iPDC Software.</property>
</object>
<packing>
<property name="x">700</property>
<property name="y">555</property>
</packing>
</child>
<child>
<object class="GtkMenuBar" id="menubar">
<property name="width_request">710</property>
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_default">True</property>
<property name="has_tooltip">True</property>
<property name="resize_mode">immediate</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="enter_pdc_detail_menuitem">
<property name="label">New iPDC Setup</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to create a new iPDC setup file.</property>
<property name="image">image6</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="open_ipdc_setup">
<property name="label">Open iPDC Setup</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to open the saved iPDC setup file.</property>
<property name="image">image4</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="pdc_details_menuitem">
<property name="label" translatable="yes">iPDC Properties</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to view the iPDC setup informations.</property>
<property name="image">image5</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_conn_table">
<property name="label" translatable="yes">Connection Table</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Display source and destination devices connection tables.</property>
<property name="image">image12</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="exit_menuitem">
<property name="label" translatable="yes">Quit</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to exit the iPDC Software.</property>
<property name="image">image3</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Edit</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="menu_add_source">
<property name="label">Add Source</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">PMU/PDC device from which configuration
and data frames would be received.</property>
<property name="image">image7</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_remove_source">
<property name="label">Remove Source</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Remove PMU/PDC device from which
data frames are being received.</property>
<property name="image">image8</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_data_off">
<property name="label" translatable="yes">Data OFF</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Turn OFF data transmission of PMU/PDC device from
which data frames are being received.</property>
<property name="image">image9</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_data_on">
<property name="label" translatable="yes">Data ON</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Turn ON data transmission of PMU/PDC device whose
data transmission is put OFF.</property>
<property name="image">image10</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_request_cfg">
<property name="label" translatable="yes">Request CFG</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Send Command frame to PMU/PDC device
to get configuration frame.</property>
<property name="image">image11</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_add_destination">
<property name="label" translatable="yes">Add Destination</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">PDC device to whom iPDC sends
configuration and data frames.</property>
<property name="image">image14</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_remove_destination">
<property name="label" translatable="yes">Remove Destination</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Remove PDC device to whom iPDC
sends data frames.</property>
<property name="image">image13</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">service tools</property>
<property name="label" translatable="yes">Tools</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkMenuItem" id="attack_detection">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Attack Detection</property>
<property name="use_underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="data_vis">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Data Visualization</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem" id="about_menuitem">
<property name="label">About</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to see the publisher, licensing, and version details.</property>
<property name="image">image15</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLinkButton" id="linkbutton1">
<property name="label" translatable="yes">Go online</property>
<property name="width_request">100</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">For more information visit the iPDC official web
'ipdc.codeplex.com/'.</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="uri">http://ipdc.codeplex.com/</property>
</object>
<packing>
<property name="x">500</property>
<property name="y">555</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="admin_label">
<property name="width_request">284</property>
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">137</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="rights_label">
<property name="width_request">180</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="x">335</property>
<property name="y">560</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="text_view">
<property name="width_request">475</property>
<property name="height_request">375</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">iPDC - A Free Phasor Data Concentrator.
Supportive IEEE C37.118 Synchrophasor std.</property>
<property name="editable">False</property>
<property name="justification">fill</property>
</object>
<packing>
<property name="x">320</property>
<property name="y">165</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="text_view1">
<property name="width_request">800</property>
<property name="height_request">70</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="editable">False</property>
<property name="justification">fill</property>
<property name="cursor_visible">False</property>
</object>
<packing>
<property name="y">40</property>
</packing>
</child>
<child>
<object class="GtkButton" id="utiliy_tools">
<property name="label" translatable="yes">Utility tools</property>
<property name="width_request">284</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">541</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="time_lable">
<property name="width_request">162</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Local Time of System</property>
<property name="justify">right</property>
<property name="track_visited_links">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<attributes>
<attribute name="style" value="normal"/>
<attribute name="weight" value="heavy"/>
<attribute name="gravity" value="west"/>
<attribute name="foreground" value="#712204430000"/>
</attributes>
</object>
<packing>
<property name="x">545</property>
<property name="y">115</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator1">
<property name="width_request">800</property>
<property name="height_request">1</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="y">536</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -1,546 +0,0 @@
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAccelGroup" id="accelgroup1"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
</object>
<object class="GtkImage" id="image10">
<property name="visible">True</property>
<property name="stock">gtk-go-up</property>
<property name="pixel_size">10</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="stock">gtk-go-down</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image12">
<property name="visible">True</property>
<property name="stock">gtk-select-color</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image15">
<property name="visible">True</property>
<property name="stock">gtk-about</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="stock">gtk-missing-image</property>
</object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="stock">gtk-quit</property>
<property name="pixel_size">10</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="stock">gtk-sort-ascending</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="stock">gtk-remove</property>
<property name="icon-size">1</property>
</object>
<object class="GtkImage" id="image9">
<property name="visible">True</property>
<property name="stock">gtk-media-stop</property>
<property name="icon-size">1</property>
</object>
<object class="GtkWindow" id="ipdc">
<property name="tooltip_text" translatable="yes">iPDC - A Free Phasor Data Concentrator.
Supportive IEEE C37.118 Synchrophasor std.</property>
<property name="title" translatable="yes">iPDC - v1.3</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">710</property>
<property name="default_height">590</property>
<property name="icon_name">gnome-obex-server</property>
<property name="focus_on_map">False</property>
<property name="gravity">center</property>
<child>
<object class="GtkLayout" id="layout1">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="add_pmu_button">
<property name="label" translatable="yes">Add a Source Device</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">PMU/PDC device from which configuration
and data frames would be received.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">180</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_pmu_button">
<property name="label" translatable="yes">Remove a Source Device</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Remove PMU/PDC device from which
data frames are being received.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">225</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmd_data_off_button">
<property name="label" translatable="yes">Turn OFF Data Transmission</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Turn OFF data transmission of PMU/PDC device from
which data frames are being received.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">270</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmd_data_on_button">
<property name="label" translatable="yes">Turn ON Data Transmission</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Turn ON data transmission of PMU/PDC device whose
data transmission is put OFF.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">315</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmd_cfg_button">
<property name="label" translatable="yes">Request Configuration Frame</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Send Command frame to PMU/PDC device
to get configuration frame.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">360</property>
</packing>
</child>
<child>
<object class="GtkButton" id="add_pdc_button">
<property name="label" translatable="yes">Add a Destination Device</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">PDC device to whom iPDC sends
configuration and data frames.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">405</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_pdc_button">
<property name="label" translatable="yes">Remove a Destination Device</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Remove PDC device to whom iPDC
sends data frames.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">449</property>
</packing>
</child>
<child>
<object class="GtkButton" id="display_conn_table_button">
<property name="label" translatable="yes">iPDC Connection Table</property>
<property name="width_request">240</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Display source and destination devices connection tables.</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">495</property>
</packing>
</child>
<child>
<object class="GtkButton" id="exit_button">
<property name="label" translatable="yes">EXIT</property>
<property name="width_request">100</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Click to exit the iPDC Software.</property>
</object>
<packing>
<property name="x">603</property>
<property name="y">555</property>
</packing>
</child>
<child>
<object class="GtkMenuBar" id="menubar">
<property name="width_request">710</property>
<property name="height_request">40</property>
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_tooltip">True</property>
<property name="resize_mode">immediate</property>
<child>
<object class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">_File</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu1">
<property name="visible">True</property>
<child>
<object class="GtkImageMenuItem" id="enter_pdc_detail_menuitem">
<property name="label">New iPDC Setup</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to create a new iPDC setup file.</property>
<property name="image">image6</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="open_ipdc_setup">
<property name="label">Open iPDC Setup</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to open the saved iPDC setup file.</property>
<property name="image">image4</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="pdc_details_menuitem">
<property name="label" translatable="yes">iPDC Properties</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to view the iPDC setup informations.</property>
<property name="image">image5</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_conn_table">
<property name="label" translatable="yes">Connection Table</property>
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Display source and destination devices connection tables.</property>
<property name="image">image12</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="exit_menuitem">
<property name="label" translatable="yes">Quit</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to exit the iPDC Software.</property>
<property name="image">image3</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem2">
<property name="visible">True</property>
<property name="label" translatable="yes">Edit</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu2">
<property name="visible">True</property>
<child>
<object class="GtkImageMenuItem" id="menu_add_source">
<property name="label">Add Source</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">PMU/PDC device from which configuration
and data frames would be received.</property>
<property name="image">image7</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_remove_source">
<property name="label">Remove Source</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Remove PMU/PDC device from which
data frames are being received.</property>
<property name="image">image8</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_data_off">
<property name="label" translatable="yes">Data OFF</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Turn OFF data transmission of PMU/PDC device from
which data frames are being received.</property>
<property name="image">image9</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_data_on">
<property name="label" translatable="yes">Data ON</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Turn ON data transmission of PMU/PDC device whose
data transmission is put OFF.</property>
<property name="image">image10</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_request_cfg">
<property name="label" translatable="yes">Request CFG</property>
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Send Command frame to PMU/PDC device
to get configuration frame.</property>
<property name="image">image11</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_add_destination">
<property name="label" translatable="yes">Add Destination</property>
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">PDC device to whom iPDC sends
configuration and data frames.</property>
<property name="image">image14</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem" id="menu_remove_destination">
<property name="label" translatable="yes">Remove Destination</property>
<property name="visible">True</property>
<property name="tooltip_text" translatable="yes">Remove PDC device to whom iPDC
sends data frames.</property>
<property name="image">image13</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu" id="menu3">
<property name="visible">True</property>
<child>
<object class="GtkImageMenuItem" id="about_menuitem">
<property name="label">About</property>
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_STRUCTURE_MASK</property>
<property name="tooltip_text" translatable="yes">Click to see the publisher, licensing, and version details.</property>
<property name="image">image15</property>
<property name="use_stock">False</property>
<property name="always_show_image">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLinkButton" id="linkbutton1">
<property name="label" translatable="yes">Go online</property>
<property name="width_request">100</property>
<property name="height_request">35</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">For more information visit the iPDC official web
'ipdc.codeplex.com/'.</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="uri">http://ipdc.codeplex.com/</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">555</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="admin_label">
<property name="width_request">235</property>
<property name="height_request">40</property>
<property name="visible">True</property>
</object>
<packing>
<property name="x">20</property>
<property name="y">143</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="rights_label">
<property name="width_request">180</property>
<property name="height_request">28</property>
<property name="visible">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="x">260</property>
<property name="y">560</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="text_view">
<property name="width_request">421</property>
<property name="height_request">350</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="tooltip_text" translatable="yes">iPDC - A Free Phasor Data Concentrator.
Supportive IEEE C37.118 Synchrophasor std.</property>
<property name="editable">False</property>
<property name="justification">fill</property>
</object>
<packing>
<property name="x">285</property>
<property name="y">181</property>
</packing>
</child>
<child>
<object class="GtkTextView" id="text_view1">
<property name="width_request">720</property>
<property name="height_request">70</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="editable">False</property>
<property name="justification">fill</property>
<property name="cursor_visible">False</property>
</object>
<packing>
<property name="y">36</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator1">
<property name="width_request">800</property>
<property name="height_request">20</property>
<property name="visible">True</property>
</object>
<packing>
<property name="x">-20</property>
<property name="y">536</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="time_lable">
<property name="width_request">162</property>
<property name="height_request">20</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="tooltip_text" translatable="yes">Local Time of System</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="justify">right</property>
<property name="track_visited_links">False</property>
<attributes>
<attribute name="style" value="normal"/>
<attribute name="weight" value="heavy"/>
<attribute name="gravity" value="west"/>
<attribute name="foreground" value="#712204430000"/>
</attributes>
</object>
<packing>
<property name="x">545</property>
<property name="y">107</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

51
iPDC/map_vis.c Normal file
View File

@ -0,0 +1,51 @@
#include <stdlib.h>
#include "align_sort.h"
#include "map_vis.h"
#include "parser.h"
#include "osm-gps-map.h"
#include "Attack_detect.h"
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
} myParameters;
gboolean update_images(gpointer* pars){
myParameters* parameters = (myParameters*) pars;
struct data_frame *df = TSB[0].first_data_frame;
if(parameters->g_green_image == NULL){
return FALSE;
}
if (parameters->util_map == NULL){
return FALSE;
}
if (df == NULL){
return FALSE;
}
int freq = to_intconvertor(df->dpmu[0]->freq);
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
if(parameters->util_map != NULL){
// if(parameters->g_last_image != 0){
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
// }
// if (freq > 300){
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
// }else{
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
// }
if(parameters->g_last_image != 0){
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
}
if (green){
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
}else{
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
}
}
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
return TRUE;
}

0
iPDC/map_vis.h Normal file
View File

View File

@ -61,8 +61,6 @@
#include "align_sort.h" #include "align_sort.h"
#include "connections.h" #include "connections.h"
#include "recreate.h" #include "recreate.h"
#include "utility_tools.h"
#include "Attack_detect.h"
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */
/* FUNCTION cfgparser(): */ /* FUNCTION cfgparser(): */
@ -1274,26 +1272,26 @@ int dataparser(unsigned char data[]) {
} }
/*pavan changes*/ /*pavan changes*/
attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY); // attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
/*pavan changes*/ /*pavan changes*/
// temp code // temp code
/* karthik changes*/ /* karthik changes*/
int freq = to_intconvertor(df->dpmu[0]->freq); // int freq = to_intconvertor(df->dpmu[0]->freq);
if(util_map != NULL){ // if(util_map != NULL){
g_red_image = gdk_pixbuf_new_from_file_at_size ("red.png", 24,24,NULL); // g_red_image = gdk_pixbuf_new_from_file_at_size ("red.png", 24,24,NULL);
g_green_image = gdk_pixbuf_new_from_file_at_size ("green.png", 24,24,NULL); // g_green_image = gdk_pixbuf_new_from_file_at_size ("green.png", 24,24,NULL);
if(g_last_image != 0){ // if(g_last_image != 0){
osm_gps_map_image_remove(util_map, g_last_image); // osm_gps_map_image_remove(util_map, g_last_image);
} // }
if (freq > 300){ // if (freq > 300){
g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image); // g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
}else{ // }else{
g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image); // g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
} // }
gtk_widget_show_all(GTK_WIDGET(util_map)); // gtk_widget_show_all(GTK_WIDGET(util_map));
} // }
/* karthik changes */ /* karthik changes */
if((config_change == 14) ||(config_change == 10)) if((config_change == 14) ||(config_change == 10))

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,5 +1,8 @@
#include<gtk/gtk.h> #include<gtk/gtk.h>
#include "utility_tools.h" #include "utility_tools.h"
#include "align_sort.h"
#include "parser.h"
#include "Attack_detect.h"
#define UI_fILE "./utility_tools.ui" #define UI_fILE "./utility_tools.ui"
@ -12,9 +15,59 @@
// osm_gps_map_image_add(map, lat, lon, image); // osm_gps_map_image_add(map, lat, lon, image);
// } // }
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
} myParameters;
gboolean update_images(gpointer* pars){
myParameters* parameters = (myParameters*) pars;
struct data_frame *df = TSB[0].first_data_frame;
if(parameters->g_green_image == NULL){
return FALSE;
}
if (parameters->util_map == NULL){
return FALSE;
}
if (df == NULL){
return FALSE;
}
int freq = to_intconvertor(df->dpmu[0]->freq);
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
if(parameters->util_map != NULL){
// if(parameters->g_last_image != 0){
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
// }
// if (freq > 300){
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
// }else{
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
// }
if(parameters->g_last_image != 0){
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
}
if (green){
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
}else{
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
}
}
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
return TRUE;
}
void utility_tools(GtkButton *but, gpointer udata) void utility_tools(GtkButton *but, gpointer udata)
{ {
OsmGpsMap *util_map;
GtkWidget *window;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
// -------------------
GtkBuilder *builder; GtkBuilder *builder;
GError *error = NULL; GError *error = NULL;
builder = gtk_builder_new(); builder = gtk_builder_new();
@ -23,6 +76,8 @@ void utility_tools(GtkButton *but, gpointer udata)
g_warning("%s", error->message); g_warning("%s", error->message);
g_free(error); g_free(error);
} }
g_red_image = gdk_pixbuf_new_from_file_at_size ("red.png", 24,24,NULL);
g_green_image = gdk_pixbuf_new_from_file_at_size ("green.png", 24,24,NULL);
window = GTK_WIDGET(gtk_builder_get_object(builder, "util_window")); window = GTK_WIDGET(gtk_builder_get_object(builder, "util_window"));
GtkContainer *map_container = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout")); GtkContainer *map_container = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
@ -33,14 +88,17 @@ void utility_tools(GtkButton *but, gpointer udata)
"tile-cache", "/tmp/", "tile-cache", "/tmp/",
NULL); NULL);
osm_gps_map_set_center_and_zoom (util_map, 15.4589, 75.0078, 10); osm_gps_map_set_center_and_zoom (util_map, 15.4589, 75.0078, 10);
g_red_image = gdk_pixbuf_new_from_file_at_size ("red.png", 24,24,NULL);
g_green_image = gdk_pixbuf_new_from_file_at_size ("green.png", 24,24,NULL);
// 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(util_map,15.518597, 74.925584, g_green_image); g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
myParameters parameters = {util_map, g_red_image, g_green_image, g_last_image};
gpointer data = (gpointer) &parameters;
g_timeout_add(20, (GSourceFunc) update_images, data);
gtk_widget_set_size_request(GTK_WIDGET(util_map), 600, 500); gtk_widget_set_size_request(GTK_WIDGET(util_map), 600, 500);
gtk_container_add(map_container, GTK_WIDGET(util_map)); gtk_container_add(map_container, GTK_WIDGET(util_map));
g_signal_connect(window, "destroy", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_widget_show_all(window); gtk_widget_show_all(window);
gtk_main(); gtk_main();

View File

@ -1,3 +1,4 @@
#include <stdio.h>
#include<gtk/gtk.h> #include<gtk/gtk.h>
#include "osm-gps-map.h" #include "osm-gps-map.h"
@ -7,10 +8,6 @@
#define CH_GET_WIDGET(builder, name, data) \ #define CH_GET_WIDGET(builder, name, data) \
CH_GET_OBJECT(builder, name, GTK_WIDGET, data) CH_GET_OBJECT(builder, name, GTK_WIDGET, data)
OsmGpsMap *util_map;
GtkWidget *window;
static GdkPixbuf *g_red_image = NULL;
static GdkPixbuf *g_green_image = NULL;
static OsmGpsMapImage *g_last_image = NULL;
void utility_tools(GtkButton *but, gpointer udata); void utility_tools(GtkButton *but, gpointer udata);