Statistics
| Revision:

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

History | View | Annotate | Download (1.36 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
#include "world.h"
19

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

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

    
30
        load_world("../../test/world.txt", 100);
31

    
32

    
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
        robot_create(argv[1]);
51
        robot_create(argv[1]);
52
        robot_create(argv[1]);
53

    
54

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

    
71
        return 0;
72
}
73