Compare commits

..

No commits in common. "fe01d4486af6133df164775bf070b9bfe75afcea" and "552561756c37699da1dfc1c9df2055902805ba64" have entirely different histories.

12 changed files with 217 additions and 577 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

View File

@ -296,6 +296,18 @@
<property name="top-attach">0</property> <property name="top-attach">0</property>
</packing> </packing>
</child> </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> <child>
<object class="GtkLayout" id="graph_layoutvol"> <object class="GtkLayout" id="graph_layoutvol">
<property name="height-request">150</property> <property name="height-request">150</property>
@ -312,7 +324,6 @@
<object class="GtkGrid"> <object class="GtkGrid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-top">16</property>
<child> <child>
<object class="GtkBox" id="mlad"> <object class="GtkBox" id="mlad">
<property name="can-focus">False</property> <property name="can-focus">False</property>
@ -484,8 +495,7 @@
<object class="GtkLabel" id="legend_label1"> <object class="GtkLabel" id="legend_label1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&gt;65600V or <property name="label" translatable="yes">&gt;6900V</property>
&lt; 65300</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -520,8 +530,8 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;65600V <property name="label" translatable="yes">&lt;6800V
&gt;65300V</property> &lt;6300V</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -751,7 +761,6 @@
<object class="GtkLabel" id="legend_label3"> <object class="GtkLabel" id="legend_label3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&gt; 0.5</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -786,7 +795,7 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&lt; 0.5</property> <property name="label" translatable="yes">Normal</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -918,7 +927,7 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">IITdh</property> <property name="label" translatable="yes">RSS</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -933,39 +942,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<!-- n-columns=2 n-rows=1 --> <placeholder/>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkColorButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="rgba">rgb(0,255,0)</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">dharwad</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>
@ -1026,7 +1003,7 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">IITdh</property> <property name="label" translatable="yes">RSS</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -1041,39 +1018,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<!-- n-columns=2 n-rows=1 --> <placeholder/>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkColorButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="rgba">rgb(0,255,0)</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">dharwad</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>
@ -1134,7 +1079,7 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">IITdh</property> <property name="label" translatable="yes">RSS</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -1149,39 +1094,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<!-- n-columns=2 n-rows=1 --> <placeholder/>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkColorButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="rgba">rgb(0,255,0)</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">dharwad</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child> </child>
<child> <child>
<placeholder/> <placeholder/>
@ -1196,59 +1109,6 @@
<property name="top-attach">3</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child>
<!-- n-columns=1 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<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">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="maplabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">Voltage Magnitude</property>
<attributes>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="graphlabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Voltage Magnitude</property>
<attributes>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>

View File

@ -296,6 +296,18 @@
<property name="top-attach">0</property> <property name="top-attach">0</property>
</packing> </packing>
</child> </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> <child>
<object class="GtkLayout" id="graph_layoutvol"> <object class="GtkLayout" id="graph_layoutvol">
<property name="height-request">150</property> <property name="height-request">150</property>
@ -312,9 +324,9 @@
<object class="GtkGrid"> <object class="GtkGrid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="margin-top">16</property>
<child> <child>
<object class="GtkBox" id="mlad"> <object class="GtkBox" id="mlad">
<property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
@ -484,8 +496,7 @@
<object class="GtkLabel" id="legend_label1"> <object class="GtkLabel" id="legend_label1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&gt;65600V or <property name="label" translatable="yes">&gt;6900V</property>
&lt; 65300</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -520,8 +531,8 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;65600V <property name="label" translatable="yes">&lt;6800V
&gt;65300V</property> &lt;6300V</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -581,7 +592,6 @@
</child> </child>
<child> <child>
<object class="GtkBox" id="mlfreq"> <object class="GtkBox" id="mlfreq">
<property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<child> <child>
@ -619,7 +629,7 @@
<object class="GtkLabel" id="legend_label2"> <object class="GtkLabel" id="legend_label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Deviation &gt; 0.5 mHz</property> <property name="label" translatable="yes">Attack/Event</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -654,7 +664,7 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">deviation &lt; 0.5mHz</property> <property name="label" translatable="yes">Normal</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -751,7 +761,7 @@
<object class="GtkLabel" id="legend_label3"> <object class="GtkLabel" id="legend_label3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&gt; 0.5</property> <property name="label" translatable="yes">Attack/Event</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -786,7 +796,7 @@
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">&lt; 0.5</property> <property name="label" translatable="yes">Normal</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@ -1100,59 +1110,6 @@
<property name="top-attach">3</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child>
<!-- n-columns=1 n-rows=3 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<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">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="maplabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="xpad">3</property>
<property name="ypad">3</property>
<property name="label" translatable="yes">Voltage Magnitude</property>
<attributes>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="graphlabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Voltage Magnitude</property>
<attributes>
<attribute name="scale" value="2"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>

