Methods of the ActiveX control

The ActiveX control has two properties to define the EtherCAT master, who's topolgy should be displayed :

TargetNetId

The TargetNetId defines the TwinCAT System the ActiveX control should connect to. The remote TwinCAT Systems, that are registered on the local system, can be displayed with the help of the system manager. Press the button Choose Target Systems... Icon(Methods of the ActiveX control 1:) in the toolbar to display these:

Methods of the ActiveX control 2:

In the example above you can either enter '172.16.2.133.1.1' or an empty string as TargetNetId to connect to the local TwinCAT System. With '5.0.39.217.1.1' as TargetNetId you can connect to the remote computer CX_0027D9.

DeviceId

The DeviceId is the unique Id of the EtherCAT master device in the TwinCAT I/O system. This Id is displayed in the configuration dialog of the EtherCAT device in the System Manager. Select the EtherCAT device in the tree view of the System Manager and open the Tab General. Here the device Id is displayed in the textbox Id:

Methods of the ActiveX control 3:

In the example above you must choose 1 as DeviceId.

Display the online topology

You can either display the topology of the current configuration, or the topology that is determined by a bus scan. The property OnlineMode is used for this:

Next you must call ShowOnlineTopology, to display the topology:

Methods of the ActiveX control 4:

DeviceId

Description

The property DeviceId defines the EtherCAT device of the TwinCAT target system one wants to display. The DeviceId is the unique Id of the EtherCAT master device in the TwinCAT I/O System

Property type

Read-write property

Default value

0

