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