read method
Creates a temporary connection and reads the given metric
Creates a temporary connection and reads the given metrics. Requires either AddConnectionS7 or AddConnectionModbus or AddConnectionOPCUA object as request body. Requires also the associated metrics as an array of MetricS7, MetricModbus or MetricOPCUA objects. Returns an array of read values as Value object or an Error object if the reading went wrong. When an Internal Server Error occours, an Error object will be returned.
Parameters:
-
ReadRequest readRequest (required):
-
String uuidToken: Used for remote connections to device
Implementation
Future<List<Status>?> read(
ReadRequest readRequest, {
required String uuidToken,
}) async {
final response = await readWithHttpInfo(
readRequest,
uuidToken: uuidToken,
);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty &&
response.statusCode != HttpStatus.noContent) {
final responseBody = await _decodeBodyBytes(response);
return (await apiClient.deserializeAsync(responseBody, 'List<Status>')
as List)
.cast<Status>()
.toList();
}
return null;
}