ipdcGui.h File Reference

#include <gtk/gtk.h>
Include dependency graph for ipdcGui.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _ChData

Defines

#define CH_GET_OBJECT(builder, name, type, data)   data->name = type(gtk_builder_get_object (builder, #name) )
#define CH_GET_WIDGET(builder, name, data)   CH_GET_OBJECT(builder, name, GTK_WIDGET, data)

Typedefs

typedef struct _ChData ChData

Functions

int isNumber (char *s)
void destroy (GtkWidget *widget, gpointer udata)
void display_pdc_detail (GtkButton *widget, gpointer udata)
void about_ipdc (GtkButton *widget, gpointer udata)
void ipdc_help (GtkButton *but, gpointer udata)
void validation_result (char *msg)
void ipdc_colors ()
void pdc_details (GtkButton *button, gpointer udata)
void fill_pdc_details ()
int validation_pdc_detail (GtkButton *button, gpointer udata)
void add_pmu (GtkButton *but, gpointer udata)
int add_pmu_validation (GtkButton *but, gpointer udata)
void cmd_or_remove_pmu (GtkButton *but, gpointer udata)
int cmd_or_remove_pmu_validation (GtkButton *but, gpointer udata)
void add_new_pdc (GtkButton *but, gpointer udata)
int new_pdc_validation (GtkButton *but, gpointer udata)
void remove_pdc (GtkButton *but, gpointer udata)
int remove_pdc_validation (GtkButton *but, gpointer udata)
void connection_table (GtkButton *but, gpointer udata)

Variables

char find_butn [2]
char buff [8000]
long int time_thrd_id
ChDatadata
GtkWidget * pdc_detail_window
GtkWidget * add_pmu_window
GtkWidget * new_window
GtkWidget * p_id
GtkWidget * p_udp
GtkWidget * p_tcp
GtkWidget * p_ip
GtkWidget * p_port
GtkWidget * p_protocol
pthread_t show_sys_time

Define Documentation

#define CH_GET_OBJECT ( builder,
name,
type,
data   )     data->name = type(gtk_builder_get_object (builder, #name) )

Definition at line 36 of file ipdcGui.h.

#define CH_GET_WIDGET ( builder,
name,
data   )     CH_GET_OBJECT(builder, name, GTK_WIDGET, data)

Definition at line 38 of file ipdcGui.h.


Typedef Documentation

typedef struct _ChData ChData

Definition at line 46 of file ipdcGui.h.


Function Documentation

void about_ipdc ( GtkButton *  widget,
gpointer  udata 
)

Definition at line 284 of file ipdcGui.c.

Referenced by main().

00285         {
00286                 /* local variables */
00287                 GtkWidget *about_dialog;
00288                 const gchar    *auth[] = {"\nDr. A.M. Kulkarni <http://www.ee.iitb.ac.in/wiki/faculty/anil>", "\nProf. S.U. Ghumbre <shashi.comp@coep.ac.in>", "\nProf. V.Z. Attar <vahida.comp@coep.ac.in>", "\nNitesh Pandit <panditnitesh@gmail.com>", "\nKedar V. Khandeparkar <kedar.khandeparkar@gmail.com>", NULL};
00289 
00290                 /* Create a about dialog for displaying about the iPDC. */
00291                 about_dialog = gtk_about_dialog_new ();
00292 
00293                 /* Define the diffrent properties of about_dialog. */
00294                 gtk_about_dialog_set_program_name ((GtkAboutDialog *)about_dialog, "\t\t\t\tiPDC 1.0\t\t\t\t");
00295                 gtk_about_dialog_set_comments ((GtkAboutDialog *)about_dialog, "A Phasor Data Concentrator for WAMS.\n\nUnder guidance of Dr. A.M. Kulkarni\nDepartment of Electrical Engineering\nIndian Institute of Technology, Bombay\nMumbai, INDIA\n\nAuthors: Kedar Khandeparkar\n    Nitesh Pandit");
00296 
00297                 gtk_about_dialog_set_license ((GtkAboutDialog *)about_dialog, "\t\t\t\tiPDC - A Phasor Data Concentrator\n\nGeneral Public License (GPL)\n\nAuthors:\n\t\tKedar V. Khandeparkar <kedar.khandeparkar@gmail.com>\n\t\tNitesh Pandit <panditnitesh@gmail.com>\n\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU General Public License\nas published by the Free Software Foundation; either version 2\nof the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.\n");
00298 
00299                 gtk_about_dialog_set_copyright ((GtkAboutDialog *)about_dialog, "Copyright (C) 2010-2011 GPL-3.0");
00300                 gtk_about_dialog_set_website ((GtkAboutDialog *)about_dialog, "http://wafms.co.cc/ipdc/");
00301                 gtk_about_dialog_set_authors ((GtkAboutDialog *)about_dialog, auth);
00302                 gtk_about_dialog_set_logo ((GtkAboutDialog *)about_dialog, NULL);
00303 
00304                 /* Ensure that the dialog box is destroyed when the user responds */
00305                 g_signal_connect_swapped (about_dialog, "response", G_CALLBACK (gtk_widget_destroy), about_dialog);
00306 
00307                 /* Finally show the about_dialog. */
00308                 gtk_widget_show_all (about_dialog);
00309         };

Here is the caller graph for this function:

void add_new_pdc ( GtkButton *  but,
gpointer  udata 
)

Definition at line 1389 of file ipdcGui.c.

References ipdc_help(), new_pdc_validation(), new_window, p_ip, and p_protocol.

Referenced by main().

01390         {
01391                 /* local variables */
01392                 char *markup3;
01393                 GtkWidget *table, *close_button;
01394                 GtkWidget *valdbutton, *help_button, *label;
01395   
01396                 /* Create a new dialog window for Destination Detail */
01397                 new_window = gtk_dialog_new ();
01398                 g_signal_connect (new_window, "destroy", G_CALLBACK (gtk_widget_destroy), new_window);
01399                 gtk_window_set_title (GTK_WINDOW (new_window), "Add Destination");
01400                 gtk_container_set_border_width (GTK_CONTAINER (new_window), 10);
01401                 gtk_widget_set_size_request (new_window, 350, 300);
01402     
01403                 /* Create a table of 4 by 2 squares. */
01404                 table = gtk_table_new (4, 2, FALSE);
01405     
01406                 /* Set the spacing to 50 on x and 35 on y */
01407                 gtk_table_set_row_spacings (GTK_TABLE (table), 50);
01408                 gtk_table_set_col_spacings (GTK_TABLE (table), 35);
01409     
01410                 /* The dialog window is created with a vbox packed into it */                                                           
01411                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(new_window)->vbox), table, TRUE, TRUE, 0);
01412                 gtk_widget_show (table);
01413 
01414                 /* Add few buttons to the bottom of the dialog */
01415                 close_button = gtk_button_new_with_label ("close");
01416                 valdbutton = gtk_button_new_with_label ("Add");
01417                 help_button = gtk_button_new_with_label ("Help");
01418 
01419                 /* this simply creates a grid of toggle buttons on the table to demonstrate the scrolled window. */
01420                 label = gtk_label_new (" ");
01421                 markup3 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Enter Destination Device Details</b></span>");
01422                 gtk_label_set_markup (GTK_LABEL (label), markup3);
01423                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
01424                 gtk_widget_show (label);
01425                 g_free(markup3);
01426  
01427                 label = gtk_label_new ("Destination IP Address");
01428                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
01429                 gtk_widget_show (label);
01430  
01431                 label = gtk_label_new ("Protocol                 ");
01432                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
01433                 gtk_widget_show (label);
01434 
01435                 /* Create text boxes for user to enter appropriate values */
01436                 p_ip = gtk_entry_new();
01437                 gtk_entry_set_max_length ((GtkEntry *)p_ip, 15);
01438                 gtk_table_attach_defaults (GTK_TABLE (table), p_ip, 1, 2, 2, 3);
01439                 gtk_widget_show (p_ip);
01440  
01441                 /* Create combo boxe for user with some fixed values */
01442                 p_protocol = gtk_combo_box_new_text();
01443                 gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "UDP");
01444                 gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "TCP");
01445                 gtk_combo_box_set_active(GTK_COMBO_BOX(p_protocol), 0);
01446                 gtk_table_attach_defaults (GTK_TABLE (table), p_protocol, 1, 2, 3, 4);
01447                 gtk_widget_show (p_protocol);
01448 
01449                 /* Signal handling for buttons on Destination Details Window */
01450                 g_signal_connect_swapped (valdbutton, "clicked", G_CALLBACK (new_pdc_validation), valdbutton);
01451                 g_signal_connect_swapped (help_button, "clicked", G_CALLBACK (ipdc_help), NULL);
01452                 g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_widget_destroy), new_window);
01453     
01454                 /* This makes it so the button is the default. */
01455                 gtk_widget_set_can_default (close_button, TRUE);
01456                 gtk_widget_set_can_default (valdbutton, TRUE);
01457                 gtk_widget_set_can_default (help_button, TRUE);
01458                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), valdbutton, TRUE, TRUE, 0);
01459                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), help_button, TRUE, TRUE, 0);
01460                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), close_button, TRUE, TRUE, 0);
01461     
01462                 /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
01463                 gtk_widget_grab_default (valdbutton);
01464                 gtk_widget_show (valdbutton);
01465                 gtk_widget_grab_default (help_button);
01466                 gtk_widget_show (help_button);
01467                 gtk_widget_grab_default (close_button);
01468                 gtk_widget_show (close_button);
01469 
01470                 /* Finally show the new_window */
01471                 gtk_widget_show (new_window);
01472         };

Here is the call graph for this function:

Here is the caller graph for this function:

void add_pmu ( GtkButton *  but,
gpointer  udata 
)

Definition at line 972 of file ipdcGui.c.

References add_pmu_validation(), add_pmu_window, ipdc_help(), p_id, p_ip, p_port, and p_protocol.

Referenced by main().

