Compare commits

...

4 Commits

Author SHA1 Message Date
karthikmurakonda 4e16d1d783 refractoring 2022-11-12 16:13:21 +05:30
karthikmurakonda 4ca86dc606 refractor3 2022-11-12 12:26:56 +05:30
karthikmurakonda 476930b457 refractor2 2022-11-12 12:13:59 +05:30
karthikmurakonda a194c58812 refractor1 2022-11-12 11:56:50 +05:30
14 changed files with 900 additions and 599 deletions

View File

@ -36,17 +36,24 @@ INSTALL_PREFIX = /usr/local/
CREATE_DIR = /usr/local/share/
DESKTOP_DIR = /usr/share/applications
FILE1 = iPDC.xml
FILE1 = iPDC.ui
FILE2 = ipdcLogo.png
FILE3 = PSLab.PNG
FILE4 = ipdcLogo1.png
FILE5 = logo.png
FILE6 = iPDC.desktop
FILE7 = utility_tools.ui
FILE8 = red.png
FILE9 = green.png
FILE11 = blue.png
FILE13 = grey.png
SOLIB = lib
CC = gcc
LIBS = -lpthread
LDLIBS=`pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8` lib/liblivechart.so lib/liblivechart_static.a -Wl,--rpath=./lib
LDLIBS=`pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8` lib/liblivechart.so lib/liblivechart_static.a -Wl,--rpath=$(CREATE_DIR)iPDC/$(SOLIB)
CFLAGS=-g -I./inc -I./lib -fcommon `pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8`
PROGRAM = iPDC
@ -64,14 +71,19 @@ bin/%.o: src/%.c
install: $(PROGRAM)
gtk-builder-convert assets/iPDC.glade assets/iPDC.xml
mkdir -p $(CREATE_DIR)iPDC/$
mkdir -p $(CREATE_DIR)iPDC/
cp -f assets/$(FILE1) $(CREATE_DIR)iPDC/$(FILE1)
cp -f assets/$(FILE2) $(CREATE_DIR)iPDC/$(FILE2)
cp -f assets/$(FILE3) $(CREATE_DIR)iPDC/$(FILE3)
cp -f assets/$(FILE4) $(CREATE_DIR)iPDC/$(FILE4)
cp -f assets/$(FILE5) $(CREATE_DIR)iPDC/$(FILE5)
cp -f assets/$(FILE7) $(CREATE_DIR)iPDC/$(FILE7)
cp -f assets/$(FILE8) $(CREATE_DIR)iPDC/$(FILE8)
cp -f assets/$(FILE9) $(CREATE_DIR)iPDC/$(FILE9)
cp -f assets/$(FILE11) $(CREATE_DIR)iPDC/$(FILE11)
cp -f assets/$(FILE13) $(CREATE_DIR)iPDC/$(FILE13)
cp -f assets/$(FILE6) $(DESKTOP_DIR)/$(FILE6)
cp -r -f lib/ $(CREATE_DIR)iPDC/$(SOLIB)
cp $(PROGRAM) $(INSTALL_PREFIX)bin/$(PROGRAM)
uninstall:

View File

@ -322,14 +322,6 @@ sends data frames.</property>
<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>

663
iPDC/assets/iPDC.ui~ Normal file
View File

@ -0,0 +1,663 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.0"/>
<object class="GtkSizeGroup"/>
<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>
<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="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
'https://github.com/karthikmurakonda/iPDC-suite/discussions'.</property>
<property name="image">image1</property>
<property name="relief">none</property>
<property name="uri">https://github.com/karthikmurakonda/iPDC-suite/discussions</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_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="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>
<child>
<!-- n-columns=1 n-rows=9 -->
<object class="GtkGrid">
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">8</property>
<property name="orientation">vertical</property>
<property name="row-spacing">9</property>
<property name="row-homogeneous">True</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="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="utility_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="left-attach">0</property>
<property name="top-attach">8</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="left-attach">0</property>
<property name="top-attach">7</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="left-attach">0</property>
<property name="top-attach">6</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="left-attach">0</property>
<property name="top-attach">5</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="left-attach">0</property>
<property name="top-attach">4</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="left-attach">0</property>
<property name="top-attach">3</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="left-attach">0</property>
<property name="top-attach">1</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="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="x">20</property>
<property name="y">163</property>
</packing>
</child>
<child>
<object class="GtkAlignment">
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<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>
</child>
</object>
<packing>
<property name="x">320</property>
<property name="y">165</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -6,6 +6,7 @@
<property name="width-request">985</property>
<property name="height-request">800</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">Utility Tools</property>
<child>
<object class="GtkLayout" id="util_layout">
<property name="visible">True</property>
@ -13,166 +14,11 @@
<property name="margin-left">10</property>
<property name="margin-right">10</property>
<property name="margin-bottom">3</property>
<child>
<object class="GtkMenuBar" id="util_menubar">
<property name="width-request">900</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-default">True</property>
<property name="resize-mode">immediate</property>
<child>
<object class="GtkMenuItem">
<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">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<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">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<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">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<!-- n-columns=3 n-rows=4 -->
<object class="GtkGrid">
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="width-request">1309</property>
<property name="height-request">1022</property>
<property name="visible">True</property>
<property name="app-paintable">True</property>
<property name="can-focus">False</property>
@ -1046,7 +892,7 @@
</child>
</object>
<packing>
<property name="y">30</property>
<property name="y">6</property>
</packing>
</child>
</object>

