Dreamine.IO.Fastech.Ethernet
1.0.1
Dreamine.IO.Fastech.Ethernet 산업 자동화 및 I/O 기능을 제공합니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
FastechDigitalOutputChannel.cs
이 파일의 문서화 페이지로 가기
1
using
Dreamine.IO.Abstractions.Channels;
2
using
Dreamine.IO.Abstractions.Models;
3
using
Dreamine.IO.Abstractions.Results;
4
using
Dreamine.IO.Fastech.Ethernet.Controllers
;
5
6
namespace
Dreamine.IO.Fastech.Ethernet.Channels
;
7
16
public
sealed
class
FastechDigitalOutputChannel : IDigitalOutputChannel
17
{
26
private
readonly
FastechEthernetIoController
_controller
;
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
}
Dreamine.IO.Fastech.Ethernet.Channels
Definition
FastechAnalogInputChannel.cs:6
Dreamine.IO.Fastech.Ethernet.Controllers
Definition
FastechEthernetIoController.cs:11
Dreamine.IO.Fastech.Ethernet.Channels.FastechDigitalOutputChannel.WriteAsync
Task< IoResult > WriteAsync(IoPoint point, bool value, CancellationToken cancellationToken=default)
Definition
FastechDigitalOutputChannel.cs:185
Dreamine.IO.Fastech.Ethernet.Channels.FastechDigitalOutputChannel.ReadAsync
Task< IoResult< bool[]> > ReadAsync(IReadOnlyList< IoPoint > points, CancellationToken cancellationToken=default)
Definition
FastechDigitalOutputChannel.cs:140
Dreamine.IO.Fastech.Ethernet.Channels.FastechDigitalOutputChannel.WriteAsync
Task< IoResult > WriteAsync(IReadOnlyDictionary< IoPoint, bool > values, CancellationToken cancellationToken=default)
Definition
FastechDigitalOutputChannel.cs:222
Dreamine.IO.Fastech.Ethernet.Channels.FastechDigitalOutputChannel._controller
readonly FastechEthernetIoController _controller
Definition
FastechDigitalOutputChannel.cs:26
Dreamine.IO.Fastech.Ethernet.Channels.FastechDigitalOutputChannel.ReadAsync
async Task< IoResult< bool > > ReadAsync(IoPoint point, CancellationToken cancellationToken=default)
Definition
FastechDigitalOutputChannel.cs:89
Dreamine.IO.Fastech.Ethernet.Controllers.FastechEthernetIoController
Definition
FastechEthernetIoController.cs:22
Channels
FastechDigitalOutputChannel.cs
다음에 의해 생성됨 :
1.17.0