beautypg.com

11 peanalyzer object events, 1 _ianalyzerevents dispinterface, End_sink_map() – Teledyne LeCroy Automation API for Teledyne LeCroy PETracer_PETrainer User Manual

Page 139: Peanalyzer object events, Ianalyzerevents dispinterface

background image

Teledyne LeCroy

Automation API for PETracer/PETrainer

134

11 PEAnalyzer Object Events

11.1 _IAnalyzerEvents dispinterface

In order to retrieve the events from a PEAnalyzer object, you must implement the _IAnalyzerEvents

interface. Since this interface is default source interface for the

PEAnalyzer object, there is very simple

implementation from such languages like Visual Basic, VBA, VBScript, WSH, etc.

Some script engines impose restrictions on handling events from “indirect” automation objects in

typeless script languages (when the automation interface to the object is obtained from a call of some method
rather than from a creation function – like CreateObject() in VBScript). The PETracer™ provides a special COM
class allowing receiving and handling notifications from the VSE object even in script languages not supporting
event handling from "indirect" objects. Please refer to CATCAnalyzerAdapter, Page 123, for details.

C++ implementation used in the examples below utilizes a sink object by deriving it from IdispEventImpl,

but not specifying the type library as a template argument. Instead, the type library and default source interface
for the object are determined using

AtlGetObjectSourceInterface(). A

SINK_ENTRY()

macro is used for each

event from each source interface that is to be handled:


class CAnalyzerSink : public IDispEventImpl
{
BEGIN_SINK_MAP(CAnalyzerSink)

//Make sure the Event Handlers have __stdcall calling convention

SINK_ENTRY(IDC_SRCOBJ, 1, OnTraceCreated)

SINK_ENTRY(IDC_SRCOBJ, 2, OnStatusReport)

END_SINK_MAP()
. . .
}

Then, after you’ve established a connection with the server, you need to advise as to your implementation of the
event interface:

hr = CoCreateInstance( CLSID_PEAnalyzer, NULL,

CLSCTX_SERVER, IID_IPEAnalyzer, (LPVOID *)&m_poPEAnalyzer );

poAnalyzerSink = new CAnalyzerSink();


// Make sure the COM object corresponding to pUnk implements IProvideClassInfo2 or

// IPersist*. Call this method to extract info about source type library if you

// specified only 2 parameters to IDispEventImpl

hr = AtlGetObjectSourceInterface(m_poPEAnalyzer, &poAnalyzerSink->m_libid,

&poAnalyzerSink->m_iid, &poAnalyzerSink->m_wMajorVerNum,
&poAnalyzerSink->m_wMinorVerNum);

if ( FAILED(hr) )

return 1;


// connect the sink and source, m_poPEAnalyzer is the source COM object

hr = poAnalyzerSink->DispEventAdvise(m_poPEAnalyzer, &poAnalyzerSink->m_iid);

if ( FAILED(hr) )

return 1;