Dreamine.IO.Fastech.Ethernet 1.0.1
Dreamine.IO.Fastech.Ethernet 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
FastechAnalogInputChannel.cs
이 파일의 문서화 페이지로 가기
1using Dreamine.IO.Abstractions.Channels;
2using Dreamine.IO.Abstractions.Models;
3using Dreamine.IO.Abstractions.Results;
5
7
16public sealed class FastechAnalogInputChannel : IAnalogInputChannel
17{
27
52 internal FastechAnalogInputChannel(FastechEthernetIoController controller)
53 {
54 _controller = controller ?? throw new ArgumentNullException(nameof(controller));
55 }
56
89 public async Task<IoResult<double>> ReadAsync(AnalogIoPoint point, CancellationToken cancellationToken = default)
90 {
91 var result = await ReadAsync([point], cancellationToken).ConfigureAwait(false);
92
93 if (!result.IsSuccess || result.Value is null)
94 {
95 return IoResult<double>.Failure(result.Message ?? "Failed to read the analog input.", result.ErrorCode);
96 }
97
98 return result.Value.Length == 1
99 ? IoResult<double>.Success(result.Value[0])
100 : IoResult<double>.Failure("The analog input response did not contain exactly one value.");
101 }
102
135 public Task<IoResult<double[]>> ReadAsync(IReadOnlyList<AnalogIoPoint> points, CancellationToken cancellationToken = default)
136 {
137 return _controller.ReadAnalogInputsAsync(points, cancellationToken);
138 }
139}
async Task< IoResult< double > > ReadAsync(AnalogIoPoint point, CancellationToken cancellationToken=default)
Task< IoResult< double[]> > ReadAsync(IReadOnlyList< AnalogIoPoint > points, CancellationToken cancellationToken=default)