Skip to main content
Version: 2.8

Installation of Windows Services

This tutorial shows how Windows Services are installed on a target host with Windows 10 or higher, or Windows Server 19 or higher.

Preconditions

  1. A valid HumanOS License (PoC or Productive License)
  2. Example 1 is running successfully
  3. A Windows based host system. Administration rights are required.
  4. OPC-UA Client installed on development client
RECOMMENDATION

Examples work with UAExpert from Unified Automation. Download UAExpert here

Create your First Windows Service

Step 1: Switch to Licensed Gateways

First, your trial project from Tutorial 1 must be converted to a licensed project.

  1. Open the tutorial project in designer and double click on the root node Tutorial1 in your project.

  2. Select your license and the productive runtime (both must be previously installed on your client)

  3. Remove the device TestFile in the default target and recreate the device.

    NOTE

    This is only necessary, if your default target must be productive. It is also possible to keep the default target as trial using the Trial Runtime.

Step 2: Prepare Windows Service Settings

  1. Double click on your target default in your project.

  2. Navigate to tab Windows Service and check the name of the service

    IMPORTANT

    IoT projects created by older Designer often have a fixed windows service name, like HumanOS.IoT.Gateway. When creating multiple targets (gateway instances) for same host computer this might lead to the problem of overwriting existing windows services.

    Therefore, use the variable $(Target.Name) as part of windows service name.

Step 3: Publish the Gateway to the Host

Now, we are ready for a first publishing to your host system.

Note, that we directly publish to the client computer. It is also possible to publish to a file share or a remote host.

  1. Double click on your target default in your project.

  2. Navigate to tab General and check the name of the service

  3. Select the publish destination as Directory

    Set the publish directory path to C:\ProgramData\CyberTech\HumanOS.IoT.Gateways\$(Target.Name)\Updates\.

    NOTE

    Note, that we use also the variable $(Target.Name) here to prevent overwriting published artifacts by other targets (gateway configurations).

    NOTE

    Note, that we publish into an Updates folder, which can be used later on for automatic gateway updating.

  4. Navigate to the published folder on your host.

  5. Open the zip file in C:\ProgramData\CyberTech\HumanOS.IoT.Gateways\default\Updates\ and extract the files to C:\ProgramData\CyberTech\HumanOS.IoT.Gateways\default\

  6. Delete the zip file in C:\ProgramData\CyberTech\HumanOS.IoT.Gateways\default\Updates\

Now, you should have a file structure like follows:

Step 4: Register Windows Service

  1. Right click on powershell file RegisterService.ps1 and execute it with powershell (as administrator)

  2. Select the correct runtime on your host system

  3. Check and confirm the settings showed in the powershell:

    Scan HumanOS runtimes...

    Service Name = 'HumanOS.IoT.Gateway.default'
    Selected Runtime = 'HumanOS.IoT.Runtime win-x86'
    Service executable = 'C:\Program Files (x86)\CyberTech\HumanOS.IoT.Runtimes\HumanOS.IoT.Runtime-win.x86-v2.7\HumanOS.IoT.Gateway.exe'
    AppSettingsDir = 'C:\ProgramData\CyberTech\HumanOS.IoT.Gateways\default'

    Press Enter to register service...
  4. The service is not automatically started. Go to the windows services and start the service.

Create an other Windows Service

Now we want to create an other gateway as windows service which runs on the same host.

Following stumbling blocks must be considered before:

  • Services like OPC-UA Server or WebServices are bound to a TCP-IP port. Only one gateway can use a given port. Make sure, the other gateway uses a different port for that service.

  • The service name must be different from each other, otherwise they are overwritten in the registration process.

Step 1: Create a new Target

  1. Select the root node of your project and click Add new Content to Project.

  2. Set the name Gateway1

  3. Click top the Plugins node on the new target and click Add new Content to Project again.

  4. Add the OPC-UA Server with default settings to the new gateway

    NOTE

    Normally, the new gateway inherits all plugin configuration from the default configuration. Adding the OPC-UA plugin configuration again allows us to change the settings for this specific gateway, like port number.

  5. Double click on HumanOS.PeSeL.OPCUAServer plugin and change the port setting to 4841

  6. Open the target configuration and set the publish path, windows service name etc. accordingly

  7. Publish the gateway

  8. Extract the zip file accordingly to the first gateway

  9. Register the new service

Step 2: Start Services and Test

At the end you should have two windows services each one having his own OPC-UA server connecting to a XML file. Really?

  1. Start the windows services

  2. Open UA Expert and connect to both OPC-UA servers

    We notice, default has a device TestFile, but Gateway1 has no device at all.

Step 3: Update the Gateway Config

  1. Go back to the HumanOS IoT Designer and add a device to the Gateway1 target.

  2. Go to the target settings page and publish the Gateway1 again.

    NOTE

    A new zip file is copied to the Updates folder on your target host. We don't have to extract the config manually now!

  3. Go to the Windows Services and just restart the service HumanOS.IoT.Gateway.Gateway1.

    • The update process automatically create a backup of your current configuration in the Backups folder.
    • The zip file is automatically extracted and then removed from the Updates folder.
  4. Go to UAExpert and click Rebrowse on the "HumanOS" folder.

    The device appears.