Samples | System $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 = @" "; sysMan3.ConsumeMappingInfo(mappingXml); ConsumeMappingInfo overwrites all existing mappings. The complete mapping set must be passed in with every call. 6.3.15 Opening and activating the existing configuration | Opening and activating the existing configuration To activate an existing TwinCAT configuration, three steps are performed: A DTE instance is created, the solution is opened, and then ActivateConfiguration and StartRestartTwinCAT are called on the ITcSysManager object.
The ITcSysManager object is obtained from the first project in the solution. The ProgID determines which version of Visual Studio is launched. References to “Microsoft Developer Environment” and “Beckhoff TwinCAT XAE Base” must be added to the project. TE1000 218 Version: 1.7.0