ctrlX-DataLayer 4.3.0
Bosch Rexroth ctrlX Data Layer .NET API
This is the Bosch Rexroth ctrlX Data Layer API for .NET Core and .NET Standard 2.0.
Usage
Example: Read a ctrlX Data Layer node's value
// Create a new ctrlX Data Layer system to connect to a ctrlX and start.
using var system = new DatalayerSystem();
system.Start(startBroker: false);
// Create a remote according to your environment (options see Remote class).
var remote = new Remote(ip: "192.168.1.1", sslPort: 443).ToString();
// Create the client.
using var client = system.Factory.CreateClient(remote);
// Read a node with by it's node address.
var (result, value) = client.Read("framework/metrics/system/memused-percent");
if (result.IsGood())
{
Console.WriteLine($"{memUsed}: {value.ToFloat()} (single read)");
}
Example: Subscribe a ctrlX Data Layer node's value
// Create a new ctrlX Data Layer system to connect to a ctrlX and start.
using var system = new DatalayerSystem();
system.Start(startBroker: false);
// Create a remote according to your environment (options see Remote class).
var remote = new Remote(ip: "192.168.1.1", sslPort: 443).ToString();
// Create the client.
using var client = system.Factory.CreateClient(remote);
// Create the subscription properties by using helper class SubscriptionPropertiesBuilder.
var propertiesFlatbuffers = new SubscriptionPropertiesBuilder("mySubscription")
.SetKeepAliveIntervalMillis(10000)
.SetPublishIntervalMillis(1000)
.SetErrorIntervalMillis(1000)
.Build();
// Create the subscription
var (createResult, subscription) = client.CreateSubscription(propertiesFlatbuffers, userData: null);
if (createResult.IsBad())
{
Console.WriteLine($"Failed to create subscription: {createResult}");
return;
}
// Add DataChanged Event Handler
subscription.DataChanged += (subscription, eventArgs) =>
{
var notifyInfo = NotifyInfo.GetRootAsNotifyInfo(eventArgs.Item.Info.ToFlatbuffers());
var timestampUtc = DateTime.FromFileTimeUtc(Convert.ToInt64(notifyInfo.Timestamp));
Console.WriteLine($"{timestampUtc}, {notifyInfo.Node}: {eventArgs.Item.Value.ToFloat()}");
};
// Subscribe a node by it's node address.
const string cpuLoad = "framework/metrics/system/cpu-utilisation-percent";
var subscribeResult = subscription.Subscribe(address: cpuLoad);
if (subscribeResult.IsBad())
{
Console.WriteLine($"Failed to subscribe: {subscribeResult}");
return;
}
Links
Please find the code coverage reports in folder ./coverage.
License
SPDX-FileCopyrightText: Bosch Rexroth AG SPDX-License-Identifier: MIT
Terms and Conditions for the Provision of Products of Bosch Rexroth AG Free of Charge
See LICENSES/tc_for_provision_of_products_free_of_charge.pdf inside this package. Please download the latest version from https://www.boschrexroth.com. Navigate to Legal Notice (footer) -> Terms and Conditions for the Provision of Products Free of Charge
See LICENSES/*.fossinfo.xml for used open source software licenses.
About
Please note that any trademarks, logos and pictures contained or linked to in this Software are owned by or copyright © Bosch Rexroth AG and not licensed under the Software's license terms.
Bosch Rexroth AG
Bgm.-Dr.-Nebel-Str. 2
97816 Lohr am Main
GERMANY
No packages depend on ctrlX-DataLayer.
.NET 8.0
- ctrlX-DataLayer.Flatbuffers (>= 3.6.0)
.NET Standard 2.0
- ctrlX-DataLayer.Flatbuffers (>= 3.6.0)