Enabling and disabling I/O devices

To enable or disable a Tree Item in a configuration, you must create a TwinCAT System Manager instance and open the configuration. The LookupTreeItem method of the ITcSysManager interface returns an ITcSmTreeItem interface pointer implemented by the Tree Item referenced by its pathname. This interface contains a Disabled property of the Tree Item.

Procedure

The procedure for creating the ITcSysManager interface (the 'sysMan' instance here) is described in the chapter Accessing TwinCAT configurations. This interface has a LookupTreeItem method that returns an ITcSmTreeItem pointer to a Tree Item specified by its path name. The following code snippets can be used to enable or disable the “TIID^EtherCAT master” Tree Item.

Sample (CSharp):

ITcSmTreeItem item = sysMan.LookupTreeItem("TIID^EtherCAT Master");
item.Disabled = DISABLED_STATE.SMDS_DISABLED;

Please note that for this sample you have to add a reference to “Microsoft Developer Environment 10.0” as well as to “Beckhoff TCatSysManager Library 1.1” to your project.

Sample (PowerShell):

$DISABLED_STATE = @{"SMDS_NOT_DISABLED" = "0"; "SMDS_DISABLED" = "1"}
$item = $systemManager.LookupTreeItem("TIID^EtherCAT Master")
$item.Disabled = $DISABLED_STATE.SMDS_DISABLED