Method GetOrCreateDeviceAsync
- Namespace
- Kepware.Api.ClientHandler
- Assembly
- Kepware.Api.dll
GetOrCreateDeviceAsync(Channel, string, string?, IDictionary<string, object>?, CancellationToken)
Gets or creates a device with the specified name and driver in the specified channel.
public Task<Device> GetOrCreateDeviceAsync(Channel channel, string name, string? driverName = null, IDictionary<string, object>? properties = null, CancellationToken cancellationToken = default)
Parameters
channel
ChannelThe channel to which the device belongs.
name
stringThe name of the device.
driverName
stringThe name of the driver.
properties
IDictionary<string, object>The properties to set on the device.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<Device>
A task that represents the asynchronous operation. The task result contains the created or loaded device.
Exceptions
- ArgumentNullException
Thrown when the channel is null.
- ArgumentException
Thrown when the device name is null or empty.
- InvalidOperationException
Thrown when the device cannot be created or loaded.