Compatibility
The WindowsCE Eventlogger offers a high degree of compatibility to the standard Win32 based logger. Minimal effort is reqired to develop an application that supports both versions. This document provides some implementation hints on developing a compatible application.
See samples for
Developing a C# application that supports both versions of the TcEventLogger
- Add references to the "Beckhoff TcEventLogger" and the "Beckhoff TcEventLogAdsProxy" COM type libraries
- Add one global instance of the TcEventLogger
TcEventLog m_logger = null;
- Use theese two methods to connect either to a local PC Based TcEventLogger or an remote WindowsCE system. If your application is a Windows CE and shall connect the local logger pass Null for the NetId
void ConnectRemoteLogger( String strNetId )
{
TcEventLogAdsProxyLib.TcEventLogger adsLogCLient = new TcEventLogAdsProxyLib.TcEventLogger();
adsLogCLient.Connect( strNetId );
m_logger = (TcEventLog)adsLogCLient;
}
void ConnectLocalPC()
{
m_logger = new TCEVENTLOGGERLib.TcEventLog();
}- Write currently active events to the console window
foreach( TcEvent evt in m_logger.EnumActiveEventsEx() )
Console.WriteLine( evt.GetMsgString(1033) );
Developing a C++ application that supports both versions of the TcEventLogger
- Import type libraries of the "Beckhoff TcEventLogger" and the "Beckhoff TcEventLogCEProxy"
#pragma warning(disable: 4192)
#import "C:\TwinCAT\TcEventLogger\TcEventlogger.exe" no_namespace, named_guids
#import "C:\TwinCAT\TcEventLogger\TcEventLogAdsProxy.dll" no_namespace, named_guids
#pragma warning(default: 4192)- Add a member variable for the TcEventLogger object
ITcEventLogPtr m_spTcEventLog;
- Use theese two methods to connect either to a local PC Based TcEventLogger or an remote WindowsCE system. If your application is a Windows CE and shall connect the local logger pass Null for the NetId
HRESULT ConnectRemoteLogger( BSTR strNetId )
{
HRESULT hr = E_FAIL;
if ( m_spTcEventLog == NULL )
{
hr = m_spTcEventLog.CreateInstance(CLSID_TcEventLogAdsProxy);
if ( SUCCEEDED(hr) )
{
ITcEventLogAdsProxyPtr spLogCE = m_spTcEventLog;
hr = spLogCE->Connect( strNetId ); // 5.1.47.197.1.1
}
}
}
void ConnectPC( BSTR strComputer )
{
HRESULT hr=E_FAIL;
COSERVERINFO comServerInfo={0};
comServerInfo.pwszName = strComputer ;
MULTI_QI mQI={&IID_ITcEventLog, NULL, 0};
if ( m_spTcEventLog == NULL )
hr=::CoCreateInstanceEx(CLSID_TcEventLog,
NULL,
CLSCTX_SERVER,
&comServerInfo,
1,
&mQI);
if ( SUCCEEDED(hr) )
{
m_spTcEventLog = mQI.pItf;
mQI.pItf->Release();
}
}
Connect the TcEventViewer with the TcEventLoggerCE
- TcEventViewer version 2.9.0.73 is required (Shipped with TwinCAT build 2.10.1317 or higher)
- For connecting a WindowsCE device pass "ADS://<AmsNetId>" to the ITcEventView::AddConnection() method
Using the TcEventBar with the TcEventLoggerCE
- TcEventViwer version 2.9.0.73 is required (Shipped with TwinCAT build 2.10.1317 or higher)
- In the Connect field type "ADS://<AmsNetId>"