00973         {
00974                 /* local variables */
00975                 char *markup1;
00976                 GtkWidget *table, *close_button;
00977                 GtkWidget *valdbutton, *help_button, *label;
00978 
00979                 /* Create a new dialog window for Source Device Details */
00980                 add_pmu_window = gtk_dialog_new ();
00981                 g_signal_connect (add_pmu_window, "destroy", G_CALLBACK (gtk_widget_destroy), add_pmu_window);
00982                 gtk_window_set_title (GTK_WINDOW (add_pmu_window), "Add Source Device");
00983                 gtk_container_set_border_width (GTK_CONTAINER (add_pmu_window), 10);
00984                 gtk_widget_set_size_request (add_pmu_window, 350, 350);
00985     
00986                 /* Create a table of 5 by 2 squares. */
00987                 table = gtk_table_new (5, 2, FALSE);
00988     
00989                 /* Set the spacing to 20 on x and 30 on y */
00990                 gtk_table_set_row_spacings (GTK_TABLE (table), 20);
00991                 gtk_table_set_col_spacings (GTK_TABLE (table), 30);
00992     
00993                 /* Pack the table into the window */
00994                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(add_pmu_window)->vbox), table, TRUE, TRUE, 0);
00995                 gtk_widget_show (table);
00996 
00997                 /* Add few button to the bottom of the dialog */
00998                 close_button = gtk_button_new_with_label ("close");
00999                 valdbutton = gtk_button_new_with_label ("Add");
01000                 help_button = gtk_button_new_with_label ("Help");
01001     
01002                 /* This simply creates a grid of toggle buttons on the table */
01003                 label = gtk_label_new ("-");
01004                 markup1 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='12'><b>Enter Source Device Details</b></span>");
01005                 gtk_label_set_markup (GTK_LABEL (label), markup1);
01006                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
01007                 gtk_widget_show (label);
01008                 g_free (markup1);
01009  
01010                 label = gtk_label_new ("Source ID Code    ");
01011                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
01012                 gtk_widget_show (label);
01013  
01014                 label = gtk_label_new ("Source IP Address   ");
01015                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
01016                 gtk_widget_show (label);
01017 
01018                 label = gtk_label_new ("Source Port Number");
01019                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
01020                 gtk_widget_show (label);
01021  
01022                 label = gtk_label_new ("Protocol               ");
01023                 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
01024                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
01025                 gtk_widget_show (label);
01026 
01027                 /* Create text boxes for user to enter appropriate values */
01028                 p_id = gtk_entry_new();
01029                 gtk_entry_set_max_length ((GtkEntry *)p_id, 5);
01030                 gtk_table_attach_defaults (GTK_TABLE (table), p_id, 1, 2, 1, 2);
01031                 gtk_widget_show (p_id);
01032  
01033                 p_ip = gtk_entry_new();
01034                 gtk_entry_set_max_length ((GtkEntry *)p_ip, 15);
01035                 gtk_table_attach_defaults (GTK_TABLE (table), p_ip, 1, 2, 2, 3);
01036                 gtk_widget_show (p_ip);
01037 
01038                 p_port = gtk_entry_new();
01039                 gtk_entry_set_max_length ((GtkEntry *)p_port, 5);
01040                 gtk_table_attach_defaults (GTK_TABLE (table), p_port, 1, 2, 3, 4);
01041                 gtk_widget_show (p_port);
01042  
01043                 /* Create combo boxe for user with some fixed values */
01044                 p_protocol = gtk_combo_box_new_text();
01045                 gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "UDP");
01046                 gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "TCP");
01047                 gtk_combo_box_set_active(GTK_COMBO_BOX(p_protocol), 0);
01048                 gtk_table_attach_defaults (GTK_TABLE (table), p_protocol, 1, 2, 4, 5);
01049                 gtk_widget_show (p_protocol);
01050                 
01051                 /* Signal handling for buttons on Source Device Details Window */
01052                 g_signal_connect_swapped (valdbutton, "clicked", G_CALLBACK (add_pmu_validation), valdbutton);
01053                 g_signal_connect_swapped (help_button, "clicked", G_CALLBACK (ipdc_help), NULL);
01054                 g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_widget_destroy), add_pmu_window);
01055     
01056                 /* This makes it so the button is the default. */
01057                 gtk_widget_set_can_default (close_button, TRUE);
01058                 gtk_widget_set_can_default (valdbutton, TRUE);
01059                 gtk_widget_set_can_default (help_button, TRUE);
01060                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (add_pmu_window)->action_area), valdbutton, TRUE, TRUE, 0);
01061                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (add_pmu_window)->action_area), help_button, TRUE, TRUE, 0);
01062                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (add_pmu_window)->action_area), close_button, TRUE, TRUE, 0);
01063     
01064                 /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
01065                 gtk_widget_grab_default (valdbutton);
01066                 gtk_widget_show (valdbutton);
01067                 gtk_widget_grab_default (help_button);
01068                 gtk_widget_show (help_button);
01069                 gtk_widget_grab_default (close_button);
01070                 gtk_widget_show (close_button);
01071 
01072                 /* Finally show the add_pmu_window */
01073                 gtk_widget_show (add_pmu_window);
01074         };

Here is the call graph for this function:

Here is the caller graph for this function:

int add_pmu_validation ( GtkButton *  but,
gpointer  udata 
)

Definition at line 524 of file ipdcGui.c.

References add_PMU(), add_pmu_window, checkip(), DBPORT, isNumber(), p_id, p_ip, p_port, p_protocol, PDC_IDCODE, TCPPORT, UDPPORT, and validation_result().

Referenced by add_pmu().

00525         {
00526                 /* local variables */
00527                 int ret;
00528                 char *errmsg1, ip[20], tmp[4];
00529                 const char *text, *text1, *text2, *text3;
00530 
00531                 /* Get the text entries filled by user */
00532                 text = gtk_entry_get_text(GTK_ENTRY(p_id));
00533                 text1 = gtk_entry_get_text(GTK_ENTRY(p_ip));
00534                 text2 = gtk_entry_get_text(GTK_ENTRY(p_port));
00535                 text3 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(p_protocol));
00536                 memset(ip,'\0',20);
00537                 strcat(ip, text1);
00538                 strcpy (tmp, text3);
00539 
00540                 if ((!isNumber((char *)text)) || (atoi(text) == PDC_IDCODE))    /* Check text_box entry for valid integer or not? */
00541                 { 
00542                         errmsg1 = "Please enter valid value for source device ID code\n";
00543                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00544                         return 0;
00545                 }
00546                 else if((!isNumber((char *)text2)) && ((atoi(text2) < 1500 || (atoi(text2) > 65535)) || (atoi(text2) == TCPPORT || atoi(text2) == UDPPORT || atoi(text2) == DBPORT)))           /* TCP and UDP port of iPDC should not match with it */
00547                 { 
00548                         errmsg1 = "\tPlease enter valid value for source device Port\t\n";
00549                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00550                         return 0;
00551                 }
00552                 else if(!checkip(ip))           /* Check text_box entry for valid IP Address or not? */ 
00553                 {
00554                         errmsg1 = "\tPlease enter valid IP Addess of source device\t\n";
00555                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00556                         return 0;
00557                 }
00558                 else            /* Only if all the text_box entries were right */ 
00559                 {
00560                         /* call add_PMU() to actual add pmu/pdc and start communication */ 
00561                         ret = add_PMU((char *)text, (char *)text1, (char *)text2, (char *)text3);
00562                         if (ret == 0)
00563                         {
00564                                 /* Close/destroy the add_pmu_window */
00565                                 gtk_widget_destroy (add_pmu_window);
00566                                                         
00567                                 errmsg1 = "\t\tSource Device Successfully Added\t\t\n";
00568                                 validation_result (errmsg1);            /* Show the success message to user */
00569                                 return 1;
00570                         }
00571                         else
00572                         {
00573                                 errmsg1 = "\t\tDevice details already exists\t\t\n";
00574                                 validation_result (errmsg1);            /* Show the unsuccess message to user */
00575                                 return 0;
00576                         }
00577                 }
00578         };

Here is the call graph for this function:

Here is the caller graph for this function:

void cmd_or_remove_pmu ( GtkButton *  but,
gpointer  udata 
)

Definition at line 1083 of file ipdcGui.c.

References buff, cmd_or_remove_pmu_validation(), Lower_Layer_Details::data_transmission_off, find_butn, i, Lower_Layer_Details::ip, ipdc_help(), LLfirst, new_window, Lower_Layer_Details::next, p_id, p_protocol, Lower_Layer_Details::pmuid, Lower_Layer_Details::port, and Lower_Layer_Details::protocol.

Referenced by main().

