16 #ifndef DABC_ModuleSync
17 #define DABC_ModuleSync
100 uint16_t *resevid = 0,
149 bool WaitConnect(
const std::string &name,
double timeout = -1);
152 bool WaitInput(
unsigned indx,
unsigned minqueuesize = 1,
double timeout = -1);
156 {
return indx <
fInputs.size() ?
fInputs[indx]->CanRecv() :
false; }
161 Buffer Recv(
unsigned indx = 0,
double timeout = -1);
164 bool Send(
unsigned indx,
Buffer& buf,
double timeout = -1);
168 {
return Send(0, buf, timeout); }
198 virtual const char*
ClassName()
const {
return "ModuleSync"; }
Reference on memory from memory pool.
Represents command with its arguments.
Base class for module items like ports, timers, pool handles.
Base class for user-derived code, implementing main loop.
bool WaitItemEvent(double &tmout, ModuleItem *item=0, uint16_t *resevid=0, ModuleItem **resitem=0)
Buffer RecvFromAny(unsigned *port=0, double timeout=-1)
Receive buffer from any input port.
void SetSyncCommands(bool on=true)
Set if commands should be executed synchronous in main loop.
Buffer TakeBuffer(unsigned pool=0, double timeout=-1)
Take buffer from memory pool.
bool ModuleWorking(double timeout=0.)
Returns true when module in running state.
void SetTmoutExcept(bool on=true)
Set if exception should be generated when any operation is timeout.
bool WaitConnect(const std::string &name, double timeout=-1)
Waits for connection for specified port.
virtual void DoWorkerMainLoop()
Internal - entrance function for main loop execution.
virtual void ProcessItemEvent(ModuleItem *item, uint16_t evid)
Internal - central method of events processing.
bool WaitInput(unsigned indx, unsigned minqueuesize=1, double timeout=-1)
Waits until input port has specified number of buffers in the queue.
bool IsTmoutExcept() const
Returns true if timeout exception generation is configured.
uint16_t fWaitId
Internal variable, used in wait event.
bool fTmoutExcept
Flag indicates if timeout exception should be generated.
bool Send(unsigned indx, Buffer &buf, double timeout=-1)
Send buffer via specified output port.
virtual void DoWorkerAfterMainLoop()
Internal - function executed after leaving main loop.
bool IsDisconnectExcept() const
Returns true if disconnect exception should be generated by module.
ModuleItem * fWaitItem
Current item, waiting for the event.
void SetDisconnectExcept(bool on=true)
Set if disconnect exception should be generated by module.
bool IsSyncCommands() const
Returns true if commands should be executed synchronous in main loop.
virtual const char * ClassName() const
Returns class name.
virtual ~ModuleSync()
Destructor.
bool fSyncCommands
Flag indicates if commands will be executed synchronously.
virtual void ObjectCleanup()
Internal DABC method.
virtual void MainLoop()=0
Main execution function of SyncModule.
void AsyncProcessCommands()
Internal - process commands which are submitted to sync queue.
bool fDisconnectExcept
Flag indicates if disconnect exception should be generated.
bool CanRecv(unsigned indx=0) const
Method return true if receiving from specified port can be done.
virtual int PreviewCommand(Command cmd)
Internal - preview command before execution.
uint16_t WaitEvent(double timeout=-1)
Waits for any event.
CommandsQueue * fNewCommands
List of commands, submitted to the module.
bool Send(Buffer &buf, double timeout=-1)
Send buffer via first output port.
Buffer Recv(unsigned indx=0, double timeout=-1)
Receive buffer from input port.
bool fInsideMainLoop
Flag indicates if main loop is executing.
bool fWaitRes
Result of event waiting.
void StopUntilRestart()
Call this method from main loop if one want suspend of module execution until new Start of the module...
Base for dabc::ModuleSync and dabc::ModuleAsync classes.
std::vector< InputPort * > fInputs
array of input ports