beautypg.com

Teledyne LeCroy UWBTracer Automation Manual User Manual

Page 19

background image

LeCroy

UWBTracer Automation API Reference Manual

Manual Version 3.02

15

C++: ( Raw code without using type library. All error handling is omitted for simplicity )

IUwbAnalyzer* pAnalyzer = NULL;

// create UwbAnalyzer object
if ( FAILED( CoCreateInstance( CLSID_UwbAnalyzer, NULL, CLSCTX_SERVER, IID_IUwbAnalyzer,

(LPVOID *)&pAnalyzer ) )
return;


BSTR ro_file_name = SysAllocString( L"test_ro.rec" );
BSTR bstr_trace_name;

IDispatch* trace = NULL;

for( int i = 0; i < 4; i++ )
{

if( FAILED( pAnalyzer ->StartRecording( ro_file_name ) )

return; // error handling and resources releasing should be done


// Fake generation.
Sleep(3000);

if( FAILED( Analyzer->StopRecordingAndWaitForTrace( &trace ) ) )

return; // error handling and resources releasing should be done


IUwbTrace* uwbTrace = NULL;

// Query for IUwbTrace interface
if( FAILED( trace->QueryInterface( IID_IUwbTrace, (LPVOID*)uwbTrace ) ) )

return; // error handling and resources releasing should be done


OLECHAR trace_name[_MAX_PATH];
swprintf ( trace_name, "test_data%u.uwb", i );
SysAllocString( bstr_trace_name );

// Save the trace recorded to the current folder
uwbTrace->SaveCopyTo( bstr_trace_name );

// release the trace object
trace->Release();
uwbTrace->Release();

SysFreeString( bstr_trace_name ); // Free BSTR.
}

pAnalyzer->Release(); // Release the analyzer object.
SysFreeString( ro_file_name ); // Free BSTR.