#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)
{
exit(0);
}
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 <<
"Current frame rate: " << pst.
GetFramerate() <<
" Hz\n\n";
std::cout <<
"Enabled image transfer. Current frame rate: " << pst.
GetFramerate() <<
" Hz\n\n";
std::cout << "***************************\n\n";
for (int i = 0; i < 100; ++i)
{
std::cout << "Retrieval operation " << ((succes) ? "successful!\n" : "unsuccessful!\n\n");
if (succes)
{
std::cout <<
"Retrieved " << images.
images.
size() <<
" image(s) of size: " << images.
width <<
" X " << images.
height <<
"\n\n";
}
std::this_thread::sleep_for(std::chrono::milliseconds(17));
}
std::cout << "Waiting 5 seconds for image transfer to be automatically disabled...\n\n";
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
std::cout << "Retrieval operation " << ((succes) ? "successful!\n" : "unsuccessful!");
if (succes)
{
std::cout <<
"Retrieved " << images.
images.
size() <<
" image(s) of size: " << images.
width <<
" X " << images.
height <<
"\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;
}