Manual en TE1000. TwinCAT 3 EventLogger Version - 1.8
Manual en TE1000. TwinCAT 3 EventLogger Version - 1.8
TE1000
TwinCAT 3 | EventLogger
Table of contents
1 Foreword .................................................................................................................................................... 7
1.1 Notes on the documentation.............................................................................................................. 7
1.2 Safety instructions ............................................................................................................................. 8
1.3 Notes on information security ............................................................................................................ 9
2 Overview................................................................................................................................................... 10
4 Limitations................................................................................................................................................ 12
6 PLC API..................................................................................................................................................... 32
6.1 Functions and function blocks ......................................................................................................... 32
6.1.1 Asynchronous text requests ............................................................................................ 32
6.1.2 Filter................................................................................................................................. 39
6.1.3 EventEntry conversion..................................................................................................... 44
6.1.4 FB_ListenerBase2 ........................................................................................................... 47
6.1.5 FB_TcAlarm..................................................................................................................... 52
6.1.6 FB_TcArguments............................................................................................................. 58
6.1.7 FB_TcEvent ..................................................................................................................... 60
6.1.8 FB_TcEventBase............................................................................................................. 62
6.1.9 FB_TcEventLogger.......................................................................................................... 68
6.1.10 FB_TcMessage................................................................................................................ 76
6.1.11 FB_TcSourceInfo............................................................................................................. 80
6.2 Interfaces ......................................................................................................................................... 82
6.2.1 I_TcArguments ................................................................................................................ 82
6.2.2 I_TcEventBase ................................................................................................................ 92
6.2.3 I_TcMessage ................................................................................................................... 97
6.2.4 I_TcSourceInfo ................................................................................................................ 98
6.3 Data types ....................................................................................................................................... 99
6.3.1 TcEventEntry ................................................................................................................... 99
6.3.2 TcEventSeverity............................................................................................................... 99
6.3.3 TcEventConfirmationState............................................................................................. 100
6.4 Global lists ..................................................................................................................................... 100
6.4.1 Global_Constants .......................................................................................................... 100
1 Foreword
The responsible staff must ensure that the application or use of the products described satisfy all the
requirements for safety, including all the relevant laws, regulations, guidelines and standards.
Disclaimer
The documentation has been prepared with care. The products described are, however, constantly under
development.
We reserve the right to revise and change the documentation at any time and without prior announcement.
No claims for the modification of products that have already been supplied may be made on the basis of the
data, diagrams and descriptions in this documentation.
Trademarks
Beckhoff®, TwinCAT®, TwinCAT/BSD®, TC/BSD®, EtherCAT®, EtherCAT G®, EtherCAT G10®, EtherCAT P®,
Safety over EtherCAT®, TwinSAFE®, XFC®, XTS® and XPlanar® are registered trademarks of and licensed by
Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own
purposes could violate the rights of the owners.
Patent Pending
The EtherCAT Technology is covered, including but not limited to the following patent applications and
patents:
EP1590927, EP1789857, EP1456722, EP2137893, DE102015105702
with corresponding applications or registrations in various other countries.
EtherCAT® is a registered trademark and patented technology, licensed by Beckhoff Automation GmbH,
Germany
Copyright
Exclusion of liability
All the components are supplied in particular hardware and software configurations appropriate for the
application. Modifications to hardware or software configurations other than those described in the
documentation are not permitted, and nullify the liability of Beckhoff Automation GmbH & Co. KG.
Personnel qualification
This description is only intended for trained specialists in control, automation and drive engineering who are
familiar with the applicable national standards.
Description of symbols
In this documentation the following symbols are used with an accompanying safety instruction or note. The
safety instructions must be read carefully and followed without fail!
DANGER
Serious risk of injury!
Failure to follow the safety instructions associated with this symbol directly endangers the life and health of
persons.
WARNING
Risk of injury!
Failure to follow the safety instructions associated with this symbol endangers the life and health of per-
sons.
CAUTION
Personal injuries!
Failure to follow the safety instructions associated with this symbol can lead to injuries to persons.
NOTE
Damage to the environment or devices
Failure to follow the instructions associated with this symbol can lead to damage to the environment or
equipment.
Tip or pointer
This symbol indicates information that contributes to better understanding.
In addition, the recommendations from Beckhoff regarding appropriate protective measures should be
observed. Further information regarding information security and industrial security can be found in our
https://www.beckhoff.com/secguide.
Beckhoff products and solutions undergo continuous further development. This also applies to security
functions. In light of this continuous further development, Beckhoff expressly recommends that the products
are kept up to date at all times and that updates are installed for the products once they have been made
available. Using outdated or unsupported product versions can increase the risk of cyber threats.
To stay informed about information security for Beckhoff products, subscribe to the RSS feed at https://
www.beckhoff.com/secinfo.
2 Overview
The TwinCAT 3 EventLogger provides an interface for the exchange of messages between TwinCAT
components and non-TwinCAT components.
This documentation is aimed at the user of the TwinCAT 3 EventLogger. Information about how the
TwinCAT 3 EventLogger is used by different TwinCAT 3 components can be found in the respective product
documentations.
Product components
All the components of the TwinCAT 3 EventLogger are present in the respective basic installation.
Various interfaces are included in the TwinCAT 3 Engineering for programming. The necessary modules and
libraries are part of the corresponding runtime.
3 System requirements
Technical data Requirement
Operating system Windows 7/10, Windows Embedded Standard 7, Windows CE 7
Target platform PC architecture (x86, x64 or ARM)
TwinCAT version TwinCAT 3.1 build 4022.20 or higher
Required TwinCAT setup level TwinCAT 3 XAE, XAR
Required TwinCAT license Any runtime license (PLC, C++)
Visual Studio version Parts of the TwinCAT 3 EventLogger are usable from Visual Studio
2013.
4 Limitations
• Events have a maximum size of 8 kb when transmitted. Make sure that this limit is observed when
using the TwinCAT 3 EventLogger. It refers to all elements that are transmitted and described in this
documentation, including the dynamic elements (Attributes, SourceName, JSON Attributes).
• The interface for receiving events in real-time stores a maximum of 1024 events temporarily until they
have to be retrieved.
If they are not retrieved in time, events are lost.
• The TwinCAT 3 EventLogger offers a connection to the TwinCAT HMI (TF2xxx). The
TwinCAT PLC HMI (TF18xx), conversely, cannot receive the events.
5 Technical introduction
The TwinCAT 3 EventLogger transmits so-called events. An event is a message or an alarm.
This technical introduction focuses on the data that are transmitted as the contents of an event, because
they are necessary for the understanding of the process. The transmission and reception of an event are
explained in detail in the API descriptions for PLC and C++ as well as in the samples.
Events
An event itself is not used directly, but rather the derived types "messages" or "alarms".
EventClass (GUID) Event classes are groups of events (possibly for a topic).
Event-ID (UDINT) The event is clearly identified within an event class by an Event-ID.
Text (String) Description of the event. The description is intended for people and can therefore
also be internationalized. Arguments can be inserted at runtime to make the text
individually adaptable.
Source Info Source of the occurrence of an event. Source consists of three elements. These
can be used as desired, but there is a corresponding recommendation as to how
they should be used.
• Source-ID (INT): TcCOM object ID
• Source Name (STRING): Path within the TcCOM object. e.g. path to a function
block in a PLC project
• Source-GUID (GUID): Can be used, for example, to identify a project or a (sub-)
product.
JSON Attribute Can be used as desired. Whereas the "text" (see above) is intended for people as
(STRING) recipients, the JSON attribute is intended for programmatic reception. A JSON
string can easily be created (serialized) and processed (deserialized). TwinCAT
offers the JsonXml library in real-time for this (see Documentation PLC library
Tc3_JsonXml).
In addition to these elements, events possess further elements, which are described in the TMC Editor
[} 16].
Messages
Messages are stateless. They are sent when called and the corresponding registered components are
delivered.
Identification
Alarm
In addition, a confirmation can be demanded. Distinction is made between the following confirmation states:
• WaitForConfirmation
• Confirmed or Reset
Calling the corresponding methods causes an event to be transmitted and sets the alarm to the respective
state.
• If a confirmation takes place via Confirm(), the state is set to Confirmed.
• If a confirmation takes place via Clear(TRUE), the state is set to Reset.
If the call of a method is invalid in the current state, this will be indicated by a return value.
When shutting down TwinCAT (RUN → CONFIG transition), a dispose that sets a Clear time stamp is
executed internally for all alarms in the Raised state. There is no confirmation for these alarms.
Identification
The TwinCAT 3 EventLogger identifies an alarm using the EventClass, Event-ID and Source Info. Thus an
alarm (combination of EventClass and Event-ID) can be used at different points in a program. For example,
an alarm "storage empty" can be used for different storages, since different "Source Info" is provided at
runtime (see also Handling sources [} 28]).
Architecture
The TwinCAT 3 EventLogger transmits events centrally between other components. These components
include the real-time programming interfaces PLC or C++ as the primary source of events.
During the development the messages can be displayed in the TwinCAT Engineering (XAE).
An HMI, for example, can receive messages and display them accordingly. The customer can create further
components of his own for receiving events.
The TwinCAT 3 EventLogger keeps a limited number of the last events in a cache. This can be queried from
the Engineering, for example after a restart, in order to enable a diagnosis to be made. The cache is
dependent on the secured shutdown of the computer.
Workflow
The general workflow for establishing asynchronous communication between components is as follows:
See also:
• Documentation TwinCAT 3 type system
• API descriptions PLC [} 32] and C++ [} 102]
• Samples [} 161]
5.1 Event
Events are described within the event class.
Properties of events
Name This name designates the event, e.g. in the generated source code.
ID Clearly identifies the event within the event class.
Display Text This text is used for the event class for the display. It can be internationalized (see
Internationalization/translations [} 21]).
Severity Severity of the event. This is provided by the generated source code and thus represents
the default behavior; however, a different value can also be used there:
• Verbose
• Info
• Warning
• Error
• Critical
All known event classes are listed on the Event Classes tab in the TwinCAT type system. The TMC editor,
in which the event classes can be defined and edited, can be opened via the context menu commands Edit
and New.
In addition to the project event classes, TwinCAT also provides further event classes such as ADS return
codes and system events.
Name This name designates the event class, for example in the generated source code.
Namespace Like all data types, event classes may also belong to a namespace.
DisplayText This text is used for the event class for the display. It can be internationalized (see
Internationalization/translations [} 21]).
Guid Like all data types it identifies the currently described event class. It is calculated
automatically and changes in the event of changes within the event class.
If event classes are used in a PLC library, they should also be part of the library in order to ensure that the
data types are contained in the TwinCAT type system of every application that uses the PLC library.
To make this possible the event classes must be "pinned" in the PLC library. To do this, select the command
Pin Global Data Type in the context menu of the created data type under External Types in the PLC library
object.
Analogous to the other TwinCAT data types there is a possibility for C++ projects to define event classes
locally in the C++ project.
The event classes are declared for use in the corresponding C++ modules (irrespective of where they were
defined). If an event class is added to a C++ module, it is automatically embedded in the TMC file of the
module.
The "names" of the events and event classes are used in the code generation. An event class can thus be
used across different versions of an event class through its name.
The "severity" is provided by the code generation. The programmer thus has the possibility to set this
individually when creating the events. The severity as described in the TMC editor [} 16] should thus be
considered the default behavior. The severity can deviate from this in the specific application case.
PLC
A GVL TC_EVENTS is created in the PLC and contains the event classes as subelements and is updated
following changes (saving/closing the TMC editor). These global constants in turn contain the events
themselves as subelements together with the individual elements EventId, Severity and the UUID of the
event class to which they belong.
These elements can be used by means of IntelliSense for the parameters, e.g. with Create()/CreateEx().
Logged-in PLC
The code is not updated if a connection to a PLC exists (login). The update then takes place follow-
ing a logout.
Via "OnlineChange" the changes to an event class can be applied if the option "Update boot project" is
selected.
C++
TcCOM modules must use the event classes, i.e. they must be entered as used in the TMC editor. A code
generation then creates a namespace, "TcEvents", as part of the <DriverName>Services.h- file. The
namespace can be used by means of IntelliSense for the parameters of the event classes/events, e.g. with
CreateMessage()/CreateAlarm().
Compatibility
The C++ source code generation requires Visual Studio 2013 or newer.
5.4 Internationalization/translations
The texts of the events ("DisplayText") for display in HMIs, for example, can be internationalized.
The "Translations" section in the TMC editor is provided for this. The section describes a table in whose rows
the keys are assigned to the texts in different languages.
Keys to be translated
The keys are automatically determined from the texts ("Display Text") of the events and event classes. It is
possible to describe individually whether the keys are to be adopted into the translation:
Languages to be included
Languages can be selected and added. If a language is requested at runtime for which no text is stored, the
English text will be used.
Translations
Additional functions
The import and export functions relate to an XML/CSV format, which can be investigated by way of an
example through an export.
The translation information is stored in its own area of the configuration files, which can also be edited
outside of the TwinCAT XAE.
Time stamp
\EventLogger\TimestampSource DWORD 0 = CurPentiumTime [default]
2 = CurSystemTime
\EventLogger\TimestampBase DWORD 0 = SystemTime [default]
1 = ExternalTimeHard
2 = ExternalTimeMedium
3 = ExternalTimeSoft
For 1 to 3, refer to the
documentation for "Corrected time
stamps" https://
infosys.beckhoff.com/index.php?
content=../content/1033/
corrected_timestamps/
index.html&id=.
Maximum size of the message cache
\EventLogger\MaxDatabaseSize DWORD 20 [default]
in MB
On reaching the limit, half of the
messages will be discarded.
Message cache location
\EventLogger\DatabaseDir STRING :memory: = main memory
(From > TwinCAT 3.1 Build (messages are deleted with the
4024.22) transition to CONFIG and also
reboot etc.)
<path> = file system folder for
storing the LoggedEvents.db file
If the key is not present, the
database is placed in the boot
folder.
Under Windows CE this is used to
store the database non-
persistently.
Save messages in the Windows Error Log
\EventLogger\WindowsEventLog\T DWORD 0 = None [default]
ypesSupported | 0x1 = Messages
| 0x2 = Alarms
| 0x3 = both
\EventLogger\WindowsEventLog\L DWORD 1033 [default]
ogLocaleId 0 = current locale
\EventLogger\WindowsEventLog\M DWORD 0 = Verbose [default]
inLogLevel 1 = Info
2 = Warning
3 = Error
Logging TwinCAT system errors
See also https://infosys.beckhoff.com/index.php?content=../content/1033/tceventlogger/html/
tceventlogger/setup.htm&id=4066395915595472851
HKEY_LOCAL_MACHINE\SOFTW DWORD 3 = acceptance of the system
ARE\[WOW6432Node\]Beckhoff\T errors into the Tc3 EventLogger
winCAT\System[LogMessageType] 4 = acceptance of the system
errors into the Tc3 EventLogger
and the error list of the XAE.
If the keys do not exist, they must be created with the specified type.
5.6 Engineering
TwinCAT Logged Events window
Compatibility
The TwinCAT Logged Events window is available from Visual Studio 2013.
The target system events can be loaded from the cache database mentioned above and displayed via the
Logged Window. The window is opened in the TwinCAT 3 Engineering (XAE) via
View > Other Windows > TwinCAT Logged Events.
You can configure whether alarms or messages should be displayed via the Alarms or
Messages button respectively.
The severity from which the events should be displayed can be selected via the drop-down menu.
Provides an export of the data in a CVS format, where the information that is currently displayed
is exported.
Deletes (after a prompt) the cache database on the target system.
The columns in the window and the temporal resolution can be configured using the commands in the
context menu:
TwinCAT options
The TwinCAT engineering settings in the TwinCAT options (Tools > Options) provide basic settings for the
TwinCAT 3 EventLogger.
5.7 Arguments
The texts of the events can be individualized by programming with "arguments".
A marking with the notation {n} is used for this during the description of the events in the TMC editor, where
n is an ascending number starting from 0.
Up to 128 arguments with a maximum size of 1024 bytes can be used at one event.
In the TMC editor, for example, such a Display Text is used for an event:
PLC
The arguments must thereby be defined after Create()/CreateEx(), but before Send().
fbMsg.ipArguments.Clear().AddLReal(fDividend).AddLReal(fDivisor);
In this case fDividend is set in place of {0} and fDivisor in place of {1}.
C++
The arguments must thereby be defined after CreateMessage()/CreateAlarm(), but before Send().
Output
Formatting
The output of the arguments can also be formatted. To do this the syntax {n,<Format>} is used
accordingly in the TMC editor:
Note that, for example, a REAL cannot be represented as "d" or "x" etc.
Additionally the syntax {eventID} as well as {eventclass} are available to output the corresponding
information as part of the text.
The source is also specified when creating the event in both programming languages.
PLC
Alternatively a zero can be assigned to the corresponding parameter on calling Create()/CreateEx() in order
to use the internal standard source information of the PLC. If no explicit SourceInfo is then specified, the
symbol path is output where the event is instanced as SourceName and the object ID of the PLC instance as
SourceID.
C++
TcSourceInfo is used in C++ and can be transferred, for example, in the following way with
CreateMessage()/CreateAlarm():
Output
The JsonXml library (PLC library Tc3_JsonXml) can be used to generate the JSON when creating and when
receiving.
PLC
The JSON attribute can be specified before the Send() but after the Create()/CreateEx().
C++
The JSON attribute can be specified before the Send() but after the CreateMessage()/CreateAlarm().
Output
The Logged Events window provides two visualizations for the JSON attributes, which can be selected via
the drop-down menu inside the information column and opened by clicking on the magnifying glass:
Text Visualizer
JSON Visualizer
When processing messages such as receiving, the question arises as to which messages are to be
considered at the corresponding point.
An API is provided to formulate the desired messages. For all incoming messages, the API describes which
ones are relevant, resulting in a filter.
The practical application of the filters is illustrated in Example filter [} 164] and Example Listener [} 163].
6 PLC API
6.1.1.1 FB_AsyncStrResult
Syntax
Definition:
FUNCTION_BLOCK FB_AsyncStrResult
Methods
Name Description
GetString [} 32] As soon as bBusy is FALSE and provided no error has occurred (bError =
FALSE), the requested text can be fetched with this method.
Properties
Requirements
6.1.1.1.1 GetString
As soon as bBusy is FALSE and provided no error has occurred (bError = FALSE), the requested text can
be fetched with this method.
Syntax
METHOD GetString : BOOL
VAR_INPUT
sResult : REFERENCE TO STRING;
nResult : UDINT;
END_VAR
Inputs
Return value
Example
The method may only be called if bBusy = FALSE and bError = FALSE signal that text is available.
IF NOT fb.bBusy AND NOT fb.bError THEN
bGetStringSuccess := fb.GetString(sText, SIZEOF(sText));
END_IF
6.1.1.2 FB_RequestEventClassName
This function block enables the asynchronous request for the name of an event class.
Syntax
Definition:
FUNCTION_BLOCK FB_RequestEventClassName
Methods
Name Description
GetString [} 34] As soon as bBusy is FALSE and provided no error has occurred (bError =
FALSE), the requested text can be fetched with this method.
Request [} 34] Calling this method triggers the asynchronous text request.
Properties
Requirements
6.1.1.2.1 GetString
As soon as bBusy is FALSE and provided no error has occurred (bError = FALSE), the requested text can
be fetched with this method.
Syntax
METHOD GetString : BOOL
VAR_INPUT
sResult : REFERENCE TO STRING;
nResult : UDINT;
END_VAR
Inputs
Return value
Example
The method may only be called if bBusy = FALSE and bError = FALSE signal that text is available.
IF NOT fb.bBusy AND NOT fb.bError THEN
bGetStringSuccess := fb.GetString(sText, SIZEOF(sText));
END_IF
6.1.1.2.2 Request
Syntax
METHOD Request : HRESULT
VAR_INPUT
eventClass : GUID;
nLangId : DINT;
END_VAR
Inputs
Return value
6.1.1.3 FB_RequestEventText
This function block enables the asynchronous request for an event text in the desired language.
Syntax
Definition:
FUNCTION_BLOCK FB_RequestEventText
Methods
Name Description
GetString [} 35] As soon as bBusy is FALSE and provided no error has occurred (bError =
FALSE), the requested text can be fetched with this method.
Request [} 36] Calling this method triggers the asynchronous text request.
Properties
Requirements
6.1.1.3.1 GetString
As soon as bBusy is FALSE and provided no error has occurred (bError = FALSE), the requested text can
be fetched with this method.
Syntax
METHOD GetString : BOOL
VAR_INPUT
sResult : REFERENCE TO STRING;
nResult : UDINT;
END_VAR
Inputs
Return value
Example
The method may only be called if bBusy = FALSE and bError = FALSE signal that text is available.
IF NOT fb.bBusy AND NOT fb.bError THEN
bGetStringSuccess := fb.GetString(sText, SIZEOF(sText));
END_IF
6.1.1.3.2 Request
Syntax
METHOD Request : BOOL
VAR_INPUT
eventClass : GUID;
nEventId : UDINT;
nLangId : DINT;
ipArgs : I_TcArguments;
END_VAR
Inputs
Return value
6.1.1.4 F_GetEventClassName
The function triggers the asynchronous request for the name of an event class.
Syntax
Definition:
FUNCTION F_GetEventClassName : HRESULT
VAR_INPUT
nLangId : DINT;
fbEventBase : REFERENCE TO FB_TcEventBase;
END_VAR
VAR_IN_OUT
fbResult : FB_AsyncStrResult;
END_VAR
Inputs
/ Inputs/outputs
Return value
Requirements
6.1.1.5 F_GetEventText
Syntax
Definition:
FUNCTION F_GetEventText : HRESULT
VAR_INPUT
nLangId : DINT;
fbEventBase : REFERENCE TO FB_TcEventBase;
END_VAR
VAR_IN_OUT
fbResult : FB_AsyncStrResult;
END_VAR
Inputs
/ Inputs/outputs
Return value
Requirements
6.1.2 Filter
The filter functionality is used in different places. A sample that describes the possible uses is covered in the
Example filter [} 164].
6.1.2.1 FB_TcClearLoggedEventsSettings
Provides the functionality to specify which events should be removed from the cache.
Syntax
Definition:
FUNCTION_BLOCK FB_TcClearLoggedEventsSettings IMPLEMENTS I_TcClearLoggedEventsSettings
Methods
Requirements
6.1.2.1.1 AddFilter
Inputs
Return values
6.1.2.1.2 Clear
Return values
6.1.2.1.3 SetLimit
Indicates the number of events to be cleared. The limit is applied after sorting and filtering.
Inputs
Return values
6.1.2.1.4 SetSorting
Inputs
Return values
6.1.2.2 FB_TcEventCsvExportSettings
Syntax
Definition:
FUNCTION_BLOCK FB_TcEventCsvExportSettings EXTENDS FB_TcEventExportSettings IMPLEMENTS
I_TcEventCsvExportSettings
Methods
Requirements
6.1.2.3 FB_TcEventFilter
The filters are provided via a floating interface following a structured query language. It describes which
messages should apply.
• Conditions can be linked through .AND_OP() and .OR_OP().
A filter is applied once it has been compiled. To receive messages it is assigned to a recipient via
FB_ListenerBase2.subscribe(), for example. In this way FB_ListenerBase2 takes over the filter
and provides a corresponding return value, which is described here. The filter can be amended by repeating
FB_ListenerBase2.subscribe().
Sample
EtherCAT filter
The mechanism for receiving EtherCAT emergency messages is similar to that described above. The entry
point in the chained method calls is .EtherCATDevice(), which first provides a direct query to ascertain if
it was sent from an EtherCAT device (IsEtherCATDevice()). From here you can filter based on the
manufacturer (.VendorId()), the product code (.ProductCode()) or the revision (.RevisionNo()).
Syntax
Definition:
FUNCTION_BLOCK FB_TcEventFilter IMPLEMENTS I_TcEventFilter, I_TcExpressionBase
Methods
Properties
Requirements
6.1.2.3.1 Clear
Return values
6.1.2.3.2 FilterExpression
Inputs
Return values
6.1.2.3.3 IsAlarm
Return values
6.1.2.3.4 IsMessage
Return values
6.1.2.3.5 NOT_OP
Return values
6.1.3.1 AdsErr_TO_TcEventEntry
Syntax
Definition:
Inputs
Return value
Requirements
6.1.3.2 HRESULTAdsErr_TO_TcEventEntry
Syntax
Definition:
FUNCTION HRESULTAdsErr_TO_TcEventEntry : BOOL
VAR_INPUT
hr : E_HRESULTAdsErr;
stEventEntry : REFERENCE TO TcEventEntry;
END_VAR
Inputs
Return value
Requirements
6.1.3.3 TcEventEntry_TO_AdsErr
Syntax
Definition:
FUNCTION TcEventEntry_TO_AdsErr : BOOL
VAR_INPUT
stEventEntry : TcEventEntry;
eErrorId : REFERENCE TO E_AdsErr;
END_VAR
Inputs
Return value
Requirements
6.1.3.4 TcEventEntry_TO_HRESULTAdsErr
Syntax
Definition:
FUNCTION TcEventEntry_TO_HRESULTAdsErr : BOOL
VAR_INPUT
stEventEntry : TcEventEntry;
hr : REFERENCE TO E_HRESULTAdsErr;
END_VAR
Inputs
Return value
Requirements
6.1.4 FB_ListenerBase2
New messages and state changes of alarms can be recognized through the overwriting of the event-driven
methods.
Syntax
Definition:
FUNCTION_BLOCK FB_ListenerBase2 IMPLEMENTS I_Listener2
Methods
Requirements
6.1.4.1 Execute
This method must be called cyclically so that the event queue can be processed.
Syntax
METHOD Execute : HRESULT
Return value
6.1.4.2 OnAlarmCleared
This method is called if the state of an alarm changes from Raised to Clear.
Syntax
METHOD OnAlarmCleared : HRESULT
VAR_INPUT
fbEvent : REFEENCE TO FB_TcEvent;
END_VAR
If the implementation of the callback method returns a return code <> S_OK, further callback calls will be
paused until the next execution.
Inputs
6.1.4.3 OnAlarmConfirmed
Syntax
METHOD OnAlarmConfirmed : HRESULT
VAR_INPUT
fbEvent : REFEENCE TO FB_TcEvent;
END_VAR
If the implementation of the callback method returns a return code <> S_OK, further callback calls will be
paused until the next execution.
Inputs
6.1.4.4 OnAlarmDisposed
This method is called when an alarm instance has been released again.
Syntax
METHOD OnAlarmConfirmed : HRESULT
VAR_INPUT
fbEvent : REFEENCE TO FB_TcEvent;
END_VAR
If the implementation of the callback method returns a return code <> S_OK, further callback calls will be
paused until the next execution.
Inputs
6.1.4.5 OnAlarmRaised
This method is called if the state of an alarm changes from Clear to Raised.
Syntax
METHOD OnAlarmRaised : HRESULT
VAR_INPUT
fbEvent : REFERENCE TO FB_TcEvent;
END_VAR
If the implementation of the callback method returns a return code <> S_OK, further callback calls will be
paused until the next execution.
Inputs
6.1.4.6 OnMessageSent
Syntax
METHOD OnMessageSent : HRESULT
VAR_INPUT
fbEvent : REFEENCE TO FB_TcEvent;
END_VAR
If the implementation of the callback method returns a return code <> S_OK, further callback calls will be
paused until the next execution.
Inputs
6.1.4.7 Subscribe
Syntax
METHOD Subscribe : HRESULT
VAR_INPUT
ipMessageFilterConfig : POINTER TO ITcEventFilterConfig;
ipAlarmFilterConfig : POINTER TO ITcEventFilterConfig;
END_VAR
Inputs
Return value
6.1.4.8 Subscribe2
Syntax
METHOD Subscribe2 : HRESULT
Input
Return value
6.1.4.9 Unsubscribe
Syntax
METHOD Unsubscribe : HRESULT
Return value
6.1.5 FB_TcAlarm
Syntax
Definition:
FUNCTION_BLOCK FB_TcAlarm EXTENDS FB_TcEventBase
Inheritance hierarchy
FB_TcEventBase [} 62]
FB_TcAlarm
Methods
Properties
Requirements
6.1.5.1 Clear
Syntax
METHOD Clear : HRESULT
VAR_INPUT
nTimeStamp : ULINT;
bResetConfirmation : BOOL;
END_VAR
Inputs
Return value
6.1.5.2 Confirm
Syntax
METHOD Confirm : HRESULT
VAR_INPUT
nTimeStamp: ULINT;
END_VAR
Inputs
Return value
6.1.5.3 Create
Syntax
METHOD Create : HRESULT
eventClass : GUID;
nEventId : UDINT;
eSeverity : TcEventSeverity;
bWithConfirmation : BOOL;
ipSourceInfo : I_TcSourceInfo;
END_VAR
Inputs
Return value
6.1.5.4 CreateEx
Syntax
METHOD CreateEx : HRESULT
VAR_INPUT
stEventEntry : TcEventEntry;
bWithConfirmation : BOOL;
ipSourceInfo : I_TcSourceInfo;
END_VAR
Inputs
Return value
6.1.5.5 Raise
If the alarm requires mandatory confirmation, the confirmation state is additionally set to
WaitForConfirmation.
Syntax
METHOD Raise : HRESULT
VAR_INPUT
nTimeStamp : ULINT;
END_VAR
Inputs
Return value
6.1.5.6 SetJsonAttribute
Syntax
METHOD SetJsonAttribute : HRESULT
VAR_IN_OUT CONSTANT
sJsonAttribute : STRING;
END_VAR
Inputs
Return value
6.1.6 FB_TcArguments
Arguments of an event can be defined with this function block. The ITcArguments interface is implemented
for this.
Syntax
Definition:
FUNCTION_BLOCK FB_TcArguments IMPLEMENTS I_TcArguments
Interfaces
Type Description
I_TcArguments [} 82] Defines the argument handling.
Methods
Properties
Requirements
6.1.6.1 IsEmpty
Syntax
METHOD IsEmpty : BOOL
Return value
6.1.7 FB_TcEvent
This function block provides only read methods and read properties for an event.
Syntax
Definition:
FUNCTION_BLOCK FB_TcEvent EXTENDS FB_TcEventBase IMPLEMENTS I_TcEventBase
Inheritance hierarchy
FB_TcEventBase [} 62]
FB_TcEvent
Interfaces
Type Description
I_TcEventBase [} 92] Basic interface that defines methods and properties of an event.
Methods
Properties
Requirements
6.1.8 FB_TcEventBase
Syntax
Definition:
FUNCTION_BLOCK FB_TcEventBase
Methods
Properties
Requirements
6.1.8.1 EqualsTo
This method carries out a comparison with another event specified at the input.
Syntax
METHOD EqualsTo : BOOL
VAR_INPUT
ipOther : I_TcEventBase;
END_VAR
Inputs
Return value
6.1.8.2 EqualsToEventClass
This method carries out a comparison with another event class specified at the input.
Syntax
METHOD EqualsToEventClass : BOOL
VAR_INPUT
OtherEventClass : GUID
END_VAR
Inputs
Return value
6.1.8.3 EqualsToEventEntry
This method carries out a comparison with another event specified at the input.
Syntax
METHOD EqualsToEventEntry : BOOL
VAR_INPUT
OtherEventClass : GUID;
nOtherEventID : UDINT;
eOtherSeverity : TcEventSeverity;
END_VAR
Inputs
Return value
6.1.8.4 EqualsToEventEntryEx
This method carries out a comparison with another event specified at the input.
Syntax
METHOD EqualsToEventEntryEx : BOOL
VAR_INPUT
stOther : TcEventEntry;
END_VAR
Inputs
Return value
6.1.8.5 GetJsonAttribute
Syntax
METHOD GetJsonAttribute : HRESULT
VAR_INPUT
sJsonAttribute : REFERENCE TO STRING;
nJsonAttribute : UDINT;
END_VAR
Inputs
Return value
6.1.8.6 Release
Syntax
METHOD Release : HRESULT
Return value
6.1.8.7 RequestEventClassName
Syntax
METHOD RequestEventClassName : BOOL
VAR_INPUT
nLangId : DINT;
sResult : REFERENCE TO STRING;
nResultSize : UDINT;
END_VAR
VAR_OUTPUT
bError : BOOL;
hrErrorCode : HRESULT;
END_VAR
Inputs
Return value
Outputs
6.1.8.8 RequestEventText
Syntax
METHOD RequestEventText : BOOL
VAR_INPUT
nLangId : DINT;
sResult : REFERENCE TO STRING;
nResultSize : UDINT;
END_VAR
VAR_OUTPUT
bError : BOOL;
hrErrorCode : HRESULT;
END_VAR
Inputs
Return value
Outputs
6.1.8.9 ipArguments
PROPERTY PUBLIC ipArguments : I_TcArguments
6.1.8.10 ipSourceInfo
PROPERTY ipSourceInfo : I_TcSourceInfo
6.1.9 FB_TcEventLogger
Syntax
Definition:
FUNCTION_BLOCK FB_TcEventLogger
Methods
Name Description
ClearAlarms [} 69] Clears active alarms.
ClearAllAlarms [} 69] Calls Clear() for all alarms in the Raised state.
ClearLoggedEvents [} 70] Clears logged events.
ConfirmAlarms [} 70]
ConfirmAllAlarms [} 71] Calls Confirm() for all alarms with the confirmation state WaitForConfirmation.
ExportLoggedEvents [} 71] Exports logged events.
GetAlarm [} 72] Returns the pointer to an existing alarm.
GetAlarmEx [} 72] Returns the pointer to an existing alarm.
IsAlarmRaised [} 73] Queries whether an alarm is in the Raised state.
IsAlarmRaisedEx [} 73] Queries whether an alarm is in the Raised state.
SendMessage [} 74] Sends a message.
SendMessage2 [} 75] Sends a message.
SendMessageEx [} 75] Sends a message.
SendMessageEx2 [} 76] Sends a message.
Requirements
6.1.9.1 ClearAlarms
Inputs
Return values
6.1.9.2 ClearAllAlarms
This method calls the Clear() method for all alarms in the alarm state Raised.
Syntax
METHOD ClearAllAlarms : HRESULT
VAR_INPUT
nTimeStamp : ULINT := 0;
bResetConfirmation : BOOL := FALSE;
END_VAR
Inputs
Return value
6.1.9.3 ClearLoggedEvents
Async method for clearing logged events. Returns TRUE if the asynchronous request is no longer assigned.
Inputs
Return values
6.1.9.4 ConfirmAlarms
Inputs
Return values
6.1.9.5 ConfirmAllAlarms
This method calls the Confirm() method for all alarms having the confirmation state WaitForConfirmation.
Syntax
METHOD ConfirmAllAlarms : HRESULT
VAR_INPUT
nTimeStamp : ULINT := 0;
END_VAR
Inputs
Return value
6.1.9.6 ExportLoggedEvents
Async exports logged events. Returns TRUE if the Async request is no longer active.
Inputs
Return values
6.1.9.7 GetAlarm
Syntax
METHOD GetAlarm : HRESULT
VAR_INPUT
eventClass : GUID;
nEventId : UDINT;
ipSourceInfo : I_TcSourceInfo := 0;
fbAlarm : REFERENCE TO FB_TcAlarm;
END_VAR
Inputs
Return value
6.1.9.8 GetAlarmEx
Syntax
METHOD GetAlarmEx : HRESULT
VAR_INPUT
stEventEntry : TcEventEntry;
ipSourceInfo : I_TcSourceInfo := 0; // optional
fbAlarm : REFERENCE TO FB_TcAlarm;
END_VAR
Inputs
Return value
6.1.9.9 IsAlarmRaised
Syntax
METHOD IsAlarmRaised : BOOL
VAR_INPUT
eventClass : GUID;
nEventId : UDINT;
ipSourceInfo : I_TcSourceInfo := 0;
END_VAR
Inputs
Return value
6.1.9.10 IsAlarmRaisedEx
Syntax
METHOD IsAlarmRaisedEx : BOOL
VAR_INPUT
stEventEntry : TcEventEntry;
ipSourceInfo : I_TcSourceInfo := 0;
END_VAR
Inputs
Return value
6.1.9.11 SendMessage
Syntax
METHOD SendMessage : HRESULT
VAR_INPUT
eventClass : GUID;
nEventId : UDINT;
eSeverity : TcEventSeverity;
ipSourceInfo : I_TcSourceInfo := 0;
nTimeStamp : ULINT := 0;
ipArguments : I_TcArguments := 0;
END_VAR
Inputs
Return value
6.1.9.12 SendMessage2
Inputs
Return values
6.1.9.13 SendMessageEx
Syntax
METHOD SendMessageEx : HRESULT
VAR_INPUT
stEventEntry : TcEventEntry;
ipSourceInfo : I_TcSourceInfo := 0;
nTimeStamp : ULINT := 0;
ipArguments : I_TcArguments := 0;
END_VAR
Inputs
Return value
6.1.9.14 SendMessageEx2
Inputs
Return values
6.1.10 FB_TcMessage
Syntax
Definition:
FUNCTION_BLOCK FB_TcMessage EXTENDS FB_TcEventBase IMPLEMENTS I_TcMessage
Inheritance hierarchy
FB_TcEventBase [} 62]
FB_TcMessage
Interfaces
Type Description
I_TcMessage [} 97] Provides methods and properties for the message handling.
Methods
Properties
Requirements
6.1.10.1 Create
Syntax
METHOD Create : HRESULT
VAR_INPUT
eventClass : GUID;
nEventId : UDINT;
eSeverity : TcEventSeverity;
ipSourceInfo : I_TcSourceInfo := 0;
END_VAR
Inputs
Return value
6.1.10.2 CreateEx
This method creates a message instance in the EventLogger from an event definition.
Syntax
METHOD PUBLIC CreateEx : HRESULT
VAR_INPUT
stEventEntry : TcEventEntry;
ipSourceInfo : I_TcSourceInfo := 0;
END_VAR
Inputs
Return value
6.1.10.3 SetJsonAttribute
Syntax
METHOD SetJsonAttribute : HRESULT
VAR_IN_OUT CONSTANT
sJsonAttribute : STRING;
END_VAR
Inputs
Return value
6.1.11 FB_TcSourceInfo
The source information of an event can be defined with this function block.
Syntax
Definition:
FUNCTION_BLOCK FB_TcSourceInfo IMPLEMENTS I_TcSourceInfo
Interfaces
Type Description
I_TcSourceInfo [} 98] Provides read methods and read properties of a source information.
Methods
Properties
Requirements
6.1.11.1 Clear
Syntax
METHOD Clear
6.1.11.2 ExtendName
Syntax
METHOD ExtendName : BOOL
VAR_INPUT
sExtension : STRING(255);
END_VAR
Inputs
Return value
6.1.11.3 ResetToDefault
Default values:
sName is initialized with the symbol name of the instanced function block.
If the instance of FB_TcSourceInfo is hidden with the attribute "hide", no symbol name can be created
internally for the default behavior.
Syntax
METHOD ResetToDefault
6.2 Interfaces
6.2.1 I_TcArguments
This interface defines methods for the argument handling.
Inheritance hierarchy
__SYSTEM.IQueryInterface
I_TcArguments
Methods
Name Description
AddBlob [} 83] Adds binary data as an argument.
AddBool [} 84] Adds an argument of the type BOOL.
AddByte [} 84] Adds an argument of the type BYTE.
AddDint [} 85] Adds an argument of the type DINT.
AddDWord [} 85] Adds an argument of the type DWORD.
AddEventReferencId [} 86] Adds a reference to another event as an argument.
AddEventReferenceIdGuid Adds a reference to another event as an argument.
[} 86]
AddInt [} 87] Adds an argument of the type INT.
AddLInt [} 87] Adds an argument of the type LINT.
AddLReal [} 87] Adds an argument of the type LREAL.
AddReal [} 88] Adds an argument of the type REAL.
AddSInt [} 88] Adds an argument of the type SINT.
AddString [} 89] Adds an argument of the type STRING.
AddUDint [} 89] Adds an argument of the type UDINT.
AddUInt [} 90] Adds an argument of the type INT.
AddULInt [} 90] Adds an argument of the type ULINT.
AddUSInt [} 91] Adds an argument of the type USINT.
AddWord [} 91] Adds an argument of the type WORD.
AddWString [} 91] Adds an argument of the type WSTRING.
Clear [} 92] Removes all arguments.
Properties
6.2.1.1 AddBlob
Syntax
METHOD AddBlob : I_TcArguments
VAR_INPUT
pData : PVOID;
cbData : UINT;
END_VAR
Inputs
Return value
6.2.1.2 AddBool
Syntax
METHOD AddBool : I_TcArguments
VAR_INPUT
value : BOOL;
END_VAR
Inputs
Return value
6.2.1.3 AddByte
Syntax
METHOD AddByte : I_TcArguments
VAR_INPUT
value : BYTE;
END_VAR
Inputs
Return value
6.2.1.4 AddDint
Syntax
METHOD AddDINT : I_TcArguments
VAR_INPUT
value : DINT;
END_VAR
Inputs
Return value
6.2.1.5 AddDWord
Syntax
METHOD AddDWord : I_TcArguments
VAR_INPUT
value : DWORD;
END_VAR
Inputs
Return value
6.2.1.6 AddEventReferencId
Syntax
METHOD AddEventReferenceId : I_TcArguments
VAR_INPUT
nEventId : UDINT;
END_VAR
Inputs
Return value
6.2.1.7 AddEventReferenceIdGuid
Syntax
METHOD AddEventReferenceIdGuid : I_TcArguments
VAR_INPUT
nEventId : UDINT;
EventClass : GUID;
END_VAR
Inputs
Return value
6.2.1.8 AddInt
Syntax
METHOD AddINT : I_TcArguments
VAR_INPUT
value : INT;
END_VAR
Inputs
Return value
6.2.1.9 AddLInt
Syntax
METHOD AddLInt : I_TcArguments
VAR_INPUT
value : LINT;
END_VAR
Inputs
Return value
6.2.1.10 AddLReal
Syntax
METHOD AddLReal : I_TcArguments
VAR_INPUT
value : LREAL;
END_VAR
Inputs
Return value
6.2.1.11 AddReal
Syntax
METHOD AddReal : I_TcArguments
VAR_INPUT
value : REAL;
END_VAR
Inputs
Return value
6.2.1.12 AddSInt
Syntax
METHOD AddSInt : I_TcArguments
VAR_INPUT
value : SInt;
END_VAR
Inputs
Return value
6.2.1.13 AddString
Syntax
METHOD AddString : I_TcArguments
VAR_IN_OUT CONSTANT
value : STRING;
END_VAR
Inputs
Return value
6.2.1.14 AddUDint
Syntax
METHOD AddUDInt : I_TcArguments
VAR_INPUT
value : UDINT;
END_VAR
Inputs
Return value
6.2.1.15 AddUInt
Syntax
METHOD AddUInt : I_TcArguments
VAR_INPUT
value : UINT;
END_VAR
Inputs
Return value
6.2.1.16 AddULInt
Syntax
METHOD AddULInt : I_TcArguments
VAR_INPUT
value : ULINT;
END_VAR
Inputs
Return value
6.2.1.17 AddUSInt
Syntax
METHOD AddUSInt : I_TcArguments
VAR_INPUT
value : USINT
END_VAR
Inputs
Return value
6.2.1.18 AddWord
Syntax
METHOD AddWord : I_TcArguments
VAR_INPUT
value : WORD;
END_VAR
Inputs
Return value
6.2.1.19 AddWString
Syntax
METHOD AddWString : I_TcArguments
VAR_IN_OUT CONSTANT
value : WSTRING;
END_VAR
Inputs
Return value
6.2.1.20 Clear
Syntax
METHOD Clear : I_TcArguments
Return value
6.2.2 I_TcEventBase
Methods and properties of an event are defined in this basic interface.
Methods
Name Description
EqualsTo [} 93] Compares the event with another instance.
EqualsToEventClass [} 93] Compares the event class of the event with another event class.
EqualsToEventEntryEx Compares the event definition of the event with another event definition.
[} 94]
GetJsonAttribute [} 95] Returns the Json attribute.
RequestEventClassName Requests the name of the event class.
[} 95]
RequestEventText [} 96] Returns the text for the event.
Properties
Requirements
6.2.2.1 EqualsTo
This method carries out a comparison with another event specified at the input.
Syntax
METHOD EqualsTo : BOOL
VAR_INPUT
ipOther : I_TcEventBase;
END_VAR
Inputs
Return value
6.2.2.2 EqualsToEventClass
This method carries out a comparison with another event class specified at the input.
Syntax
METHOD EqualsToEventClass : BOOL
VAR_INPUT
OtherEventClass : GUID
END_VAR
Inputs
Return value
6.2.2.3 EqualsToEventEntry
This method carries out a comparison with another event specified at the input.
Syntax
METHOD EqualsToEventEntry : BOOL
VAR_INPUT
OtherEventClass : GUID;
nOtherEventID : UDINT;
eOtherSeverity : TcEventSeverity;
END_VAR
Inputs
Return value
6.2.2.4 EqualsToEventEntryEx
This method carries out a comparison with another event specified at the input.
Syntax
METHOD EqualsToEventEntryEx : BOOL
VAR_INPUT
stOther : TcEventEntry;
END_VAR
Inputs
Return value
6.2.2.5 GetJsonAttribute
Syntax
METHOD GetJsonAttribute : HRESULT
VAR_INPUT
sJsonAttribute : REFERENCE TO STRING;
nJsonAttribute : UDINT;
END_VAR
Inputs
Return value
6.2.2.6 RequestEventClassName
Syntax
METHOD RequestEventClassName : BOOL
VAR_INPUT
nLangId : DINT;
sResult : REFERENCE TO STRING;
nResultSize : UDINT;
END_VAR
VAR_OUTPUT
bError : BOOL;
hrErrorCode : HRESULT;
END_VAR
Inputs
Return value
Outputs
6.2.2.7 RequestEventText
Syntax
METHOD RequestEventText : BOOL
VAR_INPUT
nLangId : DINT;
sResult : REFERENCE TO STRING;
nResultSize : UDINT;
END_VAR
VAR_OUTPUT
bError : BOOL;
hrErrorCode : HRESULT;
END_VAR
Inputs
Return value
Outputs
6.2.3 I_TcMessage
This interface provides methods and properties for the message handling.
Inheritance hierarchy
I_TcEventBase [} 92]
I_TcMessage
Methods
Name Description
Send [} 97] Sends a message
Requirements
6.2.3.1 Send
Syntax
METHOD Send : HRESULT
VAR_INPUT
nTimeStamp: ULINT;
END_VAR
Inputs
Return value
6.2.4 I_TcSourceInfo
This interface defines properties for an item of source information.
Methods
Name Description
EqualsTo [} 98] Compares an instance with source information with another instance.
Properties
Requirements
6.2.4.1 EqualsTo
This method compares an instance with source information with another instance.
Syntax
METHOD EqualsTo : BOOL
VAR_INPUT
ipOther : I_TcSourceInfo;
END_VAR
Inputs
Return value
6.3.1 TcEventEntry
Defines an event by means of event class, event ID and severity.
Syntax
Definition:
TYPE TcEventEntry :
STRUCT
uuidEventClass : GUID;
nEventId : UDINT;
eSeverity : TcEventSeverity;
END_STRUCT
END_TYPE
Parameter
6.3.2 TcEventSeverity
Defines the severity of the event.
Syntax
Definition:
{attribute 'qualified_only'}
TYPE TcEventSeverity : (
Verbose := 0,
Info := 1,
Warning := 2,
Error := 3,
Critical := 4);
END_TYPE
Parameter
Name Description
4 Critical Critical
3 Error Error
2 Warning Warning
1 Info Information
0 Verbose Extended output
6.3.3 TcEventConfirmationState
Defines the confirmation state of an alarm.
Syntax
Definition:
{attribute 'qualified_only'}
TYPE TcEventConfirmationState : (
NotSupported := 0,
NotRequired := 1,
WaitForConfirmation := 2,
Confirmed := 3,
Reset := 4);
END_TYPE
Parameter
Name Description
Confirmed Confirmed
NotRequired Confirmation not necessary in the current state.
(Alarm not currently in the Raised state).
NotSupported Was initialized without confirmation.
Reset Initial state
WaitForConfirmation Waiting for confirmation.
6.4.1 Global_Constants
VAR_GLOBAL CONSTANT
EMPTY_EVENT_CLASS : GUID := (Data1:=16#0, Data2:=16#0, Data3:=16#0, Data4:=[16#0,16#0,16#0,16#0,
16#0,16#0,16#0,16#0]);
EMPTY_EVENT_ID : UDINT := 16#0;
EMPTY_SEVERITY : TcEventSeverity := TcEventSeverity.Verbose;
SUCCESS_EVENT : TcEventEntry := ( uuidEventClass := EMPTY_EVENT_CLASS, nEventID := EMPTY_EVE
NT_ID, eSeverity := EMPTY_SEVERITY );
END_VAR
6.4.2 GVL
{attribute 'qualified_only'}
VAR_GLOBAL
nLangId_OnlineMonitoring : DINT := 1033;
END_VAR
6.4.4 Global_Version
All libraries have a certain version. This version can be seen in the PLC library repository among others.
A global constant contains the library version information (of type ST_LibVersion):
Global_Version
VAR_GLOBAL CONSTANT
stLibVersion_Tc3_EventLogger : ST_LibVersion;
END_VAR
To check whether the version you have is the version you need, use the function F_CmpLibVersion (defined
in the Tc2_System library).
7 C++ API
7.1 Interfaces
7.1.1 ITcEvent
This interface provides general methods for ITcAlarm and ITcMessage. It is used in the callbacks of the
interfaces ITcAlarmListener and ITcMessageListener.
Syntax
TCOM_DECL_INTERFACE("4A9CB0E9-8969-4B85-B567-605110511200", ITcEvent)
Methods
Name Description
GetEventClass [} 102] Returns the GUID of the event class.
GetEventId [} 102] Returns the ID of the event.
GetSeverity [} 103] Returns the Severity of the event.
GetSourceInfo [} 103] Returns the SourceInfo.
GetJsonAttribute [} 103] Returns the JSON attribute.
GetText [} 104] Returns the text asynchronously.
GetEventClassName [} 104] Returns the event class name asynchronously.
7.1.1.1 GetEventClass
Returns the GUID of the event class.
Syntax
virtual HRESULT TCOMAPI GetEventClass (GUID eventClass)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.1.2 GetEventId
Returns the ID of the event.
Syntax
virtual HRESULT TCOMAPI GetEventId (UDINT EventId)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.1.3 GetSeverity
Returns the Severity of the event.
Syntax
virtual HRESULT TCOMAPI GetSeverity (TcEventSeverity severity)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.1.4 GetSourceInfo
Returns the SourceInfo.
Syntax
virtual HRESULT TCOMAPI GetSourceInfo (ITcSourceInfo pipSourceInfo)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.1.5 GetJsonAttribute
Returns the JSON attribute.
Syntax
virtual HRESULT TCOMAPI GetJsonAttribute (STRING sJsonAttribute, UDINT nJsonAttribute)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.1.6 GetText
Returns the text asynchronously.
Syntax
virtual HRESULT TCOMAPI GetText (DINT nLangId, ITcAsyncStringResult pipResult)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.1.7 GetEventClassName
Returns the event class name asynchronously.
Syntax
virtual HRESULT TCOMAPI GetClassName (DINT nLangId, ITcAsyncStringResult pipResult)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.2 ITcMessage
This interface represents a message from the TwinCAT 3 EventLogger.
Syntax
TCOM_DECL_INTERFACE("6474ED2C-E483-454E-A67D-233E6D337C08", ITcMessage)
Methods
Name Description
SetJsonAttribute [} 105] Sets the JSON attribute.
GetArguments [} 105] Returns the interface pointer for the arguments.
Send [} 106] Sends the message.
7.1.2.1 SetJsonAttribute
Sets the JSON attribute.
Syntax
virtual HRESULT TCOMAPI SetJsonAttribute (STINRG sJsonAttribute)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.2.2 GetArguments
Returns the interface pointer for the arguments.
Syntax
virtual HRESULT TCOMAPI GetArguments (ITcArguments pipArguments)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.2.3 Send
Sends the message.
Syntax
virtual HRESULT TCOMAPI Send (ULINT timeStamp)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3 ITcAlarm
This interface represents an alarm from the TwinCAT 3 EventLogger.
Syntax
TCOM_DECL_INTERFACE("EC6D4FF7-5805-4DDB-A316-27894E77D644", ITcAlarm)
Methods
Name Description
SetJsonAttribute [} 106] Sets the JSON attribute.
GetArguments [} 107] Returns the interface pointer for the arguments.
GetIsRaised [} 107] Returns TRUE if the alarm is in the raised state.
Raise [} 108] Sets the alarm state to Raised.
Clear [} 108] Sets the alarm state to Not Raised.
GetConfirmationState [} 108] Returns the confirmation state.
Confirm [} 109] Sets the alarm state to Confirmed.
7.1.3.1 SetJsonAttribute
Sets the Json attribute.
Syntax
virtual HRESULT TCOMAPI SetJsonAttribute (STRING sJsonAttribute)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3.2 GetArguments
Returns the interface pointer for the arguments.
Syntax
virtual HRESULT TCOMAPI GetArguments (ITcArguments pipArguments)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3.3 GetIsRaised
Returns TRUE in the parameter blsRaised if the alarm is in the Raised state.
Syntax
virtual HRESULT TCOMAPI GetIsRaised (BOOL32 bIsRaised)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3.4 Raise
Sets the alarm state [} 14] to Raised.
If the alarm requires mandatory confirmation, the confirmation state is additionally set to
WaitForConfirmation.
Syntax
virtual HRESULT TCOMAPI Raise (ULINT timeStamp)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3.5 Clear
Sets the alarm state [} 14] to Not Raised.
Syntax
virtual HRESULT TCOMAPI Clear (ULINT timeStamp, BOOL32 bResetConfirmation)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3.6 GetConfirmationState
Returns the confirmation state [} 14].
Syntax
virtual HRESULT TCOMAPI GetConfirmationState (… state)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.3.7 Confirm
Sets the confirmation state [} 14] of WaitingForConfirmation to Confirmed.
Syntax
virtual HRESULT TCOMAPI Confirm (ULINT timeStamp)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4 ITcEventLogger
This interface represents the TwinCAT 3 EventLogger itself.
Syntax
TCOM_DECL_INTERFACE("B2D5D4E2-07F6-44F4-A292-92CA8035AA86", ITcEventLogger)
Required includes:
#include "TcRouterInterfaces.h"
#include "TcEventLoggerInterfaces.h"
Methods
Name Description
CreateMessage [} 110] Creates an instance that implements ITcMessage.
CreateAlarm [} 110] Creates an instance that implements ITcAlarm.
GetAlarm [} 111] Returns the pointer to an existing alarm.
IsAlarmRaised [} 112] Queries whether an alarm is in the Raised state.
ConfirmAllAlarms [} 112] Calls Confirm() for all alarms with the confirmation
state WaitForConfirmation.
ClearAllAlarms [} 112] Calls Clear() for all alarms in the Raised state.
SendTcMessage [} 113] Sends a message.
AddMessageListener [} 113] Adds a message listener.
RemoveMessageListener [} 114] Removes a message listener.
NotifyMessageListener [} 114] Processes a queue for a message listener.
AddAlarmListener [} 115] Adds an alarm listener.
RemoveAlarmListener [} 115] Removes an alarm listener.
NotifyAlarmListener [} 115] Processes a queue for an alarm listener.
GetEventText [} 116] Returns a text for an event.
GetEventClassName [} 116] Returns the class name for an event.
CreateArguments [} 117] Creates an instance that implements ITcArguments.
7.1.4.1 CreateMessage
Creates an instance that implements ITcMessage.
Syntax
virtual HRESULT TCOMAPI CreateMessage (GUID eventClass, UDINT eventId, GUID severit, ITcSourceInfo i
pSourceInfo, ITcMessage pipMessage)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.2 CreateAlarm
Creates an instance that implements ITcAlarm.
Syntax
virtual HRESULT TCOMAPI CreateAlarm (GUID eventClass, UDINT eventId, GUID severity, BOOL32 bWithConf
irmation, ITcSourceInfo ipSourceInfo, ITcAlarm pipAlarm)
Parameter
Return value
Type Description
HRESULT Returns S_OK if a new alarm was successfully created.
Returns ERROR_ALREADY_EXISTS if the alarm already exists.
In case of error an HRESULT is returned as the error code.
7.1.4.3 GetAlarm
Returns an interface pointer to an existing instance.
Syntax
virtual HRESULT TCOMAPI GetAlarm (GUID eventClass, UDINT eventId, ITcSourceInfo ipSourceInfo, ITcAla
rm pipAlarm)
Parameter
Return value
Type Description
HRESULT Returns ADS_E_NOTFOUND if no instance was
found.
Returns S_OK if everything was successful,
otherwise an HRESULT as the error code.
7.1.4.4 IsAlarmRaised
Queries whether an alarm is in the Raised state.
Syntax
virtual HRESULT TCOMAPI IsAlarmRaised (GUID eventClass, UDINT eventId, BOOL32 bIsRaised, ITcSourceIn
fo ipSourceInfo)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.5 ConfirmAllAlarms
Calls Confirm() for all alarms with the confirmation state WaitForConfirmation.
Syntax
virtual HRESULT TCOMAPI ConfirmAllAlarms (ULINT timeStamp)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.6 ClearAllAlarms
Calls Clear() for all alarms in the Raised state.
Syntax
virtual HRESULT TCOMAPI ClearAllAlarms (ULINT timestamp, BOOL32 bResetConfirmation)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.7 SendTcMessage
Sends a message.
Syntax
virtual HRESULT TCOMAPI SendTcMessage (GUID eventClass, UDINT eventId, GUID severity, ITcSourceInfo
ipSourceInfo, ULINT timeStamp, ITcArguments ipSerializedArguments)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.8 AddMessageListener
Adds a message listener.
Syntax
virtual HRESULT TCOMAPI AddMessageListener (ITcMessageListener ipListener, ITcEventFilterConfig pipF
ilterConfig)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.9 RemoveMessageListener
Removes a message listener.
Syntax
virtual HRESULT TCOMAPI RemoveMessageListener (ITcMessageListener ipListener)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.10 NotifyMessageListener
Processes a queue for the message listener.
Syntax
virtual HRESULT TCOMAPI NotifyMessageListener (ITcMessageListener ipListener)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.11 AddAlarmListener
Adds an alarm listener.
Syntax
virtual HRESULT TCOMAPI AddAlarmListener (ITcMessageListener ipListener, ITcEventFilterConfig pipFil
terConfig)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.12 RemoveAlarmListener
Removes an alarm listener.
Syntax
virtual HRESULT TCOMAPI RemoveAlarmListener (ITcMessageListener ipListener)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.13 NotifyAlarmListener
Processes a queue for an alarm listener.
Syntax
virtual HRESULT TCOMAPI NotifyMessageListener (ITcMessageListener ipListener)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.14 GetEventText
Returns a text for an event.
Syntax
virtual HRESULT TCOMAPI GetEventText (GUID eventClass, UDINT eventId, ITcSourceInfo ipSourceInfo, IT
cArguments ipArguments, DINT nLangId, ITcAsyncStringResult pipResult)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.15 GetEventClassName
Returns the class name for an event.
Syntax
virtual HRESULT TCOMAPI GetEventClassName (GUID eventClass, DINT nLangId, ITcAsyncStringResult pipRe
sult)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.1.4.16 CreateArguments
Creates an instance that implements ITcArguments.
Syntax
virtual HRESULT TCOMAPI CreateArguments (ITcArguments ipArguments)
Parameter
Return value
Type Description
HRESULT Returns S_OK if the method call was successful, otherwise an
HRESULT as the error code.
7.2.1 TcEventEntry
Defines an event by means of event class, event ID and severity.
Syntax
Definition:
typedef struct
{
GUID uuidEventClass;
UDINT nEventId;
TcEventSeverity eSeverity;
}TcEventEntry;
Parameter
7.2.2 TcEventSeverity
Defines the severity of the event.
Syntax
Definition:
typedef enum
{
Verbose = 0,
Info = 1,
Warning = 2,
Error = 3,
Critical = 4
}TcEventSeverity;
7.2.3 TcEventConfirmationState
Defines the confirmation state of an alarm.
Syntax
Definition:
typedef enum
{
NotSupported = 0,
NotRequired = 1,
WaitForConfirmation = 2,
Confirmed = 3,
Reset = 4
}TcEventConfirmationState;
8 COM API
It is possible to access the EventLogger from Windows systems via the COM interface.
8.1 Classes
8.1.1 TcEventLogger
This class represents the connection to a TwinCAT 3 Eventlogger.
Syntax
public class: ITcEventLogger2, _ITcEventLoggerEvents
Constructor
Call:
TcEventLogger logger : new TcEventLogger();
Interfaces
Name Description
ITcEventLogger2 [} 145] Interface for sending commands to the EventLogger.
_ITcEventLoggerEvents [} 128] This interface provides the messages for occurring events.
Methods
events
Properties
8.1.1.1 ITcEventLogger_ClearAllAlarms
This method sets all alarms that are in the "Raised" state to "Not Raised".
Syntax
public virtual void ITcEventLogger_ClearAllAlarms([bool bResetConfirmation = True])
Parameter
8.1.1.2 ITcEventLogger_ClearLoggedEvents
This method clears the events cache.
The current alarm states are not changed by this.
Syntax
public virtual void ITcEventLogger_ClearLoggedEvents()
8.1.1.3 ITcEventLogger_ConfirmAllAlarms
This method confirms all alarms that have to be confirmed, i.e. those that are in the "WaitForConfirmation"
state.
Syntax
public virtual void ITcEventLogger_ConfirmAllAlarms()
8.1.1.4 ITcEventLogger_Connect
This method connects the object with an EventLogger on a runtime system on the basis of the AmsNetId.
Syntax
public virtual void ITcEventLogger_Connect([string Address = localhost])
Parameter
8.1.1.5 ITcEventLogger_Disconnect
This method disconnects the object from the EventLogger.
Syntax
public virtual void ITcEventLogger_Disconnect()
8.1.1.6 ITcEventLogger_GetEventClassName
This method returns the EventClass name that matches a given EventClass GUID.
Syntax
public virtual string ITcEventLogger_GetEventClassName(System.Guid EventClass, int nLangId)
Parameter
Return value
8.1.1.7 ITcEventLogger_GetLoggedEvents
This method returns a collection of stored latest events.
Syntax
public virtual TcLoggedEventCollection ITcEventLogger_GetLoggedEvents(uint nMaxEntiries)
Parameter
Return value
8.1.1.8 ITcEventLogger_GetText
This method returns the text of an event.
Syntax
public virtual string ITcEventLogger_GetText(System.Guid EventClass, uint EventId, uint objectId,
TcEventLoggerAdsProxyLib.TcEventArgumentsInfo pArgInfo, System.IntPtr pArgData, int nLangId)
Parameter
Return value
8.1.1.9 ITcEventLogger_ActiveAlarms
This property box returns a collection of the currently active alarms (active state is "Raised" or
"WaitingForConfirmation").
Syntax
public virtual TcEventLoggerAdsProxyLib.TcAlarmCollection ITcEventLogger_ActiveAlarms
8.1.1.10 ITcEventLogger_IsConnected
This property indicates whether the TcEventLogger object is currently connected to a target system.
This should be checked regularly in order to be able to react to a loss of connection.
Syntax
public virtual bool ITcEventLogger_IsConnected
8.1.1.11 ITcEventLogger2_SendTcMessage
This method sends a message.
Syntax
public virtual void SendTcMessage(System.Guid EventClass, uint EventId,
TcEventLoggerAdsProxyLib.SeverityLevelEnum severity, string JsonAttribute,
TcEventLoggerAdsProxyLib.TcSourceInfo pSourceInfo, TcEventLoggerAdsProxyLib.TcArguments pArguments)
Parameter
8.1.2 TcArguments
Arguments of an event can be defined with this class. The ITcArguments interface is implemented for this.
Syntax
public class: ITcArguments
Constructor
Call:
TcArguments args : new TcArguments();
Interfaces
Name Description
ITcArguments Interface for describing the arguments.
Methods
Properties
8.1.2.1 Add
This method adds an argument.
Syntax
public virtual void Add(object Item)
Parameter
8.1.2.2 AddV
This method adds an array of arguments.
Syntax
public virtual void AddV(params object[] args)
Parameter
8.1.2.3 Clear
This method deletes all arguments.
Syntax
public virtual void Clear()
8.1.2.4 GetEnumerator
This method returns an enumeration of the arguments.
Syntax
public virtual System.Collections.IEnumerator GetEnumerator()
Return value
8.1.2.5 Remove
This method deletes an argument.
Syntax
public virtual void Remove(uint Index)
Parameter
8.1.2.6 Set
This method sets an argument.
Syntax
public virtual void Set(uint Index, object Item)
Parameter
8.1.2.7 Count
This property returns the number.
Syntax
public virtual int Count
Syntax
public virtual TcEventLoggerAdsProxyLib.TcArgumentEntry this[uint Index]
8.1.3 TcSourceInfo
This class describes the source information of an event.
Syntax
public class: ITcSourceInfo
Constructor
Call:
TcSourceInfo souceInfo: new SourceInfo();
Methods
Properties
8.1.3.1 GetData
This method returns the data for a source.
Syntax
public virtual void GetData(uint Index, out TcEventLoggerAdsProxyLib.TcSourceInfoTypeEnum pInfoType,
System.IntPtr pData, out uint cbData)
Parameter
8.1.3.2 IsSourceInfoTypeSupported
This method can be used to check whether the source information type has been defined.
Syntax
public virtual bool IsSourceInfoTypeSupported(TcSourceInfoTypeEnum infoType)
Parameter
Return value
8.1.3.3 Count
This property returns the number.
Syntax
public virtual int Count
8.1.3.4 Guid
This property returns the GUID of the source.
Syntax
public virtual System.Guid Guid
8.1.3.5 Id
This property returns the Id.
Syntax
public virtual uint Id
8.1.3.6 Name
This property returns the name.
Syntax
public virtual string Name
8.2 Interfaces
8.2.1 _ITcEventLoggerEvents
This interface provides the messages for occurring events.
Syntax
public interface _ITcEventLoggerEvents
Methods
8.2.1.1 AlarmCleared
Called if an alarm changes to the "Not Raised" state.
Syntax
public virtual void AlarmCleared(TcAlarm evtObj, bool bRemove)
Parameter
8.2.1.2 AlarmConfirmed
Called if an alarm changes to the "Confirmed" state.
Syntax
public virtual void AlarmConfirmed(TcAlarm evtObj, bool bRemove)
Parameter
8.2.1.3 AlarmRaised
Called if an alarm changes to the "Raised" state.
Syntax
public virtual void AlarmRaised(TcAlarm evtObj)
Parameter
8.2.1.4 MessageSend
Called when a message has been sent.
Syntax
void MessageSent(TcMessage evtObj)
Parameter
8.2.2 ITcAlarm3
This interface represents an alarm.
Syntax
public interface ITcAlarm3
Methods
Properties
8.2.2.1 Confirm
This method confirms the alarm.
Syntax
public virtual void Confirm()
8.2.2.2 GetArgumentData
This method returns the data of the arguments.
Syntax
public virtual void GetArgumentData(ref System.IntPtr ppArgData, uint size)
Parameter
8.2.2.3 GetArgumentInfo
This method returns the (type) information for the arguments.
Syntax
public virtual void GetArgumentInfo(ref TcEventArgumentsInfo pArgInfo)
Parameter
8.2.2.4 GetEventClassName
This method returns the EventClass name.
Syntax
public virtual string GetEventClassName(int langId)
Parameter
Return value
8.2.2.5 GetText
This method returns the event text, including the arguments.
Syntax
public virtual string GetText(int langId)
Parameter
Return value
8.2.2.6 IsSourceInfoTypeSupported
This method can be used to check whether the source information type has been defined.
Syntax
public virtual bool IsSourceInfoTypeSupported(TcSourceInfoTypeEnum infoType)
Parameter
Return value
8.2.2.7 GetCauseRemedy
This method returns the cause/remedy information, if this has been defined.
Syntax
public virtual TcCauseRemedyCollection GetCauseRemedy(int langId)
Parameter
Return value
8.2.2.8 ConfirmationState
This property returns the Confirmation State.
Syntax
Public virtual ConfirmationStateEnum ConfirmationState
8.2.2.9 GetDetails
This method returns the details.
Syntax
public virtual TcDetailCollection GetDetails(int langId)
Parameter
Return value
8.2.2.10 EventClass
This property returns the EventClass GUID.
Syntax
public virtual System.Guid EventClass
8.2.2.11 EventId
This property returns the event ID.
Syntax
public virtual uint EventId
8.2.2.12 EventType
This property returns the type of the event.
Syntax
public virtual EventTypeEnum EventType
8.2.2.13 FileTimeCleared
This property returns the timestamp when the alarm was changed to the Cleared state.
Syntax
public virtual long FileTimeCleared
8.2.2.14 FileTimeConfirmed
This property returns the timestamp when the alarm was changed to the Confirmed state.
Syntax
public virtual long FileTimeConfirmed
8.2.2.15 FileTimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual long FileTimeRaised
8.2.2.16 IsRaised
This property indicates whether the alarm has been changed to the Raised state.
Syntax
public virtual bool IsRaised
8.2.2.17 JsonAttribute
This property returns the JSON attribute.
Syntax
public virtual string JsonAttribute
8.2.2.18 SeverityLevel
This property returns the Severity level.
Syntax
public virtual TcEventLoggerAdsProxyLib.SeverityLevelEnum SeverityLevel
8.2.2.19 SourceGuid
This property returns the GUID of the source.
Syntax
public virtual System.Guid SourceGuid
8.2.2.20 SourceId
This property returns the ID of the source.
Syntax
public virtual uint SourceId
8.2.2.21 SourceName
This property returns the name of the source.
Syntax
public virtual string SourceName
8.2.2.22 TimeCleared
This property returns the timestamp when the alarm was changed to the Cleared state.
Syntax
public virtual System.DateTime TimeCleared
8.2.2.23 TimeConfirmed
This property returns the timestamp when the alarm was changed to the Confirmed state.
Syntax
public virtual System.DateTime TimeConfirmed
8.2.2.24 TimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual System.DateTime TimeRaised
8.2.3 ITcArgumentEntry
This interface describes an argument.
Syntax
public interface ITcArgumentEntry
Methods
8.2.3.1 Get
This method returns the value as a dynamic type.
Syntax
public virtual Object Get()
Return value
8.2.3.2 GetBoolean
This method returns the value as Boolean.
Syntax
public virtual bool GetBoolean()
Return value
8.2.3.3 GetData
This method returns the value as a reference to data.
Syntax
public virtual void GetData(out TcEventArgumentTypeEnum pInfoType, System.IntPtr pData, out uint
cbData)
Parameter
8.2.3.4 GetDouble
This method returns the value as Double.
Syntax
public virtual double GetDouble
Return value
8.2.3.5 GetFloat
This method returns the value as Float.
Syntax
public virtual float GetFloat()
Return value
8.2.3.6 GetInt16
This method returns the value as Short.
Syntax
public virtual short GetInt16()
Return value
8.2.3.7 GetInt32
This method returns the value as Int.
Syntax
public virtual int GetInt32()
Return value
8.2.3.8 GetInt64
This method returns the value as Long.
Syntax
public virtual long GetInt64()
Return value
8.2.3.9 GetInt8
This method returns the value as SByte.
Syntax
public virtual sbyte GetInt8()
Return value
8.2.3.10 GetString
This method returns the value as String.
Syntax
public virtual string GetString()
Return value
8.2.3.11 GetUInt16
This method returns the value as UShort.
Syntax
public virtual ushort GetUInt16()
Return value
8.2.3.12 GetUInt32
This method returns the value as UInt.
Syntax
public virtual uint GetUInt32()
Return value
8.2.3.13 GetUInt64
This method returns the value as ULong.
Syntax
public virtual ulong GetUInt64()
Return value
8.2.3.14 GetUInt8
This method returns the value as Byte.
Syntax
public virtual byte GetUInt8()
Return value
8.2.3.15 Set
This method sets the value.
Syntax
public virtual void Set(object Item)
Parameter
8.2.4 ITcCauseRemedy
This interface describes the cause/remedy information for an event.
Syntax
public interface ITcCauseRemedy
Properties
8.2.4.1 Cause
This property returns the cause.
Syntax
public virtual string Cause
8.2.4.2 Id
This property returns the Id.
Syntax
public virtual uint Id
8.2.4.3 Remedy
This property returns the remedy.
Syntax
public virtual string Remedy
8.2.5 ITcDetail
This interface describes the details of an event.
Syntax
public interface ITcDetail
Properties
8.2.5.1 Comment
This property returns the comment on a detail.
Syntax
public virtual string Comment
8.2.5.2 Name
This property returns the name.
Syntax
public virtual string Name
8.2.5.3 text
This property returns the text for a detail.
Syntax
public virtual string text
8.2.6 ITcEvent
This interface describes an event. This event can be either a message or an alarm.
Syntax
public interface ITcEvent
Methods
Properties
8.2.6.1 GetArgumentData
This method returns the data of the arguments.
Syntax
public virtual void GetArgumentData(ref System.IntPtr ppArgData, uint size)
Parameter
8.2.6.2 GetArgumentInfo
This method returns the (type) information for the arguments.
Syntax
public virtual void GetArgumentInfo(ref TcEventArgumentsInfo pArgInfo)
Parameter
8.2.6.3 GetEventClassName
This method returns the EventClass name.
Syntax
public virtual string GetEventClassName(int langId)
Parameter
Return value
8.2.6.4 GetText
This method returns the event text, including the arguments.
Syntax
public virtual string GetText(int langId)
Parameter
Return value
8.2.6.5 IsSourceInfoTypeSupported
This method can be used to check whether the source information type has been defined.
Syntax
public virtual bool IsSourceInfoTypeSupported(TcSourceInfoTypeEnum infoType)
Parameter
Return value
8.2.6.6 EventClass
This property returns the EventClass GUID.
Syntax
public virtual System.Guid EventClass
8.2.6.7 EventId
This property returns the event ID.
Syntax
public virtual uint EventId
8.2.6.8 EventType
This property returns the type of the event.
Syntax
public virtual EventTypeEnum EventType
8.2.6.9 FileTimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual long FileTimeRaised
8.2.6.10 SeverityLevel
This property returns the Severity level.
Syntax
public virtual TcEventLoggerAdsProxyLib.SeverityLevelEnum SeverityLevel
8.2.6.11 SourceGuid
This property returns the GUID of the source.
Syntax
public virtual System.Guid SourceGuid
8.2.6.12 SourceId
This property returns the ID of the source.
Syntax
public virtual uint SourceId
8.2.6.13 SourceName
This property returns the name of the source.
Syntax
public virtual string SourceName
8.2.6.14 TimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual System.DateTime TimeRaised
8.2.7 ITcEventLogger2
Interface for sending commands to the EventLogger.
Syntax
public interface ITcEventLogger2
Methods
Properties
8.2.7.1 ClearAllAlarms
Calls Clear() for all alarms in the "Raised" state.
Syntax
public virtual void ClearAllAlarms([bool bResetConfirmation = True])
Parameter
8.2.7.2 ClearLoggedEvents
Clears the cache.
Syntax
Public virtual void ClearLoggedEvents()
8.2.7.3 ConfirmAllAlarms
Calls Confirm() for all alarms with the confirmation state "WaitForConfirmation".
Syntax
public virtual void ConfirmAllAlarms()
8.2.7.4 Connect
Connects to the EventLogger of the TwinCAT system on a given system.
Syntax
public virtual void Connect([string Address = localhost])
Parameter
8.2.7.5 Disconnect
Cancels the connection to an EventLogger of the TwinCAT system.
Syntax
public virtual void Disconnect()
8.2.7.6 GetEventClassName
Returns the class name for an event.
Syntax
public virtual string GetEventClassName(System.Guid EventClass, int nLangId)
Parameter
Return value
8.2.7.7 GetLoggedEvents
Queries the events located in the cache.
Syntax
public virtual TcEventLoggerAdsProxyLib.TcLoggedEventCollection GetLoggedEvents(uint nMaxEntiries)
Parameter
Return value
8.2.7.8 ActiveAlarms
Returns a collection with all currently active alarms.
Syntax
public virtual TcEventLoggerAdsProxyLib.TcAlarmCollection ActiveAlarms
8.2.7.9 IsConnected
Represents the connection that was established by means of Connect. Should be checked regularly.
Syntax
public virtual bool IsConnected
8.2.7.10 ITcEventLogger2_SendTcMessage
This method sends a message.
Syntax
public virtual void SendTcMessage(System.Guid EventClass, uint EventId,
TcEventLoggerAdsProxyLib.SeverityLevelEnum severity, string JsonAttribute,
TcEventLoggerAdsProxyLib.TcSourceInfo pSourceInfo, TcEventLoggerAdsProxyLib.TcArguments pArguments)
Parameter
8.2.8 ITcLoggedEvent4
This interface describes a stored event. This event can be either a message or an alarm.
Syntax
public interface ITcLoggedEvent4
Methods
Properties
8.2.8.1 GetArgumentData
This method returns the data of the arguments.
Syntax
public virtual void GetArgumentData(ref System.IntPtr ppArgData, uint size)
Parameter
8.2.8.2 GetArgumentInfo
This method returns the (type) information for the arguments.
Syntax
public virtual void GetArgumentInfo(ref TcEventArgumentsInfo pArgInfo)
Parameter
8.2.8.3 GetCauseRemedy
This method returns the cause/remedy information, if this has been defined.
Syntax
public virtual TcCauseRemedyCollection GetCauseRemedy(int langId)
Parameter
Return value
8.2.8.4 GetDetails
This method returns the details.
Syntax
public virtual TcDetailCollection GetDetails(int langId)
Parameter
Return value
8.2.8.5 GetEventClassName
This method returns the EventClass name.
Syntax
public virtual string GetEventClassName(int langId)
Parameter
Return value
8.2.8.6 GetText
This method returns the event text, including the arguments.
Syntax
public virtual string GetText(int langId)
Parameter
Return value
8.2.8.7 IsSourceInfoTypeSupported
This method can be used to check whether the source information type has been defined.
Syntax
public virtual bool IsSourceInfoTypeSupported(TcSourceInfoTypeEnum infoType)
Parameter
Return value
8.2.8.8 EventClass
This property returns the EventClass GUID.
Syntax
public virtual System.Guid EventClass
8.2.8.9 EventId
This property returns the event ID.
Syntax
public virtual uint EventId
8.2.8.10 EventType
This property returns the type of the event.
Syntax
public virtual EventTypeEnum EventType
8.2.8.11 FileTimeCleared
This property returns the timestamp when the alarm was changed to the Cleared state.
Syntax
public virtual long FileTimeCleared
8.2.8.12 FileTimeConfirmed
This property returns the timestamp when the alarm was changed to the Confirmed state.
Syntax
public virtual long FileTimeConfirmed
8.2.8.13 FileTimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual long FileTimeRaised
8.2.8.14 JsonAttribute
This property returns the JSON attribute.
Syntax
public virtual string JsonAttribute
8.2.8.15 SeverityLevel
This property returns the Severity level.
Syntax
public virtual TcEventLoggerAdsProxyLib.SeverityLevelEnum SeverityLevel
8.2.8.16 SourceGuid
This property returns the GUID of the source.
Syntax
public virtual System.Guid SourceGuid
8.2.8.17 SourceId
This property returns the ID of the source.
Syntax
public virtual uint SourceId
8.2.8.18 SourceName
This property returns the name of the source.
Syntax
public virtual string SourceName
8.2.8.19 TimeCleared
This property returns the timestamp when the alarm was changed to the Cleared state.
Syntax
public virtual System.DateTime TimeCleared
8.2.8.20 TimeConfirmed
This property returns the timestamp when the alarm was changed to the Confirmed state.
Syntax
public virtual System.DateTime TimeConfirmed
8.2.8.21 TimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual System.DateTime TimeRaised
8.2.8.22 WithConfirmation
This property describes whether a confirmation is necessary.
Syntax
public virtual bool WithConfirmation
8.2.9 ITcMessage3
This interface represents a message.
Syntax
public interface ITcMessage
Methods
Properties
8.2.9.1 GetArgumentData
This method returns the data of the arguments.
Syntax
public virtual void GetArgumentData(ref System.IntPtr ppArgData, uint size)
Parameter
8.2.9.2 GetArgumentInfo
This method returns the (type) information for the arguments.
Syntax
public virtual void GetArgumentInfo(ref TcEventArgumentsInfo pArgInfo)
Parameter
8.2.9.3 GetCauseRemedy
This method returns the cause/remedy information, if this has been defined.
Syntax
public virtual TcCauseRemedyCollection GetCauseRemedy(int langId)
Parameter
Return value
8.2.9.4 GetDetails
This method returns the details.
Syntax
public virtual TcDetailCollection GetDetails(int langId)
Parameter
Return value
8.2.9.5 GetEventClassName
This method returns the EventClass name.
Syntax
public virtual string GetEventClassName(int langId)
Parameter
Return value
8.2.9.6 GetText
This method returns the event text, including the arguments.
Syntax
public virtual string GetText(int langId)
Parameter
Return value
8.2.9.7 IsSourceInfoTypeSupported
This method can be used to check whether the source information type has been defined.
Syntax
public virtual bool IsSourceInfoTypeSupported(TcSourceInfoTypeEnum infoType)
Parameter
Return value
8.2.9.8 EventClass
This property returns the EventClass GUID.
Syntax
public virtual System.Guid EventClass
8.2.9.9 EventId
This property returns the event ID.
Syntax
public virtual uint EventId
8.2.9.10 EventType
This property returns the type of the event.
Syntax
public virtual EventTypeEnum EventType
8.2.9.11 FileTimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual long FileTimeRaised
8.2.9.12 JsonAttribute
This property returns the JSON attribute.
Syntax
public virtual string JsonAttribute
8.2.9.13 SeverityLevel
This property returns the Severity level.
Syntax
public virtual TcEventLoggerAdsProxyLib.SeverityLevelEnum SeverityLevel
8.2.9.14 SourceGuid
This property returns the GUID of the source.
Syntax
public virtual System.Guid SourceGuid
8.2.9.15 SourceId
This property returns the ID of the source.
Syntax
public virtual uint SourceId
8.2.9.16 SourceName
This property returns the name of the source.
Syntax
public virtual string SourceName
8.2.9.17 TimeRaised
This property returns the timestamp when the alarm was changed to the Raised state.
Syntax
public virtual System.DateTime TimeRaised
8.3.1 ConfirmationStateEnum
Defines the confirmation state of an alarm.
Syntax
public enum ConfirmationStateEnum
{
Confirmed,
NotRequired,
NotSupported,
Reset,
WaitForConfirmation
}
Parameter
Name Description
Confirmed Confirmed
NotRequired Confirmation not necessary in the current state.
(Alarm not currently in the Raised state).
NotSupported Was initialized without confirmation.
Reset Initial state
WaitForConfirmation Waiting for confirmation.
8.3.2 EventTypeEnum
Type definition whether a TcEvent is of the type alarm or message.
Syntax
public enum EventTypeEnum
{
Alarm,
Message
}
Parameter
Name Description
Alarm The TcEvent is of the type TcAlarm.
Message The TcEvent is of the type TcMessage.
8.3.3 SeverityLevelEnum
This enumeration defines the "severity" of the event. It is an ordered list.
Syntax
public enum SeverityLevelEnum
{
Critical,
Error,
Warning,
Info,
Verbose
}
Parameter
Name Description
4 Critical Critical
3 Error Error
2 Warning Warning
1 Info Information
0 Verbose Extended output
8.3.4 TcEventArgumentTypeEnum
Type definition of what type a TcArgument is.
Syntax
public enum TcEventArgumentTypeEnum
{
Blob,
Boolean,
Char,
Double,
E_AdsnotificationStream,
EventReference,
ExternalTimeStamp,
Float,
FormatString,
Int16,
Int32,
Int64,
Int8,
StringType,
UInt16,
UInt32,
UInt64,
UInt8,
Undefinied,
UTF8EncodedString,
WChar,
WStringType
}
8.3.5 TcSourceInfoTypeEnum
Definition of which entry in a TcSourceInfo is identified.
Syntax
public enum TcSourceInfoTypeEnum
{
SourceGuid,
SourceId,
SourceName
}
Parameter
Name Description
SourceGuid The source GUID of the TcSourceInfo.
SourceId The source ID of the TcSourceInfo. For example, the
TcCOM object ID.
SourceName The SourceName of the TcSourceInfo. For example,
the instance path within a PLC.
9 Example
9.1 PLC
9.1.1 Tutorial
This tutorial illustrates the work steps from an empty TwinCAT project to a dispatched message. It depicts
the properties of the TwinCAT 3 EventLogger described in the Technical Introduction [} 13] section in the
work sequence.
3. An event is already created below the event class. Give the event a name and enter a display text and
the severity.
fbMsg : FB_TcMessage;
END_VAR
3. Implement the send procedure as shown in the code. The message is initialized once by means of the
CreateEx method. Since the initialization requires dynamic resources it should not take place cyclically.
The initialized message is subsequently sent using the Send method.
IF bInit THEN
bInit := FALSE;
fbMsg.CreateEx(TC_EVENTS.TutorialClass.TutorialEvent, 0);
END_IF
IF bSend THEN
bSend := FALSE;
fbMsg.Send(0);
END_IF
4. Create the PLC project and start the PLC.
ð The result is shown in the LoggedEvents window in the TwinCAT 3 Engineering.
Download: https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/zip/5288319115.zip
Download: https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/
zip/27021603052539915.zip
Publisher project
In addition there is an option to set the JSON attribute in order to send it with both messages.
Listener project
The Listener project contains a function block, FB_Listener, which extends the FB_ListenerBase function
block contained in the Tc3_EventLogger. The function block implements the functions for receiving the
messages:
• OnMessageSent: when a message has been sent the EventLogger will call this method as a callback.
The method counts the number of messages.
• OnAlarmRaised/OnAlarmCleared/OnAlarmConfirmed: if the alarm changes its state the EventLogger
will call this method as a callback. The methods count the number of state changes.
• To initiate receiving of messages, an Execute method is implemented at the function block.
• The text of the last received message can be retrieved.
• The function block FB_ListenerTest uses the FB_Listener. In doing so it registers the event class to be
received once. Another event class that exists is not received to demonstrate the filter functionality.
Requirements
Download: https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/zip/10400437387.zip
Requirements
9.2 C++
9.2.1 Tutorial
This tutorial illustrates the work steps from an empty TwinCAT project to a dispatched message. It depicts
the properties of the TwinCAT 3 EventLogger described in the Technical Introduction [} 13] section in the
work sequence.
Creating an event class in the data types of the TMC file in the C++ project
ü A new TwinCAT C++ project exists with the module from the wizard "TwinCAT Module Class with Cyclic
IO".
1. Click twice on the TMC file in the C++ project to open the TMC editor. Select the command Add new
event class… from the context menu of Data Types.
3. An event is already created below the event class. Give the event a name and enter a display text and
the severity.
5. In addition, create an input bSend in order to send the event on a rising edge.
///<AutoGeneratedContent id="MemberInitialization">
m_TraceLevelMax = tlAlways;
memset(&m_Parameter, 0, sizeof(m_Parameter));
memset(&m_Inputs, 0, sizeof(m_Inputs));
memset(&m_Outputs, 0, sizeof(m_Outputs));
///</AutoGeneratedContent>
m_spEventLogger = 0;
m_spMessage = 0;
m_OldSend = FALSE;
m_Inputs.bSend = TRUE;
}
10. In addition, carry out the following initialization in the method SetObjStateSO():
// TODO: Add any additional initialization
m_spEventLogger.SetOID(OID_TCEVENTLOGGER);
hr = FAILED(hr) ? hr : m_spSrv->TcQuerySmartObjectInterface(m_spEventLogger);
hr = FAILED(hr) ? hr : m_spEventLogger-
>CreateMessage(TcEvents::TutorialClass::EventClass, TcEvents::TutorialClass::TutorialEvent.nEven
tId, TcEvents::TutorialClass::TutorialEvent.eSeverity, 0, &m_spMessage);
11. If the call of the method AddModuleToCaller() fails, carry out a deinitialization:
// Cleanup if transition failed at some stage
if ( FAILED(hr) )
{
RemoveModuleFromCaller();
m_spEventLogger = NULL;
m_spMessage = NULL;
}
12. Carry out a deinitialization in the method SetObjStateOS():
// TODO: Add any additional deinitialization
m_spEventLogger = NULL;
m_spMessage = NULL;
13. Extend the cyclic code of the module by the sending of the message:
// TODO: Replace the sample with your cyclic code
if (m_Inputs.bSend && ! m_OldSend) // raising edge
{
m_spMessage->Send(0);
}
m_OldSend = m_Inputs.bSend;
14. Create a module instance and link it with a task.
Download: https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/zip/5288321291.zip
It consists of a module that can send a message and an alarm, and a module that receives these messages.
Download: https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/zip/9007204543064459.zip
Publisher module
Single BOOL variables are used in the Publisher module as triggers on the input data area:
• bSendMessage to send a message
• bRaiseAlarm to set an alarm
• bClearAlarm to cancel an alarm
• bConfirmAlarm to confirm an alarm
In addition there is an option to set and to remove the JSON attribute in order to send it with both messages.
Listener module
The Listener module implements both the ITCMessageListener and the ITcAlarmListener interface. The
methods specified as a result of this are called by the EventLogger as callback.
• OnMessageSent: when a message has been sent the EventLogger will call this method as a callback.
The method counts the number of messages.
• OnAlarmRaised/OnAlarmCleared/OnAlarmConfirmed: if the alarm changes its state the EventLogger
will call this method as a callback. The methods count the number of state changes.
The Listener module thereby registers itself with the EventLogger for the corresponding event classes on
starting in the method SetObjStateSO().
9.3 COM
The COM interface can be used to develop your own programs that react to events.
As this is a COM interface, it can be used under Windows from different programming languages.
• https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/zip/7726430987.zip
• https://infosys.beckhoff.com/content/1033/tc3_eventlogger/Resources/zip/7726428683.zip
Each sample shows how events of the EventLogger are received. In the sample, outputs are performed on
the console.
A precise description of the functions can be found in the COM API [} 119].
10 Appendix
0x501 1281 0x98110501 ROUTERERR_RESIZEMEMORY The router memory size could not be changed.
0x502 1282 0x98110502 ROUTERERR_MAILBOXFULL The mailbox has reached the maximum number of
possible messages.
0x503 1283 0x98110503 ROUTERERR_DEBUGBOXFULL The Debug mailbox has reached the maximum num-
ber of possible messages.
Please contact your Beckhoff branch office or representative for local support and service on Beckhoff
products!
The addresses of Beckhoff's branch offices and representatives round the world can be found on her internet
pages: https://www.beckhoff.com
You will also find further documentation for Beckhoff components there.
Beckhoff Support
Support offers you comprehensive technical assistance, helping you not only with the application of
individual Beckhoff products, but also with other, wide-ranging services:
• support
• design, programming and commissioning of complex automation systems
• and extensive training program for Beckhoff system components
Hotline: +49 5246 963 157
Fax: +49 5246 963 9157
e-mail: [email protected]
Beckhoff Service
The Beckhoff Service Center supports you in all matters of after-sales service:
• on-site service
• repair service
• spare parts service
• hotline service
Hotline: +49 5246 963 460
Fax: +49 5246 963 479
e-mail: [email protected]
Beckhoff Headquarters
Huelshorstweg 20
33415 Verl
Germany