Dawn Framework 1.0
Universal data acquisition framework for embedded systems
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
dawn::CProgStatsCount Class Reference

Sample counting statistics Program. More...

#include <statscount.hxx>

Inheritance diagram for dawn::CProgStatsCount:
[legend]
Collaboration diagram for dawn::CProgStatsCount:
[legend]

Public Types

enum  { CMD_RESET = 0 , CMD_TRIGGER1 = 1 , CMD_TRIGGER2 = 2 , CMD_TRIGGER3 = 3 }
 Control command identifiers for control() More...
 
enum  
 Default descriptor validation failure codes. More...
 
enum  
 Common configuration IDs.
 
enum  { PROG_STATS_CFG_FIRST = 0 , PROG_STATS_CFG_IOBIND = 1 , PROG_STATS_CFG_LAST = 31 }
 Configuration IDs. More...
 
enum  EObjectState { STATE_STOPPED = 0 , STATE_RUNNING = 1 }
 Object operational state returned by getState() More...
 
enum  EProgClass {
  PROG_CLASS_ANY = 0 , PROG_CLASS_STATS_MIN = 1 , PROG_CLASS_STATS_MAX = 2 , PROG_CLASS_STATS_AVG = 3 ,
  PROG_CLASS_STATS_SUM = 4 , PROG_CLASS_STATS_COUNT = 5 , PROG_CLASS_STATS_RMS = 8 , PROG_CLASS_SAMPLING = 6 ,
  PROG_CLASS_DUMMY = 7 , PROG_CLASS_ADJUST = 10 , PROG_CLASS_GATEWAY = 11 , PROG_CLASS_LATEST = 12 ,
  PROG_CLASS_REDIRECT = 13 , PROG_CLASS_MOVING_AVG = 14 , PROG_CLASS_IIR_FILTER = 15 , PROG_CLASS_THRESHOLD = 16 ,
  PROG_CLASS_THRESHOLD_VALUE = 17 , PROG_CLASS_BUFFER = 18 , PROG_CLASS_SEQUENCER = 19 , PROG_CLASS_BITSPLIT = 20 ,
  PROG_CLASS_TOGGLE = 21 , PROG_CLASS_COUNTER = 22 , PROG_CLASS_SWITCH = 23 , PROG_CLASS_EXPRESSION = 24 ,
  PROG_CLASS_SELECTOR = 25 , PROG_CLASS_BITPACK = 26 , PROG_CLASS_CONFIGWRITER = 27 , PROG_CLASS_VECPACK = 28 ,
  PROG_CLASS_VECSPLIT = 29 , PROG_CLASS_MANYTOONE = 30 , PROG_CLASS_ONETOMANY = 31 , PROG_CLASS_IOMUX = 32 ,
  PROG_CLASS_IODEMUX = 33 , PROG_CLASS_USER = 511 , PROG_CLASS_LAST
}
 Program object class types. More...
 

Public Member Functions

int configure ()
 Configure Program from descriptor.
 
int deinit ()
 Deinitialize Program.
 
int doStart ()
 Start the Program.
 
int doStop ()
 Stop the Program.
 
bool getCfgFlag () const
 Check if configuration flag is set.
 
uint16_t getCls () const
 Get object class field.
 
CDescObjectgetDesc ()
 Get descriptor object for this object.
 
uint8_t getDtype () const
 Get data type field.
 
size_t getDtypeSize () const
 Get size of this object's data type.
 
uint8_t getFlags () const
 Get type-specific flags field.
 
SObjectId::UObjectId getId () const
 Get object identifier as union structure.
 
SObjectId::ObjectId getIdV () const
 Get object identifier as raw 32-bit value.
 
CIOCommongetIO (SObjectId::ObjectId id)
 Get an I/O object by ID.
 
const std::map< SObjectId::ObjectId, CIOCommon * > & getIOMap () const
 Get the I/O map for this object.
 
int getObjConfig (SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len)
 Get object configuration item.
 
CObjectgetObject (SObjectId::ObjectId id)
 Get an object by ID.
 
uint16_t getPriv () const
 Get instance/private data field.
 
virtual EObjectState getState () const
 Get current operational state.
 
uint8_t getType () const
 Get object type field.
 
bool hasThread () const
 Check if a background thread is active.
 
int init ()
 One-time initialize Program after bindings are resolved.
 
int setObjConfig (SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len)
 Set object configuration item.
 
void setObjectMapItem (SObjectId::ObjectId id, CObject *obj)
 Set an item in the object map.
 
int start ()
 Start object.
 
int stop ()
 Stop object.
 