View File

@ -13,166 +13,11 @@
<property name="margin-left">10</property>
<property name="margin-right">10</property>
<property name="margin-bottom">3</property>
<child>
<object class="GtkMenuBar" id="util_menubar">
<property name="width-request">900</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-default">True</property>
<property name="resize-mode">immediate</property>
<child>
<object class="GtkMenuItem">
<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">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<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">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<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">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<!-- n-columns=3 n-rows=4 -->
<object class="GtkGrid">
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="width-request">1309</property>
<property name="height-request">1022</property>
<property name="visible">True</property>
<property name="app-paintable">True</property>
<property name="can-focus">False</property>
@ -211,7 +56,7 @@
</child>
<child>
<object class="GtkButton" id="attack_detection">
<property name="label" translatable="yes">Attack Detection</property>
<property name="label" translatable="yes">Event Detection</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
@ -1046,7 +891,7 @@
</child>
</object>
<packing>
<property name="y">30</property>
<property name="y">6</property>
</packing>
</child>
</object>

View File

@ -1,3 +0,0 @@
#include<gtk/gtk.h>
void attack_detection_window(GtkButton *widget,gpointer udata);

View File

@ -1,3 +1,28 @@
#include<gtk/gtk.h>
#include<osm-gps-map.h>
#include "livechart.h"
void data_vis_window(GtkButton *widget,gpointer udata);
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
int current_selection;
} myParameters;
struct vis_data{
int id;
float lat;
float lon;
GdkColor color;
OsmGpsMapImage *last_image; // TODO:
GTimeVal last_update_time;
LiveChartSerie *serie_vol;
LiveChartSerie *serie_freq;
LiveChartSerie *serie_dfreq;
struct vis_data *next;
};
struct vis_data *vis_data_head;
gboolean update_vis(gpointer* pars);

View File

@ -90,9 +90,7 @@ struct _ChData
/*Tools menu*/
GtkWidget *menuitem3;
GtkWidget *attack_detection;
GtkWidget *data_vis;
};
/* ---------------------------------------------------------------- */

View File

@ -1,28 +0,0 @@
#include<gtk/gtk.h>
#include<osm-gps-map.h>
#include "livechart.h"
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
int current_selection;
} myParameters;
struct vis_data{
int id;
float lat;
float lon;
GdkColor color;
OsmGpsMapImage *last_image; // TODO:
GTimeVal last_update_time;
LiveChartSerie *serie_vol;
LiveChartSerie *serie_freq;
LiveChartSerie *serie_dfreq;
struct vis_data *next;
};
struct vis_data *vis_data_head;
gboolean update_images(gpointer* pars);

View File

@ -1,19 +0,0 @@
#include<gtk/gtk.h>
#include<stdio.h>
void attack_detection_window(GtkButton *widget,gpointer udata)
{
GtkWidget *new_window;
new_window = gtk_dialog_new();
//gtk_window_fullscreen(GTK_WINDOW(new_window));
gtk_window_set_default_size(GTK_WINDOW(new_window), 800, 600);
gtk_window_set_resizable(GTK_WINDOW(new_window), FALSE);
gtk_window_set_position(GTK_WINDOW(new_window), GTK_WIN_POS_CENTER);
//gtk_window_set_icon(GTK_WINDOW(new_window), create_pixbuf("/usr/local/share/iPDC/logo.png"));
/* Set the Title of Main Window */
gtk_window_set_title (GTK_WINDOW (new_window), "iPDC");
g_signal_connect (new_window, "destroy", G_CALLBACK(gtk_widget_destroy), new_window);
gtk_widget_show(new_window);
}

View File