View File

@ -17,9 +17,7 @@ struct vis_data{
GdkColor color; GdkColor color;
OsmGpsMapImage *last_image; // TODO: OsmGpsMapImage *last_image; // TODO:
GTimeVal last_update_time; GTimeVal last_update_time;
LiveChartSerie *serie_vol; LiveChartSerie *serie;
LiveChartSerie *serie_freq;
LiveChartSerie *serie_dfreq;
struct vis_data *next; struct vis_data *next;
}; };

View File

@ -39,11 +39,10 @@ struct _UtData
GtkWidget *swfreq; GtkWidget *swfreq;
GtkWidget *swdfreq; GtkWidget *swdfreq;
GtkWidget *swad; GtkWidget *swad;
GtkWidget *maplabel;
GtkWidget *graphlabel;
}; };
UtData *utdata; UtData *utdata;
LiveChartSerie *serie;
// global variables // global variables
int curr_measurement; int curr_measurement;

View File

@ -12,7 +12,7 @@ struct freqlist
int idcode; int idcode;
long double AVERAGE_OF_FREQUENCY; long double AVERAGE_OF_FREQUENCY;
unsigned long long int COUNT; unsigned long long int COUNT;
struct freqlist *next; struct freqlist* next;
}; };
struct vollist struct vollist
@ -20,9 +20,10 @@ struct vollist
int idcode; int idcode;
long double AVERAGE_OF_VOLTAGE; long double AVERAGE_OF_VOLTAGE;
unsigned long long int COUNT; unsigned long long int COUNT;
struct vollist *next; struct vollist* next;
}; };
struct freqlist *head = NULL; struct freqlist *head = NULL;
struct vollist *headvol = NULL; struct vollist *headvol = NULL;
@ -33,7 +34,7 @@ gboolean attack_detect_freq(struct data_frame *df)
head = (struct freqlist *)malloc(sizeof(struct freqlist)); head = (struct freqlist *)malloc(sizeof(struct freqlist));
head->AVERAGE_OF_FREQUENCY = 50; head->AVERAGE_OF_FREQUENCY = 50;
head->COUNT = 500; head->COUNT = 500;
head->idcode = to_intconvertor(df->idcode); head->idcode=to_intconvertor(df->idcode);
return TRUE; return TRUE;
} }
else else
@ -45,12 +46,10 @@ gboolean attack_detect_freq(struct data_frame *df)
if (to_intconvertor(df->idcode) == temp->idcode) if (to_intconvertor(df->idcode) == temp->idcode)
{ {
float CURR_FREQ; float CURR_FREQ;
if (df->dpmu[0]->fmt->freq == '0') if (df->dpmu[0]->fmt->freq == '0'){
{
CURR_FREQ = 50 + to_intconvertor(df->dpmu[0]->freq) * 1e-3; CURR_FREQ = 50 + to_intconvertor(df->dpmu[0]->freq) * 1e-3;
} }
else else{
{
CURR_FREQ = decode_ieee_single(df->dpmu[0]->freq); CURR_FREQ = decode_ieee_single(df->dpmu[0]->freq);
} }
printf("Current freq: %f\n", CURR_FREQ); printf("Current freq: %f\n", CURR_FREQ);
@ -76,17 +75,17 @@ gboolean attack_detect_freq(struct data_frame *df)
return TRUE; return TRUE;
} }
} }
previous = temp; previous=temp;
temp = temp->next; temp=temp->next;
} }
if (temp == NULL) if(temp==NULL)
{ {
struct freqlist *bring = (struct freqlist *)malloc(sizeof(struct freqlist)); struct freqlist* bring = (struct freqlist *)malloc(sizeof(struct freqlist));
bring = (struct freqlist *)malloc(sizeof(struct freqlist)); bring = (struct freqlist *)malloc(sizeof(struct freqlist));
bring->AVERAGE_OF_FREQUENCY = 50; bring->AVERAGE_OF_FREQUENCY = 50;
bring->COUNT = 500; bring->COUNT = 500;
bring->idcode = to_intconvertor(df->idcode); bring->idcode = to_intconvertor(df->idcode);
previous->next = bring; previous->next=bring;
return TRUE; return TRUE;
} }
} }
@ -97,48 +96,30 @@ gboolean attack_detect_vol(struct data_frame *df)
float CURR_vol; float CURR_vol;
if (df->dpmu[0]->fmt->phasor == '0') if (df->dpmu[0]->fmt->phasor == '0')
{ {
if (df->dpmu[0]->fmt->polar == '0') unsigned char s1[2];
{ unsigned char s2[2];
unsigned char s1[2]; strncpy(s1, df->dpmu[0]->phasors[0], 2);
unsigned char s2[2]; strncpy(s2, df->dpmu[0]->phasors[0] + 2, 2);
strncpy(s1, df->dpmu[0]->phasors[0], 2); long double v1 = to_intconvertor(s1);
strncpy(s2, df->dpmu[0]->phasors[0] + 2, 2); long double v2 = to_intconvertor(s2);
long double v1 = to_intconvertor(s1); CURR_vol = sqrt((v1 * v1) + (v2 * v2));
long double v2 = to_intconvertor(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[2];
strncpy(s1, df->dpmu[0]->phasors[0], 2);
CURR_vol = to_intconvertor(s1);
}
} }
else else
{ {
if (df->dpmu[0]->fmt->polar == '0') unsigned char s1[2];
{ unsigned char s2[2];
unsigned char s1[4]; strncpy(s1, df->dpmu[0]->phasors[0], 4);
unsigned char s2[4]; strncpy(s2, df->dpmu[0]->phasors[0] + 2, 4);
strncpy(s1, df->dpmu[0]->phasors[0], 4); long double v1 = decode_ieee_single(s1);
strncpy(s2, df->dpmu[0]->phasors[0] + 2, 4); long double v2 = decode_ieee_single(s2);
long double v1 = decode_ieee_single(s1); CURR_vol = sqrt((v1 * v1) + (v2 * v2));
long double v2 = decode_ieee_single(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[4];
strncpy(s1, df->dpmu[0]->phasors[0], 4);
CURR_vol = decode_ieee_single(s1);
}
} }
if (headvol == NULL) if (headvol == NULL)
{ {
headvol = (struct vollist *)malloc(sizeof(struct vollist)); headvol = (struct vollist *)malloc(sizeof(struct vollist));
headvol->AVERAGE_OF_VOLTAGE = CURR_vol; headvol->AVERAGE_OF_VOLTAGE = CURR_vol;
headvol->COUNT = 500; headvol->COUNT = 500;
headvol->idcode = to_intconvertor(df->idcode); headvol->idcode=to_intconvertor(df->idcode);
return TRUE; return TRUE;
} }
else else
@ -193,4 +174,6 @@ gboolean attack_detect_freq_vol(struct data_frame *df)
return attack_detect_freq(df) && attack_detect_vol(df); return attack_detect_freq(df) && attack_detect_vol(df);
} }
/* pavan changes */ /* pavan changes */

