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

  1. Add references to the "Beckhoff TcEventLogger" and the "Beckhoff TcEventLogAdsProxy" COM type libraries
  2. Add one global instance of the TcEventLogger
  3. TcEventLog m_logger = null;
  4. 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
  5. void ConnectRemoteLogger( String strNetId )
    {
        TcEventLogAdsProxyLib.TcEventLogger adsLogCLient = new TcEventLogAdsProxyLib.TcEventLogger();
        adsLogCLient.Connect( strNetId );
        m_logger = (TcEventLog)adsLogCLient;
    }

    void ConnectLocalPC()
    {
        m_logger = new TCEVENTLOGGERLib.TcEventLog();
    }
  6. Write currently active events to the console window
  7. foreach( TcEvent evt in m_logger.EnumActiveEventsEx() )
       Console.WriteLine( evt.GetMsgString(1033) );

Developing a C++ application that supports both versions of the TcEventLogger

  1. Import type libraries of the "Beckhoff TcEventLogger" and the "Beckhoff TcEventLogCEProxy"
  2. #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)
  3. Add a member variable for the TcEventLogger object
  4. ITcEventLogPtr m_spTcEventLog;
  5. 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
  6. 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

  1. TcEventViewer version 2.9.0.73 is required (Shipped with TwinCAT build 2.10.1317 or higher)
  2. For connecting a WindowsCE device pass "ADS://<AmsNetId>" to the ITcEventView::AddConnection() method

Using the TcEventBar with the TcEventLoggerCE

  1. TcEventViwer version 2.9.0.73 is required (Shipped with TwinCAT build 2.10.1317 or higher)
  2. In the Connect field type "ADS://<AmsNetId>"