Dreamine.IO.Fastech.Ethernet 1.0.1
Dreamine.IO.Fastech.Ethernet 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
FastechDigitalOutputChannel.cs
이 파일의 문서화 페이지로 가기
1using Dreamine.IO.Abstractions.Channels;
2using Dreamine.IO.Abstractions.Models;
3using Dreamine.IO.Abstractions.Results;
5
7
16public sealed class FastechDigitalOutputChannel : IDigitalOutputChannel
17{
27
52 internal FastechDigitalOutputChannel(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 modulePoints = Enumerable
92 .Range(0, 16)
93 .Select(channel => new IoPoint(point.Module, channel, $"DO{channel:00}"))
94 .ToArray();
95
96 var result = await ReadAsync(modulePoints, cancellationToken).ConfigureAwait(false);
97
98 if (!result.IsSuccess || result.Value is null)
99 {
100 return IoResult<bool>.Failure(result.Message ?? "Failed to read the digital output.", result.ErrorCode);
101 }
102
103 return point.Channel >= 0 && point.Channel < result.Value.Length
104 ? IoResult<bool>.Success(result.Value[point.Channel])
105 : IoResult<bool>.Failure("The digital output response did not contain the requested channel.");
106 }
107
140 public Task<IoResult<bool[]>> ReadAsync(IReadOnlyList<IoPoint> points, CancellationToken cancellationToken = default)
141 {
142 return _controller.ReadDigitalOutputsAsync(points, cancellationToken);
143 }
144
185 public Task<IoResult> WriteAsync(IoPoint point, bool value, CancellationToken cancellationToken = default)
186 {
187 return WriteAsync(new Dictionary<IoPoint, bool> { [point] = value }, cancellationToken);
188 }
189
222 public Task<IoResult> WriteAsync(IReadOnlyDictionary<IoPoint, bool> values, CancellationToken cancellationToken = default)
223 {
224 return _controller.WriteDigitalOutputsAsync(values, cancellationToken);
225 }
226}
Task< IoResult > WriteAsync(IoPoint point, bool value, CancellationToken cancellationToken=default)
Task< IoResult< bool[]> > ReadAsync(IReadOnlyList< IoPoint > points, CancellationToken cancellationToken=default)
Task< IoResult > WriteAsync(IReadOnlyDictionary< IoPoint, bool > values, CancellationToken cancellationToken=default)
async Task< IoResult< bool > > ReadAsync(IoPoint point, CancellationToken cancellationToken=default)