Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (871 Bytes)

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

    
31
        sigset_t set;
32
        //TODO: errors
33
        sigemptyset(&set);
34
        sigaddset(&set, SIGCHLD);
35
        pthread_sigmask(SIG_BLOCK, &set, NULL);
36
        g_thread_init(NULL);
37
        gdk_threads_init();
38
        g_thread_create(robot_event_loop, NULL, TRUE, NULL);
39
        
40
        //TODO: better thread to put this in?
41
        sigemptyset(&set);
42
        sigaddset(&set, SIGCHLD);
43
        pthread_sigmask(SIG_UNBLOCK, &set, NULL);
44
        
45
        gtk_gui_run(argc, argv);
46

    
47
        return 0;
48
}
49