int trigger (uint8_t cmd)
 Execute a trigger command.
 

Static Public Member Functions

static int descValidDefault (const uint32_t *data, size_t len)
 Default descriptor validation method.
 
static int validateDesc (const uint32_t *desc, size_t len)
 Validate entire descriptor.
 

Protected Member Functions

virtual int bindStateAlloc (CIOCommon *src, CIOCommon *output, io_ddata_t *ioData, io_ddata_t *outputData, SBindState **state)
 Allocate optional per-binding derived state.
 
virtual int configureExtraCfgItem (const CDescObject &desc, const SObjectCfg::SObjectCfgItem *item, size_t &offset)
 Parse program-specific config item (optional extension hook).
 
CIOCommongetOutputIO () const
 Get the output IO for the first bind.
 
CIOCommongetSourceIO () const
 Get the source IO for the first bind.
 
void handle (CIOCommon *output, io_ddata_t *data, io_ddata_t *ioData, io_ddata_t *outputData, bool &initsample)
 Process incoming sample.
 
void handleCmn (SProcessBind *bind, io_ddata_t *data)
 Common callback wrapper.
 
virtual void handleWithState (CIOCommon *output, io_ddata_t *data, io_ddata_t *ioData, io_ddata_t *outputData, bool &initsample, void *state)
 Process incoming sample with optional per-binding state.
 
virtual int onSetObjConfig (SObjectCfg::ObjectCfgId objcfg, uint32_t *data, size_t len)
 Pre-update hook for runtime configuration writes.
 

Detailed Description

Sample counting statistics Program.

Counts the number of samples received from a source I/O over time.

Definition at line 39 of file statscount.hxx.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

Control command identifiers for control()

Enumerator
CMD_RESET 

Reset object internal state.

CMD_TRIGGER1 

Object-specific trigger slot 1.

CMD_TRIGGER2 

Object-specific trigger slot 2.

CMD_TRIGGER3 

Object-specific trigger slot 3.

Definition at line 40 of file object.hxx.

◆ anonymous enum

anonymous enum
inherited

Default descriptor validation failure codes.

Negative values identify which length check failed in descValidDefault().

Definition at line 314 of file object.hxx.

◆ anonymous enum

anonymous enum
inherited

Configuration IDs.

Enumerator
PROG_STATS_CFG_FIRST 

First config ID.

PROG_STATS_CFG_IOBIND 

I/O binding configuration.

PROG_STATS_CFG_LAST 

Last config ID.

Definition at line 32 of file process.hxx.

◆ EObjectState

Object operational state returned by getState()

Enumerator
STATE_STOPPED 

Object is stopped.

STATE_RUNNING 

Object is running.

Definition at line 32 of file object.hxx.

◆ EProgClass

Program object class types.

Enumerator
PROG_CLASS_ANY 

Generic PROG type.

PROG_CLASS_STATS_MIN 

Minimum value tracker.

PROG_CLASS_STATS_MAX 

Maximum value tracker.

PROG_CLASS_STATS_AVG 

Running average calculator.

PROG_CLASS_STATS_SUM 

Sum accumulator.

PROG_CLASS_STATS_COUNT 

Sample counter.

PROG_CLASS_STATS_RMS 

Running RMS (root mean square) calculator.

PROG_CLASS_SAMPLING 

Periodic data sampler.

PROG_CLASS_DUMMY 

Dummy program (test/helper).

PROG_CLASS_ADJUST 

Scale/offset adjustment.

PROG_CLASS_GATEWAY 

Protocol-to-protocol IO gateway.

PROG_CLASS_LATEST 

Cache latest notified sample for fetch-based readers.

PROG_CLASS_REDIRECT 

Generic input-to-output routing bridge.

PROG_CLASS_MOVING_AVG 

Moving average filter.

PROG_CLASS_IIR_FILTER 

First-order IIR filter.

PROG_CLASS_THRESHOLD 

Threshold and hysteresis comparator.

PROG_CLASS_THRESHOLD_VALUE 

Threshold comparator returning gated source value.

PROG_CLASS_BUFFER 

Notify-driven history capture buffer.

PROG_CLASS_SEQUENCER 

Periodic state sequencer.

PROG_CLASS_USER 

User-defined PROG types start here.

Definition at line 31 of file common.hxx.

Member Function Documentation

◆ bindStateAlloc()

int CProgProcess::bindStateAlloc ( CIOCommon src,
CIOCommon output,
io_ddata_t ioData,
io_ddata_t outputData,
SBindState **  state 
)
protectedvirtualinherited

Allocate optional per-binding derived state.

