Design Pattern Examples
Overview of object-oriented design patterns
DesignPatternExamples_python.adapter.adapter_backendfunctions Namespace Reference

Classes

class  DDR_ErrorCode
 Represents the possible errors that can be returned from the memory block access functions. More...
 
class  Handle
 Represents an opaque token or handle to data. More...
 
class  ValueHandle
 Represents a value that can be passed into or out of a function. More...
 

Functions

DDR_ErrorCode ddr_openmemoryblock (blockName, Handle dataHandle)
 Open access to a memory block for exclusive use, given the name of the memory block.
 
DDR_ErrorCode ddr_closememoryblock (Handle dataHandle)
 Close access to a memory block previously opened by ddr_openmemoryblock(), thus releasing it for others to open.
 
DDR_ErrorCode ddr_getmemorysize (Handle dataHandle, ValueHandle memorySizeInChunks)
 Retrieve the number of chunks in the memory block indicated by the handle to the successfully opened memory block.
 
DDR_ErrorCode ddr_getdatachunk (Handle dataHandle, int chunkOffset, ValueHandle value)
 Read a single 32-bit value at the given offset in the memory block indicated by the specified handle.
 
DDR_ErrorCode ddr_setdatachunk (Handle dataHandle, int chunkOffset, int value)
 Writes a single 32-bit value to the given offset in the memory block indicated by the specified handle.
 

Variables

int DDR_MAX_OFFSET = 32
 All offsets must from 0 to 1 less than this value.
 
str BLOCK_NAME_0 = "gorp"
 Name of the first block.
 
str BLOCK_NAME_1 = "baba"
 Name of the second block.
 
str BLOCK_NAME_2 = "yaga"
 Name of the third block.
 
os dll_path = os.path.join(os.path.dirname(__file__), "Adapter_BackEnd")
 Path to the Adapter_BackEnd DLL that will be loaded by ctypes.
 
 else :
 
cdll adapter_backend = cdll.LoadLibrary(dll_path)
 Instance of a CDLL object representing the loaded Adapter_BackEnd DLL.
 

Function Documentation

◆ ddr_closememoryblock()

DDR_ErrorCode ddr_closememoryblock ( Handle  dataHandle)

Close access to a memory block previously opened by ddr_openmemoryblock(), thus releasing it for others to open.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the ddr_openmemoryblock() function.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Definition at line 113 of file adapter_backendfunctions.py.

Referenced by DataReaderWriter.__exit__().

◆ ddr_getdatachunk()

DDR_ErrorCode ddr_getdatachunk ( Handle  dataHandle,
int  chunkOffset,
ValueHandle  value 
)

Read a single 32-bit value at the given offset in the memory block indicated by the specified handle.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the ddr_openmemoryblock() function.
chunkOffsetOffset into the memory block from which to get the value (range is 0 to DDR_MAX_OFFSET-1).
valueReturns the requested value.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Definition at line 150 of file adapter_backendfunctions.py.

Referenced by DataReaderWriter.Read(), and DataReaderWriter.Write().

◆ ddr_getmemorysize()

DDR_ErrorCode ddr_getmemorysize ( Handle  dataHandle,
ValueHandle  memorySizeInChunks 
)

Retrieve the number of chunks in the memory block indicated by the handle to the successfully opened memory block.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the ddr_openmemoryblock() function.
memorySizeInChunksReturns the number of 32-bit chunks in the memory block.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Definition at line 128 of file adapter_backendfunctions.py.

Referenced by DataReaderWriter.__enter__().

◆ ddr_openmemoryblock()

DDR_ErrorCode ddr_openmemoryblock (   blockName,
Handle  dataHandle 
)

Open access to a memory block for exclusive use, given the name of the memory block.

Use ddr_closememoryblock() to release access to the memory block.

Parameters
blockNameName of the block to access (one of the predefined names, BLOCK_NAME_0, BLOCK_NAME_1, or BLOCK_NAME_2)
dataHandleReturns a handle to be used for accessing the specific memory block.
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Definition at line 95 of file adapter_backendfunctions.py.

Referenced by DataReaderWriter.__enter__().

◆ ddr_setdatachunk()

DDR_ErrorCode ddr_setdatachunk ( Handle  dataHandle,
int  chunkOffset,
int  value 
)

Writes a single 32-bit value to the given offset in the memory block indicated by the specified handle.

Parameters
dataHandleHandle to a previously opened memory block as obtained from the ddr_openmemoryblock() function.
chunkOffsetOffset into the memory block to which to set the value (range is 0 to DDR_MAX_OFFSET-1).
valueThe value to write to the memory block
Returns
Returns a value from the DDR_ErrorCode enumeration indicating success or failure.

Definition at line 172 of file adapter_backendfunctions.py.

Referenced by DataReaderWriter.Write().

Variable Documentation

◆ adapter_backend

cdll adapter_backend = cdll.LoadLibrary(dll_path)

Instance of a CDLL object representing the loaded Adapter_BackEnd DLL.

Definition at line 78 of file adapter_backendfunctions.py.

◆ BLOCK_NAME_0

str BLOCK_NAME_0 = "gorp"

Name of the first block.

Definition at line 35 of file adapter_backendfunctions.py.

◆ BLOCK_NAME_1

str BLOCK_NAME_1 = "baba"

Name of the second block.

Definition at line 38 of file adapter_backendfunctions.py.

◆ BLOCK_NAME_2

str BLOCK_NAME_2 = "yaga"

Name of the third block.

Definition at line 41 of file adapter_backendfunctions.py.

◆ DDR_MAX_OFFSET

int DDR_MAX_OFFSET = 32

All offsets must from 0 to 1 less than this value.

Definition at line 32 of file adapter_backendfunctions.py.

◆ dll_path

os dll_path = os.path.join(os.path.dirname(__file__), "Adapter_BackEnd")

Path to the Adapter_BackEnd DLL that will be loaded by ctypes.

The DLL is located in the same directory as this file.

Definition at line 73 of file adapter_backendfunctions.py.

◆ else

else :

Definition at line 74 of file adapter_backendfunctions.py.