Managing variable mappings

Variable mappings establish connections between PLC input/output variables and I/O counterparts, NC axes, or TcCOM objects. The Automation Interface offers four operations:

Requirements

Linking individual variable (LinkVariables)

Both paths are passed as complete tree paths. The order of the parameters is source, destination.

C#

string source = "TIPC^PlcProj^PlcProj Instance^PlcTask Inputs^bIn";
string destination = "TIID^EtherCAT^EK1100^EL1004^Channel 1^Input";
systemManager.LinkVariables(source, destination);

PowerShell:

$source = "TIPC^PlcProj^PlcProj Instance^PlcTask Inputs^bIn"
$destination = "TIID^EtherCAT^EK1100^EL1004^Channel 1^Input"
$systemManager.LinkVariables($source, $destination)

Unlinking individual variable (UnlinkVariables)

C#:

systemManager.UnlinkVariables(source, destination);

PowerShell:

$systemManager.UnlinkVariables($source, $destination)

Exporting and importing all mappings (ProduceMappingInfo / ConsumeMappingInfo)

ProduceMappingInfo provides all current mappings as XML. ConsumeMappingInfo resets the mappings, overwriting all existing ones in the process. The complete mapping set must be provided. Both methods require ITcSysManager2.

C#:

ITcSysManager2 systemManager2 = (ITcSysManager2)systemManager;
string mappingInfo = systemManager2.ProduceMappingInfo();
systemManager2.ConsumeMappingInfo(mappingInfo);

PowerShell:

$mappingInfo = $systemManager.ProduceMappingInfo()
$systemManager.ConsumeMappingInfo($mappingInfo)

Clearing all mappings (ClearMappingInfo)

ClearMappingInfo removes all mappings from the solution. The method requires ITcSysManager3.

C#:

ITcSysManager3 sysMan3 = (ITcSysManager3)systemManager;
sysMan3.ClearMappingInfo();

PowerShell:

$systemManager.ClearMappingInfo()

XML-based mappings (ConsumeMappingInfo with VarLinks XML)

Mappings can be passed directly as VarLinks XML. The OwnerA node contains the path to the sending element, and OwnerB contains the path to the receiving element. Each Link names the respective variables relative to their parents.

C#:

ITcSysManager3 sysMan3 = (ITcSysManager3)sysManager;

// Read existing mappings
string existingMappings = sysMan3.ProduceMappingInfo();

// Set new mappings (provide all mappings completely)
string mappingXml = @"<VarLinks>
  <OwnerA Name=""TIPC^PLC1^PLC1 Instance"">
    <OwnerB Name=""TIID^EtherCAT Master^EL2008"">
      <Link VarA=""Outputs^bOutput1"" VarB=""Channel 1^Output""/>
      <Link VarA=""Outputs^bOutput2"" VarB=""Channel 2^Output""/>
    </OwnerB>
  </OwnerA>
</VarLinks>";

sysMan3.ConsumeMappingInfo(mappingXml);
Managing variable mappings 1:

ConsumeMappingInfo overwrites all existing mappings. The complete mapping set must be passed in with every call.