Called once during init() after source/output buffers are allocated. Derived classes that do not need extra state can use the default null state.

Reimplemented in dawn::CProgMovingAverage, and dawn::CProgStatsRms.

Definition at line 95 of file process.cxx.

Here is the caller graph for this function:

◆ configure()

int CProgProcess::configure ( )
virtualinherited

Configure Program from descriptor.

Returns
OK on success, or error code on failure.

Reimplemented from dawn::CObject.

Definition at line 189 of file process.cxx.

References dawn::CObject::getDesc().

Here is the call graph for this function:

◆ configureExtraCfgItem()

int CProgProcess::configureExtraCfgItem ( const CDescObject desc,
const SObjectCfg::SObjectCfgItem item,
size_t &  offset 
)
protectedvirtualinherited

Parse program-specific config item (optional extension hook).

Returns
OK when item was handled, negative error otherwise.

Reimplemented in dawn::CProgIIRFilter, dawn::CProgMovingAverage, and dawn::CProgThresholdBase.

Definition at line 85 of file process.cxx.

◆ deinit()

int CProgProcess::deinit ( )
virtualinherited

Deinitialize Program.

Returns
OK on success, or error code on failure.

Reimplemented from dawn::CObject.

Definition at line 259 of file process.cxx.

Here is the caller graph for this function:

◆ descValidDefault()

int CObject::descValidDefault ( const uint32_t *  data,
size_t  len 
)
staticinherited

Default descriptor validation method.

Provides basic validation that only checks if descriptor lengths are correct.

Parameters
dataDescriptor data pointer.
lenLength of descriptor data in 32-bit words.
Returns
OK on success, negative error code indicating validation stage.

Definition at line 42 of file object.cxx.

References dawn::SObjectCfg::UObjectCfgId::s, dawn::SObjectCfg::UObjectCfgId::size, and dawn::SObjectCfg::UObjectCfgId::v.

Here is the caller graph for this function:

◆ doStart()

int CProgProcess::doStart ( )
virtualinherited

Start the Program.

Returns
OK on success, or error code on failure.

Reimplemented from dawn::CObject.

Definition at line 282 of file process.cxx.

◆ doStop()

int CProgProcess::doStop ( )
virtualinherited

Stop the Program.

Returns
OK on success, or error code on failure.

Reimplemented from dawn::CObject.

Definition at line 295 of file process.cxx.

◆ getCfgFlag()

bool CObject::getCfgFlag ( ) const
inherited

Check if configuration flag is set.

Returns
True if this object has configuration data.

Definition at line 160 of file object.cxx.

References dawn::CDescObject::getSize().

Here is the call graph for this function:

◆ getCls()

uint16_t CObject::getCls ( ) const
inherited

Get object class field.

Returns
Object class identifier (0-511).

Definition at line 170 of file object.cxx.

References dawn::SObjectId::UObjectId::cls, and dawn::SObjectId::UObjectId::s.

Here is the caller graph for this function:

◆ getDesc()

CDescObject & CObject::getDesc ( )
inherited

Get descriptor object for this object.

Returns
Reference to associated CDescObject.

Definition at line 190 of file object.cxx.

◆ getDtype()

uint8_t CObject::getDtype ( ) const
inherited

Get data type field.

Returns
Data type (DTYPE_UINT32, DTYPE_FLOAT, etc.).

Definition at line 175 of file object.cxx.

References dawn::SObjectId::UObjectId::dtype, and dawn::SObjectId::UObjectId::s.

Here is the caller graph for this function:

◆ getDtypeSize()

size_t CObject::getDtypeSize ( ) const
inherited

Get size of this object's data type.

Returns
Size in bytes for the configured data type.

Definition at line 195 of file object.cxx.

References dawn::SObjectId::getDtypeSize_(), and dawn::CDescObject::getObjectDtype().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFlags()

uint8_t CObject::getFlags ( ) const
inherited

Get type-specific flags field.

Returns
Flags value (0-3).

Definition at line 180 of file object.cxx.

References dawn::SObjectId::UObjectId::flags, and dawn::SObjectId::UObjectId::s.

Here is the caller graph for this function:

◆ getId()

SObjectId::UObjectId CObject::getId ( ) const
inherited

Get object identifier as union structure.

Returns
Reference to UObjectId structure.

Definition at line 150 of file object.cxx.

◆ getIdV()

SObjectId::ObjectId CObject::getIdV ( ) const
inherited

Get object identifier as raw 32-bit value.

Returns
ObjectID as uint32_t.

Definition at line 155 of file object.cxx.

References dawn::SObjectId::UObjectId::v.

Here is the caller graph for this function:

