Basic model of line chart
This commit is contained in:
parent
c4b2a05020
commit
5886069a3d
|
@ -46,7 +46,7 @@ FILE6 = iPDC.desktop
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LIBS = -lpthread
|
LIBS = -lpthread
|
||||||
LDLIBS=`pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8`
|
LDLIBS=`pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8` lib/liblivechart.so lib/liblivechart_static.a -Wl,--rpath=./lib
|
||||||
CFLAGS=-g -I./inc -I./lib -fcommon `pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8`
|
CFLAGS=-g -I./inc -I./lib -fcommon `pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0 gee-0.8`
|
||||||
|
|
||||||
PROGRAM = iPDC
|
PROGRAM = iPDC
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<requires lib="gtk+" version="3.24"/>
|
<requires lib="gtk+" version="3.24"/>
|
||||||
<object class="GtkWindow" id="util_window">
|
<object class="GtkWindow" id="util_window">
|
||||||
<property name="width-request">800</property>
|
<property name="width-request">800</property>
|
||||||
<property name="height-request">600</property>
|
<property name="height-request">700</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLayout" id="util_layout">
|
<object class="GtkLayout" id="util_layout">
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<!-- n-columns=3 n-rows=3 -->
|
<!-- n-columns=2 n-rows=2 -->
|
||||||
<object class="GtkGrid">
|
<object class="GtkGrid">
|
||||||
<property name="width-request">100</property>
|
<property name="width-request">100</property>
|
||||||
<property name="height-request">80</property>
|
<property name="height-request">80</property>
|
||||||
|
@ -271,22 +271,15 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkLayout" id="graph_layout">
|
||||||
</child>
|
<property name="height-request">150</property>
|
||||||
<child>
|
<property name="visible">True</property>
|
||||||
<placeholder/>
|
<property name="can-focus">False</property>
|
||||||
</child>
|
</object>
|
||||||
<child>
|
<packing>
|
||||||
<placeholder/>
|
<property name="left-attach">1</property>
|
||||||
</child>
|
<property name="top-attach">1</property>
|
||||||
<child>
|
</packing>
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
|
|
|
@ -0,0 +1,302 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Generated with glade 3.38.2 -->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk+" version="3.24"/>
|
||||||
|
<object class="GtkWindow" id="util_window">
|
||||||
|
<property name="width-request">800</property>
|
||||||
|
<property name="height-request">600</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLayout" id="util_layout">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<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">800</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=3 -->
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="width-request">100</property>
|
||||||
|
<property name="height-request">80</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="app-paintable">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="margin-top">10</property>
|
||||||
|
<property name="column-spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<!-- n-columns=1 n-rows=5 -->
|
||||||
|
<object class="GtkGrid">
|
||||||
|
<property name="width-request">80</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="row-spacing">35</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="voltage">
|
||||||
|
<property name="label" translatable="yes">Voltage</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="freq">
|
||||||
|
<property name="label" translatable="yes">Frequency</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="attack_detection">
|
||||||
|
<property name="label" translatable="yes">Attack Detection</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="algorithm">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="active">0</property>
|
||||||
|
<items>
|
||||||
|
<item id="0" translatable="yes">kmeans</item>
|
||||||
|
<item id="1" translatable="yes">simple</item>
|
||||||
|
</items>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="dimmension">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
<property name="active">0</property>
|
||||||
|
<items>
|
||||||
|
<item id="0" translatable="yes">frequency only</item>
|
||||||
|
<item id="1" translatable="yes">frequency,voltage</item>
|
||||||
|
<item id="2" translatable="yes">voltage</item>
|
||||||
|
</items>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">0</property>
|
||||||
|
<property name="top-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLayout" id="map_layout">
|
||||||
|
<property name="width-request">600</property>
|
||||||
|
<property name="height-request">500</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">1</property>
|
||||||
|
<property name="top-attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="y">30</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</interface>
|
|
@ -9,5 +9,4 @@ typedef struct{
|
||||||
} myParameters;
|
} myParameters;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gboolean update_images(gpointer* pars);
|
gboolean update_images(gpointer* pars);
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include<gtk/gtk.h>
|
#include<gtk/gtk.h>
|
||||||
#include "osm-gps-map.h"
|
#include "osm-gps-map.h"
|
||||||
|
#include "livechart.h"
|
||||||
|
|
||||||
/* Convenience macros for obtaining objects from UI file */
|
/* Convenience macros for obtaining objects from UI file */
|
||||||
#define CH_GET_OBJECT(builder, name, type, data) \
|
#define CH_GET_OBJECT(builder, name, type, data) \
|
||||||
|
@ -24,14 +25,11 @@ struct _UtData
|
||||||
GtkWidget *dimmension;
|
GtkWidget *dimmension;
|
||||||
OsmGpsMap *util_map;
|
OsmGpsMap *util_map;
|
||||||
GtkContainer *map_layout;
|
GtkContainer *map_layout;
|
||||||
|
GtkContainer *graph_layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
UtData *utdata;
|
UtData *utdata;
|
||||||
|
LiveChartSerie *serie;
|
||||||
/* UI variables */
|
|
||||||
int curr_measurement = 0;
|
|
||||||
int algorithm =0;
|
|
||||||
int dimmensions = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,19 @@
|
||||||
#include "Attack_detect.h"
|
#include "Attack_detect.h"
|
||||||
#include "connections.h"
|
#include "connections.h"
|
||||||
#include "livechart.h"
|
#include "livechart.h"
|
||||||
// #include "utility_tools.h"
|
#include "utility_tools.h"
|
||||||
|
|
||||||
|
extern int curr_measurement;
|
||||||
|
extern int algorithm;
|
||||||
|
extern int dimmensions;
|
||||||
|
|
||||||
|
// debug
|
||||||
|
int loops = 0;
|
||||||
|
|
||||||
gboolean update_images(gpointer* pars){
|
gboolean update_images(gpointer* pars){
|
||||||
int match=0,id;
|
int match=0,id;
|
||||||
myParameters* parameters = (myParameters*) pars;
|
myParameters* parameters = (myParameters*) pars;
|
||||||
struct data_frame *df = TSB[0].first_data_frame;
|
struct data_frame *df = TSB[4].first_data_frame;
|
||||||
struct Lower_Layer_Details *LLptr;
|
struct Lower_Layer_Details *LLptr;
|
||||||
|
|
||||||
if (df == NULL){
|
if (df == NULL){
|
||||||
|
@ -20,36 +26,38 @@ gboolean update_images(gpointer* pars){
|
||||||
}
|
}
|
||||||
// if (curr_measurement==1)
|
// if (curr_measurement==1)
|
||||||
// {
|
// {
|
||||||
while (df != NULL){
|
int freq = to_intconvertor(df->dpmu[0]->freq)-200;
|
||||||
id = to_intconvertor(df->idcode);
|
live_chart_serie_add(serie, freq);
|
||||||
printf("id = %d\n",id);
|
loops++;
|
||||||
|
printf("loops: %d\n", loops);
|
||||||
|
// id = to_intconvertor(df->idcode);
|
||||||
|
// printf("id = %d\n",id);
|
||||||
|
|
||||||
LLptr = LLfirst;
|
// LLptr = LLfirst;
|
||||||
|
|
||||||
while(LLptr != NULL){
|
// while(LLptr != NULL){
|
||||||
printf("pmuid = %d\n",LLptr->pmuid);
|
// printf("pmuid = %d\n",LLptr->pmuid);
|
||||||
if(LLptr->pmuid == id){
|
// if(LLptr->pmuid == id){
|
||||||
match = 1;
|
// match = 1;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
LLptr = LLptr->next;
|
// LLptr = LLptr->next;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(match == 1){
|
// if(match == 1){
|
||||||
float lat = LLptr->latitude;
|
float lat = 79.347312;
|
||||||
float lon = LLptr->longitude;
|
float lon = -69.439209;
|
||||||
float freq = to_intconvertor(df->dpmu[0]->freq)*0.001+50;
|
// float freq = to_intconvertor(df->dpmu[0]->freq)*0.001+50;
|
||||||
printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
|
printf("lat = %f, lon = %f, freq = %d\n",lat,lon,freq);
|
||||||
// gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
// gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
||||||
|
// if(parameters->g_last_image != 0){
|
||||||
if(parameters->g_last_image != 0){
|
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
||||||
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
// }
|
||||||
}
|
// if (freq > 50.300){
|
||||||
if (freq > 50.300){
|
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
|
||||||
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
|
// }else{
|
||||||
}else{
|
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
|
||||||
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_image);
|
// }
|
||||||
}
|
|
||||||
// if(parameters->g_last_image != 0){
|
// if(parameters->g_last_image != 0){
|
||||||
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
||||||
// }
|
// }
|
||||||
|
@ -58,15 +66,10 @@ gboolean update_images(gpointer* pars){
|
||||||
// }else{
|
// }else{
|
||||||
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
|
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
df = df->dnext;
|
|
||||||
}
|
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
|
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
#include "osm-gps-map.h"
|
#include "osm-gps-map.h"
|
||||||
#include "map_vis.h"
|
#include "map_vis.h"
|
||||||
#include "utility_tools.h"
|
#include "utility_tools.h"
|
||||||
|
#include "livechart.h"
|
||||||
|
|
||||||
#define UI_fILE "./assets/utility_tools.ui"
|
#define UI_fILE "./assets/utility_tools.ui"
|
||||||
#define RED_IMAGE "./assets/red.png"
|
#define RED_IMAGE "./assets/red.png"
|
||||||
#define GREEN_IMAGE "./assets/green.png"
|
#define GREEN_IMAGE "./assets/green.png"
|
||||||
|
|
||||||
|
int curr_measurement = 0;
|
||||||
|
int algorithm =0;
|
||||||
|
int dimmensions = 0;
|
||||||
|
|
||||||
// void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image)
|
// void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image)
|
||||||
// {
|
// {
|
||||||
|
@ -35,7 +38,6 @@ void on_frequency_clicked(GtkButton *but, gpointer udata)
|
||||||
gtk_widget_set_sensitive(utdata->frequency, FALSE);
|
gtk_widget_set_sensitive(utdata->frequency, FALSE);
|
||||||
gtk_widget_set_sensitive(utdata->attack_detection, TRUE);
|
gtk_widget_set_sensitive(utdata->attack_detection, TRUE);
|
||||||
|
|
||||||
|
|
||||||
// printf("Frequency\n");
|
// printf("Frequency\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +76,6 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
builder = gtk_builder_new();
|
builder = gtk_builder_new();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!gtk_builder_add_from_file(builder, UI_fILE, &error))
|
if (!gtk_builder_add_from_file(builder, UI_fILE, &error))
|
||||||
{
|
{
|
||||||
g_warning("%s", error->message);
|
g_warning("%s", error->message);
|
||||||
|
@ -91,6 +91,7 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
utdata->dimmension = GTK_WIDGET(gtk_builder_get_object(builder, "dimmension"));
|
utdata->dimmension = GTK_WIDGET(gtk_builder_get_object(builder, "dimmension"));
|
||||||
// utdata->util_map = GTK_WIDGET(gtk_builder_get_object(builder, "util_map"));
|
// utdata->util_map = GTK_WIDGET(gtk_builder_get_object(builder, "util_map"));
|
||||||
utdata->map_layout = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
|
utdata->map_layout = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
|
||||||
|
utdata->graph_layout = GTK_CONTAINER(gtk_builder_get_object(builder, "graph_layout"));
|
||||||
|
|
||||||
gtk_widget_set_sensitive(utdata->voltage, FALSE);
|
gtk_widget_set_sensitive(utdata->voltage, FALSE);
|
||||||
gtk_widget_set_visible(utdata->algorithm, FALSE);
|
gtk_widget_set_visible(utdata->algorithm, FALSE);
|
||||||
|
@ -100,16 +101,11 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
g_signal_connect(utdata->frequency, "clicked", G_CALLBACK(on_frequency_clicked), NULL);
|
g_signal_connect(utdata->frequency, "clicked", G_CALLBACK(on_frequency_clicked), NULL);
|
||||||
g_signal_connect(utdata->voltage, "clicked", G_CALLBACK(on_voltage_clicked), NULL);
|
g_signal_connect(utdata->voltage, "clicked", G_CALLBACK(on_voltage_clicked), NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g_red_image = gdk_pixbuf_new_from_file_at_size(RED_IMAGE, 24, 24, NULL);
|
g_red_image = gdk_pixbuf_new_from_file_at_size(RED_IMAGE, 24, 24, NULL);
|
||||||
g_green_image = gdk_pixbuf_new_from_file_at_size(GREEN_IMAGE, 24, 24, NULL);
|
g_green_image = gdk_pixbuf_new_from_file_at_size(GREEN_IMAGE, 24, 24, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
utdata->util_map = g_object_new(OSM_TYPE_GPS_MAP,
|
utdata->util_map = g_object_new(OSM_TYPE_GPS_MAP,
|
||||||
"map-source", OSM_GPS_MAP_SOURCE_OPENSTREETMAP,
|
"map-source", OSM_GPS_MAP_SOURCE_OSMC_TRAILS,
|
||||||
"tile-cache", "/tmp/",
|
"tile-cache", "/tmp/",
|
||||||
NULL);
|
NULL);
|
||||||
osm_gps_map_set_center_and_zoom(utdata->util_map, 15.4589, 75.0078, 10);
|
osm_gps_map_set_center_and_zoom(utdata->util_map, 15.4589, 75.0078, 10);
|
||||||
|
@ -118,8 +114,6 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
g_last_image = osm_gps_map_image_add(utdata->util_map, 15.4589, 75.0078, g_red_image);
|
g_last_image = osm_gps_map_image_add(utdata->util_map, 15.4589, 75.0078, g_red_image);
|
||||||
g_last_image = osm_gps_map_image_add(utdata->util_map, 15.518597, 74.925584, g_green_image);
|
g_last_image = osm_gps_map_image_add(utdata->util_map, 15.518597, 74.925584, g_green_image);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_last_image};
|
myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_last_image};
|
||||||
gpointer data = (gpointer)¶meters;
|
gpointer data = (gpointer)¶meters;
|
||||||
guint pid = g_timeout_add(20, (GSourceFunc)update_images, data);
|
guint pid = g_timeout_add(20, (GSourceFunc)update_images, data);
|
||||||
|
@ -127,8 +121,40 @@ void utility_tools(GtkButton *but, gpointer udata)
|
||||||
gtk_widget_set_size_request(GTK_WIDGET(utdata->util_map), 600, 500);
|
gtk_widget_set_size_request(GTK_WIDGET(utdata->util_map), 600, 500);
|
||||||
|
|
||||||
gtk_container_add(utdata->map_layout, GTK_WIDGET(utdata->util_map));
|
gtk_container_add(utdata->map_layout, GTK_WIDGET(utdata->util_map));
|
||||||
|
|
||||||
|
// add live chart
|
||||||
|
serie = live_chart_serie_new("Hello", (LiveChartSerieRenderer*)live_chart_line_new (live_chart_values_new(10000)));
|
||||||
|
// live_chart set color to the serie
|
||||||
|
GdkRGBA color;
|
||||||
|
color.red = 1.0;
|
||||||
|
color.green = 0.0;
|
||||||
|
color.blue = 1.0;
|
||||||
|
color.alpha = 1.0;
|
||||||
|
|
||||||
|
live_chart_path_set_color(live_chart_serie_get_line(serie), &color);
|
||||||
|
LiveChartConfig *config = live_chart_config_new();
|
||||||
|
live_chart_yaxis_set_unit(config->y_axis, "mHz");
|
||||||
|
live_chart_xaxis_set_tick_interval(config->x_axis, 20);
|
||||||
|
live_chart_xaxis_set_tick_length(config->x_axis, 100);
|
||||||
|
live_chart_yaxis_update_bounds(config->y_axis, 1);
|
||||||
|
live_chart_path_set_visible(config->x_axis->lines, FALSE);
|
||||||
|
|
||||||
|
LiveChartChart *chart = live_chart_chart_new(config);
|
||||||
|
live_chart_chart_add_serie(chart, serie);
|
||||||
|
|
||||||
|
// gtk_widget_set_hexpand(GTK_WIDGET(chart), TRUE);
|
||||||
|
// gtk_widget_set_vexpand(GTK_WIDGET(chart), TRUE);
|
||||||
|
gtk_widget_set_size_request(GTK_WIDGET(chart), 600, 150);
|
||||||
|
|
||||||
|
gtk_container_add(utdata->graph_layout, GTK_WIDGET(chart));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
g_signal_connect(utdata->util_window, "destroy", G_CALLBACK(on_window_destroy), GUINT_TO_POINTER(pid));
|
g_signal_connect(utdata->util_window, "destroy", G_CALLBACK(on_window_destroy), GUINT_TO_POINTER(pid));
|
||||||
|
|
||||||
|
// gtk_widget_set_vexpand(GTK_WIDGET(utdata->util_map), TRUE);
|
||||||
|
// gtk_widget_set_hexpand(GTK_WIDGET(utdata->util_map), TRUE);
|
||||||
gtk_widget_show_all(utdata->util_window);
|
gtk_widget_show_all(utdata->util_window);
|
||||||
|
|
||||||
gtk_widget_hide(utdata->algorithm);
|
gtk_widget_hide(utdata->algorithm);
|
||||||
|
|
Loading…
Reference in New Issue