Dreamine.PLC.Core 1.0.1
Dreamine.PLC.Core 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
PlcValidation.cs
이 파일의 문서화 페이지로 가기
1using Dreamine.PLC.Abstractions.Devices;
2using Dreamine.PLC.Abstractions.Results;
3
5
14public static class PlcValidation
15{
40 public static PlcResult ValidateCount(int count)
41 {
42 if (count <= 0)
43 {
44 return PlcResult.Failure("The PLC request count must be greater than zero.");
45 }
46
47 return PlcResult.Success();
48 }
49
74 public static PlcResult ValidateAddress(PlcAddress address)
75 {
76 if (address.DeviceType == PlcDeviceType.Unknown)
77 {
78 return PlcResult.Failure("The PLC device type is unknown.");
79 }
80
81 if (address.Offset < 0)
82 {
83 return PlcResult.Failure("The PLC address offset must be greater than or equal to zero.");
84 }
85
86 if (address.BitOffset.HasValue &&
87 address.BitOffset is < 0 or > 15)
88 {
89 return PlcResult.Failure("The PLC bit offset must be between 0 and 15.");
90 }
91
92 return PlcResult.Success();
93 }
94
119 public static PlcResult ValidateWordValues(IReadOnlyList<short> values)
120 {
121 if (values.Count == 0)
122 {
123 return PlcResult.Failure("The PLC word value collection must not be empty.");
124 }
125
126 return PlcResult.Success();
127 }
128
153 public static PlcResult ValidateBitValues(IReadOnlyList<bool> values)
154 {
155 if (values.Count == 0)
156 {
157 return PlcResult.Failure("The PLC bit value collection must not be empty.");
158 }
159
160 return PlcResult.Success();
161 }
162}
static PlcResult ValidateAddress(PlcAddress address)
static PlcResult ValidateBitValues(IReadOnlyList< bool > values)
static PlcResult ValidateCount(int count)
static PlcResult ValidateWordValues(IReadOnlyList< short > values)