01084         {
01085                 /* local variables */
01086                 GtkWidget *scrolled_window;
01087                 GtkWidget *table, *close_button;
01088                 GtkWidget *valdbutton, *help_button, *label;
01089 
01090                 int on_flag = 0, off_flag = 0;
01091                 char line [40], *p_buff, tmp_str[20]; 
01092                 char ip[20],protocol[6],port[6],pmuid[6];
01093                 char *i,*p,*port_num,*id, *markup2;
01094                 FILE *file_1;
01095   
01096                 /* Copy the 'udata' that came along with signal to identifies which function should execute */
01097                 strcpy(find_butn,(char *) udata);
01098 
01099                 /* Create a new dialog window for the scrolled window to be packed into */
01100                 new_window = gtk_dialog_new ();
01101                 g_signal_connect (new_window, "destroy", G_CALLBACK (gtk_widget_destroy), new_window);
01102 
01103                 /* Set the window title according to fired signal */
01104                 if(!strcmp(find_butn, "1"))
01105                 {
01106                         gtk_window_set_title (GTK_WINDOW (new_window), "Remove Source Device");
01107                 }
01108                 else if(!strcmp(find_butn, "2"))
01109                 {
01110                         gtk_window_set_title (GTK_WINDOW (new_window), "Turn OFF Data Transmission");
01111                 }
01112                 else if(!strcmp(find_butn, "3"))
01113                 {
01114                         gtk_window_set_title (GTK_WINDOW (new_window), "Turn ON Data Transmission");
01115                 }
01116                 else
01117                 {
01118                         gtk_window_set_title (GTK_WINDOW (new_window), "Configuration Frame Request");
01119                 }
01120                 gtk_container_set_border_width (GTK_CONTAINER (new_window), 10);
01121                 gtk_widget_set_size_request (new_window, 450, 350);
01122     
01123                 /* Create a new scrolled window */
01124                 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
01125                 gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
01126 
01127                 /* The policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS. GTK_POLICY_AUTOMATIC will automatically decide whether you need scrollbars,
01128                    whereas GTK_POLICY_ALWAYS will always leave the scrollbars there. The first one is the horizontal scrollbar, the second is vertical. */
01129                 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
01130 
01131                 /* The dialog window is created with a vbox packed into it */                                                           
01132                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(new_window)->vbox), scrolled_window, TRUE, TRUE, 0);
01133                 gtk_widget_show (scrolled_window);
01134     
01135                 /* create a table of 4 by 2 squares. */
01136                 table = gtk_table_new (4, 2, FALSE);
01137     
01138                 /* Set the spacing to 15 on x and 25 on y */
01139                 gtk_table_set_row_spacings (GTK_TABLE (table), 15);
01140                 gtk_table_set_col_spacings (GTK_TABLE (table), 25);
01141     
01142                 /* Pack the table into the scrolled window */
01143                 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), table);
01144                 gtk_widget_show (table);
01145 
01146                 memset(buff,'\0',sizeof(buff));
01147                 memset(line,'\0',40);
01148 
01149                 /* Open the file 'pdc.txt' in read mode */
01150                 file_1 = fopen ("ipaddress.txt","r");
01151                 if ((file_1 == NULL) || (fgets (line, 40,file_1) == NULL))
01152                 {
01153                         /* Place lable on a spacific position on table with text 'Sorry, No Records...!!!'*/
01154                         label = gtk_label_new (" ");
01155                         markup2 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Sorry, No Records...!!!\n-------------------------------------------------------------------\n</b></span>");
01156                         gtk_label_set_markup (GTK_LABEL (label), markup2);
01157                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
01158                         gtk_widget_show (label);
01159                         g_free(markup2);
01160                 } 
01161                 else 
01162                 {
01163                         /* This simply creates a grid of toggle buttons on the table to demonstrate the scrolled window. */
01164                         label = gtk_label_new (" ");
01165                         markup2 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Connection Details</b></span>");
01166                         gtk_label_set_markup (GTK_LABEL (label), markup2);
01167                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
01168                         gtk_widget_show (label);
01169                         g_free(markup2);
01170 
01171                         /* Check wether fired signal from remove source or send CFG request */
01172                         if(!strcmp(find_butn, "1") || !strcmp(find_butn, "4"))
01173                         {
01174                                 /* Open the file 'ipaddress.txt' in read mode */
01175                                 file_1 = fopen ("ipaddress.txt","r");
01176 
01177                                 /* Add the button with title according to fired signal */
01178                                 if(!strcmp(find_butn, "4"))
01179                                 {
01180                                         valdbutton = gtk_button_new_with_label ("Send");
01181                                 }
01182                                 if(!strcmp(find_butn, "1"))
01183                                 {
01184                                         valdbutton = gtk_button_new_with_label ("Remove");      
01185                                 }
01186                                         
01187                                 p_buff = " -------------------------------------------------------------------------------------------------\n|   Source ID  |            IP           |       Port      |     Protocol    |\n-------------------------------------------------------------------------------------------------\n";
01188                                 strcat(buff, p_buff);
01189                                 memset(line,'\0',40);
01190 
01191                                 while (fgets (line, 40,file_1) != NULL)         
01192                                 { 
01193                                         memset(ip,'\0',20);
01194                                         memset(port,'\0',6);
01195                                         memset(protocol,'\0',6);
01196                                         memset(pmuid,'\0',6);
01197 
01198                                         /* Read the file data seprated by spaces and store into pointers */
01199                                         id = strtok (line," "); 
01200                                         i = strtok (NULL," "); 
01201                                         port_num = strtok (NULL," "); 
01202                                         p = strtok (NULL," "); 
01203                                 
01204                                         /* Copy the data into variables */
01205                                         strcpy(pmuid, id);
01206                                         strcpy(ip, i);
01207                                         strcpy(port, port_num);
01208                                         strcpy(protocol, p);
01209         
01210                                         /* Concate all the data into a big buffer */
01211                                         strcat(buff, "|     ");
01212                                         strcat(buff, pmuid);
01213                                         strcat(buff, "\t\t");
01214                                         strcat(buff, ip);
01215                                         strcat(buff, "\t\t");
01216                                         strcat(buff, port);
01217                                         strcat(buff, "\t    ");
01218                                         strncat(buff, protocol, 3);
01219                                         strcat(buff, "       |\n");
01220                                         strcat(buff, "-------------------------------------------------------------------------------------------------\n");
01221                                 }
01222                                 fclose (file_1);
01223                         }
01224 
01225                         else if(!strcmp(find_butn, "2"))        /* if signal fired from send Transmission OFF request to Source device */
01226                         {
01227                                 if(LLfirst != NULL)
01228                                 {
01229                                         /* Add a "Send" button to the bottom of the dialog */
01230                                         valdbutton = gtk_button_new_with_label ("Send");
01231                                         struct Lower_Layer_Details *t = LLfirst;
01232 
01233                                         p_buff = " -------------------------------------------------------------------------------------------------\n|   Source ID  |            IP           |       Port      |     Protocol    |\n-------------------------------------------------------------------------------------------------\n";
01234                                         strcat(buff, p_buff);
01235         
01236                                         while(t != NULL)
01237                                         {
01238                                                 if(t->data_transmission_off == 0)
01239                                                 {
01240                                                         /* Concate all the data into a big buffer */
01241                                                         memset(tmp_str,'\0',sizeof(tmp_str));
01242                                                         sprintf(tmp_str, "%d", t->pmuid);
01243                                                         strcat(buff, "|     ");
01244                                                         strcat(buff, tmp_str);
01245                                                         strcat(buff, "\t\t");   
01246                                                         strcat(buff, t->ip);
01247                                                         strcat(buff, "\t\t");
01248                                                         memset(tmp_str,'\0',sizeof(tmp_str));
01249                                                         sprintf(tmp_str, "%d", t->port);
01250                                                         strcat(buff, tmp_str);
01251                                                         strcat(buff, "\t    ");
01252                                                         strncat(buff, t->protocol, 3);
01253                                                         strcat(buff, "       |\n");
01254                                                         strcat(buff, "-------------------------------------------------------------------------------------------------\n");
01255                                                         off_flag = 1;
01256                                                 }
01257                                                 t = t->next;
01258                                         }                       
01259                                 }
01260                         }       
01261 
01262                         else if(!strcmp(find_butn, "3"))        /* if signal fired from send Transmission ON request to Source device */
01263                         {
01264                                 if(LLfirst != NULL)
01265                                 {
01266                                         /* Add a "Send" button to the bottom of the dialog */
01267                                         valdbutton = gtk_button_new_with_label ("Send");
01268                                         struct Lower_Layer_Details *t = LLfirst;
01269 
01270                                         p_buff = " -------------------------------------------------------------------------------------------------\n|   Source ID  |            IP           |       Port      |     Protocol    |\n-------------------------------------------------------------------------------------------------\n";
01271                                         strcat(buff, p_buff);
01272         
01273                                         while(t != NULL)
01274                                         {
01275                                                 if(t->data_transmission_off == 1)
01276                                                 {
01277                                                         strcat(buff, "|\t");
01278                                                         memset(tmp_str,'\0',sizeof(tmp_str));
01279                                                         sprintf(tmp_str, "%d", t->pmuid);
01280                                                         strcat(buff, tmp_str);
01281                                                         strcat(buff, "\t\t\t");
01282                                                         strcat(buff, t->ip);
01283                                                         strcat(buff, "\t\t");
01284                                                         memset(tmp_str,'\0',sizeof(tmp_str));
01285                                                         sprintf(tmp_str, "%d", t->port);
01286                                                         strcat(buff, tmp_str);
01287                                                         strcat(buff, "\t\t");
01288                                                         strcat(buff, t->protocol);
01289                                                         strcat(buff, "\t|\n");
01290                                                         strcat(buff, "-----------------------------------------------------------------------------------------------\n");
01291                                                         on_flag = 1;
01292                                                 }
01293                                                 t = t->next;
01294                                         }                       
01295                                 }
01296                         }       
01297 
01298                         /* Simply check for source objects whose Transmission is not OFF  (or ON)*/
01299                         if ((!strcmp(find_butn, "2")) && (off_flag == 0))
01300                         {
01301                                 /* Place lable on a spacific position on table with text 'Sorry, No Records...!!!'*/
01302                                 label = gtk_label_new (" ");
01303                                 markup2 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Sorry, No Records...!!!\n--------------------------------------------------------------------------\n</b></span>");
01304                                 gtk_label_set_markup (GTK_LABEL (label), markup2);
01305                                 gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
01306                                 gtk_widget_show (label);
01307                                 g_free(markup2);
01308                         }
01309                         else if ((!strcmp(find_butn, "3")) && (on_flag == 0))   /* Simply check for source objects whose Transmission is not ON (or OFF) */
01310                         {
01311                                 /* Place lable on a spacific position on table with text 'Sorry, No Records...!!!'*/
01312                                 label = gtk_label_new (" ");
01313                                 markup2 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Sorry, No Records...!!!\n--------------------------------------------------------------------------\n</b></span>");
01314                                 gtk_label_set_markup (GTK_LABEL (label), markup2);
01315                                 gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
01316                                 gtk_widget_show (label);
01317                                 g_free(markup2);
01318                         }
01319                         else
01320                         {
01321                                 /* This simply creates a grid of toggle buttons on the table to demonstrate the scrolled window. */
01322                                 label = gtk_label_new (buff);
01323                                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 1, 2);
01324                                 gtk_widget_show (label);
01325                  
01326                                 label = gtk_label_new ("Source ID Code   :");
01327                                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
01328                                 gtk_widget_show (label);
01329                  
01330                                 label = gtk_label_new ("Protocol         :");
01331                                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
01332                                 gtk_widget_show (label);
01333 
01334                                 /* Create text boxes for user to enter appropriate values */
01335                                 p_id = gtk_entry_new();
01336                                 gtk_entry_set_max_length ((GtkEntry *)p_id, 5);
01337                                 gtk_table_attach_defaults (GTK_TABLE (table), p_id, 1, 2, 2, 3);
01338                                 gtk_widget_show (p_id);
01339                  
01340                                 /* Create combo boxe for user with some fixed values */
01341                                 p_protocol = gtk_combo_box_new_text();
01342                                 gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "UDP");
01343                                 gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "TCP");
01344                                 gtk_combo_box_set_active(GTK_COMBO_BOX(p_protocol), 0);
01345                                 gtk_table_attach_defaults (GTK_TABLE (table), p_protocol, 1, 2, 3, 4);
01346                                 gtk_widget_show (p_protocol);
01347 
01348                                 /* Add a "Help" button to the bottom of the dialog */
01349                                 help_button = gtk_button_new_with_label ("Help");
01350 
01351                                 /* Signal handling for buttons on Window */
01352                                 g_signal_connect_swapped (valdbutton, "clicked", G_CALLBACK (cmd_or_remove_pmu_validation), valdbutton);
01353                                 g_signal_connect_swapped (help_button, "clicked", G_CALLBACK (ipdc_help), NULL);
01354                     
01355                                 /* This makes it so the button is the default. */
01356                                 gtk_widget_set_can_default (valdbutton, TRUE);
01357                                 gtk_widget_set_can_default (help_button, TRUE);
01358                                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), valdbutton, TRUE, TRUE, 0);
01359                                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), help_button, TRUE, TRUE, 0);
01360                     
01361                                 /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
01362                                 gtk_widget_grab_default (valdbutton);
01363                                 gtk_widget_show (valdbutton);
01364                                 gtk_widget_grab_default (help_button);
01365                                 gtk_widget_show (help_button);
01366                         }
01367                 }
01368 
01369                 /* Add a "Close" button to the bottom of the dialog */
01370                 close_button = gtk_button_new_with_label ("Close");
01371                 g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_widget_destroy), new_window);
01372                 gtk_widget_set_can_default (close_button, TRUE);
01373                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), close_button, TRUE, TRUE, 0);
01374                 gtk_widget_grab_default (close_button);
01375                 gtk_widget_show (close_button);
01376                 on_flag = 0, off_flag = 0;
01377 
01378                 /* Finally show the new_window */
01379                 gtk_widget_show (new_window);
01380         };

