37 #include <boost/thread.hpp> 38 #include <boost/format.hpp> 39 #include <sys/types.h> 41 #include <sys/syscall.h> 82 dat =
new std::complex<float>[_size];
115 if(nl >
maxlen)
return false;
140 std::complex<float> *
dat;
176 SoDaBase(
const std::string & oname);
190 SoDaBase * findSoDaObject(
const std::string & oname);
238 reason = std::string(_reason);
248 if(thrower != NULL) {
249 ret = (boost::format(
"SoDa Object [%s] threw exception [%s]\n") % thrower->getObjName() % reason).str();
252 ret = (boost::format(
"Unknown SoDa Object threw exception [%s]\n") % reason).str();
263 return toString().c_str();
293 if(th != NULL)
return;
314 return th->try_join_for(boost::chrono::milliseconds(m));
324 virtual void run() = 0;
379 tid = syscall(SYS_gettid);
380 debugMsg(boost::format(
"%s starting as TID %x.\n") % getObjName() % tid);
385 std::cerr << getObjName() <<
" caught " << exc.
toString() << std::endl;
388 std::cerr << getObjName() <<
" caught " << exc->
toString() << std::endl;
390 catch (
const std::exception & e) {
391 std::cerr << getObjName() <<
" caught exception here: " << e.what() << std::endl;
394 std::cerr << getObjName() <<
" caught unknown exception" << std::endl;
396 debugMsg(boost::format(
"%s terminating.\n") % getObjName());
401 std::cerr <<
"\n-----------" 405 <<
" A SoDaThread caught a sig segv" 412 signal(sig, SIG_DFL);
413 kill(getpid(), SIGSEGV);
417 struct sigaction act;
418 sigemptyset(&act.sa_mask);
421 sigaction(SIGSEGV, &act, 0);
const char * what()
Create a string that explains this exception.
virtual void execGetCommand(Command *cmd)
optional method to handle "GET" commands – commands that request a response
The Thread baseclass for all SoDa thread objects.
unsigned int maxflen
the maximum length in terms of real floats
std::string & getObjName()
get the name of this object
SoDaBuf(unsigned int _size)
constructor: Allocate a complex/real buffer of complex data values
static void sigsegHandler(int sig)
float * fdat
the storage array (REAL version) Storage is common to both types
static bool first_time
have we seen the first call to getTime?
The SoDa Exception class.
SoDaBase * thrower
who caused the exception, if anyone?
void start()
Execute the threads run loop.
std::string toString()
Create a string that explains this exception.
static std::map< std::string, SoDaBase *> ObjectDirectory
a class member – directory of all registered objects.
unsigned int getComplexMaxLen()
Return the maximum number of complex float values that this buffer can hold.
void join()
more properly "Wait for this thread to exit its run loop".
bool setComplexLen(unsigned int nl)
set the length of the buffer (in number of complex floats.)
static double base_first_time
time of first call to getTime from anyone.
std::complex< float > * dat
the storage array (complex version) Storage is common to both types
float * getFloatBuf()
Return a pointer to the storage buffer of floats.
std::complex< float > * getComplexBuf()
Return a pointer to the storage buffer of complex floats.
This is a list of all the commands that can "do something" to one or more components in the SoDa radi...
virtual void execRepCommand(Command *cmd)
optional method that reports status or the result of some action.
bool waitForJoin(unsigned int m)
wait for the thread to stop running, or the specified time to pass.
A simple base class to provide debug messaging from any derived class.
SoDaThread(const std::string &oname)
SoDaException(const char *_reason, SoDaBase *obj)
The constructor.
std::string objname
the name of the object
void outerRun()
the run method that is called by the boost thread handler.
virtual void execSetCommand(Command *cmd)
optional method to handle "SET" commands – commands that set internal state in the object...
MultiMBox< SoDaBuf > DatMBox
Mailboxes that carry float or complex data are of type DatMBox.
CmdType cmd
the command type (SET, GET, REP)
MultiMBox< Command > CmdMBox
Mailboxes that carry commands only are of type CmdMBox.
unsigned int getComplexLen()
Return the number of complex float values in this buffer.
unsigned int flen
the current length of the buffer in REAL fp values
SoDaException(const std::string &_reason, SoDaBase *obj=NULL)
The constructor.
std::string reason
what was the cause of the exception?
unsigned int getFloatMaxLen()
Return the maximum number of float values that this buffer can hold.
bool setFloatLen(unsigned int nl)
set the length of the buffer (in number of floats.)
unsigned int getFloatLen()
Return the number of float values in this buffer.
unsigned int maxlen
the maximum length in terms of complex floats
void execCommand(Command *cmd)
Execute (dispatch) a message removed from the command stream to one of the basic Command handler func...
unsigned int len
the current length of the buffer in complex fp values