View File

@ -29,6 +29,7 @@ struct DTWvollist
struct DTWvollist *next; struct DTWvollist *next;
}; };
struct DTWfreqlist *dtwhead = NULL; struct DTWfreqlist *dtwhead = NULL;
struct DTWvollist *dtwheadvol = NULL; struct DTWvollist *dtwheadvol = NULL;
@ -42,7 +43,7 @@ int DTWfreqDistance(struct data_frame *df)
dtwhead->flag = 0; dtwhead->flag = 0;
dtwhead->idcode = to_intconvertor(df->idcode); dtwhead->idcode = to_intconvertor(df->idcode);
dtwhead->next = NULL; dtwhead->next = NULL;
dtwhead->result = 1; dtwhead->result=1;
return 1; return 1;
} }
else else
@ -150,7 +151,7 @@ int DTWfreqDistance(struct data_frame *df)
bring->flag = 0; bring->flag = 0;
bring->idcode = to_intconvertor(df->idcode); bring->idcode = to_intconvertor(df->idcode);
bring->next = NULL; bring->next = NULL;
bring->result = 1; bring->result=1;
previous->next = bring; previous->next = bring;
return 1; return 1;
} }
@ -168,7 +169,7 @@ int DTWvolDistance(struct data_frame *df)
dtwheadvol->flag = 0; dtwheadvol->flag = 0;
dtwheadvol->idcode = to_intconvertor(df->idcode); dtwheadvol->idcode = to_intconvertor(df->idcode);
dtwheadvol->next = NULL; dtwheadvol->next = NULL;
dtwheadvol->result = 1; dtwheadvol->result=1;
return 1; return 1;
} }
else else
@ -182,41 +183,23 @@ int DTWvolDistance(struct data_frame *df)
float CURR_vol; float CURR_vol;
if (df->dpmu[0]->fmt->phasor == '0') if (df->dpmu[0]->fmt->phasor == '0')
{ {
if (df->dpmu[0]->fmt->polar == '0') unsigned char s1[2];
{ unsigned char s2[2];
unsigned char s1[2]; strncpy(s1,df->dpmu[0]->phasors[0],2);
unsigned char s2[2]; strncpy(s2,df->dpmu[0]->phasors[0]+2,2);
strncpy(s1, df->dpmu[0]->phasors[0], 2); long double v1 = to_intconvertor(s1);
strncpy(s2, df->dpmu[0]->phasors[0] + 2, 2); long double v2 = to_intconvertor(s2);
long double v1 = to_intconvertor(s1); CURR_vol = sqrt((v1*v1)+(v2*v2));
long double v2 = to_intconvertor(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[2];
strncpy(s1, df->dpmu[0]->phasors[0], 2);
CURR_vol = to_intconvertor(s1);
}
} }
else else
{ {
if (df->dpmu[0]->fmt->polar == '0') unsigned char s1[4];
{ unsigned char s2[4];
unsigned char s1[4]; strncpy(s1,df->dpmu[0]->phasors[0],4);
unsigned char s2[4]; strncpy(s2,df->dpmu[0]->phasors[0]+2,4);
strncpy(s1, df->dpmu[0]->phasors[0], 4); long double v1 = decode_ieee_single(s1);
strncpy(s2, df->dpmu[0]->phasors[0] + 2, 4); long double v2 =decode_ieee_single(s2);
long double v1 = decode_ieee_single(s1); CURR_vol = sqrt((v1*v1)+(v2*v2));
long double v2 = decode_ieee_single(s2);
CURR_vol = sqrt((v1 * v1) + (v2 * v2));
}
else
{
unsigned char s1[4];
strncpy(s1, df->dpmu[0]->phasors[0], 4);
CURR_vol = decode_ieee_single(s1);
}
} }
// printf("count1: %d\ncount2: %d\n",count_track1,count_track2); // printf("count1: %d\ncount2: %d\n",count_track1,count_track2);
@ -306,7 +289,7 @@ int DTWvolDistance(struct data_frame *df)
bring->flag = 0; bring->flag = 0;
bring->idcode = to_intconvertor(df->idcode); bring->idcode = to_intconvertor(df->idcode);
bring->next = NULL; bring->next = NULL;
bring->result = 1; bring->result=1;
previous->next = bring; previous->next = bring;
return 1; return 1;
} }

