📄 bcam.h
字号:
{
IMPLEMENT_THIS(CTrigger, Mode); ///< This() retruns a pointer to outer class
public:
void operator=(DCSTriggerMode Value);
DCSTriggerMode operator()();
} Mode; ///< Mode feature
friend class CMode;
/// Get and set the trigger parameter
class CParameter
{
IMPLEMENT_THIS(CTrigger, Parameter); ///< This() retruns a pointer to outer class
public:
void operator=(unsigned long Value);
unsigned long operator()();
} Parameter; ///< Trigger parameter feature
friend class CParameter;
friend class CBoolControl;
friend class CBcam;
protected:
void Save(const CPropertyBagPtr ptrBag);
void Restore(const CPropertyBagPtr ptrBag);
} Trigger; ///< Trigger feature
friend class CTrigger;
friend class CTrigger::CMode;
friend class CTrigger::CParameter;
friend class CTrigger::CBoolControl;
friend class CTrigger::CPolarity;
/// Inquire and set OneShot
class COneShot
{
IMPLEMENT_THIS(CBcam, OneShot); ///< This() returns a pointer to outer class
public:
bool IsSupported();
void Set();
void SetAsync(void *pContext = NULL);
} OneShot; ///< One shot feature
friend class COneShot;
/// Inquire, set and reset ContinuousShot
class CContinuousShot
{
IMPLEMENT_THIS(CBcam, ContinuousShot); ///< This() returns a pointer to the outer class
public:
bool IsSupported();
void operator=(bool Value);
bool operator()();
void SetAsync(bool Value, void *pContext = NULL );
} ContinuousShot; ///< Continous shot (ISO_EN) feature
friend class CContinuousShot;
// Inquire, set and reset MultiShot
/*
class CMultiShot
{
public:
bool IsSupported();
void operator=(bool Value);
bool operator()();
class CCountNumber
{
public:
void operator=(unsigned long Value);
unsigned long operator()();
} CountNumber;
} MultiShot;
*/
// Allocate isochronous channel, resource handle and bandwidth
ULONG AllocateResources(unsigned long MaxBuffers, unsigned long MaxBufferSize, unsigned long BytePerPacket = 0);
// Release isochronous channel, resource handle and bandwidth
void FreeResources();
// Grab image with or without asserting OneShot
void GrabImage( void *pBuffer, size_t BufferSize, Timespan Timeout = INFINITE, bool OneShot = true );
// Grab image asynchronously
void GrabImageAsync( void *pBuffer, size_t BufferSize, void *pContext = NULL, bool OneShot = true);
// Grab n buffers (Multishot)
void GrabImages( void *pBuffer[], size_t numBuffers, size_t BufferSize, Timespan Timeout = INFINITE );
/// Inquire, get and set Format7 parameters
class CFormatSeven
{
IMPLEMENT_THIS( CBcam, FormatSeven ); ///< This() returns pointer to outer class
public:
/// Inquire, get and set a specific Format7 mode
class _FormatSeven
{
const size_t m_Mode; ///< video mode of format 7
public:
CSize MaxSize();
/// Inquire, get and set the image position
class CImagePosition
{
IMPLEMENT_THIS( _FormatSeven, Position ); ///< This() returns pointer to outer class
public:
void operator=(CPoint Value);
CPoint operator()();
CSize Inc();
void SetAsync(CPoint Value, void *pContext = NULL);
} Position; ///< Image position of mode
friend class CImagePosition;
/// Inquire, get and set the image size
class CImageSize
{
IMPLEMENT_THIS( _FormatSeven, Size ); ///< This() returns pointer to outer class
public:
void operator=(CSize Value);
CSize operator()();
CSize Inc();
void SetAsync(CSize Value, void *pContext = NULL);
} Size; ///< Image size of mode
friend class CImageSize;
/// Inquire, get and set the image type
class CColorCoding
{
IMPLEMENT_THIS( _FormatSeven, ColorCoding ); ///< This() returns pointer to outer class
public:
bool IsSupported(DCSColorCode ColorCode);
void operator=(DCSColorCode Value);
DCSColorCode operator()();
} ColorCoding; ///< image type of mode
friend class CColorCoding;
unsigned long PixelPerFrame();
unsigned long BytePerFrame();
unsigned long PacketsPerFrame();
/// Inquire, get and set the packet parameters
class CBytePerPacket
{
IMPLEMENT_THIS(_FormatSeven, BytePerPacket); ///< This() returns pointer to outer class.
public:
unsigned long Inc();
unsigned long Max();
unsigned long Rec();
void operator=(unsigned long Value);
unsigned long operator()();
void SetAsync(unsigned long Value, void *pContext = NULL);
} BytePerPacket; ///< Packet parameters of mode
friend class CBytePerPacket;
const size_t baseoffset; ///< offset of first video mode
/// Access to outer class
CFormatSeven* This(){ return (CFormatSeven*)((BYTE*)this - baseoffset); }
/// Constructor
_FormatSeven( size_t offset,size_t mode ):baseoffset(offset), m_Mode(mode){}
protected:
void Save(const CPropertyBagPtr ptrBag);
void Restore(const CPropertyBagPtr ptrBag);
friend class CBcam;
};
friend class _FormatSeven;
friend class _FormatSeven::CImagePosition;
friend class _FormatSeven::CImageSize;
friend class _FormatSeven::CColorCoding;
friend class _FormatSeven::CBytePerPacket;
_FormatSeven Format7_0; ///< Mode 0 of format 7
_FormatSeven Format7_1; ///< Mode 1 of format 7
_FormatSeven Format7_2; ///< Mode 2 of format 7
_FormatSeven Format7_3; ///< Mode 3 of format 7
_FormatSeven Format7_4; ///< Mode 4 of format 7
_FormatSeven Format7_5; ///< Mode 5 of format 7
_FormatSeven Format7_6; ///< Mode 6 of format 7
_FormatSeven Format7_7; ///< Mode 7 of format 7
/// Access to the modes of format 7
_FormatSeven& operator[]( int i ){
switch (i)
{
case 0: return Format7_0;
case 1: return Format7_1;
case 2: return Format7_2;
case 3: return Format7_3;
case 4: return Format7_4;
case 5: return Format7_5;
case 6: return Format7_6;
case 7: return Format7_7;
default:
throw BcamException( BCAM_E_UNSUPPORTED_VIDEO_MODE, _T( "Mode not defined" ), &i );
}
}
/// Constructor
CFormatSeven() :
Format7_0( offsetof( CFormatSeven, Format7_0 ), 0 ),
Format7_1( offsetof( CFormatSeven, Format7_1 ), 1 ),
Format7_2( offsetof( CFormatSeven, Format7_2 ), 2 ),
Format7_3( offsetof( CFormatSeven, Format7_3 ), 3 ),
Format7_4( offsetof( CFormatSeven, Format7_4 ), 4 ),
Format7_5( offsetof( CFormatSeven, Format7_5 ), 5 ),
Format7_6( offsetof( CFormatSeven, Format7_6 ), 6 ),
Format7_7( offsetof( CFormatSeven, Format7_7 ), 7 )
{
}
} FormatSeven; ///< Format 7 feature
friend class CFormatSeven;
friend class CFormatSeven::_FormatSeven;
friend class CFormatSeven::_FormatSeven::CImagePosition;
friend class CFormatSeven::_FormatSeven::CImageSize;
friend class CFormatSeven::_FormatSeven::CBytePerPacket;
friend class CFormatSeven::_FormatSeven::CColorCoding;
// Wait for completion of asynchronous function calls
void WaitForCompletion(FunctionCode_t *pFunktionCode, unsigned long *pErrorCode,
void**ppContext = NULL, Timespan Timeout = INFINITE);
// Post an I/O completion packet to the completion port
void Notify(FunctionCode_t FunctionCode, void* pContext = NULL);
// Cancel all function calls
void Cancel();
/// Supply information about the camera and the driver
class CInfo
{
IMPLEMENT_THIS( CBcam, Info ); ///< This() returns pointer to outer class.
public:
CString DeviceName();
CString NodeId();
CString ModelName();
CString VendorName();
CString CameraFirmwareVersion();
unsigned long CameraDcamVersion();
CString DriverSoftwareVersion();
// For information purposes only. This value is set by the driver
long IsoChannel();
// For information purposes only. This value is set by the driver
BcamIsoSpeed IsoSpeed();
} Info; ///< Camera information object
friend class CInfo;
/// get and set feature
class CBoolControl
{
public:
void operator=(bool Value);
bool operator()();
} ErrorChecking, ///< Error checking feature of the driver
ValueCaching; ///< Value caching feature of the driver
/// Memory Channels.
class CMemoryChannels
{
public:
bool IsSupported() const;
unsigned long Count() const;
unsigned long Current() const;
/// Memory Channel.
class CMemoryChannel
{
public:
void Load();
void Save();
protected:
CMemoryChannel( CMemoryChannels* pParent, unsigned long iNumber );
private:
CMemoryChannels *m_pParent;
unsigned long m_iNumber;
friend class CMemoryChannels;
};
CMemoryChannel operator[]( int i );
protected:
CMemoryChannels(){};
private:
IMPLEMENT_THIS( CBcam, MemoryChannels ); ///< This() returns pointer to outer class
friend class CBcam;
friend class CMemoryChannel;
}
MemoryChannels;
friend class CMemoryChannels;
friend class CMemoryChannels::CMemoryChannel;
protected:
// close the file handle
void CloseFileHandle();
// create completion port
void CreateCompletionPort();
// send command to camera synchronously
bool Transmit( DWORD IoCtl, void *pArg, size_t argSize, void *pRes=NULL, size_t resSize=0, Timespan timeout = INFINITE );
// send command to camera asynchronously
bool Transmit( DWORD IoCtl, void *pArg, size_t argSize , BcamOL* pOL );
// send command to and retrieve information from camera asynchronously
bool Transmit( DWORD IoCtl, void *pArg, size_t argSize, void* pRes, size_t resSize, BcamOL* pOL );
// try to send command to camera synchronously, throw on failure
void TryTransmit( LPCTSTR context,
DWORD IoCtl, void *pArg, size_t argSize, void *pRes = NULL, size_t resSize = 0,
Timespan timeout= INFINITE );
// is the camera object valid
bool IsValid();
// Registers a client window for handle related device notifications
HDEVNOTIFY RegisterDeviceNotifcation(HWND hWnd);
// unregister client window from device notifications
void UnregisterDeviceNotification(HDEVNOTIFY hNotify);
// Unregister the client window from device interface related notifications
static void InternalUnregisterClient();
// reopens the camera driver
void Reopen();
// The thread procedure of the message loop thread
static DWORD WINAPI MessageLoop(LPVOID lpThreadParameter);
// When a windows gets registered for device notifications, it will be subclassed by this window procedure
static LRESULT CALLBACK BcamWindowProc(HWND, UINT, WPARAM, LPARAM);
// The window procedure of the hidden message-only window
static LRESULT CALLBACK HiddenWindowProc(HWND, UINT, WPARAM, LPARAM);
// Close the hidden message-only window
static void CloseHiddenWindow();
protected:
HANDLE m_hCamera; ///< handle to the opened device
CString m_DeviceName; ///< friendly devcie name of device we have opened
HDEVNOTIFY m_hDevHandleNotify; ///< device notification handle for file handle related notivations
HDEVNOTIFY m_hDevHandleNotifyOpt; ///< device notification handle for an additional registered window
HWND m_hWndHandleNotify; ///< window handle for which we register handle related notifications
static HDEVNOTIFY s_hDevInterfaceNotify; ///< device notification handle for interface related notifications
static BcamMap_t s_BcamMap; ///< map the open devices
static HWND s_hWndMsgOnly; ///< message-only window used for device notifications instead of a user supplied window
static HWND s_hWndNotify; ///< window handle for which we register device notifications
static WNDPROC s_lpPrevWndFunc; ///< Pointer to the window function we subclass
BcamCallbackFunc m_OnRemoveRequestCallback; ///< pointer to OnRemoveRequest callback function
BcamCallbackFunc m_OnRemoveCompleteCallback;///< pointer to OnRemoveComplete callback function
void* m_pvOnRemoveRequest; ///< void pointer which will passed to the OnRemoveRequest callback function
void* m_pvOnRemoveComplete; ///< void pointer which will passed to the OnRemoveComplete callback function
HANDLE m_hCompletionPort; ///< handle to the completion port
const ULONG m_CompletionKey; ///< key used with the completion port
static ULONG s_CompletionKey; ///< unique key for each instance
long m_IsoChannel; ///< allocated isochronous channel.
BcamIsoSpeed m_IsoSpeed; ///< isochronous speed
/// Does some clean up
static class CCleanUp {
public:
~CCleanUp();
} s_CleanUp;
friend class CBcam::CCleanUp;
}; // CBcam
} // namespace Bcam
#endif // BCAM_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -