Skip to content

README .NET datalayer.client.simple

This .NET sample reads values from ctrlX Data Layer.

Introduction

The sample demonstrates how to read values from ctrlX Data Layer tree and write out the values to console. A subscription is used to get values by data change event in a deterministic publish interval. The single read is performed every 10 seconds in an endless loop.

Description

The implementation include the following steps:

  • Create and start the 'DatalayerSystem' service
  • Create a client with 'tcp' protocol for remote connection or 'ipc' protocol if running inside snap.
  • Create a subscription with publish interval of 1 s
  • Write data change notification of subscription to console with timestamp, node and value
  • Read value with client via single read once and in an endless loop every 10 s

Prerequisites

Please read the common .NET docs here, first.

Debug and Run

Launch the app with the debugger attached by pressing F5.

Build and Install

  1. Launch Visual Studio Code
  2. Click on the Remote Explorer from the menu.
  3. Choose Open Folder.
  4. Open the directory datalayer.client.
  5. Build and install snap as described here.
  6. Check the output using Diagnostics:

  7. Login into your ctrlX

  8. Navigate to Diagnostics -> Logbook
  9. Click Settings on the right top corner
  10. Enable Show system messages
  11. Navigate to Filter -> Units and check your snap.sdk-net-client-simple.app.service
  12. Now you should the see the app output diagnostics.
  13. Press Refresh to update.

  14. If you have root permissions, you can also watch the output on any ssh console with the command:

    sudo snap logs sdk-net-client-simple.app -f | more
    

Console Output

Running inside snap: True
ctrlX Data Layer system started.
ctrlX Data Layer client created.
Client connected: True
10.03.2021 09:15:10, framework/metrics/system/cpu-utilisation-percent: 6 (subscription)
10.03.2021 10:15:12, framework/metrics/system/memused-percent: 14 (single read)
10.03.2021 09:15:11, framework/metrics/system/cpu-utilisation-percent: 13,6 (subscription)
10.03.2021 09:15:12, framework/metrics/system/cpu-utilisation-percent: 2,5 (subscription)
10.03.2021 09:15:13, framework/metrics/system/cpu-utilisation-percent: 7,4 (subscription)
10.03.2021 09:15:14, framework/metrics/system/cpu-utilisation-percent: 6 (subscription)
10.03.2021 09:15:15, framework/metrics/system/cpu-utilisation-percent: 3,7 (subscription)
10.03.2021 09:15:16, framework/metrics/system/cpu-utilisation-percent: 4,9 (subscription)
10.03.2021 09:15:18, framework/metrics/system/cpu-utilisation-percent: 6 (subscription)
10.03.2021 09:15:19, framework/metrics/system/cpu-utilisation-percent: 7,2 (subscription)
10.03.2021 09:15:20, framework/metrics/system/cpu-utilisation-percent: 6 (subscription)
10.03.2021 10:15:22, framework/metrics/system/memused-percent: 14 (single read)
10.03.2021 09:15:21, framework/metrics/system/cpu-utilisation-percent: 5 (subscription)
10.03.2021 09:15:22, framework/metrics/system/cpu-utilisation-percent: 7,3 (subscription)
10.03.2021 09:15:23, framework/metrics/system/cpu-utilisation-percent: 4,9 (subscription)
10.03.2021 09:15:24, framework/metrics/system/cpu-utilisation-percent: 2,5 (subscription)
10.03.2021 09:15:25, framework/metrics/system/cpu-utilisation-percent: 6,1 (subscription)
10.03.2021 09:15:26, framework/metrics/system/cpu-utilisation-percent: 6 (subscription)
10.03.2021 09:15:27, framework/metrics/system/cpu-utilisation-percent: 8,8 (subscription)
10.03.2021 09:15:28, framework/metrics/system/cpu-utilisation-percent: 10,3 (subscription)
10.03.2021 09:15:29, framework/metrics/system/cpu-utilisation-percent: 4,9 (subscription)
10.03.2021 09:15:30, framework/metrics/system/cpu-utilisation-percent: 7,2 (subscription)
10.03.2021 10:15:32, framework/metrics/system/memused-percent: 14 (single read)
10.03.2021 09:15:31, framework/metrics/system/cpu-utilisation-percent: 6,1 (subscription)

Install the App

Login into ctrlX and install the App (Apps).

Gratulations - We're finished - Let's start coding

Support

Developer Community

Please join the Developer Community

SDK Forum

Please visit the SDK Forum

Issues

If you've found an error in these sample, please file an issue

License

SPDX-FileCopyrightText: Bosch Rexroth AG SPDX-License-Identifier: MIT