Here is the call graph for this function:

Here is the caller graph for this function:

int cmd_or_remove_pmu_validation ( GtkButton *  but,
gpointer  udata 
)

Definition at line 589 of file ipdcGui.c.

References configuration_request(), find_butn, isNumber(), new_window, p_id, p_protocol, put_data_transmission_off(), put_data_transmission_on(), remove_Lower_Node(), and validation_result().

Referenced by cmd_or_remove_pmu().

00590         {
00591                 /* local variables */
00592                 int ret;
00593                 char *errmsg1, tmp[4];
00594                 const char *text, *text1;
00595         
00596                 /* Get the text entries filled by user */
00597                 text = gtk_entry_get_text(GTK_ENTRY(p_id));
00598                 text1 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(p_protocol));
00599                 memset(tmp, '\0', 4);
00600                 strcpy (tmp, text1);
00601 
00602                 if (!isNumber((char *)text))            /* Check text_box entry for valid integer or not?  */
00603                 { 
00604                         errmsg1 = "\tPlease enter valid value for Source device ID code\t\n";
00605                         validation_result (errmsg1);
00606                         return 0;
00607                 }
00608                 else            /* Only if all the text_box entries were right */ 
00609                 {
00610                         if(!strcmp(find_butn, "1"))     /* If function called by 'Remove source device' */
00611                         {
00612                                 /* call remove_Lower_Node() to remove source device */ 
00613                                 ret = remove_Lower_Node((char *)text, (char *)text1);
00614                                 if (ret == 0)
00615                                 {
00616                                         /* Close/destroy the Source remove window */
00617                                         gtk_widget_destroy (new_window);                        
00618 
00619                                         errmsg1 = "\tSource device successfully removed\t\n";
00620                                         validation_result (errmsg1);            /* Show the success message to user */
00621                                         return 1;
00622                                 }
00623                                 else
00624                                 {
00625                                         errmsg1 = "\t\tEntered Source device not found\t\t\n";
00626                                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00627                                         return 0;
00628                                 }
00629                         }
00630                         else if(!strcmp(find_butn, "2"))        /* If function called by 'Send Data Transmission OFF' */
00631                         {
00632                                 /* call put_data_transmission_off() to put OFF data of source device */ 
00633                                 ret = put_data_transmission_off((char *)text, (char *)text1);
00634                                 if (ret == 0)
00635                                 {
00636                                         /* Close/destroy the Send command frame window */
00637                                         gtk_widget_destroy (new_window);                        
00638                                         
00639                                         errmsg1 = "\tData Transmission put OFF\t\n";
00640                                         validation_result (errmsg1);            /* Show the success message to user */
00641                                         return 1;
00642                                 }
00643                                 else
00644                                 {
00645                                         errmsg1 = "\t\tEntered Source device not found\t\t\n";
00646                                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00647                                         return 0;
00648                                 }
00649                         }
00650                         else if(!strcmp(find_butn, "3"))        /* If function called by 'Send Data Transmission ON' */
00651                         {
00652                                 /* call put_data_transmission_on() to put ON data of source device */ 
00653                                 ret = put_data_transmission_on((char *)text, (char *)text1);
00654                                 if (ret == 0)
00655                                 {
00656                                         /* Close/destroy the Send command frame window */
00657                                         gtk_widget_destroy (new_window);                        
00658                                         
00659                                         errmsg1 = "\tData Transmission put ON\t\n";
00660                                         validation_result (errmsg1);            /* Show the success message to user */
00661                                         return 1;
00662                                 }
00663                                 else
00664                                 {
00665                                         errmsg1 = "\t\tEntered Source device not found\t\t\n";
00666                                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00667                                         return 0;
00668                                 }
00669                         }
00670                         else if(!strcmp(find_butn, "4"))        /* If function called by Send Configuration request */
00671                         {
00672                                 /* call configuration_request() to send Configuration request */ 
00673                                 ret = configuration_request((char *)text, (char *)text1);
00674                                 if (ret == 0)
00675                                 {
00676                                         /* Close/destroy the Send command frame window */
00677                                         gtk_widget_destroy (new_window);                        
00678                                         
00679                                         errmsg1 = "\t\tConfiguration Frame request sent\t\t\n";
00680                                         validation_result (errmsg1);            /* Show the success message to user */
00681                                         return 1;
00682                                 }
00683                                 else
00684                                 {
00685                                         errmsg1 = "\t\tEntered Source device not found\t\t\n";
00686                                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00687                                         return 0;
00688                                 }
00689                         }
00690                         else
00691                         {
00692                                 errmsg1 = "\t\t\tUNKNOWN FUNCTION CALL\t\t\t\n";
00693                                 validation_result (errmsg1);                    /* Show the unsuccess message to user */
00694                                 return 1;
00695                         }
00696                 }
00697         };

Here is the call graph for this function:

Here is the caller graph for this function:

void connection_table ( GtkButton *  but,
gpointer  udata 
)

Definition at line 1653 of file ipdcGui.c.

References buff, i, Lower_Layer_Details::ip, new_window, Lower_Layer_Details::pmuid, Lower_Layer_Details::port, and Lower_Layer_Details::protocol.

Referenced by main().

01654         {
01655                 /* local variables */
01656                 GtkWidget *scrolled_window;
01657                 GtkWidget *table, *close_button;
01658                 GtkWidget *label;
01659 
01660                 char *i,*p,*port_num,*id;
01661                 char line [40], *p_buff; 
01662                 char ip[20],protocol[6],port[6],pmuid[6];
01663                 char *markup5, *markup6, *markup7, *markup8;
01664                 FILE *file_1;
01665   
01666                 /* Create a new dialog window for the scrolled window to be packed into */
01667                 new_window = gtk_dialog_new ();
01668                 g_signal_connect (new_window, "destroy", G_CALLBACK (gtk_widget_destroy), new_window);
01669                 gtk_window_set_title (GTK_WINDOW (new_window), "iPDC Connections");
01670                 gtk_container_set_border_width (GTK_CONTAINER (new_window), 10);
01671                 gtk_widget_set_size_request (new_window, 450, 350);
01672     
01673                 /* Create a new scrolled window. */
01674                 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
01675                 gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
01676     
01677                 /* the policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS. GTK_POLICY_AUTOMATIC will automatically decide whether you need scrollbars,
01678                    whereas GTK_POLICY_ALWAYS will always leave the scrollbars there. The first one is the horizontal scrollbar, the second is vertical. */
01679                 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
01680 
01681                 /* The dialog window is created with a vbox packed into it. */                                                          
01682                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(new_window)->vbox), scrolled_window, TRUE, TRUE, 0);
01683                 gtk_widget_show (scrolled_window);
01684     
01685                 /* Create a table of 4 by 1 squares */
01686                 table = gtk_table_new (4, 1, FALSE);
01687     
01688                 /* Set the spacing to 15 on x and 25 on y */
01689                 gtk_table_set_row_spacings (GTK_TABLE (table), 15);
01690                 gtk_table_set_col_spacings (GTK_TABLE (table), 25);
01691     
01692                 /* Pack the table into the scrolled window */
01693                 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), table);
01694                 gtk_widget_show (table);
01695 
01696                 /* Add a "close" button to the bottom of the dialog */
01697                 close_button = gtk_button_new_from_stock (GTK_STOCK_OK);// or GTK_STOCK_APPLY);
01698 
01699                 /* Print some text on lable with color and proper font */
01700                 label = gtk_label_new ("-");
01701                 markup5 = g_markup_printf_escaped ("<span foreground=\"#006666\" font='12'><b>Source Devices Connection Table\t\t</b></span>");
01702                 gtk_label_set_markup (GTK_LABEL (label), markup5);
01703                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
01704                 gtk_widget_show (label);
01705 
01706                 /* Open the "ipaddress.txt" file */
01707                 memset(buff,'\0',sizeof(buff));
01708                 file_1 = fopen ("ipaddress.txt","r");
01709                 if (file_1 == NULL)
01710                 {
01711                         /* Place lable on a spacific position on table with text 'Sorry, No Records...!!!'*/
01712                         label = gtk_label_new (" ");
01713                         markup6 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Sorry, No Records...!!!\n--------------------------------------------------\n</b></span>");
01714                         gtk_label_set_markup (GTK_LABEL (label), markup6);
01715                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 1, 2);
01716                         gtk_widget_show (label);
01717                         g_free(markup6);
01718                 }
01719                 else 
01720                 { 
01721                         p_buff = " -------------------------------------------------------------------------------------------------\n|   Source ID  |            IP           |       Port      |     Protocol    |\n-------------------------------------------------------------------------------------------------\n";
01722                         strcat(buff, p_buff);
01723                         memset(line,'\0',40);
01724 
01725                         while (fgets (line, 40,file_1) != NULL)         /* read a line */
01726                         { 
01727                                 memset(ip,'\0',20);
01728                                 memset(port,'\0',6);
01729                                 memset(protocol,'\0',6);
01730                                 memset(pmuid,'\0',6);
01731 
01732                                 /* Read the file data seprated by spaces and store into pointers */
01733                                 id = strtok (line," "); 
01734                                 i = strtok (NULL," "); 
01735                                 port_num = strtok (NULL," "); 
01736                                 p = strtok (NULL," "); 
01737                                 
01738                                 /* Copy the data into variables */
01739                                 strcpy(pmuid, id);
01740                                 strcpy(ip, i);
01741                                 strcpy(port, port_num);
01742                                 strcpy(protocol, p);
01743         
01744                                 /* Concate all the data into a big buffer */
01745                                 strcat(buff, "|     ");
01746                                 strcat(buff, pmuid);
01747                                 strcat(buff, "\t\t");
01748                                 strcat(buff, ip);
01749                                 strcat(buff, "\t\t");
01750                                 strcat(buff, port);
01751                                 strcat(buff, "\t");
01752                                 strcat(buff, "    ");
01753                                 strncat(buff, protocol, 3);
01754                                 strcat(buff, "       |\n");
01755                                 strcat(buff, "-------------------------------------------------------------------------------------------------\n");
01756                         }
01757                         fclose (file_1);
01758                 }
01759 
01760                 /* This simply creates a grid of toggle buttons on the table to demonstrate the scrolled window. */
01761                 label = gtk_label_new (buff);
01762                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
01763                 gtk_widget_show (label);
01764  
01765                 /* Print some text on lable with color and proper font */
01766                 label = gtk_label_new ("-");
01767                 markup7 = g_markup_printf_escaped ("<span foreground=\"#006666\" font='12'><b>Destination Devices Connection Table</b></span>");
01768                 gtk_label_set_markup (GTK_LABEL (label), markup7);
01769                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
01770                 gtk_widget_show (label);
01771                 g_free (markup7);
01772 
01773                 /* Open the "ipaddress.txt" file */
01774                 memset(buff,'\0',sizeof(buff));
01775                 file_1 = fopen ("upperpdc_ip.txt","r");
01776                 if (file_1 == NULL)
01777                 {
01778                         /* Place lable on a spacific position on table with text 'Sorry, No Records...!!!'*/
01779                         label = gtk_label_new (" ");
01780                         markup8 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Sorry, No Records...!!!\n--------------------------------------------------\n</b></span>");
01781                         gtk_label_set_markup (GTK_LABEL (label), markup8);
01782                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
01783                         gtk_widget_show (label);
01784                         g_free(markup8);
01785                 }
01786                 else 
01787                 { 
01788                         p_buff = " -------------------------------------------------------------------------------------------------\n|           IP              |          Port         |         Protocol         |\n-------------------------------------------------------------------------------------------------\n";
01789                         strcat(buff, p_buff);
01790                         memset(line,'\0',40);
01791 
01792                         while (fgets (line, 40,file_1) != NULL)         
01793                         { 
01794                                 memset(ip,'\0',20);
01795                                 memset(port,'\0',6);
01796                                 memset(protocol,'\0',6);
01797 
01798                                 /* Read the file data seprated by spaces and store into pointers */
01799                                 i = strtok (line," "); 
01800                                 port_num = strtok (NULL," "); 
01801                                 p = strtok (NULL," "); 
01802                                 
01803                                 /* Copy the data into variables */
01804                                 strcpy(ip, i);
01805                                 strcpy(port, port_num);
01806                                 strcpy(protocol, p);
01807         
01808                                 /* Concate all the data into a big buffer */
01809                                 strcat(buff, "|     ");
01810                                 strcat(buff, ip);
01811                                 strcat(buff, "\t\t");
01812                                 strcat(buff, port);
01813                                 strcat(buff, "\t\t    ");
01814                                 strncat(buff, protocol, 3);
01815                                 strcat(buff, "             |\n");
01816                                 strcat(buff, "-------------------------------------------------------------------------------------------------\n");
01817                         }
01818                         fclose (file_1);
01819                 }
01820 
01821                 /* Display the file information on lable */
01822                 label = gtk_label_new (buff);
01823                 gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
01824                 gtk_widget_show (label);
01825 
01826                 /* Signal handling when Window will distroy or closed */
01827                 g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_widget_destroy), new_window);
01828     
01829                 /* This makes it so the button is the default. */
01830                 gtk_widget_set_can_default (close_button, TRUE);
01831                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), close_button, TRUE, TRUE, 0);
01832     
01833                 /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
01834                 gtk_widget_grab_default (close_button);
01835                 gtk_widget_show (close_button);
01836 
01837                 /* Finally show the new_window or Connection window */
01838                 gtk_widget_show (new_window);
01839         };

Here is the caller graph for this function:

void destroy ( GtkWidget *  widget,
gpointer  udata 
)

Definition at line 112 of file ipdcGui.c.

References tname.

Referenced by main().

00113         {
00114                 FILE *f;
00115                 char name[20],*psid,*psname,psN[15];
00116 
00117                 g_print ("\niPDC Closing....Bye\n\n");
00118                 system(" ps ux | awk '/bash/ && !/awk/ {print $2 ,$7}'>names.txt");
00119                 f = fopen("names.txt","r");
00120 
00121                 /* closing both the iPDC and extra termial we opened for displaying data */
00122                 int flag = 0;   
00123                 if (f != NULL)
00124                 {
00125                         memset(name,'\0',20);
00126                         memset(psN,'\0',15);
00127                         while (fgets (name, 20,f) != NULL)
00128                         {
00129                                 psid = strtok (name," "); 
00130                                 psname = strtok (NULL," "); 
00131                                 strncpy(psN,psname,5);
00132                                 if(strstr(tname,psN)) 
00133                                 {
00134                                         flag = 1;                       
00135                                         break;
00136                                 }       
00137                         }
00138                         if(flag)
00139                         {
00140                                 if(!kill(atoi(psid), SIGKILL))
00141                                 {
00142                                         printf("Sent a SIGKILL signal to Process ID %d\n",atoi(psid));
00143                                 } 
00144                                 else 
00145                                 {
00146                                         printf("Signal not sent to %d\n",(int)psid);
00147                                 }
00148                         }
00149                         fclose(f);
00150                         remove("names.txt");
00151                         exit(1);
00152                 } else {        
00153         
00154                         perror("names.txt");
00155         
00156                 }       
00157                 gtk_main_quit();
00158                 exit(1);
00159         };

Here is the caller graph for this function:

void display_pdc_detail ( GtkButton *  widget,
gpointer  udata 
)

Definition at line 168 of file ipdcGui.c.

References new_window.

Referenced by main().

00169         {
00170                 /* local variables */
00171                 char line[20];
00172                 char *markup;
00173                 GtkWidget *new_window, *table;
00174                 GtkWidget *label, *ok_button;
00175                 FILE *file_1;  
00176 
00177                 /* Open the file 'pdc.txt' in read mode */
00178                 file_1 = fopen ("pdc.txt","r");
00179                 if (file_1 != NULL)
00180                 {
00181                         /* If its available, then create a new dialog window for displaying the iPDC details. */
00182                         new_window = gtk_dialog_new ();
00183                         g_signal_connect (new_window, "destroy", G_CALLBACK (gtk_widget_destroy), new_window);
00184                         gtk_window_set_title (GTK_WINDOW (new_window), "iPDC Details");
00185                         gtk_container_set_border_width (GTK_CONTAINER (new_window), 10);
00186                         gtk_widget_set_size_request (new_window, 350, 350);
00187         
00188                         /* create a table of 6 by 2 squares. */
00189                         table = gtk_table_new (6, 2, FALSE);
00190     
00191                         /* set the spacing to 10 on x and 10 on y */
00192                         gtk_table_set_row_spacings (GTK_TABLE (table), 10);
00193                         gtk_table_set_col_spacings (GTK_TABLE (table), 10);
00194             
00195                         /* pack the table into the window */
00196                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG(new_window)->vbox), table, TRUE, TRUE, 0);
00197                         gtk_widget_show (table);
00198                         
00199                         /* Add a "close" button to the bottom of the dialog */
00200                         ok_button = gtk_button_new_with_label ("OK");
00201 
00202                         /* This simply creates a grid of labels on the table to demonstrate the window. 
00203                            g_markup_printf_escaped (): function to display diffrent color and font of text on label */
00204                         label = gtk_label_new (" ");
00205                         markup = g_markup_printf_escaped ("<span foreground=\"#990033\" font='12'><b>iPDC Details</b></span>");
00206                         gtk_label_set_markup (GTK_LABEL (label), markup);
00207                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
00208                         gtk_widget_show (label);
00209                         g_free (markup);
00210 
00211                         label = gtk_label_new ("iPDC ID Code      ");
00212                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
00213                         gtk_widget_show (label);
00214          
00215                         label = gtk_label_new ("iPDC UDP Port     ");
00216                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
00217                         gtk_widget_show (label);
00218 
00219                         label = gtk_label_new ("iPDC TCP Port      ");
00220                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
00221                         gtk_widget_show (label);
00222          
00223                         label = gtk_label_new ("Database Server IP");
00224                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
00225                         gtk_widget_show (label);
00226 
00227                         label = gtk_label_new ("Database Server Port");
00228                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6);
00229                         gtk_widget_show (label);
00230 
00231                         /* This simply read from file and print on label in the table. */
00232                         memset(line,'\0',sizeof(line));
00233                         fgets (line, 20, file_1);
00234                         label = gtk_label_new (line);
00235                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
00236                         gtk_widget_show (label);
00237 
00238                         memset(line,'\0',sizeof(line));
00239                         fgets (line, 20, file_1);                                                               
00240                         label = gtk_label_new (line);
00241                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3);
00242                         gtk_widget_show (label);
00243 
00244                         memset(line,'\0',sizeof(line));
00245                         fgets (line, 20, file_1);                                                               
00246                         label = gtk_label_new (line);
00247                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4);
00248                         gtk_widget_show (label);
00249  
00250                         memset(line,'\0',sizeof(line));
00251                         fgets (line, 20, file_1);                                                               
00252                         label = gtk_label_new (line);
00253                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 4, 5);
00254                         gtk_widget_show (label);
00255                         fclose (file_1);
00256                 
00257                         /* This is print static text (9000) on label in the table. */
00258                         label = gtk_label_new ("9000");
00259                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 5, 6);
00260                         gtk_widget_show (label);
00261 
00262                         /* Define signal on ok_button when it "clicked". */
00263                         g_signal_connect_swapped (ok_button, "clicked", G_CALLBACK (gtk_widget_destroy), new_window);
00264             
00265                         /* This makes it so the ok_button is the default. */
00266                         gtk_widget_set_can_default (ok_button, TRUE);
00267                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), ok_button, TRUE, TRUE, 0);
00268             
00269                         /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
00270                         gtk_widget_grab_default (ok_button);
00271                         gtk_widget_show (ok_button);
00272 
00273                         /* Finally show the new_window. */
00274                         gtk_widget_show (new_window);
00275                 }
00276         };

Here is the caller graph for this function:

void fill_pdc_details (  ) 

Definition at line 813 of file ipdcGui.c.

References _ChData::add_pdc_button, _ChData::add_pmu_button, _ChData::cmd_cfg_button, _ChData::cmd_data_off_button, _ChData::cmd_data_on_button, data, dbserver_ip, _ChData::display_conn_table_button, _ChData::enter_pdc_detail_menuitem, ipdc_help(), p_id, p_ip, p_tcp, p_udp, pdc_detail_window, _ChData::pdc_details_menuitem, PDC_IDCODE, recreate_cfg_objects(), recreate_Connection_Table(), _ChData::remove_pdc_button, _ChData::remove_pmu_button, setup(), TCPPORT, UDPPORT, validation_pdc_detail(), and validation_result().

Referenced by main(), and pdc_details().

