|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Accessor for the shared component registry. More...
#include <ComponentMemory.h>
Public Member Functions | |
| ComponentMemory (MasterMemory *master) | |
| ~ComponentMemory () | |
| bool | getMemoryUsage (uint64 &alloc, uint64 &usage) |
| Report allocation/usage of the component segment. | |
| bool | open () |
| Attach to the existing component segment. | |
| bool | create (uint32 indexSize) |
| Create the component segment (master only). | |
| std::vector< ComponentInfoStruct > * | getAllComponents () |
| Snapshot all components. | |
| std::vector< ComponentInfoStruct > * | getAllLocalComponents () |
| Snapshot components on this node. | |
| std::vector< ComponentInfoStruct > * | getAllLocalComponents (uint8 type) |
| Snapshot local components of type. | |
| std::vector< ComponentInfoStruct > * | getAllModules () |
| Snapshot all module components. | |
| std::vector< ComponentInfoStruct > * | getAllCatalogs () |
| Snapshot all catalog components. | |
| bool | writeComponentsToMsg (DataMessage *msg) |
| Serialize all component records into msg. | |
| bool | writeComponentNamesToMsg (DataMessage *msg) |
| Write just the component names into msg. | |
| bool | syncComponents (DataMessage *msg) |
| Merge component records received from a remote node. | |
| bool | confirmComponentID (uint32 id) |
| Mark a provisionally reserved component id as ready (syncStatus 2). | |
| bool | cancelComponentID (uint32 id) |
| Release a provisionally reserved component id. | |
| uint8 | lookupComponentID (const char *name, uint32 &id) |
| Look up a component by name without filtering on readiness. | |
| bool | createComponent (uint32 id, uint8 type, uint8 policy, uint8 selfTrigger, const char *name, uint64 size, uint16 nodeID, uint16 procID, uint64 time, uint32 &existingID) |
| Register a component record. | |
| bool | destroyComponent (uint32 cid) |
| Remove a component record and free its space. | |
| bool | getComponentName (uint32 cid, char *name, uint32 maxNameLen) |
| Copy the component name into name. | |
| std::string | getComponentNameString (uint32 cid) |
| uint8 | getComponentType (uint32 cid) |
| bool | getComponentID (const char *name, uint32 &cid) |
| Look up a component id by name. | |
| ComponentStats | getComponentStats (uint32 cid) |
| bool | setComponentStats (uint32 cid, ComponentStats &stats) |
| Overwrite the component's stats. | |
| AveragePerfStats | getComponentPerfStats (uint32 cid) |
| bool | setComponentPerfStats (uint32 cid, AveragePerfStats &perfStruct) |
| Store new performance averages. | |
| bool | isComponentLocal (uint32 cid) |
| bool | isComponentLocal (const char *name) |
| bool | getComponentLocation (uint32 cid, uint16 &nodeID, uint16 &procID) |
| Get the node/process the component runs in. | |
| uint8 | getComponentPolicy (uint32 cid) |
| bool | updateComponentInformation (uint32 cid, uint8 type, uint8 policy, uint8 selfTrigger, uint16 nodeID, uint16 procID) |
| Update type/policy/self-trigger/location in one call. | |
| bool | setComponentPolicy (uint32 cid, uint8 policy) |
| Set the migration policy. | |
| uint8 | getComponentSelfTrigger (uint32 cid) |
| bool | setComponentSelfTrigger (uint32 cid, uint8 selfTrigger) |
| Set the self-trigger policy. | |
| uint16 | getComponentNodeID (uint32 cid) |
| uint16 | getComponentProcessID (uint32 cid) |
| bool | updateComponentLocation (uint32 cid, uint16 nodeID, uint16 procID) |
| Record a new location (after migration). | |
| bool | addComponentStats (uint32 cid, uint8 status, uint64 usageCPUTicks, DataMessage *inputMsg, DataMessage *outputMsg, uint32 runCount, uint32 cycleCount) |
| Fold a run's activity into the component's stats (counters, rings, CPU ticks). | |
| bool | canComponentMigrate (uint32 cid) |
| std::list< uint16 > * | findProcessComponents (uint16 procID) |
| List ids of components in process procID. | |
| char * | getComponentData (uint32 cid, uint64 &size) |
| Copy a component's whole data area (for migration). | |
| bool | setComponentData (uint32 cid, const char *data, uint64 size, bool wasMigrated) |
| Replace a component's data area (after migration). | |
| bool | hasParameter (uint32 cid, const char *name) |
| bool | deleteParameter (uint32 cid, const char *name) |
| Remove the parameter. | |
| bool | addLocalPerformanceStats (std::list< PerfStats > &perfStats) |
| Append PerfStats for all local components. | |
| std::string | printFriendly () |
| std::string | toXML (bool stats=true) |
Private data (named binary blobs owned by a component) | |
Blobs are stored inline in the component record with optional mimetype. | |
| bool | setPrivateData (uint32 cid, const char *name, const char *data, uint64 size, const char *mimetype=NULL) |
| Create/replace blob name. | |
| uint64 | getPrivateDataSize (uint32 cid, const char *name) |
| std::string | getPrivateDataMimetype (uint32 cid, const char *name) |
| bool | getPrivateData (uint32 cid, const char *name, char *data, uint64 maxSize) |
| Copy blob into caller buffer data (max maxSize). | |
| char * | getPrivateDataCopy (uint32 cid, const char *name, uint64 &size) |
| bool | deletePrivateData (uint32 cid, const char *name) |
| Delete blob name. | |
| std::map< std::string, std::string > | getPrivateDataKeysAndTypes (uint32 cid) |
| std::list< std::string > | getPrivateDataKeys (uint32 cid) |
Parameter creation | |
Overloads create string/integer/float parameters or collections thereof; values are copied into the component record. min/max/interval of 0 mean unconstrained.
| |
| bool | createParameter (uint32 cid, const char *name, const char *val, const char *defaultValue=NULL) |
| bool | createParameter (uint32 cid, const char *name, const char *val, uint32 count, uint32 defaultIndex) |
| bool | createParameter (uint32 cid, const char *name, std::vector< std::string > values, const char *defaultValue=NULL) |
| bool | createParameter (uint32 cid, const char *name, int64 *val, uint32 count, uint32 defaultIndex) |
| bool | createParameter (uint32 cid, const char *name, std::vector< std::string > values, int64 defaultValue) |
| bool | createParameter (uint32 cid, const char *name, std::vector< int64 > values, int64 defaultValue=0) |
| bool | createParameter (uint32 cid, const char *name, float64 *val, uint32 count, uint32 defaultIndex) |
| bool | createParameter (uint32 cid, const char *name, std::vector< std::string > values, float64 defaultValue) |
| bool | createParameter (uint32 cid, const char *name, std::vector< float64 > values, float64 defaultValue=0) |
| bool | createParameter (uint32 cid, const char *name, int64 val, int64 min=0, int64 max=0, int64 interval=0) |
| bool | createParameter (uint32 cid, const char *name, float64 val, float64 min=0, float64 max=0, float64 interval=0) |
Parameter access | |
Typed getters convert where sensible; getters return 0/empty on missing parameters. Setters clamp to min/max where configured.
| |
| uint8 | getParameterDataType (uint32 cid, const char *name) |
| uint32 | getParameterValueSize (uint32 cid, const char *name) |
| bool | getParameter (uint32 cid, const char *name, char *val, uint32 maxSize) |
| bool | getParameter (uint32 cid, const char *name, int64 &val) |
| bool | getParameter (uint32 cid, const char *name, float64 &val) |
| std::string | getParameterString (uint32 cid, const char *name, uint32 maxSize) |
| std::string | getParameterString (uint32 cid, const char *name) |
| int64 | getParameterInt (uint32 cid, const char *name) |
| float64 | getParameterFloat (uint32 cid, const char *name) |
| bool | getParameterAsBool (uint32 cid, const char *name) |
| bool | setParameter (uint32 cid, const char *name, const char *val) |
| bool | setParameter (uint32 cid, const char *name, int64 val) |
| bool | setParameter (uint32 cid, const char *name, float64 val) |
| bool | resetParameter (uint32 cid, const char *name) |
| Restore the parameter's default value/index. | |
| bool | tweakParameter (uint32 cid, const char *name, int32 tweak) |
| Step the value by tweak * interval (or collection index). | |
Static Public Member Functions | |
| static bool | UnitTest () |
| Self-test. | |
Accessor for the shared component registry.
One instance per process (created by MemoryManager). The node master calls create(); other processes open(). Every method locks the segment's named cross-process mutex and re-attaches when the segment was resized elsewhere (serial check). String/char* out parameters are copied into caller buffers; returned containers (vectors/lists) are heap-allocated and owned by the caller. The master pointer is borrowed.
Definition at line 262 of file ComponentMemory.h.
| cmlabs::ComponentMemory::ComponentMemory | ( | MasterMemory * | master | ) |
| master | Segment bookkeeping interface (borrowed, not owned). |
Definition at line 14 of file ComponentMemory.cpp.
| cmlabs::ComponentMemory::~ComponentMemory | ( | ) |
Definition at line 23 of file ComponentMemory.cpp.
References cmlabs::utils::CloseSharedMemorySegment().
| bool cmlabs::ComponentMemory::addComponentStats | ( | uint32 | cid, |
| uint8 | status, | ||
| uint64 | usageCPUTicks, | ||
| DataMessage * | inputMsg, | ||
| DataMessage * | outputMsg, | ||
| uint32 | runCount, | ||
| uint32 | cycleCount ) |
Fold a run's activity into the component's stats (counters, rings, CPU ticks).
Caller keeps ownership of both messages.
Definition at line 622 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, COMPSTATUS_STARTING, cmlabs::ComponentStats::currentRunStartTime, cmlabs::ComponentStats::cycleCount, cmlabs::DataMessage::data, DRAFTMSGSIZE, cmlabs::ComponentStats::firstRunStartTime, GETCOMPDATA, cmlabs::DataMessage::getSize(), cmlabs::GetTimeNow(), cmlabs::ComponentStats::msgInBytes, cmlabs::ComponentStats::msgInCount, cmlabs::ComponentStats::msgOutBytes, cmlabs::ComponentStats::msgOutCount, cmlabs::ComponentStats::recentInMsg, cmlabs::ComponentStats::recentInPos, cmlabs::ComponentStats::recentOutMsg, cmlabs::ComponentStats::recentOutPos, cmlabs::ComponentStats::runCount, cmlabs::DataMessageHeader::size, cmlabs::ComponentInfoStruct::stats, cmlabs::ComponentInfoStruct::status, cmlabs::ComponentStats::time, and cmlabs::ComponentStats::usageCPUTicks.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::addLocalPerformanceStats | ( | std::list< PerfStats > & | perfStats | ) |
Append PerfStats for all local components.
Definition at line 47 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ComponentStats::currentRunStartTime, cmlabs::ComponentStats::cycleCount, cmlabs::ComponentStats::firstRunStartTime, GETCOMPDATA, cmlabs::ComponentStats::migrationCount, cmlabs::ComponentStats::msgInBytes, cmlabs::ComponentStats::msgInCount, cmlabs::ComponentStats::msgOutBytes, cmlabs::ComponentStats::msgOutCount, cmlabs::ComponentInfoStruct::nodeID, cmlabs::ComponentInfoStruct::procID, cmlabs::ComponentStats::runCount, cmlabs::ComponentInfoStruct::size, cmlabs::ComponentInfoStruct::stats, cmlabs::ComponentInfoStruct::status, cmlabs::ComponentInfoStruct::type, and cmlabs::ComponentStats::usageCPUTicks.
| bool cmlabs::ComponentMemory::cancelComponentID | ( | uint32 | id | ) |
Release a provisionally reserved component id.
Definition at line 457 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ComponentInfoStruct::createdTime, GETCOMPDATA, cmlabs::ComponentInfoStruct::nodeID, cmlabs::ComponentInfoStruct::procID, cmlabs::ComponentInfoStruct::syncStatus, and cmlabs::ComponentInfoStruct::type.
| bool cmlabs::ComponentMemory::canComponentMigrate | ( | uint32 | cid | ) |
Definition at line 836 of file ComponentMemory.cpp.
References COMPONENT_CAN_MIGRATE, and getComponentPolicy().
| bool cmlabs::ComponentMemory::confirmComponentID | ( | uint32 | id | ) |
Mark a provisionally reserved component id as ready (syncStatus 2).
Definition at line 436 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::syncStatus, and cmlabs::ComponentInfoStruct::type.
Referenced by syncComponents(), and UnitTest().
| bool cmlabs::ComponentMemory::create | ( | uint32 | indexSize | ) |
Create the component segment (master only).
| indexSize | Component-id capacity. |
Definition at line 206 of file ComponentMemory.cpp.
References COMPONENTMEMORYID, cmlabs::utils::CreateSharedMemorySegment(), cmlabs::GetTimeNow(), and cmlabs::utils::StringFormat().
| bool cmlabs::ComponentMemory::createComponent | ( | uint32 | id, |
| uint8 | type, | ||
| uint8 | policy, | ||
| uint8 | selfTrigger, | ||
| const char * | name, | ||
| uint64 | size, | ||
| uint16 | nodeID, | ||
| uint16 | procID, | ||
| uint64 | time, | ||
| uint32 & | existingID ) |
Register a component record.
| id | Requested component id. |
| type | Component type. |
| policy | Migration policy. |
| selfTrigger | SELFTRIGGER_* policy. |
| name | Unique component name. |
| size | Initial record size in bytes. |
| nodeID | Node the component lives on. |
| procID | Process the component lives in. |
| time | Creation timestamp (µs). |
| existingID | Receives the id of a pre-existing component with the same name, if any. |
Definition at line 546 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ComponentInfoStruct::createdTime, GETCOMPDATA, getComponentID(), cmlabs::GetTimeNow(), LOG_MEMORY, LogPrint, MAXKEYNAMELEN, cmlabs::ComponentInfoStruct::name, cmlabs::ComponentInfoStruct::nodeID, cmlabs::ComponentInfoStruct::policy, cmlabs::ComponentInfoStruct::procID, cmlabs::ComponentInfoStruct::selfTrigger, cmlabs::ComponentInfoStruct::size, cmlabs::utils::strcpyavail(), stricmp, cmlabs::ComponentInfoStruct::syncStatus, and cmlabs::ComponentInfoStruct::type.
Referenced by syncComponents(), and UnitTest().
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| const char * | val, | ||
| const char * | defaultValue = NULL ) |
Definition at line 1632 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, getParameter(), PARAM_STRING, cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, cmlabs::ParamHeader::size, cmlabs::utils::strcpyavail(), and cmlabs::ParamHeader::type.
Referenced by createParameter(), createParameter(), createParameter(), createParameter(), createParameter(), setParameter(), and UnitTest().
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| const char * | val, | ||
| uint32 | count, | ||
| uint32 | defaultIndex ) |
Definition at line 1684 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ParamCollectionHeader::count, cmlabs::ParamCollectionHeader::defaultIndex, GETCOMPDATA, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_STRING_COLL, cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, cmlabs::ParamHeader::size, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| float64 * | val, | ||
| uint32 | count, | ||
| uint32 | defaultIndex ) |
Definition at line 1861 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ParamCollectionHeader::count, cmlabs::ParamCollectionHeader::defaultIndex, GETCOMPDATA, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_FLOAT_COLL, cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, cmlabs::ParamHeader::size, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| float64 | val, | ||
| float64 | min = 0, | ||
| float64 | max = 0, | ||
| float64 | interval = 0 ) |
Definition at line 1956 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ParamFloatHeader::defaultVal, GETCOMPDATA, getParameter(), cmlabs::ParamFloatHeader::interval, cmlabs::ParamFloatHeader::maxVal, cmlabs::ParamFloatHeader::minVal, PARAM_FLOAT, cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, cmlabs::ParamHeader::size, cmlabs::ParamHeader::type, and cmlabs::ParamFloatHeader::val.
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| int64 * | val, | ||
| uint32 | count, | ||
| uint32 | defaultIndex ) |
Definition at line 1814 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ParamCollectionHeader::count, cmlabs::ParamCollectionHeader::defaultIndex, GETCOMPDATA, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_INTEGER_COLL, cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, cmlabs::ParamHeader::size, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| int64 | val, | ||
| int64 | min = 0, | ||
| int64 | max = 0, | ||
| int64 | interval = 0 ) |
Definition at line 1908 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ParamIntegerHeader::defaultVal, GETCOMPDATA, getParameter(), cmlabs::ParamIntegerHeader::interval, cmlabs::ParamIntegerHeader::maxVal, cmlabs::ParamIntegerHeader::minVal, PARAM_INTEGER, cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, cmlabs::ParamHeader::size, cmlabs::ParamHeader::type, and cmlabs::ParamIntegerHeader::val.
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| std::vector< float64 > | values, | ||
| float64 | defaultValue = 0 ) |
Definition at line 1800 of file ComponentMemory.cpp.
References createParameter().
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| std::vector< int64 > | values, | ||
| int64 | defaultValue = 0 ) |
Definition at line 1772 of file ComponentMemory.cpp.
References createParameter().
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| std::vector< std::string > | values, | ||
| const char * | defaultValue = NULL ) |
Definition at line 1740 of file ComponentMemory.cpp.
References createParameter().
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| std::vector< std::string > | values, | ||
| float64 | defaultValue ) |
Definition at line 1786 of file ComponentMemory.cpp.
References cmlabs::utils::Ascii2Float64(), and createParameter().
| bool cmlabs::ComponentMemory::createParameter | ( | uint32 | cid, |
| const char * | name, | ||
| std::vector< std::string > | values, | ||
| int64 | defaultValue ) |
Definition at line 1758 of file ComponentMemory.cpp.
References cmlabs::utils::Ascii2Int64(), and createParameter().
| bool cmlabs::ComponentMemory::deleteParameter | ( | uint32 | cid, |
| const char * | name ) |
Remove the parameter.
Definition at line 2025 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, COMPINFOUSAGE, GETCOMPDATA, getParameter(), cmlabs::ComponentInfoStruct::paramCount, cmlabs::ComponentInfoStruct::paramSize, and cmlabs::ParamHeader::size.
Referenced by setParameter(), and UnitTest().
| bool cmlabs::ComponentMemory::deletePrivateData | ( | uint32 | cid, |
| const char * | name ) |
Delete blob name.
Definition at line 1596 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, COMPINFOUSAGE, cmlabs::ComponentInfoStruct::dataCount, cmlabs::ComponentInfoStruct::dataSize, GETCOMPDATA, getPrivateData(), and cmlabs::PrivateHeader::size.
Referenced by setPrivateData(), and UnitTest().
| bool cmlabs::ComponentMemory::destroyComponent | ( | uint32 | cid | ) |
Remove a component record and free its space.
Definition at line 688 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, GETCOMPOFFSETP, and cmlabs::ComponentInfoStruct::size.
Referenced by UnitTest().
| std::list< uint16 > * cmlabs::ComponentMemory::findProcessComponents | ( | uint16 | procID | ) |
List ids of components in process procID.
Definition at line 818 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.
| std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllCatalogs | ( | ) |
Snapshot all catalog components.
Definition at line 190 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, COMP_CATALOG, COMP_WHITEBOARD, and GETCOMPDATA.
| std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllComponents | ( | ) |
Snapshot all components.
Definition at line 129 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.
Referenced by printFriendly(), toXML(), writeComponentNamesToMsg(), and writeComponentsToMsg().
| std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllLocalComponents | ( | ) |
Snapshot components on this node.
Definition at line 144 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.
| std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllLocalComponents | ( | uint8 | type | ) |
Snapshot local components of type.
Definition at line 159 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.
| std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllModules | ( | ) |
Snapshot all module components.
Definition at line 174 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, COMP_EXTERNAL, COMP_INTERNAL, and GETCOMPDATA.
| char * cmlabs::ComponentMemory::getComponentData | ( | uint32 | cid, |
| uint64 & | size ) |
Copy a component's whole data area (for migration).
| cid | Component id. |
| size | Receives byte count. |
Definition at line 758 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::size.
| bool cmlabs::ComponentMemory::getComponentID | ( | const char * | name, |
| uint32 & | cid ) |
Look up a component id by name.
Definition at line 1214 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and stricmp.
Referenced by createComponent(), isComponentLocal(), and UnitTest().
| bool cmlabs::ComponentMemory::getComponentLocation | ( | uint32 | cid, |
| uint16 & | nodeID, | ||
| uint16 & | procID ) |
Get the node/process the component runs in.
Definition at line 952 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::nodeID, and cmlabs::ComponentInfoStruct::procID.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::getComponentName | ( | uint32 | cid, |
| char * | name, | ||
| uint32 | maxNameLen ) |
Copy the component name into name.
Definition at line 1079 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::name, and cmlabs::utils::strcpyavail().
Referenced by UnitTest().
| std::string cmlabs::ComponentMemory::getComponentNameString | ( | uint32 | cid | ) |
Definition at line 1057 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::name.
| uint16 cmlabs::ComponentMemory::getComponentNodeID | ( | uint32 | cid | ) |
Definition at line 977 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::nodeID.
Referenced by UnitTest().
| AveragePerfStats cmlabs::ComponentMemory::getComponentPerfStats | ( | uint32 | cid | ) |
Definition at line 1146 of file ComponentMemory.cpp.
References GETCOMPDATA, open(), and cmlabs::ComponentInfoStruct::perfStats.
| uint8 cmlabs::ComponentMemory::getComponentPolicy | ( | uint32 | cid | ) |
Definition at line 840 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::policy.
Referenced by canComponentMigrate().
| uint16 cmlabs::ComponentMemory::getComponentProcessID | ( | uint32 | cid | ) |
Definition at line 999 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::procID.
Referenced by UnitTest().
| uint8 cmlabs::ComponentMemory::getComponentSelfTrigger | ( | uint32 | cid | ) |
Definition at line 909 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::selfTrigger.
Referenced by UnitTest().
| ComponentStats cmlabs::ComponentMemory::getComponentStats | ( | uint32 | cid | ) |
Definition at line 1122 of file ComponentMemory.cpp.
References GETCOMPDATA, open(), and cmlabs::ComponentInfoStruct::stats.
Referenced by UnitTest().
| uint8 cmlabs::ComponentMemory::getComponentType | ( | uint32 | cid | ) |
Definition at line 1100 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::type.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::getMemoryUsage | ( | uint64 & | alloc, |
| uint64 & | usage ) |
Report allocation/usage of the component segment.
Definition at line 35 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL.
| bool cmlabs::ComponentMemory::getParameter | ( | uint32 | cid, |
| const char * | name, | ||
| char * | val, | ||
| uint32 | maxSize ) |
Definition at line 2246 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_STRING, PARAM_STRING_COLL, cmlabs::utils::strcpyavail(), and cmlabs::ParamHeader::type.
Referenced by createParameter(), createParameter(), createParameter(), createParameter(), createParameter(), createParameter(), deleteParameter(), getParameter(), getParameter(), getParameter(), getParameterAsBool(), getParameterDataType(), getParameterFloat(), getParameterInt(), getParameterString(), getParameterString(), getParameterValueSize(), hasParameter(), resetParameter(), setParameter(), setParameter(), setParameter(), tweakParameter(), and UnitTest().
| bool cmlabs::ComponentMemory::getParameter | ( | uint32 | cid, |
| const char * | name, | ||
| float64 & | val ) |
Definition at line 2328 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_FLOAT, PARAM_FLOAT_COLL, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::getParameter | ( | uint32 | cid, |
| const char * | name, | ||
| int64 & | val ) |
Definition at line 2292 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_INTEGER, PARAM_INTEGER_COLL, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::getParameterAsBool | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2170 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_FLOAT, PARAM_FLOAT_COLL, PARAM_INTEGER, PARAM_INTEGER_COLL, PARAM_STRING, PARAM_STRING_COLL, stricmp, and cmlabs::ParamHeader::type.
| uint8 cmlabs::ComponentMemory::getParameterDataType | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2051 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), and cmlabs::ParamHeader::type.
| float64 cmlabs::ComponentMemory::getParameterFloat | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2163 of file ComponentMemory.cpp.
References getParameter().
| int64 cmlabs::ComponentMemory::getParameterInt | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2156 of file ComponentMemory.cpp.
References getParameter().
| std::string cmlabs::ComponentMemory::getParameterString | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2117 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_STRING, PARAM_STRING_COLL, and cmlabs::ParamHeader::type.
| std::string cmlabs::ComponentMemory::getParameterString | ( | uint32 | cid, |
| const char * | name, | ||
| uint32 | maxSize ) |
Definition at line 2108 of file ComponentMemory.cpp.
References getParameter().
| uint32 cmlabs::ComponentMemory::getParameterValueSize | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2072 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_FLOAT, PARAM_FLOAT_COLL, PARAM_INTEGER, PARAM_INTEGER_COLL, PARAM_STRING, and cmlabs::ParamHeader::type.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::getPrivateData | ( | uint32 | cid, |
| const char * | name, | ||
| char * | data, | ||
| uint64 | maxSize ) |
Copy blob into caller buffer data (max maxSize).
Definition at line 1467 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getPrivateData(), and cmlabs::PrivateHeader::size.
Referenced by deletePrivateData(), getPrivateData(), getPrivateDataCopy(), getPrivateDataMimetype(), getPrivateDataSize(), setPrivateData(), and UnitTest().
| char * cmlabs::ComponentMemory::getPrivateDataCopy | ( | uint32 | cid, |
| const char * | name, | ||
| uint64 & | size ) |
Definition at line 1436 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getPrivateData(), and cmlabs::PrivateHeader::size.
| std::list< std::string > cmlabs::ComponentMemory::getPrivateDataKeys | ( | uint32 | cid | ) |
Definition at line 1559 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIALRETURN, cmlabs::ComponentInfoStruct::dataSize, GETCOMPDATA, and cmlabs::ComponentInfoStruct::paramSize.
| std::map< std::string, std::string > cmlabs::ComponentMemory::getPrivateDataKeysAndTypes | ( | uint32 | cid | ) |
Definition at line 1520 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIALRETURN, cmlabs::ComponentInfoStruct::dataSize, GETCOMPDATA, and cmlabs::ComponentInfoStruct::paramSize.
| std::string cmlabs::ComponentMemory::getPrivateDataMimetype | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 1497 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, and getPrivateData().
| uint64 cmlabs::ComponentMemory::getPrivateDataSize | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 1412 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getPrivateData(), and cmlabs::PrivateHeader::size.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::hasParameter | ( | uint32 | cid, |
| const char * | name ) |
Definition at line 2004 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, and getParameter().
| bool cmlabs::ComponentMemory::isComponentLocal | ( | const char * | name | ) |
Definition at line 1049 of file ComponentMemory.cpp.
References getComponentID(), and isComponentLocal().
| bool cmlabs::ComponentMemory::isComponentLocal | ( | uint32 | cid | ) |
Definition at line 1022 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::nodeID.
Referenced by isComponentLocal().
| uint8 cmlabs::ComponentMemory::lookupComponentID | ( | const char * | name, |
| uint32 & | id ) |
Look up a component by name without filtering on readiness.
| name | Component name to look up. |
| id | Receives the component id when found. |
Definition at line 1234 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::name, stricmp, and cmlabs::ComponentInfoStruct::syncStatus.
| bool cmlabs::ComponentMemory::open | ( | ) |
Attach to the existing component segment.
Definition at line 240 of file ComponentMemory.cpp.
References cmlabs::ComponentMemoryStruct::cid, cmlabs::utils::CloseSharedMemorySegment(), COMPONENTMEMORYID, cmlabs::utils::OpenSharedMemorySegment(), and cmlabs::utils::StringFormat().
Referenced by getComponentPerfStats(), and getComponentStats().
| std::string cmlabs::ComponentMemory::printFriendly | ( | ) |
Definition at line 83 of file ComponentMemory.cpp.
References getAllComponents(), and cmlabs::utils::StringFormat().
| bool cmlabs::ComponentMemory::resetParameter | ( | uint32 | cid, |
| const char * | name ) |
Restore the parameter's default value/index.
Definition at line 2530 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), PARAM_FLOAT, PARAM_FLOAT_COLL, PARAM_INTEGER, PARAM_INTEGER_COLL, PARAM_STRING, PARAM_STRING_COLL, setParameter(), and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::setComponentData | ( | uint32 | cid, |
| const char * | data, | ||
| uint64 | size, | ||
| bool | wasMigrated ) |
Replace a component's data area (after migration).
| cid | Component id. |
| data | New data area. |
| size | Byte count. |
| wasMigrated | Marks a migration event. |
Definition at line 782 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentStats::migrationCount, cmlabs::ComponentInfoStruct::size, and cmlabs::ComponentInfoStruct::stats.
| bool cmlabs::ComponentMemory::setComponentPerfStats | ( | uint32 | cid, |
| AveragePerfStats & | perfStruct ) |
Store new performance averages.
Definition at line 1170 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::perfStats.
| bool cmlabs::ComponentMemory::setComponentPolicy | ( | uint32 | cid, |
| uint8 | policy ) |
Set the migration policy.
Definition at line 888 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::policy.
| bool cmlabs::ComponentMemory::setComponentSelfTrigger | ( | uint32 | cid, |
| uint8 | selfTrigger ) |
Set the self-trigger policy.
Definition at line 930 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::selfTrigger.
| bool cmlabs::ComponentMemory::setComponentStats | ( | uint32 | cid, |
| ComponentStats & | stats ) |
Overwrite the component's stats.
Definition at line 1192 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::stats.
| bool cmlabs::ComponentMemory::setParameter | ( | uint32 | cid, |
| const char * | name, | ||
| const char * | val ) |
Definition at line 2365 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, createParameter(), deleteParameter(), getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_STRING, PARAM_STRING_COLL, cmlabs::utils::strcpyavail(), stricmp, and cmlabs::ParamHeader::type.
Referenced by resetParameter().
| bool cmlabs::ComponentMemory::setParameter | ( | uint32 | cid, |
| const char * | name, | ||
| float64 | val ) |
Definition at line 2482 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_FLOAT, PARAM_FLOAT_COLL, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::setParameter | ( | uint32 | cid, |
| const char * | name, | ||
| int64 | val ) |
Definition at line 2435 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, PARAM_INTEGER, PARAM_INTEGER_COLL, and cmlabs::ParamHeader::type.
| bool cmlabs::ComponentMemory::setPrivateData | ( | uint32 | cid, |
| const char * | name, | ||
| const char * | data, | ||
| uint64 | size, | ||
| const char * | mimetype = NULL ) |
Create/replace blob name.
Data is copied.
Definition at line 1329 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ComponentInfoStruct::dataCount, cmlabs::ComponentInfoStruct::dataSize, deletePrivateData(), GETCOMPDATA, getPrivateData(), cmlabs::PrivateHeader::size, and stricmp.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::syncComponents | ( | DataMessage * | msg | ) |
Merge component records received from a remote node.
Definition at line 520 of file ComponentMemory.cpp.
References confirmComponentID(), createComponent(), cmlabs::DataMessage::getInt(), cmlabs::DataMessage::getString(), and cmlabs::DataMessage::getTime().
| std::string cmlabs::ComponentMemory::toXML | ( | bool | stats = true | ) |
Definition at line 107 of file ComponentMemory.cpp.
References getAllComponents(), and cmlabs::utils::StringFormat().
| bool cmlabs::ComponentMemory::tweakParameter | ( | uint32 | cid, |
| const char * | name, | ||
| int32 | tweak ) |
Step the value by tweak * interval (or collection index).
Definition at line 2592 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, getParameter(), cmlabs::ParamCollectionHeader::index, cmlabs::ParamFloatHeader::interval, cmlabs::ParamIntegerHeader::interval, cmlabs::ParamFloatHeader::maxVal, cmlabs::ParamIntegerHeader::maxVal, cmlabs::ParamFloatHeader::minVal, cmlabs::ParamIntegerHeader::minVal, PARAM_FLOAT, PARAM_FLOAT_COLL, PARAM_INTEGER, PARAM_INTEGER_COLL, PARAM_STRING_COLL, cmlabs::ParamHeader::type, cmlabs::ParamFloatHeader::val, and cmlabs::ParamIntegerHeader::val.
Referenced by UnitTest().
|
static |
Self-test.
Definition at line 2670 of file ComponentMemory.cpp.
References addComponentStats(), COMP_INTERNAL, COMPONENT_CAN_MIGRATE, cmlabs::MemoryManager::componentMemory, COMPSTATUS_RUNNING, confirmComponentID(), cmlabs::DataMapsMemory::confirmTagID(), cmlabs::DataMapsMemory::confirmTypeLevelID(), cmlabs::MemoryManager::create(), createComponent(), cmlabs::DataMapsMemory::createNewTag(), cmlabs::DataMapsMemory::createNewTypeLevel(), createParameter(), cmlabs::ComponentStats::cycleCount, cmlabs::MemoryManager::dataMapsMemory, deleteParameter(), deletePrivateData(), destroyComponent(), cmlabs::unittest::detail(), DRAFTMSGSIZE, cmlabs::unittest::fail(), getComponentID(), getComponentLocation(), getComponentName(), getComponentNodeID(), getComponentProcessID(), getComponentSelfTrigger(), getComponentStats(), getComponentType(), cmlabs::DataMessage::getInt(), getParameter(), getParameterValueSize(), getPrivateData(), getPrivateDataSize(), cmlabs::DataMessage::getSize(), cmlabs::DataMapsMemory::getTagID(), cmlabs::DataMapsMemory::getTagName(), cmlabs::DataMapsMemory::getTypeLevelID(), cmlabs::DataMapsMemory::getTypeLevelName(), cmlabs::ComponentStats::msgInBytes, cmlabs::ComponentStats::msgInCount, cmlabs::ComponentStats::msgOutBytes, cmlabs::ComponentStats::msgOutCount, cmlabs::unittest::progress(), cmlabs::ComponentStats::recentInMsg, cmlabs::ComponentStats::runCount, SELFTRIGGER_ALLOW, SELFTRIGGER_WARN, cmlabs::DataMessage::setInt(), setPrivateData(), cmlabs::DataMessage::setString(), cmlabs::utils::strcpyavail(), tweakParameter(), updateComponentLocation(), and cmlabs::ComponentStats::usageCPUTicks.
Referenced by cmlabs::Register_ComponentMemory_Tests().
| bool cmlabs::ComponentMemory::updateComponentInformation | ( | uint32 | cid, |
| uint8 | type, | ||
| uint8 | policy, | ||
| uint8 | selfTrigger, | ||
| uint16 | nodeID, | ||
| uint16 | procID ) |
Update type/policy/self-trigger/location in one call.
Definition at line 861 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::nodeID, cmlabs::ComponentInfoStruct::policy, cmlabs::ComponentInfoStruct::procID, cmlabs::ComponentInfoStruct::selfTrigger, cmlabs::ComponentInfoStruct::syncStatus, and cmlabs::ComponentInfoStruct::type.
| bool cmlabs::ComponentMemory::updateComponentLocation | ( | uint32 | cid, |
| uint16 | nodeID, | ||
| uint16 | procID ) |
Record a new location (after migration).
Definition at line 736 of file ComponentMemory.cpp.
References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::nodeID, and cmlabs::ComponentInfoStruct::procID.
Referenced by UnitTest().
| bool cmlabs::ComponentMemory::writeComponentNamesToMsg | ( | DataMessage * | msg | ) |
Write just the component names into msg.
Definition at line 479 of file ComponentMemory.cpp.
References getAllComponents(), and cmlabs::DataMessage::setString().
| bool cmlabs::ComponentMemory::writeComponentsToMsg | ( | DataMessage * | msg | ) |
Serialize all component records into msg.
Definition at line 497 of file ComponentMemory.cpp.
References getAllComponents().