/// <inheritdoc/>
        public async Task <HistoryReadNextResponseApiModel <VariantValue> > HistoryReadRawNextAsync(
            EndpointApiModel endpoint, HistoryReadNextRequestApiModel request,
            CancellationToken ct)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException(nameof(endpoint));
            }
            if (string.IsNullOrEmpty(endpoint.Url))
            {
                throw new ArgumentNullException(nameof(endpoint.Url));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (string.IsNullOrEmpty(request.ContinuationToken))
            {
                throw new ArgumentNullException(nameof(request.ContinuationToken));
            }
            var response = await _methodClient.CallMethodAsync(_deviceId, _moduleId,
                                                               "HistoryReadNext_V2", _serializer.SerializeToString(new {
                endpoint,
                request
            }), null, ct);

            return(_serializer.Deserialize <HistoryReadNextResponseApiModel <VariantValue> >(response));
        }
        /// <summary>
        /// Read next history
        /// </summary>
        /// <param name="endpoint"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <HistoryReadNextResponseApiModel <VariantValue> > HistoryReadNextAsync(
            EndpointApiModel endpoint, HistoryReadNextRequestApiModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var result = await _historian.HistoryReadNextAsync(
                endpoint.ToServiceModel(), request.ToServiceModel());

            return(result.ToApiModel());
        }
        public async Task <HistoryReadNextResponseApiModel <VariantValue> > HistoryReadRawNextAsync(
            string endpointId, [FromBody][Required] HistoryReadNextRequestApiModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var readresult = await _client.HistoryReadNextAsync(
                endpointId, request.ToServiceModel());

            return(readresult.ToApiModel(d => d));
        }
Beispiel #4
0
        /// <summary>
        /// Read next history
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <HistoryReadNextResponseApiModel> HistoryReadNextAsync(
            HistoryReadNextRequestApiModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var result = await _historian.HistoryReadNextAsync(
                _twin.Endpoint, request.ToServiceModel());

            return(new HistoryReadNextResponseApiModel(result));
        }
Beispiel #5
0
 /// <summary>
 /// Convert back to service model
 /// </summary>
 /// <returns></returns>
 public static HistoryReadNextRequestModel ToServiceModel(
     this HistoryReadNextRequestApiModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new HistoryReadNextRequestModel {
         ContinuationToken = model.ContinuationToken,
         Abort = model.Abort,
         Header = model.Header.ToServiceModel()
     });
 }
        public async Task <HistoryReadNextResponseApiModel <HistoricEventApiModel[]> > HistoryReadEventsNextAsync(
            string endpointId,
            [FromBody][Required] HistoryReadNextRequestApiModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            var readresult = await _historian.HistoryReadEventsNextAsync(
                endpointId, request.ToServiceModel());

            return(readresult.ToApiModel(d => d?.Select(v => v.ToApiModel()).ToArray()));
        }
        /// <inheritdoc/>
        public async Task <HistoryReadNextResponseApiModel <JToken> > HistoryReadRawNextAsync(
            string endpointId, HistoryReadNextRequestApiModel content, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(endpointId))
            {
                throw new ArgumentNullException(nameof(endpointId));
            }
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (string.IsNullOrEmpty(content.ContinuationToken))
            {
                throw new ArgumentNullException(nameof(content.ContinuationToken));
            }
            var request = _httpClient.NewRequest(
                $"{_serviceUri}/v2/history/read/{endpointId}/next", _resourceId);

            request.SetContent(content);
            var response = await _httpClient.PostAsync(request, ct).ConfigureAwait(false);

            response.Validate();
            return(response.GetContent <HistoryReadNextResponseApiModel <JToken> >());
        }
        /// <inheritdoc/>
        public async Task <HistoryReadNextResponseApiModel <HistoricEventApiModel[]> > HistoryReadEventsNextAsync(
            string endpointId, HistoryReadNextRequestApiModel content, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(endpointId))
            {
                throw new ArgumentNullException(nameof(endpointId));
            }
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (string.IsNullOrEmpty(content.ContinuationToken))
            {
                throw new ArgumentNullException(nameof(content.ContinuationToken));
            }
            var request = _httpClient.NewRequest(
                $"{_serviceUri}/v2/read/{endpointId}/events/next", Resource.Platform);

            _serializer.SerializeToRequest(request, content);
            var response = await _httpClient.PostAsync(request, ct).ConfigureAwait(false);

            response.Validate();
            return(_serializer.DeserializeResponse <HistoryReadNextResponseApiModel <HistoricEventApiModel[]> >(response));
        }
Beispiel #9
0
 /// <summary>
 /// Read next batch of historic values
 /// </summary>
 /// <remarks>
 /// Read next batch of historic values of a node using historic access.
 /// The endpoint must be activated and connected and the module client
 /// and server must trust each other.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='endpointId'>
 /// The identifier of the activated endpoint.
 /// </param>
 /// <param name='request'>
 /// The history read next request
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <HistoryReadNextResponseApiModelHistoricValueApiModel> HistoryReadValueNextAsync(this IAzureOpcHistoryClient operations, string endpointId, HistoryReadNextRequestApiModel request, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.HistoryReadValueNextWithHttpMessagesAsync(endpointId, request, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #10
0
 /// <summary>
 /// Read next batch of historic values
 /// </summary>
 /// <remarks>
 /// Read next batch of historic values of a node using historic access.
 /// The endpoint must be activated and connected and the module client
 /// and server must trust each other.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='endpointId'>
 /// The identifier of the activated endpoint.
 /// </param>
 /// <param name='request'>
 /// The history read next request
 /// </param>
 public static HistoryReadNextResponseApiModelHistoricValueApiModel HistoryReadValueNext(this IAzureOpcHistoryClient operations, string endpointId, HistoryReadNextRequestApiModel request)
 {
     return(operations.HistoryReadValueNextAsync(endpointId, request).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Read next batch of historic events
 /// </summary>
 /// <remarks>
 /// Read next batch of historic events of a node using historic access. The
 /// endpoint must be activated and connected and the module client and server
 /// must trust each other.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='endpointId'>
 /// The identifier of the activated endpoint.
 /// </param>
 /// <param name='body'>
 /// The history read next request
 /// </param>
 public static HistoricEventApiModelHistoryReadNextResponseApiModel HistoryReadEventsNext(this IAzureOpcHistoryClient operations, string endpointId, HistoryReadNextRequestApiModel body)
 {
     return(operations.HistoryReadEventsNextAsync(endpointId, body).GetAwaiter().GetResult());
 }
Beispiel #12
0
 /// <summary>
 /// Read history call with custom encoded extension object details
 /// </summary>
 /// <param name="api"></param>
 /// <param name="endpointUrl"></param>
 /// <param name="request"></param>
 /// <param name="ct"></param>
 /// <returns></returns>
 public static Task <HistoryReadNextResponseApiModel <VariantValue> > HistoryReadRawNextAsync(
     this IHistoryModuleApi api, string endpointUrl, HistoryReadNextRequestApiModel request,
     CancellationToken ct = default)
 {
     return(api.HistoryReadRawNextAsync(NewEndpoint(endpointUrl), request, ct));
 }