0% found this document useful (0 votes)
9 views

Class Documentation ApplicationClientUsage enUS

Uploaded by

jmppf2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Class Documentation ApplicationClientUsage enUS

Uploaded by

jmppf2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Overview of the

ApplicationClientUsage 1
administration

Example for "Program.cs" 2


Explanations for
COMOS "Program.cs" 3
Syntax of the
Platform COMOS.ApplicationClientU 4
Class documentation sage.config
ApplicationClientUsage

Programming Manual

03/2021 V10.4
Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent damage
to property. The notices referring to your personal safety are highlighted in the manual by a safety alert symbol, notices
referring only to property damage have no safety alert symbol. These notices shown below are graded according to
the degree of danger.

DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.

WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.

CAUTION
indicates that minor personal injury can result if proper precautions are not taken.

NOTICE
indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will be
used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to property
damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific
task in accordance with the relevant documentation, in particular its warning notices and safety instructions.
Qualified personnel are those who, based on their training and experience, are capable of identifying risks and
avoiding potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:

WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation. If products and components from other manufacturers are used, these must be recommended or
approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and maintenance
are required to ensure that the products operate safely and without any problems. The permissible ambient
conditions must be complied with. The information in the relevant documentation must be observed.

Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication may
be trademarks whose use by third parties for their own purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software described.
Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the information in this
publication is reviewed regularly and any necessary corrections are included in subsequent editions.

Siemens AG Copyright © Siemens AG 2021.


Digital Industries Ⓟ 03/2021 Subject to change All rights reserved
Postfach 48 48
90026 NÜRNBERG
GERMANY
Table of contents

1 Overview of the ApplicationClientUsage administration...................................................................... 5


2 Example for "Program.cs"....................................................................................................................... 7
3 Explanations for "Program.cs".............................................................................................................. 11
4 Syntax of the COMOS.ApplicationClientUsage.config......................................................................... 13

Class documentation ApplicationClientUsage


Programming Manual, 03/2021 V10.4 3
Table of contents

Class documentation ApplicationClientUsage


4 Programming Manual, 03/2021 V10.4
Overview of the ApplicationClientUsage
administration 1
Siemens provides you with a package of program libraries, a class documentation and
configuration files for the "ApplicationClientUsage" function.
1. Copy the contents of the package to your computer:
– If Siemens provides you with a zipped file (zip, 7z), you need to unzip the files.
– If Siemens provides you with an exe file, you need to start the exe file.
2. Open your development environment.
3. Create a new class and reference the Siemens program libraries.
An example of such a class is available in the chapter Example for "Program.cs" (Page 7).
In this example, the class is called "Program.cs" but you can use any name.
4. Program the class according to your requirements.
– You can find a connected example in the chapter Example for "Program.cs" (Page 7).
– You can find an explanation of the example in the chapter Explanations for "Program.cs"
(Page 11).
In the class, you define mandatory access to a config file, among other things. See the
following step 5 for more details.
– The Siemens installation package also includes a class documentation.
Start the class documentation with "index.htm".
5. Administer the config file defined in step 4.
In this example, the config file is called "COMOS.ApplicationClientUsage.config". See also
chapter Syntax of the COMOS.ApplicationClientUsage.config (Page 13).
The name of the config file is random and is assigned by the call in "Program.cs".

Class documentation ApplicationClientUsage


Programming Manual, 03/2021 V10.4 5
Overview of the ApplicationClientUsage administration

Class documentation ApplicationClientUsage