View File

@ -11,14 +11,14 @@
struct kmeans1 struct kmeans1
{ {
int idcode; int idcode;
unsigned long long int count_A; unsigned long long int count_A = 1000;
unsigned long long int count_B; unsigned long long int count_B = 1000;
unsigned long long int count_C; unsigned long long int count_C = 1000;
long double A; long double A = 50;
long double B; long double B = 49;
long double C; long double C = 51;
struct kmeans1 *next; struct kmeans1 *next;
}; }
struct kmeans1 *headk = NULL; struct kmeans1 *headk = NULL;
@ -26,7 +26,6 @@ gboolean kmeans(struct data_frame *df)
{ {
if (headk == NULL) if (headk == NULL)
{ {
headk = (struct kmeans1 *)malloc(sizeof(struct kmeans1));
headk->A = 50; headk->A = 50;
headk->B = 49; headk->B = 49;
headk->C = 51; headk->C = 51;
@ -39,8 +38,8 @@ gboolean kmeans(struct data_frame *df)
} }
else else
{ {
struct kmeans1 *temp = headk; struct kmeans1 *temp == headk;
struct kmeans1 *previous = NULL; struct kmeans1 *previous == NULL;
while (temp != NULL) while (temp != NULL)
{ {
if (temp->idcode == to_intconvertor(df->idcode)) if (temp->idcode == to_intconvertor(df->idcode))
@ -80,10 +79,10 @@ gboolean kmeans(struct data_frame *df)
} }
break; break;
} }
previous = temp; previous=temp;
temp = temp->next; temp = temp->next;
} }
if (temp == NULL) if(temp==NULL)
{ {
struct kmeans1 *bring = (struct kmeans1 *)malloc(sizeof(struct kmeans1)); struct kmeans1 *bring = (struct kmeans1 *)malloc(sizeof(struct kmeans1));
bring->A = 50; bring->A = 50;
@ -94,7 +93,7 @@ gboolean kmeans(struct data_frame *df)
bring->count_C = 1000; bring->count_C = 1000;
bring->next = NULL; bring->next = NULL;
bring->idcode = to_intconvertor(df->idcode); bring->idcode = to_intconvertor(df->idcode);
previous->next = bring; previous->next=bring;
return TRUE; return TRUE;
} }
} }

View File