◆ getIO()

CIOCommon * CBindableObject::getIO ( SObjectId::ObjectId  id)
inherited

Get an I/O object by ID.

Parameters
idObject ID to retrieve.
Returns
Pointer to the I/O object, or nullptr if not found.

Definition at line 41 of file bindable.cxx.

Here is the caller graph for this function:

◆ getIOMap()

const std::map< SObjectId::ObjectId, CIOCommon * > & CBindableObject::getIOMap ( ) const
inherited

Get the I/O map for this object.

Returns
Pointer to a map of object IDs to I/O objects.

Definition at line 18 of file bindable.cxx.

Here is the caller graph for this function:

◆ getObjConfig()

int CObject::getObjConfig ( SObjectCfg::ObjectCfgId  objcfg,
uint32_t *  data,
size_t  len 
)
inherited

Get object configuration item.

Retrieves configuration data for this object.

Parameters
objcfgConfiguration ID specifying which config item to retrieve.
dataPointer to buffer for configuration data.
lenLength of buffer in 32-bit words.
Returns
OK on success, negative error code on failure.

Definition at line 240 of file object.cxx.

References dawn::SObjectCfg::SObjectCfgItem::data, dawn::SObjectCfg::objectCfgGetSize(), and dawn::CDescObject::objectCfgItemId().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getObject()

CObject * CBindableObject::getObject ( SObjectId::ObjectId  id)
inherited

Get an object by ID.

Parameters
idObject ID to retrieve.
Returns
Pointer to the object, or nullptr if not found.

Definition at line 52 of file bindable.cxx.

References dawn::CBindableObject::getIO(), dawn::SObjectId::objectIdGetType(), and dawn::SObjectId::OBJTYPE_IO.

Here is the call graph for this function:

◆ getOutputIO()

CIOCommon * dawn::CProgProcess::getOutputIO ( ) const
inlineprotectedinherited

Get the output IO for the first bind.

Convenience for sub-classes that need to emit an initial value during doStart() without iterating the internal bind vector.

Returns
Pointer to the first bind's output IO, or nullptr.

Definition at line 251 of file process.hxx.

◆ getPriv()

uint16_t CObject::getPriv ( ) const
inherited

Get instance/private data field.

Returns
Instance ID (0-16383).

Definition at line 185 of file object.cxx.

References dawn::SObjectId::UObjectId::priv, and dawn::SObjectId::UObjectId::s.

Here is the caller graph for this function:

◆ getSourceIO()

CIOCommon * dawn::CProgProcess::getSourceIO ( ) const
inlineprotectedinherited

Get the source IO for the first bind.

Convenience for sub-classes that need to read the current source value during doStart().

Returns
Pointer to the first bind's source IO, or nullptr.

Definition at line 268 of file process.hxx.

◆ getState()

virtual EObjectState dawn::CObject::getState ( ) const
inlinevirtualinherited

Get current operational state.

Default returns STATE_RUNNING after successful start(), STATE_STOPPED otherwise. Objects with richer states (e.g. paused) should override.

Returns
Current EObjectState value.

Definition at line 183 of file object.hxx.

References dawn::CObject::STATE_RUNNING, and dawn::CObject::STATE_STOPPED.

◆ getType()

uint8_t CObject::getType ( ) const
inherited

Get object type field.

Returns
Object type (OBJTYPE_IO, OBJTYPE_PROTO, OBJTYPE_PROG).

Definition at line 165 of file object.cxx.

References dawn::SObjectId::UObjectId::s, and dawn::SObjectId::UObjectId::type.

◆ handle()

void dawn::CProgProcessTemplate< StatsOpCount >::handle ( CIOCommon output,
io_ddata_t data,
io_ddata_t ioData,
io_ddata_t outputData,
bool &  initsample 
)
inlineprotectedvirtualinherited

Process incoming sample.

Parameters
[in]outputResult output I/O object.
[in]dataSample data from source I/O.
[in]ioDataPer-binding input data buffer.
[in]outputDataPer-binding output data buffer.
[in,out]initsamplePer-binding initial sample flag.

Implements dawn::CProgProcess.

Definition at line 81 of file process_template.hxx.

◆ handleCmn()

void dawn::CProgProcess::handleCmn ( SProcessBind *  bind,
io_ddata_t data 
)
inlineprotectedinherited

Common callback wrapper.

Parameters
[in]bindPer-binding state.
[in]dataSample data.

Definition at line 284 of file process.hxx.

References dawn::CProgProcess::handleWithState().

Here is the call graph for this function:

◆ handleWithState()