Syntax (C#)

int DeviceId { set; get; }
    Member of IEcTopologyCtrl

Example(C#)

//Read DeviceId from SystemManager 
axEcTopologyCtrl1.DeviceId = 1;
axEcTopologyCtrl1.ShowOnlineTopology();
//Get DeviceId via IEnumEtherCATDevices interface 
IEnumEtherCATDevices devices;
IEtherCATDevice device;

axEcTopologyCtrl1.GetEnumEtherCATDevices(out devices);
uint fetched = 0;

devices.Next(1, out device, out fetched);
if (fetched == 1)
    axEcTopologyCtrl1.DeviceId = device.DeviceId;

axEcTopologyCtrl1.ShowOnlineTopology();

TargetNetId

Description

The property TargetNetId defines to which TwinCAT system the ActiveX control should connect to. The TargetNetId is the AMS NetId, that is used in the TwinCAT system to identify a TwinCAT computer.

Property type

Read-write property

Default value

AMS NetId of the local system

Syntax (C#)

string TargetNetId { set; get; }
    Member of IEcTopologyCtrl

Example(C#)

axEcTopologyCtrl1.TargetNetId = "";             // Connection local TwinCAT-System
//axEcTopologyCtrl1.TargetNetId = "172.16.2.122.1.1"; // Connection TwinCAT-System with AMS NetId 172.16.2.122.1.1
axEcTopologyCtrl1.DeviceId = 1;
axEcTopologyCtrl1.ShowOnlineTopology();

ZoomFactor

Description

The property ZoomFactor defines the zoom factor of the topology display.

Property type

Read-write property

Default value

3

Syntax (C#)

double ZoomFactor { set; get; }
    Member of IEcTopologyCtrl

SlaveDescriptionPath

Description

The property SlaveDescriptionPath defines the path where the device descriptions of the EtherCAT slaves are stored. Normally one does not have to change this value, because the default path is the path where TwinCAT stores these description files.

Property type

Read-write property

Default value

%\TwinCAT\Io\EtherCAT

Syntax (C#)

string SlaveDescriptionPath { set; get; }
    Member of IEcTopologyCtrl

OnlineMode

Description

The property OnlineMode defines which Topology is to be displayed when calling ShowOnlineTopology. OnlineMode can hold following values:

OnlineMode

Description

TOPOLOGY_ONLINE_MODE_SCANNED

The topology determined with a bus scan.

TOPOLOGY_ONLINE_MODE_CONFIGURED

The currently configured topology.

Property type

Read-write property

Default value

TOPOLOGY_ONLINE_MODE_CONFIGURED

Syntax (C#)

ECTOPOLOGYLib.TOPOLOGY_ONLINE_MODE OnlineMode { set; get; }
    Member of IEcTopologyCtrl

Example(C#)

axEcTopologyCtrl1.TargetNetId = "172.16.2.122.1.1";     // Connection TwinCAT-System with AMS NetId 172.16.2.122.1.1
axEcTopologyCtrl1.DeviceId = 1;
axEcTopologyCtrl1.OnlineMode = TOPOLOGY_ONLINE_MODE.TOPOLOGY_ONLINE_MODE_CONFIGURED; //Show topology of current configuration
axEcTopologyCtrl1.ShowOnlineTopology();

MasterState

Description

The read only property containes the current state of the master:

MasterState

Description

TOPOLOGY_MASTER_STATE_INVALID

Master is in an invalid state

TOPOLOGY_MASTER_STATE_INT

Master is in the EtherCAT state Init

TOPOLOGY_MASTER_STATE_PREOP

Master is in the EtherCAT state Pre-Operational

TOPOLOGY_MASTER_STATE_SAFEOP

Master is in the EtherCAT state Safe-Operational

TOPOLOGY_MASTER_STATE_OP

Master is in the EtherCAT state Operational

TOPOLOGY_MASTER_STATE_OFFLINE

No connection to the master exists at the moment. This is the case for instance. if the the TwinCAT system is stopped.

Property type

Read-Only property

Default value

Syntax (C#)

ECTOPOLOGYLib.TOPOLOGY_MASTER_STATE MasterState { get; }
    Member of IEcTopologyCtrl

ShowCrcErrorMarker

Description

The property ShowCrcErrorMarker defines, if the existance of crc errors should be displayed graphically in the online view. If this value is true, a red circle for every ethernet port with a detected error is displayed beneath the EtherCAT slave.

Property type

Read-write property

Default value

false

Syntax (C#)

bool ShowCrcErrorMarker { set; get; }
    Member of IEcTopologyCtrl

ShowSlaveInfo

Description

The property ShowSlaveInfo defines, if the information dialog for the selected device should be displayed in the online view. The dialog is display in the right corner of the view and contains additional information about the EtherCAT slave

Property type

Read-write property

Default value

false

Syntax (C#)

bool ShowSlaveInfo { set; get; }
    Member of IEcTopologyCtrl

ShowAdvancedSettingsMenu

Description

The property ShowAdvancedSettingsMenu defines, if the entry AdvancedSettings... should be added to the context menu of an EtherCAT slave. If this menu entry is selected, the event OnAdvancedSettings is fired.

Property type

Read-write property

Default value

false

Syntax (C#)

bool ShowAdvancedSettingsMenu { set; get; }
    Member of IEcTopologyCtrl

BackColor

Description

The property BackColor determines the backgroud color.

Property type

Read-write property

Default value

0x00FFFFFF(white)

Syntax (C#)

uint BackColor { set; get; }
    Member of IEcTopologyCtrl

ShowOnlineTopology

Description

Displays the online topology of an EtherCAT device. The device is selected with the help of the properties DeviceId and TargetNetId. With the help of the parameter OnlineMode one can additionally specify, how the topology is determined

Syntax (C#)

void ShowOnlineTopology()
    Member of IEcTopologyCtrl

Example(C#)

axEcTopologyCtrl1.TargetNetId = "172.16.2.122.1.1";     // Connection TwinCAT-System wtih AMS NetId 172.16.2.122.1.1
axEcTopologyCtrl1.DeviceId = 1;         // EtherCAT device with Id 1
axEcTopologyCtrl1.ShowOnlineTopology();     // show topology

ShowOfflineTopology

Description

Displays the offline topology of an EtherCAT device belonging to an opened System Manager configuration.

Parameter

TCatSysManagerLib.ITcSmTreeItem pEtherCATDevice

interface to the Systen Manager treeItem interfaces of an EtherCAT device

Syntax (C#)

void ShowOfflineTopology(TCatSysManagerLib.ITcSmTreeItem pEtherCATDevice)
    Member of IEcTopologyCtrl

GetEnumEtherCATDevices

Description

With the help of GetEnumEtherCATDevices one receives an enumeration interface for the open EtherCAT Devices in the TwinCAT system. With this interface one can enumerate over the individual EtherCAT devices and one can read out the name and the DeviceId of these EtherCAT devices.

Parameter

out IEnumEtherCATDevices ppEnum

Interface IEnumEtherCATDevices

Syntax (C#)

void GetEnumEtherCATDevices(out IEnumEtherCATDevices ppEnum)
    Member of IEcTopologyCtrl

Example(C#)

//Get DeviceId via IEnumEtherCATDevices interface 
IEnumEtherCATDevices devices;
IEtherCATDevice device;

axEcTopologyCtrl1.GetEnumEtherCATDevices(out devices);
uint fetched = 0;

do
{
    devices.Next(1, out device, out fetched);
    if (fetched == 1)
        Console.WriteLine(String.Format("Name:{0} Device Id:{0:d}", device.Name, device.DeviceId));
} while (fetched == 1);