graph drawing(unrefractored)
This commit is contained in:
parent
5886069a3d
commit
e88e009376
|
@ -31,6 +31,11 @@ struct _UtData
|
|||
UtData *utdata;
|
||||
LiveChartSerie *serie;
|
||||
|
||||
// global variables
|
||||
int curr_measurement;
|
||||
int algorithm;
|
||||
int dimmension;
|
||||
|
||||
|
||||
|
||||
void utility_tools(GtkButton *but, gpointer udata);
|
|
@ -8,9 +8,6 @@
|
|||
#include "livechart.h"
|
||||
#include "utility_tools.h"
|
||||
|
||||
extern int curr_measurement;
|
||||
extern int algorithm;
|
||||
extern int dimmensions;
|
||||
|
||||
// debug
|
||||
int loops = 0;
|
||||
|
@ -18,56 +15,64 @@ int loops = 0;
|
|||
gboolean update_images(gpointer* pars){
|
||||
int match=0,id;
|
||||
myParameters* parameters = (myParameters*) pars;
|
||||
struct data_frame *df = TSB[4].first_data_frame;
|
||||
struct data_frame *df = TSB[0].first_data_frame;
|
||||
struct Lower_Layer_Details *LLptr;
|
||||
|
||||
if (df == NULL){
|
||||
return TRUE;
|
||||
}
|
||||
// if (curr_measurement==1)
|
||||
// {
|
||||
int freq = to_intconvertor(df->dpmu[0]->freq)-200;
|
||||
if (curr_measurement==0)
|
||||
{
|
||||
int n = df->num_pmu;
|
||||
if (n==0) return TRUE;
|
||||
int i = 0;
|
||||
int freq;
|
||||
while (i < n){
|
||||
freq = to_intconvertor(df->dpmu[i]->freq)-200;
|
||||
live_chart_serie_add(serie, freq);
|
||||
loops++;
|
||||
printf("loops: %d\n", loops);
|
||||
// id = to_intconvertor(df->idcode);
|
||||
// printf("id = %d\n",id);
|
||||
id = to_intconvertor(TSB[0].idlist[i].idcode);
|
||||
printf("id = %d\n",id);
|
||||
|
||||
// LLptr = LLfirst;
|
||||
LLptr = LLfirst;
|
||||
match = 0;
|
||||
while(LLptr != NULL){
|
||||
printf("pmuid = %d\n",LLptr->pmuid);
|
||||
if(LLptr->pmuid == id){
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
LLptr = LLptr->next;
|
||||
}
|
||||
|
||||
// while(LLptr != NULL){
|
||||
// printf("pmuid = %d\n",LLptr->pmuid);
|
||||
// if(LLptr->pmuid == id){
|
||||
// match = 1;
|
||||
// break;
|
||||
// }
|
||||
// LLptr = LLptr->next;
|
||||
// }
|
||||
|
||||
// if(match == 1){
|
||||
if(match == 1){
|
||||
float lat = 79.347312;
|
||||
float lon = -69.439209;
|
||||
// float freq = to_intconvertor(df->dpmu[0]->freq)*0.001+50;
|
||||
printf("lat = %f, lon = %f, freq = %d\n",lat,lon,freq);
|
||||
// gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
||||
// if(parameters->g_last_image != 0){
|
||||
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
||||
// }
|
||||
// if (freq > 50.300){
|
||||
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
|
||||
// }else{
|
||||
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
float freq = to_intconvertor(df->dpmu[i]->freq)*0.001+50;
|
||||
printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
|
||||
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
|
||||
if(parameters->g_last_image != 0){
|
||||
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
|
||||
}
|
||||
if (freq > 50.300){
|
||||
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
|
||||
}else{
|
||||
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_red_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);
|
||||
}
|
||||
}
|
||||
df = df->dnext;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
|
||||
return TRUE;
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#define RED_IMAGE "./assets/red.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)
|
||||
// {
|
||||
|
@ -38,7 +35,7 @@ void on_frequency_clicked(GtkButton *but, gpointer udata)
|
|||
gtk_widget_set_sensitive(utdata->frequency, FALSE);
|
||||
gtk_widget_set_sensitive(utdata->attack_detection, TRUE);
|
||||
|
||||
// printf("Frequency\n");
|
||||
printf("Frequency\n");
|
||||
}
|
||||
|
||||
// on clicking the button attack_detection
|
||||
|
@ -51,7 +48,7 @@ void on_attack_detection_clicked(GtkButton *but, gpointer udata)
|
|||
|
||||
gtk_widget_show(utdata->algorithm);
|
||||
gtk_widget_show(utdata->dimmension);
|
||||
// printf("Attack Detection\n");
|
||||
printf("Attack Detection\n");
|
||||
}
|
||||
|
||||
// on clicking the button voltage
|
||||
|
@ -63,7 +60,7 @@ void on_voltage_clicked(GtkButton *but, gpointer udata)
|
|||
gtk_widget_set_sensitive(utdata->voltage, FALSE);
|
||||
gtk_widget_set_sensitive(utdata->frequency, TRUE);
|
||||
gtk_widget_set_sensitive(utdata->attack_detection, TRUE);
|
||||
// printf("Voltage\n");
|
||||
printf("Voltage\n");
|
||||
}
|
||||
|
||||
void utility_tools(GtkButton *but, gpointer udata)
|
||||
|
@ -114,6 +111,9 @@ 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.518597, 74.925584, g_green_image);
|
||||
|
||||
curr_measurement = 0;
|
||||
algorithm = 0;
|
||||
dimmension = 0;
|
||||
myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_last_image};
|
||||
gpointer data = (gpointer)¶meters;
|
||||
guint pid = g_timeout_add(20, (GSourceFunc)update_images, data);
|
||||
|
|
Loading…
Reference in New Issue