@ -1,19 +1,179 @@
#include<gtk/gtk.h>
#include<stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include "global.h"
#include "align_sort.h"
#include "data_vis.h"
#include "parser.h"
#include "osm-gps-map.h"
#include "Attack_detect.h"
#include "Kmeans.h"
#include "Dynamic_time_warping.h"
#include "connections.h"
#include "livechart.h"
#include "utility_tools.h"
#include "Kmeans2.h"
void data_vis_window(GtkButton *widget,gpointer udata)
{
GtkWidget *new_window;
new_window = gtk_dialog_new();
//gtk_window_fullscreen(GTK_WINDOW(new_window));
gtk_window_set_default_size(GTK_WINDOW(new_window), 800, 600);
gtk_window_set_resizable(GTK_WINDOW(new_window), FALSE);
gtk_window_set_position(GTK_WINDOW(new_window), GTK_WIN_POS_CENTER);
//gtk_window_set_icon(GTK_WINDOW(new_window), create_pixbuf("/usr/local/share/iPDC/logo.png"));
int loops = 0;
/* Set the Title of Main Window */
gtk_window_set_title (GTK_WINDOW (new_window), "iPDC");
g_signal_connect (new_window, "destroy", G_CALLBACK(gtk_widget_destroy), new_window);
gtk_widget_show(new_window);
}
gboolean update_vis(gpointer* pars){
int match=0,id, cfg_match=0;
myParameters* parameters = (myParameters*) pars;
struct cfg_frame* temp_cfg;
pthread_mutex_lock(&mutex_on_TSB);
struct data_frame *df = TSB[MAXTSB-1].first_data_frame;
struct Lower_Layer_Details *LLptr;
struct vis_data *vis_ptr;
if (df == NULL){
pthread_mutex_unlock(&mutex_on_TSB);
return TRUE;
}
int i = 0, k = 0;
float freq,vol_magnitude,angle, dfreq;
unsigned char freq_fmt, anal_fmt, phas_fmt, polar_fmt;
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)){
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 {
temp_cfg = temp_cfg->cfgnext;
}
}
pthread_mutex_unlock(&mutex_cfg);
// get data from df.
if(freq_fmt == '1'){
freq = decode_ieee_single(df->dpmu[i]->freq);
printf("freq = %f\n",freq);
}else{
freq = to_intconvertor(df->dpmu[i]->freq)*1e-3+50;
printf("freq = %f\n",freq);
}
unsigned char first2bytes[2];
strncpy(first2bytes, df->dpmu[i]->phasors[0], 2);
unsigned char last2bytes[2];
strncpy(last2bytes, df->dpmu[i]->phasors[0]+2, 2);
vol_magnitude = to_intconvertor(first2bytes);
float imaginary = to_intconvertor(last2bytes);
vis_ptr = vis_data_head;
match = 0;
while(vis_ptr != NULL){
if(vis_ptr->id == id){
match = 1;
break;
}
vis_ptr = vis_ptr->next;
}
lat = vis_ptr->lat;
lon = vis_ptr->lon;
live_chart_serie_add(vis_ptr->serie_freq, freq);
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){
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{
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{
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{
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)){
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 == 0){
if(!kmeans(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)){
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 == 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);
}
}
}
}
df = df->dnext;
k++;
}
pthread_mutex_unlock(&mutex_on_TSB);
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
return TRUE;
}

View File

@ -45,13 +45,10 @@
#include "parser.h"
#include "global.h"
#include "ipdcGui.h"
#include "attack_detection.h"
#include "data_vis.h"
#include "utility_tools.h"
/* Common fixed path for storage of few common files */
#define UI_fILE "./assets/iPDC.ui"
//#define UI_fILE "/usr/local/share/iPDC/iPDC.xml"
#define UI_fILE "/usr/local/share/iPDC/iPDC.ui"
/* ---------------------------------------------------------------- */
@ -123,7 +120,6 @@ int main(int argc, char **argv)
GW(admin_label);
GW(time_lable);
GW(menuitem3);
GW(attack_detection);
GW(data_vis);
GW(utility_tools);
#undef GW
@ -293,8 +289,7 @@ int main(int argc, char **argv)
g_signal_connect (data->about_menuitem, "activate", G_CALLBACK(about_ipdc), NULL);
g_signal_connect (data->ipdc, "destroy", G_CALLBACK(destroy), NULL);
g_signal_connect(data->attack_detection,"activate",G_CALLBACK(attack_detection_window),NULL);
g_signal_connect(data->data_vis, "activate", G_CALLBACK(data_vis_window), NULL);
g_signal_connect(data->data_vis, "activate", G_CALLBACK(utility_tools), NULL);
/* Destroy builder, since we don't need it anymore */