void CProgProcess::handleWithState ( CIOCommon output,
io_ddata_t data,
io_ddata_t ioData,
io_ddata_t outputData,
bool &  initsample,
void *  state 
)
protectedvirtualinherited

Process incoming sample with optional per-binding state.

The default implementation preserves the original handle() contract.

Reimplemented in dawn::CProgMovingAverage, and dawn::CProgStatsRms.

Definition at line 110 of file process.cxx.

References dawn::CProgProcess::handle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasThread()

bool CProgProcess::hasThread ( ) const
virtualinherited

Check if a background thread is active.

Returns
Always false.

Reimplemented from dawn::CObject.

Definition at line 305 of file process.cxx.

◆ init()

int CProgProcess::init ( )
virtualinherited

One-time initialize Program after bindings are resolved.

Returns
OK on success, or error code on failure.

Reimplemented from dawn::CObject.

Definition at line 207 of file process.cxx.

References dawn::CProgProcess::bindStateAlloc(), and dawn::CBindableObject::getIO().

Here is the call graph for this function:

◆ onSetObjConfig()

virtual int dawn::CObject::onSetObjConfig ( SObjectCfg::ObjectCfgId  objcfg,
uint32_t *  data,
size_t  len 
)
inlineprotectedvirtualinherited

Pre-update hook for runtime configuration writes.

Called by setObjConfig() before descriptor-backed storage is updated. Derived classes may validate incoming data and prepare/apply runtime side effects. Returning a negative error rejects the update.

Parameters
objcfgConfiguration ID that will be updated.
dataPointer to new config words.
lenNumber of config words.
Returns
OK on success, or negative error code to reject update.

Reimplemented in dawn::CIOAdcStream, dawn::CIOAdcSync, and dawn::CIOPwm.

Definition at line 386 of file object.hxx.

Here is the caller graph for this function:

◆ setObjConfig()

int CObject::setObjConfig ( SObjectCfg::ObjectCfgId  objcfg,
uint32_t *  data,
size_t  len 
)
inherited

Set object configuration item.

Updates a configuration item for this object.

Parameters
objcfgConfiguration ID specifying which config item to update.
dataPointer to configuration data.
lenLength of configuration data in 32-bit words.
Returns
OK on success, negative error code on failure.

Definition at line 200 of file object.cxx.

References dawn::SObjectCfg::SObjectCfgItem::data, dawn::SObjectCfg::objectCfgGetRw(), dawn::SObjectCfg::objectCfgGetSize(), dawn::CDescObject::objectCfgItemId(), and dawn::CObject::onSetObjConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setObjectMapItem()

void CBindableObject::setObjectMapItem ( SObjectId::ObjectId  id,
CObject obj 
)
inherited

Set an item in the object map.

Parameters
idObject ID to set.
objObject pointer to associate with the ID.

Definition at line 23 of file bindable.cxx.

References dawn::SObjectId::objectIdGetType(), and dawn::SObjectId::OBJTYPE_IO.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

int dawn::CObject::start ( )
inlineinherited

Start object.

Tracks operational state and calls doStart(). This phase may run many times during an object's lifetime and should not perform one-time allocation. Sets started on successful doStart() return.

Returns
OK on success, negative error code on failure.

Definition at line 116 of file object.hxx.

References dawn::CObject::doStart().

Here is the call graph for this function:

◆ stop()

int dawn::CObject::stop ( )
inlineinherited

Stop object.

Tracks operational state and calls doStop(). This phase may run many times during an object's lifetime and should not perform one-time deallocation. Always clears started regardless of doStop() return value.

Returns
OK on success, negative error code on failure.

Definition at line 145 of file object.hxx.

References dawn::CObject::doStop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trigger()

int CProgProcess::trigger ( uint8_t  cmd)
virtualinherited

Execute a trigger command.

Parameters
[in]cmdCommand identifier (EObjectCmd value).
Returns
OK on success, -ENOTSUP if not supported.

Reimplemented from dawn::CObject.

Reimplemented in dawn::CProgThresholdBase.

Definition at line 310 of file process.cxx.

References dawn::CObject::CMD_RESET.

Here is the caller graph for this function:

◆ validateDesc()

int CObject::validateDesc ( const uint32_t *  desc,
size_t  len 
)
staticinherited

Validate entire descriptor.

Validates a descriptor binary object-by-object using default checks.

Parameters
descDescriptor binary pointer.
lenDescriptor length in 32-bit words.
Returns
OK on success, negative error code indicating validation stage.

Definition at line 123 of file object.cxx.

References dawn::CObject::descValidDefault().

Here is the call graph for this function:
Here is the caller graph for this function:

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