libcyberradio  22.01.24
UdpStatusReceiver Class Reference

UDP status receiver. More...

#include <UdpStatusReceiver.h>

Inheritance diagram for UdpStatusReceiver:
Thread Debuggable

Public Member Functions

 UdpStatusReceiver (std::string ifname, unsigned int port, bool debug, bool updatePE)
 Constructs a UdpStatusReceiver object. More...
 
virtual ~UdpStatusReceiver ()
 Destroys a UdpStatusReceiver object.
 
virtual void run ()
 Executes the main processing loop for the thread.
 
bool setStatusInterface (std::string ifname)
 Sets the interface name. More...
 
bool setStatusInterface (std::string ifname, bool makeSocketFlag)
 Sets the interface name. More...
 
bool setStatusPort (unsigned int port)
 Sets the UDP port. More...
 
bool setStatusPort (unsigned int port, bool makeSocketFlag)
 Sets the UDP port. More...
 
bool okToSend (long int pendingSamples, bool lockIfOk)
 Determines if it is OK to send data. More...
 
long int getFreeSpace (void)
 Gets the amount of free space available. More...
 
bool sentNSamples (long int samplesSent)
 Updates status based on the number of samples sent. More...
 
virtual void start ()
 Starts thread processing.
 
virtual void interrupt ()
 Interrupts (stops) the thread.
 
virtual void sleep (double secs)
 Pauses thread execution for a given time, checking for user interrupts during that time. More...
 
virtual bool isRunning () const
 Determines if the thread is running or not. More...
 
virtual void setName (const std::string &name)
 Sets the name of the thread. More...
 
virtual void setClass (const std::string &cls)
 Sets the class identifer string for the thread. More...
 
virtual boost::thread::id getId () const
 Gets the identifier of the underlying Boost thread. More...
 
virtual std::string getIdString () const
 Gets the identifier string for this thread. More...
 
virtual void onInterrupt ()
 Executes code that must run when the thread is interrupted. More...
 
virtual void onException (const std::exception &ex)
 Executes code that must run when an unhandled exception occurs within the thread. More...
 
virtual void setDebugName (const std::string &debug_name)
 Sets the debug name for this object. More...
 
virtual void setDebugFile (FILE *debug_fp)
 Sets the debug file pointer for this object. More...
 
virtual void setDebugTimeFormat (const std::string &debug_timefmt)
 Sets the debug time format for this object. More...
 
virtual int debug (const char *format,...)
 Outputs debug information. More...
 
virtual const char * debugBool (bool x)
 Gets a debug output string for a Boolean value. More...
 
virtual bool isDebug () const
 Gets whether this object produces debug output. More...
 
virtual std::string getDebugName () const
 Gets the debug name for this object. More...
 
virtual std::string rawString (const std::string &data)
 Gets a "raw" string representation of a given data string. More...
 

Detailed Description

UDP status receiver.

Definition at line 37 of file UdpStatusReceiver.h.

Constructor & Destructor Documentation

◆ UdpStatusReceiver()

UdpStatusReceiver ( std::string  ifname,
unsigned int  port,
bool  debug,
bool  updatePE 
)

Constructs a UdpStatusReceiver object.

Parameters
ifnameEthernet interface name
portUDP port
debugWhether or not to produce debug output
updatePE

Definition at line 28 of file UdpStatusReceiver.cpp.

Member Function Documentation

◆ debug()

int debug ( const char *  format,
  ... 
)
virtualinherited

Outputs debug information.

This method follows the same semantics as printf(). Output is preceded by a timestamp and the name of the object, if provided.

Parameters
formatThe printf()-style format string.
...Comma-separated list of arguments to print. Note that these need to be arguments that can be supported natively through printf().
Returns
The number of characters outputted.

Definition at line 95 of file Debuggable.cpp.

◆ debugBool()

const char * debugBool ( bool  x)
virtualinherited

Gets a debug output string for a Boolean value.

Parameters
xBoolean value
Returns
A constant string, either "true" or "false".

Definition at line 126 of file Debuggable.cpp.

◆ getDebugName()

std::string getDebugName ( ) const
virtualinherited

Gets the debug name for this object.

Returns
The debug name, as a string.

Definition at line 138 of file Debuggable.cpp.

◆ getFreeSpace()

long int getFreeSpace ( void  )

Gets the amount of free space available.

Returns
Amount of free space.

Definition at line 262 of file UdpStatusReceiver.cpp.

◆ getId()

boost::thread::id getId ( ) const
virtualinherited

Gets the identifier of the underlying Boost thread.

Returns
The thread identifier. If the thread is not running, this returns boost::thread().

Definition at line 91 of file Thread.cpp.

◆ getIdString()

std::string getIdString ( ) const
virtualinherited

Gets the identifier string for this thread.

Returns
The thread identifier string.

Definition at line 96 of file Thread.cpp.

◆ isDebug()

