pmu.c File Reference

#include <stdio.h>
#include <signal.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <gtk/gtk.h>
#include "PmuGui.h"
#include "ServerFunction.h"
#include "CfgGuiFunctions.h"
#include "CfgFunction.h"
Include dependency graph for pmu.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define UI_fILE   "pmu.glade"
#define GW(name)   CH_GET_WIDGET(builder, name, pmu_data)

Functions

int main (int argc, char **argv)

Define Documentation

#define GW ( name   )     CH_GET_WIDGET(builder, name, pmu_data)

Referenced by main().

#define UI_fILE   "pmu.glade"

Definition at line 47 of file pmu.c.

Referenced by main().


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 53 of file pmu.c.

References _pmuStruct::about_menuitem, about_pmu(), cfg_chng_options(), cfg_create_function(), _pmuStruct::cfg_modification_button, create_cfg(), _pmuStruct::create_cfg_button, destroy(), _pmuStruct::E_button, _pmuStruct::exit_button, _pmuStruct::exit_menuitem, GW, hdr_create_function(), _pmuStruct::header_frm_button, pid, pmu_colors(), pmu_data, _pmuStruct::pmu_details_button, pmu_server(), _pmuStruct::Pmu_Simulator, show_pmu_details(), start_server(), and UI_fILE.

00054         {
00055                 /* local variables */
00056                 GtkBuilder *builder;
00057                 GError     *error = NULL;
00058 
00059                 pid = fork();
00060                 if (pid == 0) 
00061                 {
00062                         /* Child process for PMU SERVER Setup */
00063                         start_server();
00064                 }
00065                 else 
00066                 {      
00067                         /* Main process for PMU Configuration Setup */
00068 
00069                         /* Init GTK+ */
00070                         gtk_init(&argc, &argv);         
00071 
00072                         /* Create new GtkBuilder object */
00073                         builder = gtk_builder_new();
00074 
00075                         /* Add glade file to GtkBuilder */
00076                         if(!gtk_builder_add_from_file(builder, UI_fILE, &error))
00077                         {
00078                                 g_warning("%s", error->message);
00079                                 g_free(error);
00080                                 return(1);
00081                         }
00082         
00083                         /* Allocate data structure */
00084                         pmu_data = g_slice_new(pmuStruct);
00085 
00086                         /* Get objects from UI */
00087                         #define GW(name) CH_GET_WIDGET(builder, name, pmu_data)
00088                         GW(Pmu_Simulator);
00089                         GW(create_cfg_button);
00090                         GW(header_frm_button);
00091                         GW(pmu_details_button);
00092                         GW(cfg_modification_button);
00093                         GW(pmu_menubar);
00094                         GW(img_label);
00095                         GW(welcome_pmu);
00096                         GW(admin_label);
00097                         GW(logo_butun);
00098                         GW(exit_button);
00099                         GW(footer_label);
00100                         GW(about_menuitem);
00101                         GW(exit_menuitem);
00102                         GW(E_button);
00103                         #undef GW 
00104         
00105                         /* Connect signal to builder */
00106                         gtk_builder_connect_signals(builder, pmu_data);
00107                         gtk_builder_connect_signals(builder, NULL);
00108 
00109                         /* Set the Title of Main Window */
00110                         gtk_window_set_title (GTK_WINDOW (pmu_data->Pmu_Simulator), "PMU Simulator");
00111 
00112                         /* Open the file "PmuServer.txt" in read mode */
00113                         FILE *file_1 = fopen ("PmuServer.txt","rb");
00114                         if (file_1 == NULL)
00115                         {
00116                                 pmu_server();
00117                         }
00118                         else 
00119                         {
00120                                 fclose(file_1);
00121                                 //validation_result ("\t\tPMU Server run successfully.\t\t\n");
00122                         }
00123 
00124                         /* Open the file "cfg2.bin" in read mode */
00125                         file_1 = fopen ("cfg2.bin","rb");
00126                         if (file_1 != NULL)
00127                         {
00128                                 fclose(file_1);
00129                                 create_cfg();
00130 
00131                                 /* Disable the create Configuration button because cfg is already present in the system */
00132                                 gtk_widget_set_sensitive(GTK_WIDGET(pmu_data->create_cfg_button), FALSE);
00133                         }
00134                         else
00135                         {
00136                                 /* Disable all buttons except create Configuration button because cfg is not present in the system */
00137                                 gtk_widget_set_sensitive(GTK_WIDGET(pmu_data->header_frm_button), FALSE);
00138                                 gtk_widget_set_sensitive(GTK_WIDGET(pmu_data->pmu_details_button), FALSE);
00139                                 gtk_widget_set_sensitive(GTK_WIDGET(pmu_data->cfg_modification_button), FALSE);
00140                         }               
00141 
00142                         /* Decorate the GUI */
00143                         pmu_colors();
00144 
00145                         /* Signal handling for buttons on  Main PMU Window */
00146                         g_signal_connect (pmu_data->create_cfg_button, "clicked", G_CALLBACK(cfg_create_function), NULL); 
00147                         g_signal_connect (pmu_data->header_frm_button, "clicked", G_CALLBACK(hdr_create_function), NULL); 
00148                         g_signal_connect (pmu_data->cfg_modification_button, "clicked", G_CALLBACK(cfg_chng_options), NULL); 
00149                         g_signal_connect (pmu_data->pmu_details_button, "clicked", G_CALLBACK(show_pmu_details), NULL); 
00150                         g_signal_connect (pmu_data->exit_button, "clicked", G_CALLBACK (destroy), NULL);
00151                         g_signal_connect (pmu_data->about_menuitem, "button_press_event", G_CALLBACK(about_pmu), NULL);
00152                         g_signal_connect (pmu_data->exit_menuitem, "button_press_event", G_CALLBACK(destroy), NULL);
00153                         g_signal_connect (pmu_data->E_button, "clicked", G_CALLBACK(destroy), NULL);
00154                         g_signal_connect_swapped (pmu_data->Pmu_Simulator, "destroy", G_CALLBACK (destroy), NULL);
00155 
00156                         /* Destroy builder, since we don't need it anymore */
00157                         g_object_unref(G_OBJECT(builder));
00158 
00159                         /* Show window. All other widgets are automatically shown by GtkBuilder */
00160                         gtk_widget_show(pmu_data->Pmu_Simulator);
00161 
00162                         /* GTK Main */
00163                         gtk_main();
00164 
00165                         /* Free any allocated data */
00166                         g_slice_free(pmuStruct, pmu_data);
00167                 }
00168                 return(0);
00169         }

Here is the call graph for this function:

Generated on Tue Jun 7 13:44:18 2011 for PMUSimulator by  doxygen 1.6.3