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
channelChannelThe channel to which the device belongs.
namestringThe name of the device.
driverNamestringThe name of the driver.
propertiesIDictionary<string, object>The properties to set on the device.
cancellationTokenCancellationTokenThe 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.