Creating license requests

A TwinCAT license request file with the extension .tclrq contains the information required to generate a license. It is submitted to Beckhoff, which then issues the corresponding license file. Starting with TwinCAT Build 4026.7, this file can be generated directly via the Automation Interface. To do this, call ConsumeXml with an LicenseRequest element on the license node.

Requirements

C# sample

The license node is accessed via the tree path TIRC^License. The LicenseRequest XML contains the required fields Provider, LicenseId, and CustomerId, as well as the target path in LicenseRequestFilePath. After calling ConsumeXml, the .tclrq file is located at the specified path.

// Look up license node (TIRC = TwinCAT Runtime Configuration)
ITcSmTreeItem licenseNode = sysManager.LookupTreeItem(@"TIRC^License");

string licenseRequestXml = @"<TreeItem>
  <LicenseDef>
    <LicenseRequest>
      <Provider>Beckhoff Automation</Provider>
      <LicenseId>1234</LicenseId>
      <CustomerId>4321</CustomerId>
      <Comment>Lizenzanfrage Projekt XY</Comment>
      <LicenseRequestFilePath>C:\Temp\MyLicense.tclrq</LicenseRequestFilePath>
    </LicenseRequest>
  </LicenseDef>
</TreeItem>";

licenseNode.ConsumeXml(licenseRequestXml);
// The file is created at the specified path

PowerShell sample

# Look up license node (TIRC = TwinCAT Runtime Configuration)
$licenseNode = $sysManager.LookupTreeItem("TIRC^License")

$licenseRequestXml = @"
<TreeItem>
  <LicenseDef>
    <LicenseRequest>
      <Provider>Beckhoff Automation</Provider>
      <LicenseId>1234</LicenseId>
      <CustomerId>4321</CustomerId>
      <Comment>Lizenzanfrage Projekt XY</Comment>
      <LicenseRequestFilePath>C:\Temp\MyLicense.tclrq</LicenseRequestFilePath>
    </LicenseRequest>
  </LicenseDef>
</TreeItem>
"@

$licenseNode.ConsumeXml($licenseRequestXml)
# The file is created at the specified path
Creating license requests 1:

The availability of this feature starts with TwinCAT Build 4026.7. When reading data via ProduceXml, LicenseRequestFilePath may be empty. That's normal, because the path is only used to create the file and isn't saved afterward.