Statistics
| Revision:

root / branches / simulator / projects / simulator / simulator / core / main.c @ 1044

History | View | Annotate | Download (1.3 KB)

1
/**
2
 * @file main.c
3
 * @author Colony Project
4
 * @brief Initializes the program.
5
 *
6
 * Contains only the main function, which
7
 * initializes the program.
8
 **/
9

    
10
#include <stdlib.h>
11
#include <stdio.h>
12
#include <gtk/gtk.h>
13
#include <glib.h>
14
#include <signal.h>
15

    
16
#include "gtk_gui.h"
17
#include "robot.h"
18

    
19
int main(int argc, char** argv)
20
{
21
        if (robots_initialize())
22
                return -1;
23

    
24
        if(argc<=1){
25
                printf("Usage: simulator <robot execetuable>\n");
26
                exit(-1);
27
        }
28

    
29

    
30
        robot_create(argv[1]);
31
        /*robot_create(argv[1]);
32
        robot_create(argv[1]);
33
        robot_create(argv[1]);
34
        robot_create(argv[1]);
35
        robot_create(argv[1]);
36
        robot_create(argv[1]);
37
        robot_create(argv[1]);
38
        robot_create(argv[1]);
39
        robot_create(argv[1]);
40
        robot_create(argv[1]);
41
        robot_create(argv[1]);
42
        robot_create(argv[1]);
43
        robot_create(argv[1]);
44
        robot_create(argv[1]);
45
        robot_create(argv[1]);
46
        robot_create(argv[1]);
47
        robot_create(argv[1]);
48
        robot_create(argv[1]);
49
        robot_create(argv[1]);
50
        */
51

    
52

    
53
        sigset_t set;
54
        //TODO: errors
55
        sigemptyset(&set);
56
        sigaddset(&set, SIGCHLD);
57
        pthread_sigmask(SIG_BLOCK, &set, NULL);
58
        g_thread_init(NULL);
59
        gdk_threads_init();
60
        g_thread_create(robot_event_loop, NULL, TRUE, NULL);
61
        
62
        //TODO: better thread to put this in?
63
        sigemptyset(&set);
64
        sigaddset(&set, SIGCHLD);
65
        pthread_sigmask(SIG_UNBLOCK, &set, NULL);
66
        
67
        gtk_gui_run(argc, argv);
68

    
69
        return 0;
70
}
71