bool isDebug ( ) const
virtualinherited

Gets whether this object produces debug output.

Returns
True if producing debug, false otherwise.

Definition at line 133 of file Debuggable.cpp.

◆ isRunning()

bool isRunning ( ) const
virtualinherited

Determines if the thread is running or not.

Returns
True if the thread is running, false otherwise.

Definition at line 72 of file Thread.cpp.

◆ okToSend()

bool okToSend ( long int  pendingSamples,
bool  lockIfOk 
)

Determines if it is OK to send data.

Parameters
pendingSamplesNumber of samples pending
lockIfOkWhether or not to lock sending if sending is OK
Returns
True if OK to send, false otherwise.

Definition at line 251 of file UdpStatusReceiver.cpp.

◆ onException()

void onException ( const std::exception &  ex)
virtualinherited

Executes code that must run when an unhandled exception occurs within the thread.

The base-class method does nothing. Override this method in derived classes to perform custom exception processing.

Parameters
exThe exception that occurred.

Definition at line 110 of file Thread.cpp.

◆ onInterrupt()

void onInterrupt ( )
virtualinherited

Executes code that must run when the thread is interrupted.

The base-class method does nothing. Override this method in derived classes to perform custom interrupt processing.

Definition at line 87 of file Thread.cpp.

◆ rawString()

std::string rawString ( const std::string &  data)
virtualinherited

Gets a "raw" string representation of a given data string.

"Raw" string representations mimic Python string representations. Whitespace characters are denoted by backslash representations ("\\r", "\\n", "\\t", "\\v", "\\f"), while other non-printable characters are represented with hex representation ("\\x00", etc.)

Parameters
dataData string
Returns
The data's "raw" representation.

Definition at line 143 of file Debuggable.cpp.

◆ sentNSamples()

bool sentNSamples ( long int  samplesSent)

Updates status based on the number of samples sent.

Parameters
samplesSentNumber of samples sent
Returns
True if there is free space available, false otherwise.

Definition at line 267 of file UdpStatusReceiver.cpp.

◆ setClass()

void setClass ( const std::string &  cls)
virtualinherited

Sets the class identifer string for the thread.

Parameters
clsThe new class identifer for the thread.

Definition at line 82 of file Thread.cpp.

◆ setDebugFile()

void setDebugFile ( FILE *  debug_fp)
virtualinherited

Sets the debug file pointer for this object.

Parameters
debug_fpFile to send debug output to.

Definition at line 81 of file Debuggable.cpp.

◆ setDebugName()

void setDebugName ( const std::string &  debug_name)
virtualinherited

Sets the debug name for this object.

Use this method to set unique debug names for objects of the same class for easy differentiation.

Parameters
debug_nameName for identifying this object in debug output.

Definition at line 74 of file Debuggable.cpp.

◆ setDebugTimeFormat()

void setDebugTimeFormat ( const std::string &  debug_timefmt)
virtualinherited

Sets the debug time format for this object.

Parameters
debug_timefmtFormat string for displaying timestamp, as compatible with strftime(). If this is an empty string, don't display a timestamp.

Definition at line 88 of file Debuggable.cpp.

◆ setName()

void setName ( const std::string &  name)
virtualinherited

Sets the name of the thread.

Parameters
nameThe new name of the thread.

Definition at line 77 of file Thread.cpp.

◆ setStatusInterface() [1/2]

bool setStatusInterface ( std::string  ifname)

Sets the interface name.

Parameters
ifnameEthernet interface name
Returns
True if the action succeeded, false otherwise.

Definition at line 116 of file UdpStatusReceiver.cpp.

◆ setStatusInterface() [2/2]

bool setStatusInterface ( std::string  ifname,
bool  makeSocketFlag 
)

Sets the interface name.

Parameters
ifnameEthernet interface name
makeSocketFlagWhether or not to create a UDP socket
Returns
True if the action succeeded, false otherwise.

Definition at line 120 of file UdpStatusReceiver.cpp.

◆ setStatusPort() [1/2]

bool setStatusPort ( unsigned int  port)

Sets the UDP port.

Parameters
portUDP port
Returns
True if the action succeeded, false otherwise.

Definition at line 129 of file UdpStatusReceiver.cpp.

◆ setStatusPort() [2/2]

bool setStatusPort ( unsigned int  port,
bool  makeSocketFlag 
)

Sets the UDP port.

Parameters
portUDP port
makeSocketFlagWhether or not to create a UDP socket
Returns
True if the action succeeded, false otherwise.

Definition at line 134 of file UdpStatusReceiver.cpp.

◆ sleep()

void sleep ( double  secs)
virtualinherited

Pauses thread execution for a given time, checking for user interrupts during that time.

The sleep timer has microsecond resolution.

Parameters
secsNumber of seconds to "sleep".

Definition at line 65 of file Thread.cpp.


The documentation for this class was generated from the following files: