10 pevscriptengine object events, 1 _ivscriptengineevents interface, Example – Teledyne LeCroy Automation API for Teledyne LeCroy PETracer_PETrainer User Manual
Page 133: End_sink_map(), Pevscriptengine object events, Ivscriptengineevents interface
Teledyne LeCroy
Automation API for PETracer/PETrainer
128
10 PEVScriptEngine Object Events
10.1 _IVScriptEngineEvents interface
In order to retrieve the event notifications from PETracer™ 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 PEVScriptEngine object, there is a 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 an automation interface to the object is obtained from a call of some method
rather than from creation function – like CreateObject() in VBScript). The PETracer provides a special COM
class allowing the receiving and handling of notifications from a VSE object even in script languages not
supporting event handling from "indirect" objects. Please refer to CATCAnalyzerAdapter, Page 123, for details.
Example
C++:
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:
class CVSEngineSink : public IDispEventImpl
{
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);
}
...
};