Dreamine.PLC.Mitsubishi.MC 1.0.1
Dreamine.PLC.Mitsubishi.MC 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.PLC.Mitsubishi.MC.Protocol.MitsubishiMcBinary3EResponseParser 클래스 참조sealed

더 자세히 ...

Public 멤버 함수

PlcResult< MitsubishiMcBinary3EResponseParse (ReadOnlySpan< byte > frame)
PlcResult< short[]> ParseReadWords (ReadOnlySpan< byte > frame, int count)
PlcResult< bool[]> ParseReadBits (ReadOnlySpan< byte > frame, int count)

정적 Private 멤버 함수

static ushort ReadUInt16LittleEndian (ReadOnlySpan< byte > buffer, int offset)

정적 Private 속성

const int MinimumResponseLength = 11

상세한 설명

Mitsubishi MC Binary 3E 응답 프레임을 구문 분석합니다.

MitsubishiMcBinary3EResponseParser.cs 파일의 13 번째 라인에서 정의되었습니다.

멤버 함수 문서화

◆ Parse()

PlcResult< MitsubishiMcBinary3EResponse > Dreamine.PLC.Mitsubishi.MC.Protocol.MitsubishiMcBinary3EResponseParser.Parse ( ReadOnlySpan< byte > frame)
inline

원시 Binary 3E 응답의 헤더, 길이, 종료 코드 및 데이터를 구문 분석합니다.

매개변수
frame응답 프레임입니다.
반환값
구문 분석된 응답 결과입니다.

MitsubishiMcBinary3EResponseParser.cs 파일의 48 번째 라인에서 정의되었습니다.

49 {
50 if (frame.Length < MinimumResponseLength)
51 {
52 return PlcResult<MitsubishiMcBinary3EResponse>.Failure(
53 $"The Mitsubishi MC response frame is too short. Length: {frame.Length}");
54 }
55
56 var subHeader = ReadUInt16LittleEndian(frame, 0);
57 if (subHeader != 0xD000)
58 {
59 return PlcResult<MitsubishiMcBinary3EResponse>.Failure(
60 $"Invalid Mitsubishi MC response sub-header: 0x{subHeader:X4}");
61 }
62
63 var responseDataLength = ReadUInt16LittleEndian(frame, 7);
64 var expectedFrameLength = 9 + responseDataLength;
65
66 if (frame.Length < expectedFrameLength)
67 {
68 return PlcResult<MitsubishiMcBinary3EResponse>.Failure(
69 $"The Mitsubishi MC response frame is incomplete. Expected: {expectedFrameLength}, Actual: {frame.Length}");
70 }
71
72 var endCode = ReadUInt16LittleEndian(frame, 9);
73 var dataLength = responseDataLength - 2;
74
75 var data = new byte[dataLength];
76 if (dataLength > 0)
77 {
78 frame.Slice(11, dataLength).CopyTo(data);
79 }
80
81 var response = new MitsubishiMcBinary3EResponse(endCode, data);
82
83 if (!response.IsSuccess)
84 {
85 return PlcResult<MitsubishiMcBinary3EResponse>.Failure(
86 $"Mitsubishi MC response returned error end code: 0x{endCode:X4}",
87 endCode);
88 }
89
90 return PlcResult<MitsubishiMcBinary3EResponse>.Success(response);
91 }

다음을 참조함 : MinimumResponseLength, ReadUInt16LittleEndian().

다음에 의해서 참조됨 : ParseReadBits(), ParseReadWords().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ParseReadBits()

PlcResult< bool[]> Dreamine.PLC.Mitsubishi.MC.Protocol.MitsubishiMcBinary3EResponseParser.ParseReadBits ( ReadOnlySpan< byte > frame,
int count )
inline

Binary 3E 읽기 응답에서 압축된 비트 값을 구문 분석합니다.

매개변수
frame응답 프레임입니다.
count예상 비트 수입니다.
반환값
비트 값 결과입니다.

MitsubishiMcBinary3EResponseParser.cs 파일의 187 번째 라인에서 정의되었습니다.

