Version 8.9.0
 
Loading...
Searching...
No Matches
examples/generic/daemon/irDirectDaemon.cpp

Cross platform example: This example shows the implementation of a TCP streaming server application.

Cross platform example: This example shows the implementation of a TCP streaming server application.

#include <iostream>
#ifdef _WIN32
//needed before windows.h ...
#include<winsock2.h>
#include<WS2tcpip.h>
#else
#include <csignal>
#endif
// Optris logging interface
#include <IRLogger.h>
// Class wrapping callback routines
#include "IRDaemon.h"
#define DIRECT_DAEMON_PORT 1337
evo::IRDaemon* _daemon = NULL;
#ifdef _WIN32
BOOL ctrlHandler(DWORD fdwCtrlType)
{
if(_daemon) _daemon->exit();
return true;
}
#else
void sigHandler(int signum)
{
if(_daemon) _daemon->exit();
}
#endif
int main(int argc, char* argv[])
{
//-- Adjust Log level ------------------------------------------------------------
evo::IRLogger::setVerbosity(evo::IRLOG_ERROR, evo::IRLOG_OFF, "daemon.log");
//--------------------------------------------------------------------------------
//-- Install signal handler-------------------------------------------------------
#ifdef _WIN32
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ctrlHandler, TRUE);
#else
std::signal(SIGINT, sigHandler);
#endif
//--------------------------------------------------------------------------------
//-- Read device parameters ------------------------------------------------------
if(argc < 2)
{
std::cout << "No parameters given, taking default parameters. If you want to specify your own parameters, pass an xml file:" << std::endl << " ";
std::cout << argv[0] << " <path to xml file>" << std::endl;
IRDeviceParams_InitDefault(params);
}
else
{
}
IRDeviceParams_Print(params);
//--------------------------------------------------------------------------------
//-- IRDaemon instantiation ------------------------------------------------------
_daemon = new evo::IRDaemon();
_daemon->run(&params, DIRECT_DAEMON_PORT);
delete _daemon;
//--------------------------------------------------------------------------------
return 0;
}
Daemon providing IRImager data via TCP.
Definition: IRDaemon.h:27
void exit()
Notifies run method to terminate.
bool run(evo::IRDeviceParams *params, int port)
Blocking run method: Instantiates camera and streaming objects.
static bool readXMLC(const char *xmlFile, IRDeviceParams &params)
Static xml parsing method for 8-bit character path.
static void setVerbosity(IRLoggerVerbosityLevel levelStdout, IRLoggerVerbosityLevel levelFile, const char *filename=NULL)
Change verbosity level.
Structure containing device parameters.
Definition: IRDeviceParams.h:125