Here is the one example relating to this from the C++ SDK (attached):
4.7.24 LockForRead
Prototype
virtual CyResult LockForRead( void ** aPtr, unsigned long* aSize, unsigned long aFlags = 0 );
Description
Locks a buffer for read operations.
This function blocks and waits for data to be available, unless otherwise indicated by the flags
Parameters
aPtr - A pointer to the pointer that will point to the data in the buffer
aSize - A pointer to an unsigned long integer that will contain the size of the buffer.
aFlags - Possible flags that can be use in combination:
FLAG_NO_WAIT - If an image is already available, don’t wait for the next.
FLAG_ERROR_IF_EMPTY - If no image is available and no writing operation is pending, return an error.
If this flag is not present, the function waits for the next write operation.
4.7.31 Example - Locking for read
#include CyBuffer.h
CyBuffer lBuffer( 1024 );
CyResult lResult;
unsigned char * lData;
unsigned long lSize;
// ... give the buffer to a object that will fill it
// Now, we want to wait for data and then use that data
// The function uses a void** pointer, we use an unsigned
// char* pointer because it is more convenient to use.
lResult = lBuffer.LockForRead( (void**) &lData, &lSize, 0 );
// Error Handling
// Here the data is locked and will not be overwritten by
// any other thread.
// ... use the data …
// When the data is not needed anymore, release it
lBuffer.SignalReadEnd();
While this bit looks simple enough, there is a lot that needs to go on to get to the point where this call can be made. In the LabVIEW code screenshot I sent, the LockForRead step uses the sixth of six refnums that need to be opened and configured to get to that step where the camera is up and running and making data available. I'm not sure how much of that setup must be duplicated within the DLL as well. I would guess it would include at least as much as the setup of "lBuffer" as well since the C++ code does not seem to use anything that looks like a LabVIEW refnum...
This example would seem to relate to that "lBuffer" setup process:
6.1.7 Example - Setting the capacity
#include CyBuffer.h
#include CyPixelTypeFactory.h
#include CyImageBuffer.h
#include CyPixelType.h
#include CyGrayscale8.h
CyImageBuffer lBuffer;
// Now set the capacity
lBuffer.SetCapacity( 640, 480, CyGrayscale8::ID );
// This is the equivalent to the following code with a normal CyBuffer
CyBuffer lBuffer2;
CyPixelType*
lType = CyPixelTypeFactory::CreatePixelType( CyGrayscale8::ID );
lBuffer.SetCapacity( lType.GetBufferSizeFor( 640, 480 ) );
delete lType;
Message Edited by Warren Massey on 03-13-2005 04:45 AM