ReportEvent

ITcEventLogC

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

HRESULT ReportEvent([in] TcEventHeader* pEventHead,
                    [in] SAFEARRAY(VARIANT)* pEventData
);

Parameters

pEventHead

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

eventData

[in] A pointer to a safearray 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)

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 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 ITcEventLogC interface
Dim evtLoggerC As TCEVENTLOGGERLib.ITcEventLogC
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
Call evtLoggerC.ReportEvent(header, arrParam)

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).

The method can just be used to issue an alarm. A second call to reset the alarm is not possible with this method. To change the state of an already issued alarm we need the event object itself. For more convenience the method ITcEventLogC3::ReportEventEx directly returns the new created event object.