5c70d9d85a6f690ae5c591b7d884677efad7fbaa
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

1) /*
2)  * EtherPix simulator
3)  *
4)  * Copyright 2017 Stefan Schuermans <stefan schuermans info>
5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #include <gtkmm.h>
21) #include <iostream>
22) #include <string.h>
23) 
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

24) #include "config.h"
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

25) #include "etherpix_sim.glade.h"
26) #include "main_window.h"
27) 
28) int main(int argc, char *argv[])
29) {
30)   // instantiate GTK main loop
31)   Gtk::Main kit(argc, argv);
32) 
33)   // parse arguments
34)   if (argc < 2) {
35)     std::cerr << "usage: " << argv[0] << " <sim_config.etps>" << std::endl;
36)     return 2;
37)   }
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

38)   char *configFile = argv[1];
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

39) 
40)   try {
41) 
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

42)     // parse config file
43)     Config config(configFile);
44) 
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

45)     // create window
46)     Glib::RefPtr<Gtk::Builder> builder =
47)       Gtk::Builder::create_from_string(widgets_etherpix_sim);
48) 
49)     // connect main window to its class
50)     MainWindow *mainWindow;
51)     builder->get_widget_derived("MainWindow", mainWindow);
Stefan Schuermans implement drawing pixels

Stefan Schuermans authored 7 years ago

52)     mainWindow->setConfig(config);
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

53) 
54)     // append config file name to window title
Stefan Schuermans begin of config file parsing

Stefan Schuermans authored 7 years ago

55)     mainWindow->set_title(mainWindow->get_title() + " - " + configFile);
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

56) 
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

57)     // start operation
58)     config.start();
59) 
Stefan Schuermans begin of simulator: window...

Stefan Schuermans authored 7 years ago

60)     // run GTK main loop
61)     Gtk::Main::run();
62) 
Stefan Schuermans implement receiving packets

Stefan Schuermans authored 7 years ago

63)     // stop operation
64)     config.stop();
65)