10 #define mzmqServer_hpp
16 #include <milkzmqServer.hpp>
20 #include "../../libMagAOX/libMagAOX.hpp"
21 #include "../../magaox_git_version.h"
129 const std::string & file,
156 config.add(
"server.imagePort",
"",
"server.imagePort", argType::Required,
"server",
"imagePort",
false,
"int",
"");
158 config.add(
"server.shmimNames",
"",
"server.shmimNames", argType::Required,
"server",
"shmimNames",
false,
"string",
"");
160 config.add(
"server.usecSleep",
"",
"server.usecSleep", argType::Required,
"server",
"usecSleep",
false,
"int",
"");
162 config.add(
"server.fpsTgt",
"",
"server.fpsTgt", argType::Required,
"server",
"fpsTgt",
false,
"float",
"");
164 config.add(
"server.fpsGain",
"",
"server.fpsGain", argType::Required,
"server",
"fpsGain",
false,
"float",
"");
166 config.add(
"server.compress",
"",
"server.compress", argType::Required,
"server",
"compress",
false,
"bool",
"Flag to turn on compression for INT16 and UINT16.");
177 config(m_imagePort,
"server.imagePort");
180 config(m_usecSleep,
"server.usecSleep");
181 config(m_fpsTgt,
"server.fpsTgt");
183 config(m_fpsGain,
"server.fpsGain");
191 #include <sys/syscall.h>
204 log<software_error>({__FILE__, __LINE__});
215 if(serverThreadStart() < 0)
217 log<software_critical>({__FILE__, __LINE__});
221 for(
size_t n=0; n < m_imageThreads.size(); ++n)
223 if( imageThreadStart(n) > 0)
225 log<software_critical>({__FILE__, __LINE__,
"Starting image thread " + m_imageThreads[n].m_imageName});
231 std::cerr <<
"Main Thread: " << syscall(SYS_gettid) <<
"\n";
244 if(pthread_tryjoin_np(m_serverThread.native_handle(),0) == 0)
246 log<software_error>({__FILE__, __LINE__,
"server thread has exited"});
251 for(
size_t n=0; n < m_imageThreads.size(); ++n)
253 if(pthread_tryjoin_np(m_imageThreads[n].m_thread->native_handle(),0) == 0)
255 log<software_error>({__FILE__, __LINE__,
"image thread " + m_imageThreads[n].m_imageName +
" has exited"});
271 for(
size_t n=0; n < m_imageThreads.size(); ++n)
276 for(
size_t n=0; n < m_imageThreads.size(); ++n)
278 if( m_imageThreads[n].m_thread->joinable())
280 m_imageThreads[n].m_thread->join();
290 struct sigaction act;
294 act.sa_flags = SA_SIGINFO;
299 if( sigaction(SIGSEGV, &act, 0) < 0 )
301 std::string logss =
"Setting handler for SIGSEGV failed. Errno says: ";
302 logss += strerror(errno);
304 log<software_error>({__FILE__, __LINE__, errno, 0, logss});
310 if( sigaction(SIGBUS, &act, 0) < 0 )
312 std::string logss =
"Setting handler for SIGBUS failed. Errno says: ";
313 logss += strerror(errno);
315 log<software_error>({__FILE__, __LINE__, errno, 0,logss});
340 static_cast<void>(signum);
341 static_cast<void>(siginf);
342 static_cast<void>(ucont);
344 milkzmqServer::m_restart =
true;
369 const std::string & file,
373 log<software_error>({file.c_str(), (uint32_t) line,
msg});
The base-class for MagAO-X applications.
std::string m_configName
The name of the configuration file (minus .conf).
MagAO-X application to control writing ImageStreamIO streams to a zeroMQ channel.
virtual void setupConfig()
Setup the configuration system (called by MagAOXApp::setup())
int setSigSegvHandler()
Sets the handler for SIGSEGV and SIGBUS.
virtual void loadConfig()
load the configuration system results (called by MagAOXApp::setup())
virtual int appShutdown()
Do any needed shutdown tasks. Currently nothing in this app.
virtual int appStartup()
Startup functions.
static void _handlerSigSegv(int signum, siginfo_t *siginf, void *ucont)
The handler called when SIGSEGV or SIGBUS is received, which will be due to ImageStreamIO server rese...
virtual void reportError(const std::string &msg, const std::string &file, int line)
Log an error.
virtual int appLogic()
Implementation of the FSM for the Siglent SDG.
void handlerSigSegv(int signum, siginfo_t *siginf, void *ucont)
Handles SIGSEGV and SIGBUS. Sets m_restart to true.
virtual void reportNotice(const std::string &msg)
Log status (with LOG_NOTICE level of priority).
mzmqServer()
Default c'tor.
virtual void reportInfo(const std::string &msg)
Log status (with LOG_INFO level of priority).
static mzmqServer * m_selfWriter
Static pointer to this (set in constructor). Used for getting out of the static SIGSEGV handler.
std::vector< std::string > m_shMemImNames
~mzmqServer() noexcept
Destructor.
virtual void reportWarning(const std::string &msg)
Log a warning.
constexpr static logPrioT LOG_DEBUG
Used for debugging.
constexpr static logPrioT LOG_INFO
Informational. The info log level is the lowest level recorded during normal operations.
constexpr static logPrioT LOG_WARNING
A condition has occurred which may become an error, but the process continues.
constexpr static logPrioT LOG_NOTICE
A normal but significant condition.