6 Programming Manual, 03/2021 V10.4
Example for "Program.cs" 2
using System;
//Required references for connection to COMOS License Server
using Comos.ClientLicenseUsage;
using Comos.ClientLicenseUsageInterfaces;
using Comos.LicenseDefaultResults;
using Comos.LicenseMessageInterfaces;
using Comos.LicenseTracingInterfaces;
namespace TestConsoleApp
{
internal class Program
{
//Example of license name for test purpose: For external usage
the external application has to pass the required license name
private const string ExistingLicense = "Platform";

//Example of configuration file for test purpose: For external


usage the external application has to set the full path and name
where this file is stored
private const string FullFilenameRead = @"d:\Licensing
\ApplicationUsage\Comos.LicenseDistributor.config";

static void Main(string[] args)


{
try
{
Console.SetWindowSize(200, 50);
Console.WriteLine("Press any key to start ...");
Console.ReadKey();

//Set full path and name of configuration file


var usageConfig =
ClientLicenseUsage.Instance<ILicenseUsageConfiguration>();
usageConfig.ConfigurationFileName = FullFilenameRead;

//Set tracing: See implementation of classes


TraceToConsole, TracingInformation and TracingInformationCreator
var usageTrace =
ClientLicenseUsage.Instance<ILicenseTracingHandling>();
usageTrace.Tracer = new TraceToConsole();
usageTrace.InformationCreator = new
TracingInformationCreator();

//Register at event AliveStatus to retrieve updates of


the lifetime status
var usageLifetime =
ClientLicenseUsage.Instance<ILicenseUsageLifetime>();

Class documentation ApplicationClientUsage


Programming Manual, 03/2021 V10.4 7
Example for "Program.cs"

usageLifetime.AliveStatus += EvaluateAliveStatus;

//Send request to request a single license


Console.WriteLine();
Console.WriteLine($"Requesting single license
{ExistingLicense} ... ");
var requestSingleLicense =
ClientLicenseUsage.Instance<ISingleLicenseUsage>();
var result =
requestSingleLicense.RequestSingleLicense($@"<Param
ProductName=""{ExistingLicense}"" UserName=""User1"" IsAdmin=""1"" /
>");
Console.WriteLine($"RequestSingleLicense sent:
{result.Id} -> {result.Message}{Environment.NewLine}
{result.MessageBody}");
Console.WriteLine();

//Send request to check if a single license is requested


Console.WriteLine();
Console.WriteLine($"Is single license {ExistingLicense}
requested ... ");
var requestIsIngleLicenseRequested =
ClientLicenseUsage.Instance<ISingleLicenseUsage>();
result =
requestIsIngleLicenseRequested.IsSingleLicenseRequested($@"<Param
ProductName=""{ExistingLicense}"" UserName=""User1"" />");
Console.WriteLine($"IsSingleLicenseRequested sent:
{result.Id} -> {result.Message}{Environment.NewLine}
{result.MessageBody}");
Console.WriteLine();

//Here the result of the lifetime status will be


displayed due to the registration at event AliveStatus -> see method
EvaluateAliveStatus
Console.WriteLine("Waiting for lifetime status update
(interval is 2 minutes) -> Press any key to continue ...");
Console.ReadKey();

//Send request to return a single license (which was


requested before)
Console.WriteLine();
Console.WriteLine($"Returning single license
{ExistingLicense} ... ");
var requestReturnSingleLicense =
ClientLicenseUsage.Instance<ISingleLicenseUsage>();
result =
requestReturnSingleLicense.ReturnSingleLicense($@"<Param
ProductName=""{ExistingLicense}"" />");
Console.WriteLine($"ReturnSingleLicense sent:
{result.Id} -> {result.Message}{Environment.NewLine}
{result.MessageBody}");
Console.WriteLine();

Class documentation ApplicationClientUsage


8 Programming Manual, 03/2021 V10.4
Example for "Program.cs"

//Send request for shutdown: clear and dispose all used


resources
Console.WriteLine();
Console.WriteLine("Shutdown... ");
var requestShutdown =
ClientLicenseUsage.Instance<ILicenseUsageShutdown>();
result = requestShutdown.Shutdown();
usageLifetime.AliveStatus -= EvaluateAliveStatus;
Console.WriteLine($"Shutdown sent: {result.Id} ->
{result.Message}{Environment.NewLine}{result.MessageBody}");
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine(e);
}
Console.WriteLine();
Console.WriteLine("Press any key to stop application ...");
Console.ReadKey();
}
//Called due to the registration at event AliveStatus
private static void EvaluateAliveStatus(ILicenseStatusIdMessage
message)
{
Console.WriteLine($"Status Alive: ReturnCode = {message.Id},
ErrorText = {message.Message}");
if (!string.IsNullOrEmpty(message.MessageBody))
Console.WriteLine(message.MessageBody);
//Example of evaluation of the defined return code -410
//In COMOS: The Heartbeat was sent with a none existing
Cookie => COMOS License Server was restarted => request all former
requested licenses again with new Cookie
//Cookie: unique identifier at CLS for all COMOS sessions
//Heartbeat: Name for lifetime update on COMOS
if
(message.Id.Equals(((int)EnCheckMessageId.ErrorCookieNotFound).ToStr
ing()))
{
Console.WriteLine();
Console.WriteLine($"ReturnCode = {message.Id} -> Option
to reconnect already requested licenses");
}
}
}
}

See also
Explanations for "Program.cs" (Page 11)

Class documentation ApplicationClientUsage


Programming Manual, 03/2021 V10.4 9
Example for "Program.cs"

Class documentation ApplicationClientUsage


10 Programming Manual, 03/2021 V10.4
Explanations for "Program.cs" 3
Referencing Siemens program libraries
using Comos.ClientLicenseUsage;
using Comos.ClientLicenseUsageInterfaces;
using Comos.LicenseDefaultResults;
using Comos.LicenseMessageInterfaces;
using Comos.LicenseTracingInterfaces;
For more information on the interfaces, follow these steps:
1. Open the html class documentation included in the package.
2. In the class documentation, click "Classes" in the menu bar.
The list also includes the interfaces listed above.

Naming license
private const string ExistingLicense = "Platform";
• The license name is case sensitive.
• The file name of a license file supplied by Siemens Support is usually not identical to the
license name. You will receive a list of the internal license names from COMOS Support if you
have a justifiable need.
• The associated license must be available according to the information in
"COMOS.ApplicationClientUsage.config".

Naming a configuration file


private const string FullFilenameRead = @"d:\Licensing
\ApplicationUsage\Comos.LicenseDistributor.config";
• The name used here determines the file name of the configuration file.
• You can also enter network paths.

Controlling AliveStatus/ Lifetime status


var usageLifetime =
ClientLicenseUsage.Instance<ILicenseUsageLifetime>();
• During the configuration of the COMOS License Server, the property "AliveStatus" is called
"Heartbeat".
• The heartbeat of the COMOS License Server verifies the future availability of the requested
license. You can find additional information on this topic in the "Installation and
Configuration" manual, keyword "Runtime check / Heartbeat".

Class documentation ApplicationClientUsage


Programming Manual, 03/2021 V10.4 11
Explanations for "Program.cs"

Request license
requestSingleLicense.RequestSingleLicense($@"<Param
ProductName=""{ExistingLicense}"" UserName=""User1"" IsAdmin=""1"" /
>");
• ExistingLicense has been declared as a constant in this example. You can also enter the
license name here.
• UserName is case sensitive.
• IsAdmin: [0 | 1]
This property sets the access to the administrator mode. This property provides the
corresponding account with more information and feedback.
See also "Installation and Configuration" manual,
keyword <WarningBeforeExpirationAdmin>.

Optional: Using tracing


usageTrace = ClientLicenseUsage.Instance<ILicenseTracingHandling>();
• The ApplicationClientUsage function has its own tracing.
• See the html class documentation included in the package for more information:
Class TraceToConsole
Class TracingInformation
Class TracingInformationCreator

Class documentation ApplicationClientUsage


12 Programming Manual, 03/2021 V10.4
Syntax of the
COMOS.ApplicationClientUsage.config 4
Example
<?xml version="1.0" encoding="utf-8">
<configuration>
<connection name="CLS" CallingOrder="1">
<settings>
<Setting key="ComosLicenseServer" value="name_of_server" />
<Setting key="ComosLicenseServerPort" value="27017" />
<Setting key="IgnoreProxySettings" value="1" />
<Setting key="CryptUseMachineContainer" value="0" />
</settings>
</connection>
<connection name="Local" CallingOrder="2">
<settings>
...
</settings>
</connection>
</configuration>

Comments in the config file


<configuration> section: Single-row XML comments (which start with <!--) are permitted.
All other comments or additions are prohibited.

Location of the config file


The storage location and name of the config file is assigned by the call in Program.cs. See
chapter Explanations for "Program.cs" (Page 11).

Syntax
With the exception of <connection name="..." CallingOrder="...">, all entries are
identical to "Comos.LicenseLib.config". For more information on
"Comos.LicenseLib.config", see the "Installation and Configuration" manual, keyword
"Syntax of the "Comos.LicenseLib.config"".
<configuration>
• <ComosLicenseServer>
Name of the server PC on which COMOS LS Process is installed.
• <ComosLicenseServerPort>
Port through which communication with COMOS LS Process takes place. If the value is
empty, 27011 is used as a default.

Class documentation ApplicationClientUsage


Programming Manual, 03/2021 V10.4 13
Syntax of the COMOS.ApplicationClientUsage.config

• <IgnoreProxySettings>
– 0: The Internet Explorer proxy settings are used.
– 1: (Default): The proxy server is ignored.
• <CryptUseMachineContainer>
– 0: The temporary files created for the encoding through Windows are stored in the user
profile. This is the default value.
Example for Windows 10: "C:\Users\<User>\AppData\Roaming\..."
– 1: The temporary files created for the encoding through Windows are stored in the public
profile of the PC.
Example for Windows 10: "C:\Users\All Users\..." or "C:\Users\Public\..."
• <UseLicenseServer>
If this key is available, the registry key LastUsedLicenseServer is ignored.
FLEXlm: Communication takes place via the FLEXlm license server.
CLM: Communication takes place via COMOS LS Process.
The <UseLicenseServer> key is evaluated by the "Comos.dll" file - not by the
"Comos.LicenseLib.dll" file as in the case of the others.
• <connection name="..." CallingOrder="...">
The order in which the <Settings> entries are evaluated.
name: For free use.
CallingOrder: Unique natural number.

Similar functions
The keys in "COMOS.ApplicationClientUsage.config" are identical to the keys in
"Comos.LicenseLib.config". For more information on "Comos.LicenseLib.config", see the
"Installation and Configuration" manual, keyword "Syntax of the "Comos.LicenseLib.config"".

Class documentation ApplicationClientUsage


14 Programming Manual, 03/2021 V10.4

You might also like