View File

@ -1,184 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include "global.h"
#include "align_sort.h"
#include "map_vis.h"
#include "parser.h"
#include "osm-gps-map.h"
#include "Attack_detect.h"
#include "Kmeans.h"
#include "Dynamic_time_warping.h"
#include "connections.h"
#include "livechart.h"
#include "utility_tools.h"
#include "Kmeans2.h"
int loops = 0;
gboolean update_images(gpointer* pars){
int match=0,id, cfg_match=0;
myParameters* parameters = (myParameters*) pars;
struct cfg_frame* temp_cfg;
pthread_mutex_lock(&mutex_on_TSB);
struct data_frame *df = TSB[MAXTSB-1].first_data_frame;
struct Lower_Layer_Details *LLptr;
struct vis_data *vis_ptr;
if (df == NULL){
pthread_mutex_unlock(&mutex_on_TSB);
return TRUE;
}
int i = 0, k = 0;
float freq,vol_magnitude,angle, dfreq;
unsigned char freq_fmt, anal_fmt, phas_fmt, polar_fmt;
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)){
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 {
temp_cfg = temp_cfg->cfgnext;
}
}
pthread_mutex_unlock(&mutex_cfg);
// get data from df.
if(freq_fmt == '1'){
freq = decode_ieee_single(df->dpmu[i]->freq);
printf("freq = %f\n",freq);
}else{
freq = to_intconvertor(df->dpmu[i]->freq)*1e-3+50;
printf("freq = %f\n",freq);
}
unsigned char first2bytes[2];
strncpy(first2bytes, df->dpmu[i]->phasors[0], 2);
unsigned char last2bytes[2];
strncpy(last2bytes, df->dpmu[i]->phasors[0]+2, 2);
vol_magnitude = to_intconvertor(first2bytes);
float imaginary = to_intconvertor(last2bytes);
// printf("vol = %f imag = %f\n",vol_magnitude, imaginary);
vis_ptr = vis_data_head;
match = 0;
while(vis_ptr != NULL){
// printf("vis_ptr->id = %d\n",vis_ptr->id);
if(vis_ptr->id == id){
match = 1;
// printf("Matched - id : %d\n",id);
break;
}
vis_ptr = vis_ptr->next;
}
lat = vis_ptr->lat;
lon = vis_ptr->lon;
live_chart_serie_add(vis_ptr->serie_freq, freq);
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){
// printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
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{
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{
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{
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)){
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 == 0){
if(!kmeans(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)){
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 == 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);
}
}
}
}
df = df->dnext;
// i++;
k++;
}
pthread_mutex_unlock(&mutex_on_TSB);
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
return TRUE;
}

View File

@ -2,19 +2,18 @@
#include "align_sort.h"
#include "parser.h"
#include "osm-gps-map.h"
#include "map_vis.h"
#include "data_vis.h"
#include "utility_tools.h"
#include "livechart.h"
#include "connections.h"
// TODO: change this when in production
#define UI_fILE "./assets/utility_tools.ui"
#define RED_IMAGE "./assets/red.png"
#define GREEN_IMAGE "./assets/green.png"
#define YELLOW_IMAGE "./assets/yellow.png"
#define BLUE_IMAGE "./assets/blue.png"
#define GREY_IMAGE "./assets/grey.png"
#define PINK_IMAGE "./assets/pink.png"
#define UI_fILE "/usr/local/share/iPDC/utility_tools.ui"
#define RED_IMAGE "/usr/local/share/iPDC/red.png"
#define GREEN_IMAGE "/usr/local/share/iPDC/green.png"
#define BLUE_IMAGE "/usr/local/share/iPDC/blue.png"
#define GREY_IMAGE "/usr/local/share/iPDC/grey.png"
#define PINK_IMAGE "/usr/local/share/iPDC/pink.png"
GdkRGBA getIndexColor(int index){
@ -268,7 +267,7 @@ void set_dimm(GtkComboBox *combo, gpointer udata)
// Initializes utility tools window.
void utility_tools(GtkButton *but, gpointer udata)
{
GdkPixbuf *g_red_image;
@ -455,7 +454,7 @@ void utility_tools(GtkButton *but, gpointer udata)
}
temp_visptr->next = NULL;
guint pid = g_timeout_add(20, (GSourceFunc)update_images, data);
guint pid = g_timeout_add(20, (GSourceFunc)update_vis, data);
// gtk_widget_set_hexpand(GTK_WIDGET(chart), TRUE);