2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-22 22:06:13 +02:00
|
|
|
// C++ includes
|
|
|
|
#include <csignal>
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
// QT includes
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
2013-08-14 10:54:49 +02:00
|
|
|
// Json-Schema includes
|
|
|
|
#include <utils/jsonschema/JsonFactory.h>
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
// Hyperion includes
|
2013-08-14 10:54:49 +02:00
|
|
|
#include <hyperion/Hyperion.h>
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-17 16:12:42 +02:00
|
|
|
// Dispmanx grabber includes
|
|
|
|
#include <dispmanx-grabber/DispmanxWrapper.h>
|
|
|
|
|
2013-08-17 15:39:29 +02:00
|
|
|
// JsonServer includes
|
|
|
|
#include <jsonserver/JsonServer.h>
|
|
|
|
|
2013-08-22 22:06:13 +02:00
|
|
|
void signal_handler(const int signum)
|
|
|
|
{
|
|
|
|
QCoreApplication::quit();
|
|
|
|
}
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2013-08-15 21:11:02 +02:00
|
|
|
// Initialising QCoreApplication
|
2013-08-13 11:10:45 +02:00
|
|
|
QCoreApplication app(argc, argv);
|
2013-08-15 21:11:02 +02:00
|
|
|
std::cout << "QCoreApplication initialised" << std::endl;
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-22 22:06:13 +02:00
|
|
|
signal(SIGINT, signal_handler);
|
|
|
|
signal(SIGTERM, signal_handler);
|
|
|
|
|
2013-08-21 16:25:27 +02:00
|
|
|
if (argc < 2)
|
2013-08-14 10:54:49 +02:00
|
|
|
{
|
2013-08-21 16:25:27 +02:00
|
|
|
std::cout << "Missing required configuration file. Usage:" << std::endl;
|
|
|
|
std::cout << "hyperiond [config.file]" << std::endl;
|
|
|
|
return 0;
|
2013-08-14 10:54:49 +02:00
|
|
|
}
|
|
|
|
|
2013-08-22 07:57:46 +02:00
|
|
|
const std::string configFile = argv[1];
|
2013-08-21 16:25:27 +02:00
|
|
|
std::cout << "Selected configuration file: " << configFile.c_str() << std::endl;
|
|
|
|
|
|
|
|
Hyperion hyperion(configFile);
|
2013-08-15 21:11:02 +02:00
|
|
|
std::cout << "Hyperion created and initialised" << std::endl;
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-14 10:54:49 +02:00
|
|
|
DispmanxWrapper dispmanx(64, 64, 10, &hyperion);
|
2013-08-13 11:10:45 +02:00
|
|
|
dispmanx.start();
|
2013-08-15 21:11:02 +02:00
|
|
|
std::cout << "Frame grabber created and started" << std::endl;
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-08-17 15:39:29 +02:00
|
|
|
JsonServer jsonServer(&hyperion);
|
|
|
|
std::cout << "Json server created and started on port " << jsonServer.getPort() << std::endl;
|
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
app.exec();
|
2013-08-15 21:11:02 +02:00
|
|
|
std::cout << "Application closed" << std::endl;
|
2013-08-22 22:06:13 +02:00
|
|
|
|
|
|
|
// Stop the frame grabber
|
|
|
|
dispmanx.stop();
|
|
|
|
// Clear all colors (switchting off all leds)
|
|
|
|
hyperion.clearall();
|
2013-08-13 11:10:45 +02:00
|
|
|
}
|