00814         {
00815                 /* Open the file 'pdc.txt' in read mode */
00816                 FILE *file_1 = fopen ("pdc.txt","r");
00817                 if (file_1 != NULL)
00818                 {
00819                         char line[20];
00820 
00821                         /* If file is present initialize the global varialbes by details in file */
00822                         memset(line,'\0',sizeof(line));
00823                         fgets (line, 20, file_1);
00824                         PDC_IDCODE = atoi(line);
00825 
00826                         memset(line,'\0',sizeof(line));
00827                         fgets (line, 20, file_1);                                                               
00828                         UDPPORT = atoi(line);
00829 
00830                         memset(line,'\0',sizeof(line));
00831                         fgets (line, 20, file_1);                                                               
00832                         TCPPORT = atoi(line);
00833  
00834                         memset(line,'\0',sizeof(line));
00835                         fgets (line, 20, file_1);                                                               
00836                         strcpy(dbserver_ip, line);
00837                         fclose (file_1);
00838 
00839                         /* Desable the menuitem button if there is already enty for iPDC */
00840                         gtk_widget_set_sensitive(GTK_WIDGET(data->enter_pdc_detail_menuitem), FALSE);
00841 
00842                         /* Recreate the configuration objects and connection table */
00843                         recreate_cfg_objects();  
00844                         recreate_Connection_Table();
00845 
00846                         /* setup() call to stablish the connections if any */
00847                         setup();
00848                 }
00849                 else 
00850                 { 
00851                         /* local variables for iPDC Detail windows */
00852                         char *markup15;
00853                         GtkWidget *table, *label;
00854                         GtkWidget *valdbutton, *help_button;
00855           
00856                         /* Create a new dialog window for iPDC Setup */
00857                         pdc_detail_window = gtk_dialog_new ();
00858                         g_signal_connect (pdc_detail_window, "destroy", G_CALLBACK (gtk_widget_destroy), pdc_detail_window);
00859                         gtk_window_set_title (GTK_WINDOW (pdc_detail_window), "iPDC Setup");
00860                         gtk_container_set_border_width (GTK_CONTAINER (pdc_detail_window), 10);
00861                         gtk_widget_set_size_request (pdc_detail_window, 350, 350);
00862                  
00863                         /* Create a table of 6 by 2 squares. */
00864                         table = gtk_table_new (6, 2, FALSE);
00865             
00866                         /* Set the spacing to 15 on x and 25 on y */
00867                         gtk_table_set_row_spacings (GTK_TABLE (table), 15);
00868                         gtk_table_set_col_spacings (GTK_TABLE (table), 25);
00869             
00870                         /* Pack the table into the window */
00871                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG(pdc_detail_window)->vbox), table, TRUE, TRUE, 0);
00872                         gtk_widget_show (table);
00873 
00874                         /* Add few button to the bottom of the dialog */
00875                         valdbutton = gtk_button_new_with_label ("Add");
00876                         help_button = gtk_button_new_with_label ("Help");
00877             
00878                         /* This simply creates a grid of toggle buttons on the table */
00879                         label = gtk_label_new (" ");
00880                         markup15 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='12'><b>Fill iPDC Details</b></span>");
00881                         gtk_label_set_markup (GTK_LABEL (label), markup15);
00882                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
00883                         gtk_widget_show (label);
00884                         g_free (markup15);
00885          
00886                         label = gtk_label_new ("iPDC ID Code       ");
00887                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
00888                         gtk_widget_show (label);
00889          
00890                         label = gtk_label_new ("iPDC UDP Port      ");
00891                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
00892                         gtk_widget_show (label);
00893 
00894                         label = gtk_label_new ("iPDC TCP Port       ");
00895                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
00896                         gtk_widget_show (label);
00897          
00898                         label = gtk_label_new ("Database Server IP ");
00899                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
00900                         gtk_widget_show (label);
00901  
00902                         label = gtk_label_new ("Database Server Port");
00903                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6);
00904                         gtk_widget_show (label);
00905 
00906                         /* Create text boxes for user to enter appropriate values */
00907                         p_id = gtk_entry_new();
00908                         gtk_entry_set_max_length ((GtkEntry *)p_id, 5);
00909                         gtk_table_attach_defaults (GTK_TABLE (table), p_id, 1, 2, 1, 2);
00910                         gtk_widget_show (p_id);
00911  
00912                         p_udp = gtk_entry_new();
00913                         gtk_entry_set_max_length ((GtkEntry *)p_udp, 5);
00914                         gtk_table_attach_defaults (GTK_TABLE (table), p_udp, 1, 2, 2, 3);
00915                         gtk_widget_show (p_udp);
00916 
00917                         p_tcp = gtk_entry_new();
00918                         gtk_entry_set_max_length ((GtkEntry *)p_tcp, 5);
00919                         gtk_table_attach_defaults (GTK_TABLE (table), p_tcp, 1, 2, 3, 4);
00920                         gtk_widget_show (p_tcp);
00921  
00922                         p_ip = gtk_entry_new();
00923                         gtk_entry_set_max_length ((GtkEntry *)p_ip, 15);
00924                         gtk_table_attach_defaults (GTK_TABLE (table), p_ip, 1, 2, 4, 5);
00925                         gtk_widget_show (p_ip);
00926 
00927                         label = gtk_label_new ("9000");
00928                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 5, 6);
00929                         gtk_widget_show (label);
00930 
00931                         /* Disable all the (mentioned) buttons on main ipdc window */
00932                         gtk_widget_set_sensitive(GTK_WIDGET(data->add_pmu_button), FALSE);
00933                         gtk_widget_set_sensitive(GTK_WIDGET(data->remove_pmu_button), FALSE);
00934                         gtk_widget_set_sensitive(GTK_WIDGET(data->cmd_data_off_button), FALSE);
00935                         gtk_widget_set_sensitive(GTK_WIDGET(data->cmd_data_on_button), FALSE);
00936                         gtk_widget_set_sensitive(GTK_WIDGET(data->cmd_cfg_button), FALSE);
00937                         gtk_widget_set_sensitive(GTK_WIDGET(data->add_pdc_button), FALSE);
00938                         gtk_widget_set_sensitive(GTK_WIDGET(data->remove_pdc_button), FALSE);
00939                         gtk_widget_set_sensitive(GTK_WIDGET(data->display_conn_table_button), FALSE);
00940                         gtk_widget_set_sensitive(GTK_WIDGET(data->pdc_details_menuitem), FALSE);
00941                 
00942                         /* Signal handling for buttons on iPDC Setup Window */
00943                         g_signal_connect_swapped (pdc_detail_window, "destroy", G_CALLBACK (gtk_widget_destroy), pdc_detail_window);
00944                         g_signal_connect_swapped (valdbutton, "clicked", G_CALLBACK (validation_pdc_detail), NULL);
00945                         g_signal_connect_swapped (help_button, "clicked", G_CALLBACK (ipdc_help), NULL);
00946             
00947                         /* This makes it so the button is the default. */
00948                         gtk_widget_set_can_default (valdbutton, TRUE);
00949                         gtk_widget_set_can_default (help_button, TRUE);
00950                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pdc_detail_window)->action_area), valdbutton, TRUE, TRUE, 0);
00951                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (pdc_detail_window)->action_area), help_button, TRUE, TRUE, 0);
00952             
00953                         /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
00954                         gtk_widget_grab_default (valdbutton);
00955                         gtk_widget_show (valdbutton);
00956                         gtk_widget_grab_default (help_button);
00957                         gtk_widget_show (help_button);
00958 
00959                         /* Finally show the pdc_detail_window */
00960                         gtk_widget_show (pdc_detail_window);
00961                         validation_result ("\t\tEnter the details for iPDC setup.\t\t\n");                              
00962                 }
00963         };

Here is the call graph for this function:

Here is the caller graph for this function:

void ipdc_colors (  ) 

Definition at line 369 of file ipdcGui.c.

References _ChData::admin_label, data, _ChData::exit_button, _ChData::footer_label, _ChData::img_label, _ChData::wecome_button, and _ChData::welcome_ipdc.

Referenced by main().

00370         {
00371                 char *markup9, *markup10, *markup11;
00372 
00373                 /* Set the font and color for the heading on 'welcome_ipdc' lable */
00374                 markup9 = g_markup_printf_escaped ("<span foreground=\"#2F4F4F\" font='20'><b>\tPhasor Data Concentrator\n\t\t\t     iPDC</b></span>");
00375                 gtk_label_set_markup (GTK_LABEL (data->welcome_ipdc), markup9);
00376                 g_free (markup9);
00377 
00378                 markup10 = g_markup_printf_escaped ("<span foreground=\"#330000\" font='8'><b>\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</b>\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAll Rights Reserved</span>");//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<b>Indian Institute of Technology, Bombay</b></span>");
00379                 gtk_label_set_markup (GTK_LABEL (data->footer_label), markup10);
00380                 g_free (markup10);
00381 
00382                 markup11 = g_markup_printf_escaped ("<span foreground=\"#333333\" font='10'><b>Admin Operations</b></span>");
00383                 gtk_label_set_markup (GTK_LABEL (data->admin_label), markup11);
00384                 g_free (markup11);
00385 
00386                 /* Add a "close" button to the bottom of the dialog */  
00387                 GdkColor color;
00388                 GtkWidget *image, *image1;
00389                 gdk_color_parse( "#cccccc", &color ); 
00390                 gtk_widget_modify_bg( GTK_WIDGET(data->exit_button), GTK_STATE_NORMAL, &color );
00391 
00392                 gdk_color_parse( "#999999", &color ); 
00393                 gtk_widget_modify_bg( GTK_WIDGET(data->img_label), GTK_STATE_NORMAL, &color );
00394 
00395                 image = gtk_image_new_from_file("PSLAB.PNG");
00396                 gtk_image_get_pixel_size ((GtkImage *)image);
00397                 gtk_button_set_image ((GtkButton *)data->img_label, image);
00398                 gtk_widget_show (data->img_label);
00399 
00400                 /* Set the image (iPDC-logo) on a specific button */
00401                 image1 = gtk_image_new_from_file("ipdc_logo.png");
00402                 gtk_image_get_pixel_size ((GtkImage *)image1);
00403                 gtk_button_set_image ((GtkButton *)data->wecome_button, image1);
00404                 gtk_widget_show (data->wecome_button);
00405 
00406                 //gtk_label_get_bold (GtkLabel *label)          
00407                 //gtk_button_set_image (GtkButton *button, GtkWidget *image);
00408         };

Here is the caller graph for this function:

void ipdc_help ( GtkButton *  but,
gpointer  udata 
)

Definition at line 318 of file ipdcGui.c.

Referenced by add_new_pdc(), add_pmu(), cmd_or_remove_pmu(), fill_pdc_details(), and remove_pdc().

00319         {
00320                 /* local variables */
00321                 GtkWidget *help_dialog;
00322 
00323                 /* Create a about dialog for displaying iPDC help. */
00324                 help_dialog = gtk_about_dialog_new ();
00325 
00326                 /* Define the diffrent properties of about_dialog. */
00327                 gtk_about_dialog_set_program_name ((GtkAboutDialog *)help_dialog, "iPDC HELP\n\n");
00328                 gtk_about_dialog_set_comments ((GtkAboutDialog *)help_dialog, "1) ID Code ex. 50, 60, etc.\t\t\t\t\t\t\n\n     2) Port should be greater than 1500 and less than 65535.\n\n3) IP Address ex. 192.168.23.10\t\t\t\t\t");
00329 
00330                 /* Ensure that the dialog box is destroyed when the user responds */
00331                 g_signal_connect_swapped (help_dialog, "response", G_CALLBACK (gtk_widget_destroy), help_dialog);
00332 
00333                 /* Finally show the about_dialog. */
00334                 gtk_widget_show_all (help_dialog);
00335         };

