#ifdef WIN32
#include <windows.h>
#else
#include <csignal>
#endif
static void Exithandler(int sig);
#ifdef WIN32
BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
Exithandler(CEvent);
return TRUE;
}
#endif
#include <iostream>
#include <thread>
#include <chrono>
#include <atomic>
static std::atomic<bool> running(true);
static const uint32_t numberOfSamplesToGrab = 1000;
{
{
static uint32_t samplesGrabbed = 0;
if (samplesGrabbed++ >= numberOfSamplesToGrab)
running = false;
}
} listener;
static void Exithandler(int sig)
{
running = false;
}
int main(int argc, char *argv[])
{
#ifdef WIN32
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
#else
signal(SIGTERM, Exithandler);
signal(SIGKILL, Exithandler);
signal(SIGQUIT, Exithandler);
signal(SIGINT, Exithandler);
#endif
try
{
#ifdef WIN32
#else
#endif
std::cout <<
"Running PST Server version " << pst.
GetVersionInfo() <<
"\n";
std::cout <<
"System check: " << (int)pst.
Systemcheck() <<
"\n\n";
std::cout << "***************************\n\n";
std::cout <<
"Frame rate set to " << pst.
GetFramerate() <<
" Hz\n";
double min, max;
std::cout << "Exposure range: " << min << " s - " << max << " s\n";
std::cout << "Set exposure to " << max << "\n";
std::cout <<
"Check new exposure: " << pst.
GetExposure() <<
" s\n\n";
std::cout << "***************************\n\n";
std::cout << "Set frame rate to 60 Hz\n";
std::cout <<
"Frame rate set to " << pst.
GetFramerate() <<
" Hz\n";
std::cout <<
"Check exposure: " << pst.
GetExposure() <<
" s\n";
std::cout << "New exposure range " << min << " s - " << max << " s\n\n";
std::cout << "***************************\n\n";
double exposureHalf = min + (max - min) / 2.0;
std::cout << "Set exposure half way: " << exposureHalf << " s\n";
std::cout <<
"New exposure: " << pst.
GetExposure() <<
" s\n\n";
std::cout << "***************************\n\n";
while (running)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
{
}
std::cout << "Press enter to continue...\n";
std::cin.get();
return 0;
}