9 sasvscriptengine object events, 1 _ivscriptengineevents interface – Teledyne LeCroy SAS_SATA Tracer_Trainer Automation API Manual User Manual

Page 82

Advertising
background image

LeCroy Corporation

Automation API for SAS/SATATracer/Trainer

Manual Version 1.11

82

9 SASVScriptEngine Object Events

9.1 _IVScriptEngineEvents Interface

In order to retrieve event notifications from the SASTracer application when a

verification script engine object is running the script, you must implement the
_IVScriptEngineEvents callback interface. Since this interface is a default source interface
for the SASVScriptEngine object, there is a very simple implementation from languages like
Visual Basic, VBA, VBScript, and WSH.


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

objects in typeless script languages (when an automation interface to the object is obtained
from a call of some method, rather than from creation function, such as CreateObject() in
VBScript). The SASTracer application provides a special COM class, allowing receiving and
handling of notifications from a VSE object even in script languages not supporting event
handling from "indirect" objects.

Example

C++ implementation used in the examples below implements an event 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:

C++:

class CVSEngineSink : public IDispEventImpl<IDC_SRCOBJ_VSE, CVSEngineSink >
{
public:

...

BEGIN_SINK_MAP(CVSEngineSink)

// Make sure the Event Handlers have __stdcall calling convention.
SINK_ENTRY( IDC_SRCOBJ_VSE, 1, OnVScriptReportUpdated )
SINK_ENTRY( IDC_SRCOBJ_VSE, 2, OnVScriptFinished )
SINK_ENTRY( IDC_SRCOBJ_VSE, 3, OnNotifyClient )

END_SINK_MAP()

HRESULT __stdcall OnVScriptReportUpdated ( BSTR newLine, int TAG );
HRESULT __stdcall OnVScriptFinished( BSTR script_name, VS_RESULT result, int TAG );
HRESULT __stdcall OnNotifyClient ( int eventId, VARIANT eventBody, int TAG );

HRESULT Advise(IUnknown* pUnk)
{
AtlGetObjectSourceInterface(pUnk, &m_libid, &m_iid, &m_wMajorVerNum,
&m_wMinorVerNum);
return DispEventAdvise(pUnk, &m_iid);
}

HRESULT Unadvise(IUnknown* pUnk)
{
AtlGetObjectSourceInterface(pUnk, &m_libid, &m_iid, &m_wMajorVerNum,
&m_wMinorVerNum);
return DispEventUnadvise(pUnk, &m_iid);
}

...
};

Advertising