Project

General

Profile

Statistics
| Revision:

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

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

    
68
        return 0;
69
}
70