@ -37,143 +37,100 @@ gboolean update_images(gpointer* pars){
//printf("map_vis A: %Lf, B: %Lf,C: %Lf\n",A,B,C); //printf("map_vis A: %Lf, B: %Lf,C: %Lf\n",A,B,C);
//gboolean green = kmeans(df); //gboolean green = kmeans(df);
int i = 0, k = 0; if (curr_measurement==0)
float freq,vol_magnitude,angle, dfreq; {
unsigned char freq_fmt, anal_fmt, phas_fmt, polar_fmt; int i = 0, k = 0;
while (df!=NULL){ float freq,vol_magnitude,angle, dfreq;
float lat; unsigned char freq_fmt, anal_fmt, phas_fmt, polar_fmt;
float lon; while (df!=NULL){
loops++; float lat;
printf("loops: %d\n", loops); float lon;
loops++;
id = to_intconvertor(df->idcode); printf("loops: %d\n", loops);
printf("id = %d\n",id);
pthread_mutex_lock(&mutex_cfg); id = to_intconvertor(df->idcode);
temp_cfg = cfgfirst; printf("id = %d\n",id);
// Check for the IDCODE in Configuration Frame pthread_mutex_lock(&mutex_cfg);
while(temp_cfg != NULL){ temp_cfg = cfgfirst;
if(id == to_intconvertor(temp_cfg->idcode)){ // Check for the IDCODE in Configuration Frame
cfg_match = 1; while(temp_cfg != NULL){
printf("Matched - id : %d\n",id); if(id == to_intconvertor(temp_cfg->idcode)){
freq_fmt = temp_cfg->pmu[0]->fmt->freq; cfg_match = 1;
anal_fmt = temp_cfg->pmu[0]->fmt->analog; printf("Matched - id : %d\n",id);
phas_fmt = temp_cfg->pmu[0]->fmt->phasor; freq_fmt = temp_cfg->pmu[0]->fmt->freq;
polar_fmt = temp_cfg->pmu[0]->fmt->polar; anal_fmt = temp_cfg->pmu[0]->fmt->analog;
break; phas_fmt = temp_cfg->pmu[0]->fmt->phasor;
} else { polar_fmt = temp_cfg->pmu[0]->fmt->polar;
temp_cfg = temp_cfg->cfgnext; break;
} else {
temp_cfg = temp_cfg->cfgnext;
}
} }
} pthread_mutex_unlock(&mutex_cfg);
pthread_mutex_unlock(&mutex_cfg);
// get data from df. // get data from df.
if(freq_fmt == '1'){ if(freq_fmt == '1'){
freq = decode_ieee_single(df->dpmu[i]->freq); freq = decode_ieee_single(df->dpmu[i]->freq);
printf("freq = %f\n",freq); printf("freq = %f\n",freq);
}else{ }else{
freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50; freq = to_intconvertor(df->dpmu[i]->freq)*1e-6+50;
}
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;
} 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);
lat = vis_ptr->lat; live_chart_serie_add(serie, freq);
lon = vis_ptr->lon;
live_chart_serie_add(vis_ptr->serie_freq, freq); // check lower layer details to get longitude and lattitude.
live_chart_serie_add(vis_ptr->serie_vol, vol_magnitude); // pthread_mutex_lock(&mutex_Lower_Layer_Details);
live_chart_serie_add(vis_ptr->serie_dfreq, dfreq); // LLptr = LLfirst;
// match = 0;
// while(LLptr != NULL){
// printf("pmuid = %d\n",LLptr->pmuid);
// if(LLptr->pmuid == id){
// match = 1;
// lat = LLptr->latitude;
// lon = LLptr->longitude;
// printf("lat = %f; lon = %f\n",lat,lon);
// break;
// }
// LLptr = LLptr->next;
// }
// pthread_mutex_unlock(&mutex_Lower_Layer_Details);
if(match == 1 && cfg_match == 1){ vis_ptr = vis_data_head;
printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq); match = 0;
if(vis_ptr->last_image != 0){ while(vis_ptr != NULL){
osm_gps_map_image_remove(parameters->util_map, vis_ptr->last_image); 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;
} }
if(curr_measurement == 0){
if(vol_magnitude > 65600 || vol_magnitude < 65300){ if(match == 1 && cfg_match == 1){
vis_ptr->last_image = osm_gps_map_image_add(parameters->util_map, lat, lon, parameters->g_red_image); printf("lat = %f, lon = %f, freq = %f\n",lat,lon,freq);
if(parameters->g_last_image != 0){
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
}
if (DTWvolDistance(df)){
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,lat, lon, parameters->g_green_image);
}else{ }else{
vis_ptr->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_red_image);
}
}else if(curr_measurement == 1){
if (freq > 300){
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_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 == 1){
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 == 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){
}else if (algorithm==2 && dimmension == 0){
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 == 1){
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 == 2){
} }
} }
df = df->dnext;
// i++;
k++;
} }
df = df->dnext;
// i++;
k++;
} }
pthread_mutex_unlock(&mutex_on_TSB); pthread_mutex_unlock(&mutex_on_TSB);

View File

