public override Task<DatapointResult> GetDatapoints(Empty request, ServerCallContext context) { var datapoints = _serverApplication.GetDatapoints(); DatapointResult datapointResult = new DatapointResult(); datapointResult.ApiResult = new ApiResult { ResultCode = ResultCode.Success, Message = "Datapoints have been retrieved" }; foreach (var datapoint in datapoints) { datapointResult.Datapoints.Add(new DatapointMessage() { Identifier = datapoint.Key.StringIdentifier, Value = datapoint.Value }); } return Task.FromResult(datapointResult); }
public override Task<DatapointResult> GetDatapoint(IdentifierMessage request, ServerCallContext context) { var nodeId = new NodeId(2, request.Identifier); DatapointResult datapointResult = new DatapointResult(); if (!_serverApplication.HasDatapoint(nodeId)) { datapointResult.ApiResult = new ApiResult { ResultCode = ResultCode.Error, Message = "Datapoint does not exist" }; return Task.FromResult(datapointResult); } var value = _serverApplication.GetDatapoint(nodeId); datapointResult.ApiResult = new ApiResult { ResultCode = ResultCode.Success, Message = "Datapoint has been retrieved" }; datapointResult.Datapoints.Add(new DatapointMessage() { Identifier = request.Identifier, Value = value }); return Task.FromResult(datapointResult); }