You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SimpleSkyCam/main.cc

130 lines
2.9 KiB

/***************************************************************************************
*
* main.cc is part of SimpleSkyCam.
*
*****************************************************************************************/
#include <sys/time.h>
#include <execinfo.h>
#include "simpleskycam.h"
#include "config.h"
#include "configuration.h"
#include "gui.h"
#include "filter.h"
#include "detect.h"
#include "convert.h"
#include "ser.h"
#include "dng.h"
/**************************************************************************
* global variables
**************************************************************************/
GtkBuilder *_builder_ = NULL; // work around for the thread situation
Filter filter;
Detect detect;
Configuration config;
PosCtl posctl;
int main (int argc, char **argv) {
GtkBuilder *builder;
GObject *window;
#ifdef BUILD_WINDOWS
char buffer[16];
setvbuf (stdout, buffer, _IONBF, 16);
#endif
printf ("SimpleSkyCam - %s\n", VERSION);
printf (" written by Steffen Pohle <steffen@gulpe.de>\n");
printf ("\n");
printf ("Command Line Options for testing purpose:\n");
printf (" -d <debugpath> destination for video debugging path\n");
printf (" -dd disable debugging path\n");
printf ("\n");
printf (" -rd <debugpath> read video from dumpfile folder\n");
printf ("\n");
printf ("\n");
for (int i = 1; i < argc; i++) {
if (strcmp (argv[i], "-d") == 0) {
i++;
config.debugpath = argv[i];
}
if (strcmp (argv[i], "-dd") == 0) {
i++;
config.debugpath = NULL;
}
if (strcmp (argv[i], "-rd") == 0) {
i++;
config.readdumppath = argv[i];
}
}
gtk_init (&argc, &argv);
_builder_ = builder = gtk_builder_new ();
gtk_builder_add_from_file (builder, BUILDER_FILE, NULL);
gtk_builder_connect_signals(builder, builder);
window = gtk_builder_get_object (builder, "window-main");
if(window == NULL) {
printf("ERROR: gtk_builder_get_object() failed\n");
return 1;
}
gtk_widget_show_all (GTK_WIDGET(window));
gtk_main ();
return 0;
}
float get_cycletime(struct timeval *t) {
struct timeval t1;
float f = 0.0;
t1 = *t;
gettimeofday(t, NULL);
f = (float)(t->tv_sec - t1.tv_sec) + ((t->tv_usec - t1.tv_usec) / 1000000.0);
return f;
}
/*
* print error message and the backtrace
*/
#define SIZE 100
void errorexit (char *fmt,...) {
//
// error message
va_list args;
char text[4096];
va_start (args, fmt);
vsnprintf (text, 4096, fmt, args);
va_end (args);
printf ("***************************\n");
printf (" ERROR\n");
printf ("***************************\n");
printf ("%s", text);
//
// backtrace
int j, nptrs;
void *buffer[SIZE];
char **s;
nptrs = backtrace(buffer, SIZE);
if ((s = (char**) backtrace_symbols(buffer, nptrs)) == NULL) {
for (j = 0; j < nptrs; j++) printf ("%-5d %p\n", j, buffer[j]);
}
else {
for (j = 0; j < nptrs; j++) printf ("%-5d %s\n", j, s[j]);
}
exit (-1);
}