Difference between revisions of "OPC UA Application URI Derivation"

From OPC Labs Knowledge Base
Jump to navigation Jump to search
 
(12 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
| ModuleName || Name of the main module for the current process.
 
| ModuleName || Name of the main module for the current process.
 
|-
 
|-
| ProcessId || Numeric Id of the current process.<ref>Normally not used, as it is not stable enough for the intended purpose.</ref>
+
| ProcessId || Numeric Id of the current process.<ref>Normally not used, as it is not stable enough for the most purposes. Intended for "transient" OPC UA applications.</ref>
 
|-
 
|-
 
| ProcessName || The name of the current process.
 
| ProcessName || The name of the current process.
 
|-
 
|-
|rowspan="4"| Application Assembly || SimpleName || Simple name of the application assembly.
+
|rowspan="7"| Application Assembly || SimpleName || Simple name of the application assembly.
 
|-
 
|-
 
| Version || Version number of the application assembly.
 
| Version || Version number of the application assembly.
 +
|-
 +
| VersionMajor || Major version part of the Version.
 
|-
 
|-
 
| Culture || Supported culture of the application assembly.
 
| Culture || Supported culture of the application assembly.
Line 29: Line 31:
 
| PublicKeyToken || Public key token of the application assembly.
 
| PublicKeyToken || Public key token of the application assembly.
 
|-
 
|-
|rowspan="5"| Application Version Info || CompanyName || Name of the company from the application version info.
+
| AssemblyName || Display name of the application assembly (such as "ExampleAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").
 +
|-
 +
| AssemblyTokens || A combination of SimpleName, VersionMajor, and Culture, separated by colons. The trailing tokens are left out together with the colons that precede them, if they are at default values ("0" for the VersionMajor, and "neutral" for the Culture).
 +
|-
 +
|rowspan="9"| Application Version Info || CompanyName || Name of the company from the application version info.
 +
|-
 +
| FileDescription || Description of the file, from the application version info.
 
|-
 
|-
 
| FileVersion || File version number from the application version info.
 
| FileVersion || File version number from the application version info.
 +
|-
 +
| FileVersionMajor || Major version part of the FileVersion.
 
|-
 
|-
 
| Language || Default language string from the application version info.
 
| Language || Default language string from the application version info.
Line 38: Line 48:
 
|-
 
|-
 
| ProductVersion || Product version number from the application version info.
 
| ProductVersion || Product version number from the application version info.
 +
|-
 +
| ShortFileVersion || The part of FileVersion before the first space character (' ').
 +
|-
 +
| VersionInfoTokens || A combination of NameToken, FileVersionMajor and Language, separated by colons. The trailing tokens are left out together with the colons that precede them, if they are at default values ("0" for the FileVersionMajor, and "Language Neutral" for the Language).
 
|}
 
|}
  
 
The information in the "Application Assembly" and "Application Version Info" categories may not always be available - it depends on factors such as the type of application and the hosting process. For this reason, the template string can have one or more sections, separated by a semicolon (';'). If three or more sections are present, they are interpreted like this:
 
The information in the "Application Assembly" and "Application Version Info" categories may not always be available - it depends on factors such as the type of application and the hosting process. For this reason, the template string can have one or more sections, separated by a semicolon (';'). If three or more sections are present, they are interpreted like this:
  
* If the application version info is available, the last section from the end is used.
+
* If the application assembly information is available, the last section from the end is used.
* Otherwise, if the application assembly information is available, the second section from the end is used.
+
* Otherwise, if the application version info is available, the second section from the end is used.
 
* Otherwise, the third section from the end is used.
 
* Otherwise, the third section from the end is used.
  
If there are fewer sections, the first section that would be to the right of the position indicated by the above rules is used. This algorithm also means that you can use just one section, and the format from this section will always be used.
+
If there are fewer sections, the first available section that would be to the right of the position indicated by the above rules is used. This algorithm also means that you can use just one section, and this section will then always be used.
  
 
The default application URI template string (in QuickOPC 2023.1) is as follows:
 
The default application URI template string (in QuickOPC 2023.1) is as follows:
 
<pre>
 
<pre>
  uri:$(HostName):$(ModuleName);uri:$(HostName):$(NameToken):$(FileVersion):$(Language);uri:$(HostName):$(SimpleName):$(Version):$(Culture):$(PublicKeyToken)
+
  uri:$(HostName):$(ModuleName);uri:$(HostName):$(VersionInfoTokens);uri:$(HostName):$(AssemblyTokens)
 
</pre>
 
</pre>

Latest revision as of 14:52, 6 December 2023

Every OPC UA application (client or server) needs an application URI, which uniquely identifies the application instance in the system.

Applications based on QuickOPC determine their application URI in the following way:

  1. If the application manifest contains a non-empty ApplicationUriString property, it will be used as the application URI.
  2. Otherwise, the application URI is automatically generated, using a template string from the ApplicationUriTemplateString property in the application parameters.

The application URI template string consists of characters that are copied literally to the output string, and macros, which are replaced by values provided by QuickOPC. When the macro is expanded, it is URL-escaped before it is inserted into the output string, so that a correct URI can be formed. Macro replacements have the syntax $(name), where name is one of the names defined in the following table.

Category Name Description
Common HostName Host name of the local computer.
ModuleName Name of the main module for the current process.
ProcessId Numeric Id of the current process.[1]
ProcessName The name of the current process.
Application Assembly SimpleName Simple name of the application assembly.
Version Version number of the application assembly.
VersionMajor Major version part of the Version.
Culture Supported culture of the application assembly.
PublicKeyToken Public key token of the application assembly.
AssemblyName Display name of the application assembly (such as "ExampleAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").
AssemblyTokens A combination of SimpleName, VersionMajor, and Culture, separated by colons. The trailing tokens are left out together with the colons that precede them, if they are at default values ("0" for the VersionMajor, and "neutral" for the Culture).
Application Version Info CompanyName Name of the company from the application version info.
FileDescription Description of the file, from the application version info.
FileVersion File version number from the application version info.
FileVersionMajor Major version part of the FileVersion.
Language Default language string from the application version info.
NameToken Internal name from the application version info, without the ".exe" extension if present.
ProductVersion Product version number from the application version info.
ShortFileVersion The part of FileVersion before the first space character (' ').
VersionInfoTokens A combination of NameToken, FileVersionMajor and Language, separated by colons. The trailing tokens are left out together with the colons that precede them, if they are at default values ("0" for the FileVersionMajor, and "Language Neutral" for the Language).

The information in the "Application Assembly" and "Application Version Info" categories may not always be available - it depends on factors such as the type of application and the hosting process. For this reason, the template string can have one or more sections, separated by a semicolon (';'). If three or more sections are present, they are interpreted like this:

  • If the application assembly information is available, the last section from the end is used.
  • Otherwise, if the application version info is available, the second section from the end is used.
  • Otherwise, the third section from the end is used.

If there are fewer sections, the first available section that would be to the right of the position indicated by the above rules is used. This algorithm also means that you can use just one section, and this section will then always be used.

The default application URI template string (in QuickOPC 2023.1) is as follows:

 uri:$(HostName):$(ModuleName);uri:$(HostName):$(VersionInfoTokens);uri:$(HostName):$(AssemblyTokens)
  1. Normally not used, as it is not stable enough for the most purposes. Intended for "transient" OPC UA applications.