188 {
189 if (count <= 0)
190 {
191 return PlcResult<bool[]>.Failure("The bit count must be greater than zero.");
192 }
193
194 var responseResult = Parse(frame);
195 if (!responseResult.IsSuccess || responseResult.Value is null)
196 {
197 return PlcResult<bool[]>.Failure(
198 responseResult.Message ?? "Failed to parse Mitsubishi MC read bit response.",
199 responseResult.ErrorCode);
200 }
201
202 var data = responseResult.Value.Data;
203 var expectedDataLength = (count + 1) / 2;
204
205 if (data.Length < expectedDataLength)
206 {
207 return PlcResult<bool[]>.Failure(
208 $"The Mitsubishi MC bit response data is incomplete. Expected: {expectedDataLength}, Actual: {data.Length}");
209 }
210
211 var values = new bool[count];
212
213 for (var i = 0; i < count; i++)
214 {
215 var packed = data[i / 2];
216
217 values[i] = i % 2 == 0
218 ? (packed & 0x10) != 0
219 : (packed & 0x01) != 0;
220 }
221
222 return PlcResult<bool[]>.Success(values);
223 }

다음을 참조함 : Parse().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ ParseReadWords()

PlcResult< short[]> Dreamine.PLC.Mitsubishi.MC.Protocol.MitsubishiMcBinary3EResponseParser.ParseReadWords ( ReadOnlySpan< byte > frame,
int count )
inline

Binary 3E 읽기 응답에서 워드 값을 구문 분석합니다.

매개변수
frame응답 프레임입니다.
count예상 워드 수입니다.
반환값
워드 값 결과입니다.

MitsubishiMcBinary3EResponseParser.cs 파일의 123 번째 라인에서 정의되었습니다.

124 {
125 if (count <= 0)
126 {
127 return PlcResult<short[]>.Failure("The word count must be greater than zero.");
128 }
129
130 var responseResult = Parse(frame);
131 if (!responseResult.IsSuccess || responseResult.Value is null)
132 {
133 return PlcResult<short[]>.Failure(
134 responseResult.Message ?? "Failed to parse Mitsubishi MC read word response.",
135 responseResult.ErrorCode);
136 }
137
138 var data = responseResult.Value.Data;
139 var expectedDataLength = count * 2;
140
141 if (data.Length < expectedDataLength)
142 {
143 return PlcResult<short[]>.Failure(
144 $"The Mitsubishi MC word response data is incomplete. Expected: {expectedDataLength}, Actual: {data.Length}");
145 }
146
147 var values = new short[count];
148
149 for (var i = 0; i < count; i++)
150 {
151 values[i] = unchecked((short)ReadUInt16LittleEndian(data, i * 2));
152 }
153
154 return PlcResult<short[]>.Success(values);
155 }

다음을 참조함 : Parse(), ReadUInt16LittleEndian().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ ReadUInt16LittleEndian()

ushort Dreamine.PLC.Mitsubishi.MC.Protocol.MitsubishiMcBinary3EResponseParser.ReadUInt16LittleEndian ( ReadOnlySpan< byte > buffer,
int offset )
inlinestaticprivate

지정한 오프셋에서 리틀 엔디언 16비트 값을 읽습니다.

매개변수
buffer원본 버퍼입니다.
offset읽기 오프셋입니다.
반환값
읽은 값입니다.

MitsubishiMcBinary3EResponseParser.cs 파일의 254 번째 라인에서 정의되었습니다.

255 {
256 return (ushort)(buffer[offset] | (buffer[offset + 1] << 8));
257 }

다음에 의해서 참조됨 : Parse(), ParseReadWords().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ MinimumResponseLength

const int Dreamine.PLC.Mitsubishi.MC.Protocol.MitsubishiMcBinary3EResponseParser.MinimumResponseLength = 11
staticprivate

Minimum Response Length 값을 보관합니다.

MitsubishiMcBinary3EResponseParser.cs 파일의 23 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Parse().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: