This is an example of how to use the CircularInterface class.
#include "stdafx.h"
#include "CircClassExample.h"
#include <conio.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
UINT WaitForBufferDone(LPVOID lpdwParam);
UINT CirErrorThread(LPVOID lpdwParam);
MSG Msg;
int hDspSrf = -1;
CWinApp theApp;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(
BFNULL),
BFNULL, ::GetCommandLine(), 0))
{
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
BFU32 boardType, boardNum, init, serNum;
char ch;
BFU32 cirSetupOptions = 0;
CWinThread* pErrorThread;
CWinThread* pFrameDoneThread;
if( DoBrdOpenDialog(BOD_BRD_NUM_NON_FAMILY|BOD_HIDEJUSTOPEN, FF_BITFLOW_MODERN, &boardType, &boardNum,
&init, &serNum) )
{
return -1;
}
try
{
cout << "Creating instance of circular interface." << endl;
cirSetupOptions);
{
cout << "Couldn't create display surface" << endl;
return 1;
}
pErrorThread = AfxBeginThread(CirErrorThread, &board, THREAD_PRIORITY_HIGHEST);
return 1;
pFrameDoneThread = AfxBeginThread(WaitForBufferDone, &board, THREAD_PRIORITY_HIGHEST);
if(pFrameDoneThread ==
BFNULL)
return 1;
printf("\nPress G (as in Go) to start Acquisition ");
printf(" Press S to Stop Acquisition \n");
printf("Press P to Pause Press C to Continue\n");
printf("Press A to Abort\n");
printf("Press X to exit test\n\n");
while(!endTest)
{
while(!BFkbhit() && !endTest)
{
if(PeekMessage(&Msg,
BFNULL,0,0,PM_REMOVE))
DispatchMessage(&Msg);
else
Sleep(10);
}
if(!endTest)
ch = BFgetch();
else
ch = 'X';
cout << endl;
switch(toupper(ch))
{
case 'G':
cout <<"Circular Acquisition Started." << endl;
break;
case 'P':
cout <<"Circular Acquisition Paused." << endl;
break;
case 'C':
cout <<"Circular Acquisition Resumed." << endl;
break;
case 'S':
break;
case 'A':
break;
case 'X':
if(board.getStartAcqFlag())
break;
default:
cout <<"Key not Recognized, Try Again" << endl;
break;
}
}
CString Str;
Str.Format("\nCaptured %d Frames\nMissed %d Frames\n",
board.getNumFramesCaptured(), board.getNumFramesMissed() );
cout << Str << endl;
BFRC error = board.getCirError();
{
board.showError(error);
error = board.getCirError();
}
cout <<"\nPress Any Key to Continue." << endl;
while(!BFkbhit())
{
if(PeekMessage(&Msg,
BFNULL,0,0,PM_REMOVE))
DispatchMessage(&Msg);
else
Sleep(0);
}
if (BFkbhit()) BFgetch();
DispSurfClose(hDspSrf);
}
{
nRetCode = 1;
}
if(DispSurfIsOpen(hDspSrf))
{
DispSurfClose(hDspSrf);
}
DWORD exitCode;
while(GetExitCodeThread(pErrorThread->m_hThread,&exitCode) &&
exitCode == STILL_ACTIVE)
{
Sleep(10);
}
while(GetExitCodeThread(pFrameDoneThread->m_hThread,&exitCode) &&
exitCode == STILL_ACTIVE)
{
Sleep(10);
}
}
return nRetCode;
}
UINT WaitForBufferDone(LPVOID lpdwParam)
{
try
{
BFTick(&T0);
{
cout <<"Circular Acquisition Stopped." << endl;
cout <<"Circular Acquisition Aborted." << endl;
cout <<"BiSeqWaitDone has timed out." << endl;
cout <<"The wait in BiSeqWaitDone Failed." << endl;
cout <<"The queue was empty." << endl;
else
{
if (BFTickDelta(&T0, BFTick(&T1)) > 30)
{
if(!DispSurfFormatBlit(hDspSrf, cirHandle.pBufData,
{
cout << "Could not update the display surface" << endl;
return 1;
}
BFTick(&T0);
}
cout << setfill('0');
cout << "Buffer: "<< setw(8) << cirHandle.BufferNumber << " ";
cout << "Count: "<< setw(8) << cirHandle.FrameCount << " ";
cout << "SrcTag: "<< setw(8) << cirHandle.CXPSrcTag << " ";
cout << "XOffs: "<< setw(8) << cirHandle.CXPXOffset << " ";
cout << "YOffs: "<< setw(8) << cirHandle.CXPYOffset << " ";
cout << '\r';
}
}
}
{
return 1;
}
return 0;
}
UINT CirErrorThread(LPVOID lpdwParam)
{
{
cout << "ErrorThread - Acquisition Error!!" << endl;
}
return 0;
}