ReportEventEx

ITcEventLogC3

This method is used to issue an alarm from a COM client like the HMI program to the TcEventLogger.

HRESULTReportEventEx([in] TcEventHeader* pEventHead,
                     [in] SAFEARRAY(VARIANT)* pEventData
                     [out, retval] [out,retval] ITcEvent** pEvent
);

Parameters

pEventHead

[in] Pointer to an object of the type TcEventHeader. The object represents the alarm configuration.

eventData

[in] A pointer to a safe array that represents the event arguments. In the configuration of the event formatter it's defined how to place the event arguments into the displayed event message. The following data types are supported by the standard formatter. int (16bit), long (32bit), float(32bit), double(64bit), string(BSTR)

pEvent

[out, retval] A pointer to an ITcEvent pointer that receives the new logged event object

Return Values

S_OK

Function was successfully called

TCEVENTERR_ISSIGNALED

the event with this source id and event id was already signaled.

E_POINTER

pEventHead or pEventData or pEvent were no valid pointers.

Visual Basic sample code

' get the one and only event logger
Dim evtLogger As TCEVENTLOGGERLib.TcEventLog
Set evtLogger = New TCEVENTLOGGERLib.TcEventLog

' cast to ITcEventLogC3 interface
Dim evtLoggerC As TCEVENTLOGGERLib.ITcEventLogC3
Set evtLoggerC = evtLogger

' create event header
Dim header As TcEventHeader
header.nClass = TcEventClass.TCEVENTCLASS_ALARM ' event class
header.nPriority = TcEventPriority.TCEVENTPRIO_IMPLICIT ' event priority
header.dwFlags = TcEventFlags.TCEVENTFLAG_LOG ' event flags
header.dwUserData = 0 'user data
header.nId = 1 ' event id
header.nInvokeId = 0 'invoke id
header.fDate = Now ' event date and time
header.nMs = 123 ' milli second part of the event date and time
header.varSource = 1 ' event soruce id
header.szFmtProgId = "TcEventFormatter.TcXmlFormatter" ' event prog id

' creade event params
Dim arrParam() As Variant
ReDim arrParam(0 To 1) As Variant
arrParam(0) = 1234 ' first parameter as long
arrParam(1) = 1234.777 ' second parameter as double

' log the event
Dim evt As TcEvent
Set evt = evtLoggerC.ReportEventEx(header, arrParam)

' reset the event
evt.Reset

Remarks

After this method call the Event Logger will raise the event OnNewEvent on all client that implement the event interface _ITcEventLogEvents (VB: Dim WithEvents).