@ -7,14 +7,10 @@
#include "livechart.h" #include "livechart.h"
#include "connections.h" #include "connections.h"
// TODO: change this when in production
#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"
#define YELLOW_IMAGE "./assets/yellow.png"
#define BLUE_IMAGE "./assets/blue.png"
#define GREY_IMAGE "./assets/grey.png"
#define PINK_IMAGE "./assets/pink.png"
// void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image) // void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image)
// { // {
@ -136,20 +132,9 @@ void on_voltage_clicked(GtkButton *but, gpointer udata)
curr_measurement = 0; curr_measurement = 0;
gtk_widget_show(utdata->ml_vol); gtk_widget_show(utdata->ml_vol);
gtk_widget_show(utdata->graph_layoutvol);
gtk_widget_show(utdata->swvol);
gtk_widget_show(utdata->graphlabel);
gtk_label_set_label(utdata->maplabel, "Voltage Magnitude");
gtk_label_set_label(utdata->graphlabel, "Voltage Magnitude");
gtk_widget_hide(utdata->ml_freq); gtk_widget_hide(utdata->ml_freq);
gtk_widget_hide(utdata->ml_dfreq); gtk_widget_hide(utdata->ml_dfreq);
gtk_widget_hide(utdata->ml_ad); gtk_widget_hide(utdata->ml_ad);
gtk_widget_hide(utdata->graph_layoutfreq);
gtk_widget_hide(utdata->graph_layoutdfreq);
gtk_widget_hide(utdata->swfreq);
gtk_widget_hide(utdata->swdfreq);
gtk_widget_hide(utdata->algorithm); gtk_widget_hide(utdata->algorithm);
gtk_widget_hide(utdata->dimmension); gtk_widget_hide(utdata->dimmension);
@ -168,21 +153,9 @@ void on_frequency_clicked(GtkButton *but, gpointer udata)
curr_measurement = 1; curr_measurement = 1;
gtk_widget_show(utdata->ml_freq); gtk_widget_show(utdata->ml_freq);
gtk_widget_show(utdata->graph_layoutfreq);
gtk_widget_show(utdata->swfreq);
gtk_widget_show(utdata->graphlabel);
gtk_label_set_label(utdata->maplabel, "Frequency");
gtk_label_set_label(utdata->graphlabel, "Frequency");
gtk_widget_hide(utdata->ml_vol); gtk_widget_hide(utdata->ml_vol);
gtk_widget_hide(utdata->ml_dfreq); gtk_widget_hide(utdata->ml_dfreq);
gtk_widget_hide(utdata->ml_ad); gtk_widget_hide(utdata->ml_ad);
gtk_widget_hide(utdata->swdfreq);
gtk_widget_hide(utdata->swvol);
gtk_widget_hide(utdata->graph_layoutdfreq);
gtk_widget_hide(utdata->graph_layoutvol);
gtk_widget_hide(utdata->algorithm); gtk_widget_hide(utdata->algorithm);
gtk_widget_hide(utdata->dimmension); gtk_widget_hide(utdata->dimmension);
@ -202,20 +175,9 @@ void on_dfreq_clicked(GtkButton *but, gpointer udata)
curr_measurement = 2; curr_measurement = 2;
gtk_widget_show(utdata->ml_dfreq); gtk_widget_show(utdata->ml_dfreq);
gtk_widget_show(utdata->graph_layoutdfreq);
gtk_widget_show(utdata->swdfreq);
gtk_widget_show(utdata->graphlabel);
gtk_label_set_label(utdata->maplabel, "Frequency Rate");
gtk_label_set_label(utdata->graphlabel, "Frequency Rate");
gtk_widget_hide(utdata->ml_vol); gtk_widget_hide(utdata->ml_vol);
gtk_widget_hide(utdata->ml_freq); gtk_widget_hide(utdata->ml_freq);
gtk_widget_hide(utdata->ml_ad); gtk_widget_hide(utdata->ml_ad);
gtk_widget_hide(utdata->graph_layoutfreq);
gtk_widget_hide(utdata->graph_layoutvol);
gtk_widget_hide(utdata->swvol);
gtk_widget_hide(utdata->swfreq);
gtk_widget_hide(utdata->algorithm); gtk_widget_hide(utdata->algorithm);
@ -245,18 +207,9 @@ void on_attack_detection_clicked(GtkButton *but, gpointer udata)
gtk_widget_show(utdata->dimm_label); gtk_widget_show(utdata->dimm_label);
gtk_widget_show(utdata->ml_ad); gtk_widget_show(utdata->ml_ad);
gtk_label_set_label(utdata->maplabel, "Attack Detection");
gtk_widget_hide(utdata->ml_vol); gtk_widget_hide(utdata->ml_vol);
gtk_widget_hide(utdata->ml_freq); gtk_widget_hide(utdata->ml_freq);
gtk_widget_hide(utdata->ml_dfreq); gtk_widget_hide(utdata->ml_dfreq);
gtk_widget_hide(utdata->swvol);
gtk_widget_hide(utdata->swfreq);
gtk_widget_hide(utdata->swdfreq);
gtk_widget_hide(utdata->graph_layoutdfreq);
gtk_widget_hide(utdata->graph_layoutfreq);
gtk_widget_hide(utdata->graph_layoutvol);
gtk_widget_hide(utdata->graphlabel);
printf("Attack Detection\n"); printf("Attack Detection\n");
} }
@ -281,11 +234,6 @@ void utility_tools(GtkButton *but, gpointer udata)
{ {
GdkPixbuf *g_red_image; GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image; GdkPixbuf *g_green_image;
GdkPixbuf *g_yellow_image;
GdkPixbuf *g_blue_image;
GdkPixbuf *g_pink_image;
GdkPixbuf *g_grey_image;
OsmGpsMapImage *g_last_image; OsmGpsMapImage *g_last_image;
// ------------------- // -------------------
GtkBuilder *builder; GtkBuilder *builder;
@ -320,8 +268,7 @@ void utility_tools(GtkButton *but, gpointer udata)
utdata->swvol = GTK_WIDGET(gtk_builder_get_object(builder, "swvol")); utdata->swvol = GTK_WIDGET(gtk_builder_get_object(builder, "swvol"));
utdata->swfreq = GTK_WIDGET(gtk_builder_get_object(builder, "swfreq")); utdata->swfreq = GTK_WIDGET(gtk_builder_get_object(builder, "swfreq"));
utdata->swdfreq = GTK_WIDGET(gtk_builder_get_object(builder, "swdfreq")); utdata->swdfreq = GTK_WIDGET(gtk_builder_get_object(builder, "swdfreq"));
utdata->maplabel = GTK_WIDGET(gtk_builder_get_object(builder, "maplabel")); utdata->swad = GTK_WIDGET(gtk_builder_get_object(builder, "swad"));
utdata->graphlabel = GTK_WIDGET(gtk_builder_get_object(builder, "graphlabel"));
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);
@ -340,7 +287,6 @@ void utility_tools(GtkButton *but, gpointer udata)
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);
g_grey_image = gdk_pixbuf_new_from_file_at_size(GREY_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_OSMC_TRAILS, "map-source", OSM_GPS_MAP_SOURCE_OSMC_TRAILS,
@ -351,14 +297,14 @@ void utility_tools(GtkButton *but, gpointer udata)
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);
// TODO: add the points to window. // TODO: add the points to window.
// 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);
curr_measurement = 0; curr_measurement = 0;
algorithm = 0; algorithm = 0;
dimmension = 0; dimmension = 0;
myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_grey_image, g_last_image}; myParameters parameters = {utdata->util_map, g_red_image, g_green_image, g_last_image};
gpointer data = (gpointer)&parameters; gpointer data = (gpointer)&parameters;
gtk_widget_set_size_request(GTK_WIDGET(utdata->util_map), 600, 500); gtk_widget_set_size_request(GTK_WIDGET(utdata->util_map), 600, 500);
@ -366,93 +312,52 @@ void utility_tools(GtkButton *but, gpointer udata)
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 // add live chart
// serie = live_chart_serie_new("IIT", (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000))); serie = live_chart_serie_new("IIT", (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000)));
// // live_chart set color to the serie // live_chart set color to the serie
// GdkRGBA color = getIndexColor(0); GdkRGBA color = getIndexColor(0);
// live_chart_path_set_color(live_chart_serie_get_line(serie), &color); live_chart_path_set_color(live_chart_serie_get_line(serie), &color);
// iterate over llptr and load the map_vis_head structure // iterate over llptr and load the map_vis_head structure
// vis_data_head = (struct map_vis_head *)malloc(sizeof(struct vis_data)); // vis_data_head = (struct map_vis_head *)malloc(sizeof(struct vis_data));
LiveChartConfig *config_vol = live_chart_config_new();
live_chart_yaxis_set_unit(config_vol->y_axis, "V");
live_chart_xaxis_set_tick_interval(config_vol->x_axis, 20);
live_chart_xaxis_set_tick_length(config_vol->x_axis, 100);
live_chart_yaxis_update_bounds(config_vol->y_axis, 1);
live_chart_path_set_visible(config_vol->x_axis->lines, FALSE);
LiveChartChart *chart_vol = live_chart_chart_new(config_vol);
LiveChartConfig *config_freq = live_chart_config_new();
live_chart_yaxis_set_unit(config_freq->y_axis, "mHz");
live_chart_xaxis_set_tick_interval(config_freq->x_axis, 20);
live_chart_xaxis_set_tick_length(config_freq->x_axis, 100);
live_chart_yaxis_update_bounds(config_freq->y_axis, 1);
live_chart_path_set_visible(config_freq->x_axis->lines, FALSE);
LiveChartChart *chart_freq = live_chart_chart_new(config_freq);
LiveChartConfig *config_dfreq = live_chart_config_new();
live_chart_yaxis_set_unit(config_dfreq->y_axis, "mHz");
live_chart_xaxis_set_tick_interval(config_dfreq->x_axis, 20);
live_chart_xaxis_set_tick_length(config_dfreq->x_axis, 100);
live_chart_yaxis_update_bounds(config_dfreq->y_axis, 1);
live_chart_path_set_visible(config_dfreq->x_axis->lines, FALSE);
LiveChartChart *chart_dfreq = live_chart_chart_new(config_dfreq);
// live_chart_chart_add_serie(chart, serie);
struct Lower_Layer_Details *llptr = LLfirst; struct Lower_Layer_Details *llptr = LLfirst;
vis_data_head = (struct vis_data *)malloc(sizeof(struct vis_data)); struct vis_data * visptr = vis_data_head;
struct vis_data * temp_visptr = vis_data_head;
int index = 0; int index = 0;
while (llptr != NULL) while (llptr != NULL)
{ {
printf("\ncat\n"); visptr = (struct vis_data *)malloc(sizeof(struct vis_data));
temp_visptr->id = llptr->pmuid; visptr->id = llptr->pmuid;
temp_visptr->lat = llptr->latitude; visptr->lat = llptr->latitude;
temp_visptr->lon = llptr->longitude; visptr->lon = llptr->longitude;
temp_visptr->last_image = osm_gps_map_image_add(utdata->util_map, llptr->latitude, llptr->longitude, g_grey_image); // TODO: change the image visptr->last_image = osm_gps_map_image_add(utdata->util_map, llptr->latitude, llptr->longitude, g_red_image); // TODO: change the image
visptr->serie = live_chart_serie_new(llptr->ip, (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000)));
temp_visptr->serie_freq = live_chart_serie_new(llptr->ip, (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000))); // live_chart set color to the serie
GdkRGBA color = getIndexColor(index); GdkRGBA color = getIndexColor(index);
live_chart_path_set_color(live_chart_serie_get_line(temp_visptr->serie_freq), &color); live_chart_path_set_color(live_chart_serie_get_line(visptr->serie), &color);
live_chart_chart_add_serie(chart_freq, temp_visptr->serie_freq); visptr->next = NULL;
visptr = visptr->next;
temp_visptr->serie_vol = live_chart_serie_new(llptr->ip, (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000)));
live_chart_path_set_color(live_chart_serie_get_line(temp_visptr->serie_vol), &color);
live_chart_chart_add_serie(chart_vol, temp_visptr->serie_vol);
temp_visptr->serie_dfreq = live_chart_serie_new(llptr->ip, (LiveChartSerieRenderer*)live_chart_line_new(live_chart_values_new(10000)));
live_chart_path_set_color(live_chart_serie_get_line(temp_visptr->serie_dfreq), &color);
live_chart_chart_add_serie(chart_dfreq, temp_visptr->serie_dfreq);
temp_visptr->next = (struct vis_data *)malloc(sizeof(struct vis_data));
temp_visptr = temp_visptr->next;
index++; index++;
llptr = llptr->next; llptr = llptr->next;
} }
temp_visptr->next = NULL;
guint pid = g_timeout_add(20, (GSourceFunc)update_images, data); guint pid = g_timeout_add(20, (GSourceFunc)update_images, data);
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_hexpand(GTK_WIDGET(chart), TRUE);
// gtk_widget_set_vexpand(GTK_WIDGET(chart), TRUE); // gtk_widget_set_vexpand(GTK_WIDGET(chart), TRUE);
gtk_widget_set_size_request(GTK_WIDGET(chart_freq), 600, 150); gtk_widget_set_size_request(GTK_WIDGET(chart), 600, 150);
gtk_widget_set_size_request(GTK_WIDGET(chart_vol), 600, 150);
gtk_widget_set_size_request(GTK_WIDGET(chart_dfreq), 600, 150);
gtk_container_add(utdata->graph_layoutvol, GTK_WIDGET(chart_vol));
gtk_container_add(utdata->graph_layoutfreq, GTK_WIDGET(chart_freq));
gtk_container_add(utdata->graph_layoutdfreq, GTK_WIDGET(chart_dfreq));
gtk_container_add(utdata->graph_layoutvol, GTK_WIDGET(chart));
@ -478,8 +383,7 @@ void utility_tools(GtkButton *but, gpointer udata)
gtk_widget_hide(utdata->ml_ad); gtk_widget_hide(utdata->ml_ad);
gtk_widget_hide(utdata->swfreq); gtk_widget_hide(utdata->swfreq);
gtk_widget_hide(utdata->swdfreq); gtk_widget_hide(utdata->swdfreq);
gtk_widget_hide(utdata->graph_layoutdfreq); gtk_widget_hide(utdata->swad);
gtk_widget_hide(utdata->graph_layoutfreq);
gtk_main(); gtk_main();
} }