36namespace GENAPI_NAMESPACE
39 template <
class CDataStruct>
71 virtual void Read(
void *pBuffer, int64_t Address, int64_t Length)
75 CDataStruct *pDataStruct =
static_cast<CDataStruct*
>(
this);
76 if( ( InternalAddress < 0 ) || ( Length < 0 ) || ( InternalAddress + Length >
static_cast<int64_t
>(
sizeof(CDataStruct) ) ) )
78 memcpy( pBuffer, (uint8_t*)pDataStruct + InternalAddress, (
size_t)Length );
83 virtual void Write(
const void *pBuffer, int64_t Address, int64_t Length)
87 CDataStruct *pDataStruct =
static_cast<CDataStruct*
>(
this);
88 if( ( InternalAddress < 0 ) || ( Length < 0 ) || ( InternalAddress + Length >
static_cast<int64_t
>(
sizeof(CDataStruct) ) ) )
89 throw RUNTIME_EXCEPTION(
"CTestPortStruct::Write - Invalid address and/or length");
90 memcpy( (uint8_t*)pDataStruct + InternalAddress, pBuffer, (
size_t)Length );
98 void MemSet(
const char FillValue )
100 memset(
static_cast<CDataStruct*
>(
this), FillValue,
sizeof(CDataStruct) );
Implements a register spaces based on a C++ struct.
Definition StructPort.h:41
virtual GENAPI_NAMESPACE::EAccessMode GetAccessMode() const
Get the access mode of the node.
Definition StructPort.h:55
int64_t m_NumWrites
Number of writes since last reset.
Definition StructPort.h:131
virtual void Write(const void *pBuffer, int64_t Address, int64_t Length)
Writes a chunk of bytes to the port.
Definition StructPort.h:83
int64_t m_NumReads
Number of reads since last reset.
Definition StructPort.h:128
void ResetStatistics()
Resets the read/write statistics.
Definition StructPort.h:108
int64_t GetNumWrites()
Returns the number of writes since lastReset Statistics.
Definition StructPort.h:121
virtual void Read(void *pBuffer, int64_t Address, int64_t Length)
Reads a chunk of bytes from the port.
Definition StructPort.h:71
int64_t GetNumReads()
Returns the number of reads since lastReset Statistics.
Definition StructPort.h:115
int64_t m_BaseAddress
the base address used for the struct
Definition StructPort.h:134
virtual GENAPI_NAMESPACE::EInterfaceType GetPrincipalInterfaceType() const
Get the type of the main interface of a node.
Definition StructPort.h:61
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
Definition GCException.h:246
enum GENAPI_NAMESPACE::_EInterfaceType EInterfaceType
@ intfIPort
IPort interface.
Definition Types.h:199
enum GENAPI_NAMESPACE::_EAccessMode EAccessMode
@ RW
Read and Write.
Definition Types.h:58