The following program demonstrates how to implement continuous readout.
NOTE: The SetDots function is purely for producing a visual effect when
displaying the output to the user.
#include <iostream>
#include <iomanip>
#include "CController.h"
#include "CDeinterlace.h"
#include "CFitsFile.h"
using namespace std;
using namespace arc;
//
// Camera specific data (dsp file, dimensions, expose time)
//
#define TIM_FILE "tim.lod"
#define EXP_TIME ( float )0.5
#define IMG_ROWS 512
#define IMG_COLS 600
void FrameCallback( long lFrame, long lPCIFrame, void *pBuf, void *pArg );
std::string SetDots( const char *cStr );
CDeinterlace *pCDeint = NULL;
CFitsFile *pCFits = NULL;
//
// Main program
//
int main()
{
//
// Create an instance of the ARC controller API
//
CController cController;
cout << endl;
try
{
//
// Find all ARC pci device
//
cout << SetDots( "Getting device bindings" );
cController.GetDeviceBindings();
cout << "done!" << endl;
//
// Open a driver/device connection
//
cout << SetDots( "Opening PCI driver" );
cController.OpenDriver( 0, 4200 * 4200 * sizeof( unsigned short ) );
cout << "done!" << endl;
//
// Setup the controller
//
cout << SetDots( "Setting up controller" );
cController.SetupController( true, // Reset Controller
true, // Test Data Link ( TDL )
true, // Power On
IMG_ROWS, // Image row size
IMG_COLS, // Image col size
TIM_FILE ); // DSP timing file
cout << "done!" << endl;
//
// Create FITS data cube
//
cout << SetDots( "Creating FITS data cube" );
pCFits = new CFitsFile( "Image.fit", IMG_ROWS, IMG_COLS, CFitsFile::BPP16, true );
cout << "done!" << endl;
//
// Expose ( Continuous Readout )
//
cout << "Starting exposure ...." << endl;
cController.Continuous( IMG_ROWS, IMG_COLS, 60, EXP_TIME, NULL, FrameCallback );
cout << endl;
//
// Close the FITS data cube
//
if ( pCFits != NULL )
{
cout << SetDots( "Closing FITS" );
delete pCFits;
cout << "done!" << endl;
}
//
// Close the driver/device connection
//
cout << SetDots( "Closing PCI driver" );
cController.CloseDriver();
cout << "done!" << endl;
}
catch ( std::runtime_error &e )
{
cout << "failed!" << endl;
cerr << endl << e.what() << endl;
cController.CloseDriver();
if ( pCFits != NULL ) delete pCFits;
}
catch ( ... )
{
cerr << endl << "Error: unknown exception occurred!!!" << endl;
cController.CloseDriver();
if ( pCFits != NULL ) delete pCFits;
}
}
std::string SetDots( const char *cStr )
{
std::string sStr( cStr );
for ( int i=sStr.length(); i<40; i++ )
sStr.append( "." );
return sStr;
}
void FrameCallback( long lFrame, long lPCIFrame, void *pBuf, void *pArg )
{
if ( pCDeint == NULL )
pCDeint = new CDeinterlace();
if ( pCDeint != NULL )
{
pCDeint->RunAlg( pBuf,
IMG_ROWS,
IMG_COLS,
CDeinterlace::DEINTERLACE_CCD_QUAD );
}
if ( pCFits != NULL )
{
pCFits->Write3D( pBuf );
}
cout << "Frame: " << lFrame << " / " << lPCIFrame << " -> " << pBuf << endl;
}