Here is the caller graph for this function:

int isNumber ( char *  s  ) 

Definition at line 81 of file ipdcGui.c.

Referenced by add_pmu_validation(), cmd_or_remove_pmu_validation(), remove_pdc_validation(), and validation_pdc_detail().

00082         {
00083             int dot=0, num=0, end=0;
00084 
00085             while(isspace(*s))s++;
00086             if(*s == '-')s++;
00087             if(! *s)return 0;
00088             while(*s)
00089                 if(isspace(*s))
00090                     end=1, s++;
00091                 else if(end)
00092                     return 0;
00093                 else if(isdigit(*s))
00094                     num=1, s++;
00095                 else if(*s=='.')
00096                     if(dot)
00097                         return 0;  
00098                     else
00099                         dot=1,s++;        
00100                 else
00101                     return 0;
00102             return num;
00103         };

Here is the caller graph for this function:

int new_pdc_validation ( GtkButton *  but,
gpointer  udata 
)

Definition at line 707 of file ipdcGui.c.

References add_PDC(), checkip(), new_window, p_ip, p_protocol, and validation_result().

Referenced by add_new_pdc().

00708         {
00709                 /* local variables */
00710                 int ret;
00711                 const char *text, *text1;
00712                 char *errmsg1, ip[20], tmp[6];
00713         
00714                 /* Get the text entries for PDC, filled by user */
00715                 text = gtk_entry_get_text(GTK_ENTRY(p_ip));
00716                 text1 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(p_protocol));
00717                 memset(ip,'\0',20);
00718                 strcat(ip, text);
00719                 strcpy (tmp, text1);
00720 
00721                 if(!checkip(ip))                /* Check text_box entry for valid IP Address or not? */ 
00722                 {
00723                         errmsg1 = "\t\tPlease enter valid IP Addess of destination device\t\t\n";
00724                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00725                         return 0;
00726                 }
00727                 else            /* Only if all the text_box entries were right */ 
00728                 {
00729                         /* call add_PDC() to actual add pdc and start communication */ 
00730                         ret = add_PDC((char *)text, (char *)text1);
00731                         if (ret == 0)
00732                         {
00733                                 gtk_widget_destroy (new_window);                        
00734                                 
00735                                 errmsg1 = "\tDestination device successfully added\t\n";
00736                                 validation_result (errmsg1);    /* Show the success message to user */
00737                                 return 1;
00738                         }
00739                         else
00740                         {
00741                                 errmsg1 = "\t\tDevice details already exists\t\t\n";
00742                                 validation_result (errmsg1);    /* Show the unsuccess message to user */
00743                                 return 0;
00744                         }
00745                 }
00746         };

Here is the call graph for this function:

Here is the caller graph for this function:

void pdc_details ( GtkButton *  button,
gpointer  udata 
)

Definition at line 416 of file ipdcGui.c.

References fill_pdc_details().

Referenced by main().

00417         {
00418                 fill_pdc_details ();
00419         };

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_pdc ( GtkButton *  but,
gpointer  udata 
)

Definition at line 1481 of file ipdcGui.c.

References buff, i, Lower_Layer_Details::ip, ipdc_help(), new_window, p_ip, p_port, p_protocol, Lower_Layer_Details::port, Lower_Layer_Details::protocol, and remove_pdc_validation().

Referenced by main().

01482         {
01483                 /* local variables */
01484                 GtkWidget *scrolled_window, *label;
01485                 GtkWidget *table, *close_button;
01486                 GtkWidget *valdbutton, *help_button;
01487 
01488                 char line [40], *p_buff; 
01489                 char ip[20],protocol[6],port[6];
01490                 char *i,*p,*port_num, *markup4;
01491                 FILE *file_1;
01492   
01493                 /* Create a new dialog window for the scrolled window to be packed into */
01494                 new_window = gtk_dialog_new ();
01495                 g_signal_connect (new_window, "destroy", G_CALLBACK (gtk_widget_destroy), new_window);
01496                 gtk_window_set_title (GTK_WINDOW (new_window), "Remove Destination");
01497                 gtk_container_set_border_width (GTK_CONTAINER (new_window), 10);
01498                 gtk_widget_set_size_request (new_window, 450, 350);
01499     
01500                 /* Create a new scrolled window */
01501                 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
01502                 gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
01503     
01504                 /* The policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS. GTK_POLICY_AUTOMATIC will automatically decide whether you need scrollbars,
01505                    whereas GTK_POLICY_ALWAYS will always leave the scrollbars there. The first one is the horizontal scrollbar, the second is vertical. */
01506                 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
01507 
01508                 /* The dialog window is created with a vbox packed into it. */                                                          
01509                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(new_window)->vbox), scrolled_window, TRUE, TRUE, 0);
01510                 gtk_widget_show (scrolled_window);
01511     
01512                 /* create a table of 6 by 2 squares. */
01513                 table = gtk_table_new (6, 2, FALSE);
01514     
01515                 /* Set the spacing to 15 on x and 25 on y */
01516                 gtk_table_set_row_spacings (GTK_TABLE (table), 15);
01517                 gtk_table_set_col_spacings (GTK_TABLE (table), 25);
01518     
01519                 /* Pack the table into the scrolled window */
01520                 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), table);
01521                 gtk_widget_show (table);
01522 
01523                 /* Add few buttons to the bottom of the dialog */
01524                 close_button = gtk_button_new_with_label ("close");
01525                 valdbutton   = gtk_button_new_with_label ("Remove");
01526                 help_button  = gtk_button_new_with_label ("Help");
01527 
01528                 /* Open the "ipaddress.txt" file in read mode */
01529                 memset(buff,'\0',sizeof(buff));
01530                 file_1 = fopen ("upperpdc_ip.txt","r");
01531                 if (file_1 == NULL)
01532                 {
01533                         /* Place lable on a spacific position on table with text 'Sorry, No Records...!!!'*/
01534                         label = gtk_label_new (" ");
01535                         markup4 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Sorry, No Records...!!!\n--------------------------------------------------\n</b></span>");
01536                         gtk_label_set_markup (GTK_LABEL (label), markup4);
01537                         gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
01538                         gtk_widget_show (label);
01539                         g_free(markup4);
01540                 }
01541                 else 
01542                 { 
01543                         p_buff = " -------------------------------------------------------------------------------------------------\n|           IP              |          Port         |         Protocol         |\n-------------------------------------------------------------------------------------------------\n";
01544                         strcat(buff, p_buff);
01545                         memset(line,'\0',40);
01546 
01547                         while (fgets (line, 40,file_1) != NULL)         
01548                         { 
01549                                 memset(ip,'\0',20);
01550                                 memset(port,'\0',6);
01551                                 memset(protocol,'\0',6);
01552 
01553                                 /* Read the file data seprated by spaces and store into pointers */
01554                                 i = strtok (line," "); 
01555                                 port_num = strtok (NULL," "); 
01556                                 p = strtok (NULL," "); 
01557                                 
01558                                 /* Copy the data into variables */
01559                                 strcpy(ip, i);
01560                                 strcpy(port, port_num);
01561                                 strcpy(protocol, p);
01562         
01563                                 /* Concate all the data into a big buffer */
01564                                 strcat(buff, "|     ");
01565                                 strcat(buff, ip);
01566                                 strcat(buff, "\t\t");
01567                                 strcat(buff, port);
01568                                 strcat(buff, "\t\t    ");
01569                                 strncat(buff, protocol, 3);
01570                                 strcat(buff, "             |\n");
01571                                 strcat(buff, "-------------------------------------------------------------------------------------------------\n");
01572                         }
01573                         fclose (file_1);
01574 
01575                         /* This simply creates a grid of toggle buttons on the table to demonstrate the scrolled window. */
01576                         label = gtk_label_new (" ");
01577                         markup4 = g_markup_printf_escaped ("<span foreground=\"#990033\" font='10'><b>Destination Connection Details</b></span>");
01578                         gtk_label_set_markup (GTK_LABEL (label), markup4);
01579                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 0, 1);
01580                         gtk_widget_show (label);
01581                         g_free(markup4);
01582 
01583                         label = gtk_label_new (buff);
01584                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 2, 1, 2);
01585                         gtk_widget_show (label);
01586          
01587                         label = gtk_label_new ("Destination IP Address");
01588                         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
01589                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
01590                         gtk_widget_show (label);
01591 
01592                         label = gtk_label_new ("Destination Port       ");
01593                         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
01594                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4);
01595                         gtk_widget_show (label);
01596          
01597                         label = gtk_label_new ("Protocol                   ");
01598                         gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5);
01599                         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
01600                         gtk_widget_show (label);
01601 
01602                         /* Create text boxes for user to enter appropriate values */
01603                         p_ip = gtk_entry_new();
01604                         gtk_table_attach_defaults (GTK_TABLE (table), p_ip, 1, 2, 2, 3);
01605                         gtk_widget_show (p_ip);
01606 
01607                         p_port = gtk_entry_new();
01608                         gtk_table_attach_defaults (GTK_TABLE (table), p_port, 1, 2, 3, 4);
01609                         gtk_widget_show (p_port);
01610 
01611                         /* Create combo boxe for user with some fixed values */
01612                         p_protocol = gtk_combo_box_new_text();
01613                         gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "UDP");
01614                         gtk_combo_box_append_text(GTK_COMBO_BOX(p_protocol), "TCP");
01615                         gtk_combo_box_set_active(GTK_COMBO_BOX(p_protocol), 0);
01616                         gtk_table_attach_defaults (GTK_TABLE (table), p_protocol, 1, 2, 4, 5);
01617                         gtk_widget_show (p_protocol);
01618          
01619                         /* Signal handling for buttons on Remove PDC Window */
01620                         g_signal_connect_swapped (valdbutton, "clicked", G_CALLBACK (remove_pdc_validation), valdbutton);
01621                         g_signal_connect_swapped (help_button, "clicked", G_CALLBACK (ipdc_help), NULL);
01622             
01623                         /* This makes it so the button is the default. */
01624                         gtk_widget_set_can_default (valdbutton, TRUE);
01625                         gtk_widget_set_can_default (help_button, TRUE);
01626                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), valdbutton, TRUE, TRUE, 0);
01627                         gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), help_button, TRUE, TRUE, 0);
01628             
01629                         /* This grabs this button to be the default button. Simply hitting the "Enter" key will cause this button to activate. */
01630                         gtk_widget_grab_default (valdbutton);
01631                         gtk_widget_show (valdbutton);
01632                         gtk_widget_grab_default (help_button);
01633                         gtk_widget_show (help_button);
01634                 }
01635 
01636                 g_signal_connect_swapped (close_button, "clicked", G_CALLBACK (gtk_widget_destroy), new_window);
01637                 gtk_widget_set_can_default (close_button, TRUE);
01638                 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_window)->action_area), close_button, TRUE, TRUE, 0);
01639                 gtk_widget_grab_default (close_button);
01640                 gtk_widget_show (close_button);
01641 
01642                 /* Finally show the new_window */
01643                 gtk_widget_show (new_window);
01644         };

Here is the call graph for this function:

Here is the caller graph for this function:

int remove_pdc_validation ( GtkButton *  but,
gpointer  udata 
)

Definition at line 756 of file ipdcGui.c.

References checkip(), isNumber(), new_window, p_ip, p_port, p_protocol, remove_PDC(), and validation_result().

Referenced by remove_pdc().

00757         {
00758                 /* local variables */
00759                 int ret;
00760                 const char *text, *text1, *text2;
00761                 char *errmsg1, ip[20], tmp[6];
00762         
00763                 /* Get the text entries for remove source device by user */
00764                 text = gtk_entry_get_text(GTK_ENTRY(p_ip));
00765                 text1 = gtk_entry_get_text(GTK_ENTRY(p_port));
00766                 text2 = gtk_combo_box_get_active_text(GTK_COMBO_BOX(p_protocol));
00767                 memset(ip,'\0',20);
00768                 strcat(ip, text);
00769                 strcpy (tmp, text2);
00770 
00771                 if(!isNumber((char *)text) && (atoi(text1) < 1500 || (atoi(text1) > 65535)))    /* Check text_box entry for valid port or not? */               
00772                 { 
00773                         errmsg1 = "\tPlease enter valid value for destination device Port\t\n";
00774                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00775                         return 0;
00776                 }
00777                 else if(!checkip(ip))           /* Check text_box entry for valid IP Address or not? */ 
00778                 {
00779                         errmsg1 = "\tPlease enter valid IP Addess of destination device\t\n";
00780                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00781                         return 0;
00782                 }
00783                 else            /* Only if all the text_box entries were right */ 
00784                 {
00785                         /* Call remove_PDC() to remove PDC device entry as well as objects if it presents */
00786                         ret = remove_PDC((char *)text, (char *)text1, (char *)text2);
00787                         if (ret == 0)
00788                         {
00789                                 /* Close/destroy the remove PDC window */
00790                                 gtk_widget_destroy (new_window);                
00791                                         
00792                                 errmsg1 = "\tDestination device successfully removed\t\n";
00793                                 validation_result (errmsg1);    /* Show the success message to user */
00794                                 return 1;
00795                         }
00796                         else
00797                         {
00798                                 errmsg1 = "\t\tEntered destination device not found\t\t\n";
00799                                 validation_result (errmsg1);    /* Show the unsuccess message to user */
00800                                 return 0;
00801                         }
00802                 }
00803         };

Here is the call graph for this function:

Here is the caller graph for this function:

int validation_pdc_detail ( GtkButton *  button,
gpointer  udata 
)

Definition at line 429 of file ipdcGui.c.

References _ChData::add_pdc_button, _ChData::add_pmu_button, checkip(), _ChData::cmd_cfg_button, _ChData::cmd_data_off_button, _ChData::cmd_data_on_button, data, dbserver_ip, _ChData::display_conn_table_button, _ChData::enter_pdc_detail_menuitem, fp_updc, isNumber(), p_id, p_ip, p_tcp, p_udp, pdc_detail_window, _ChData::pdc_details_menuitem, PDC_IDCODE, recreate_cfg_objects(), _ChData::remove_pdc_button, _ChData::remove_pmu_button, setup(), TCPPORT, UDPPORT, and validation_result().

Referenced by fill_pdc_details().

00430         {
00431                 /* local variables */
00432                 char *errmsg1, ip[20];
00433                 const char *text, *text1, *text2, *text3;
00434         
00435                 /* Get the text entries filled by user */
00436                 text = gtk_entry_get_text(GTK_ENTRY(p_id));
00437                 text1 = gtk_entry_get_text(GTK_ENTRY(p_udp));
00438                 text2 = gtk_entry_get_text(GTK_ENTRY(p_tcp));
00439                 text3 = gtk_entry_get_text(GTK_ENTRY(p_ip));
00440                 memset(ip,'\0',20);
00441                 strcat(ip, text3);
00442 
00443                 if (!isNumber((char *)text))            /* Check text_box entry for valid integer or not?  */
00444                 { 
00445                         errmsg1 = "\tPlease enter valid value for iPDC ID code\t\n";
00446                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00447                         return 0;
00448                 }
00449                 else if(text1 != NULL && (atoi(text1) < 2000 || (atoi(text1) > 65535)))         /* Check text_box entry for valid port number or not? */        
00450                 { 
00451                         errmsg1 = "\tPlease enter valid value for iPDC UDP Port\t\n";
00452                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00453                         return 0;
00454                 }
00455                 else if((text2 != NULL) && ((atoi(text2) < 2000 || (atoi(text2) > 65535)) || (atoi(text2) == atoi(text1)))) /* TCP port should not match with UDP */                    
00456                 { 
00457                         errmsg1 = "\tPlease enter valid value for iPDC TCP Port,\nand it should be other then UDP Port";
00458                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00459                         return 0;
00460                 }
00461                 else if(!checkip(ip))           /* Check text_box entry for valid IP Address or not? */         
00462                 {
00463                         errmsg1 = "Please enter valid IP Addess for iPDC Database Server\n";
00464                         validation_result (errmsg1);            /* Show the unsuccess message to user */
00465                         return 0;
00466                 }
00467                 else            /* Only if all the text_box entries were right */ 
00468                 {
00469                         FILE *fp_updc;
00470 
00471                         /* Open the file "pdc.txt" and write all the enterd informations */
00472                         fp_updc = fopen ("pdc.txt","w");
00473                         fputs(text, fp_updc);
00474                         fputc('\n',fp_updc);    
00475                         PDC_IDCODE = atoi(text);
00476 
00477                         fputs(text1, fp_updc);
00478                         fputc('\n',fp_updc);    
00479                         UDPPORT = atoi(text1);
00480 
00481                         TCPPORT = atoi(text2);
00482                         fputs(text2, fp_updc);
00483                         fputc('\n',fp_updc);    
00484 
00485                         fputs(text3, fp_updc);
00486                         strcpy(dbserver_ip, (char *) text3);
00487                         fclose(fp_updc);
00488 
00489                         /* Close/destroy the pdc_detail_window */
00490                         gtk_widget_destroy (pdc_detail_window);                 
00491 
00492                         /* Enable all (mentioned) buttons on main ipdc window */
00493                         gtk_widget_set_sensitive(GTK_WIDGET(data->add_pmu_button), TRUE);
00494                         gtk_widget_set_sensitive(GTK_WIDGET(data->remove_pmu_button), TRUE);
00495                         gtk_widget_set_sensitive(GTK_WIDGET(data->cmd_data_off_button), TRUE);
00496                         gtk_widget_set_sensitive(GTK_WIDGET(data->cmd_data_on_button), TRUE);
00497                         gtk_widget_set_sensitive(GTK_WIDGET(data->cmd_cfg_button), TRUE);
00498                         gtk_widget_set_sensitive(GTK_WIDGET(data->add_pdc_button), TRUE);
00499                         gtk_widget_set_sensitive(GTK_WIDGET(data->remove_pdc_button), TRUE);
00500                         gtk_widget_set_sensitive(GTK_WIDGET(data->display_conn_table_button), TRUE);
00501                         gtk_widget_set_sensitive(GTK_WIDGET(data->pdc_details_menuitem), TRUE);
00502 
00503                         /* Disable the menuitem for iPDC details entries */
00504                         gtk_widget_set_sensitive(GTK_WIDGET(data->enter_pdc_detail_menuitem), FALSE);
00505                                         
00506                         /* setup() call to stablish the connections at iPDC restart */
00507                         recreate_cfg_objects();
00508                         setup();                        
00509 
00510                         errmsg1 = "\t\tiPDC Setup Successfully Done\t\t\n";
00511                         validation_result (errmsg1);            /* Show the success message to user */
00512                         return 1;
00513                 }
00514         };

Here is the call graph for this function:

Here is the caller graph for this function:

void validation_result ( char *  msg  ) 

Definition at line 343 of file ipdcGui.c.

Referenced by add_pmu_validation(), cmd_or_remove_pmu_validation(), fill_pdc_details(), new_pdc_validation(), remove_pdc_validation(), and validation_pdc_detail().

00344         {
00345                 /* local variables */
00346                 GtkWidget *val_dialog;
00347 
00348                 /* Create a new about dialog to displaying the status message of last performed operation. */
00349                 val_dialog = gtk_about_dialog_new ();
00350 
00351                 /* Define the diffrent properties of val_dialog. */
00352                 gtk_about_dialog_set_program_name ((GtkAboutDialog *)val_dialog, " ");
00353                 gtk_about_dialog_set_comments ((GtkAboutDialog *)val_dialog, msg);
00354                 
00355                 /* Ensure that the dialog box is destroyed when the user responds */
00356                 g_signal_connect_swapped (val_dialog, "response", G_CALLBACK (gtk_widget_destroy), val_dialog);
00357 
00358                 /* Finally show the val_dialog. */
00359                 gtk_widget_show_all (val_dialog);
00360         };

Here is the caller graph for this function:


Variable Documentation

GtkWidget* add_pmu_window

Definition at line 83 of file ipdcGui.h.

Referenced by add_pmu(), and add_pmu_validation().

char buff[8000]

Definition at line 79 of file ipdcGui.h.

Referenced by cmd_or_remove_pmu(), connection_table(), and remove_pdc().

Definition at line 81 of file ipdcGui.h.

Referenced by fill_pdc_details(), ipdc_colors(), main(), and validation_pdc_detail().

char find_butn[2]

Definition at line 78 of file ipdcGui.h.

Referenced by cmd_or_remove_pmu(), and cmd_or_remove_pmu_validation().

GtkWidget* new_window
GtkWidget* p_id
GtkWidget * p_ip
GtkWidget* p_port

Definition at line 86 of file ipdcGui.h.

Referenced by add_pmu(), add_pmu_validation(), remove_pdc(), and remove_pdc_validation().

GtkWidget * p_protocol
GtkWidget * p_tcp

Definition at line 85 of file ipdcGui.h.

Referenced by fill_pdc_details(), and validation_pdc_detail().

GtkWidget * p_udp

Definition at line 85 of file ipdcGui.h.

Referenced by fill_pdc_details(), and validation_pdc_detail().

GtkWidget* pdc_detail_window

Definition at line 82 of file ipdcGui.h.

Referenced by fill_pdc_details(), and validation_pdc_detail().

pthread_t show_sys_time

Definition at line 87 of file ipdcGui.h.

long int time_thrd_id

Definition at line 80 of file ipdcGui.h.

Generated on Tue Jun 7 13:37:00 2011 for iPDC-(PhasorDataConcentrator) by  doxygen 1.6.3