forked from tlgimenes/X-CubeSat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
97 lines (73 loc) · 2.65 KB
/
main.cpp
File metadata and controls
97 lines (73 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* X-CubeSat Controller: Real-time communication with satellite program
Copyright (C) 2014 - Tiago Lobato Gimenes
Authors: Tiago Lobato Gimenes <tlgimenes@gmail.com>
Comments, questions and bugreports should be submitted via
https://github.com/tlgimenes/X-CubeSat
More details can be found at the project home page:
https://github.com/tlgimenes/X-CubeSat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, visit http://www.fsf.org/
*/
#include <gtkmm.h>
#include <sqlite3.h>
#include <libsqlitewrapped.h>
#include <iostream>
#include <istream>
#include "log.hpp"
#include "main_window_callback.hpp"
#include "menu.hpp"
#include "manager.hpp"
#include "init.hpp"
#include "defs.hpp"
/* -------------------------------------------------------- */
/* Flush the content in the fifo file to allow to
* track the most recent satellite
*/
void flush_fifo_file(const char *fileName);
/* -------------------------------------------------------- */
/* -------------------------------------------------------- */
/* MAIN FUNCTION
*/
int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
Manager *man;
Terminal *term;
flush_fifo_file(FIFO_FILE);
Log::init();
DataBase::init();
Init::XCubeSat_Controller_start(&man, &term);
MainWindowCallback * mainWindow = new MainWindowCallback(man, term, &kit);
// Main loop for the program
kit.run(*(mainWindow->get_main_window()));
kit.quit();
return 0;
}
/* -------------------------------------------------------- */
/* -------------------------------------------------------- */
#define GET_FIFO_LINE(garbage) \
fifo.getline(garbage, MAX_M_SIZE); \
fifo.getline(garbage, MAX_M_SIZE); \
fifo.getline(garbage, MAX_M_SIZE);
/* -------------------------------------------------------- */
void flush_fifo_file(const char *fileName)
{
std::ifstream fifo(fileName, std::ifstream::in);
char *garbage = new char[MAX_M_SIZE];
if(fifo) {
GET_FIFO_LINE(garbage);
while(!fifo.eof()) {
GET_FIFO_LINE(garbage);
}
}
fifo.close();
}
/* -------------------------------------------------------- */