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

더 자세히 ...

Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer에 대한 상속 다이어그램 :
Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer에 대한 협력 다이어그램:

Public 멤버 함수

 MitsubishiMcUdpSimulatorServer (MitsubishiMcSimulatorServerOptions options)
 MitsubishiMcUdpSimulatorServer (MitsubishiMcSimulatorServerOptions options, InMemoryPlcMemory memory)
Task StartAsync (CancellationToken cancellationToken=default)
async Task StopAsync ()
async ValueTask DisposeAsync ()

속성

bool IsRunning [get]

이벤트

EventHandler< string >? StatusChanged

Private 멤버 함수

async Task ReceiveLoopAsync (CancellationToken cancellationToken)
void OnProtocolStatusChanged (object? sender, string e)

정적 Private 멤버 함수

static IPAddress ParseAddress (string host)

Private 속성

readonly MitsubishiMcSimulatorServerOptions _options
readonly MitsubishiMcBinary3ESimulatorProtocol _protocol
CancellationTokenSource? _cts
UdpClient? _udpClient
Task? _receiveTask

상세한 설명

로컬 및 PC 간 테스트용 최소 Mitsubishi MC Binary 3E UDP 서버를 제공합니다.

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

생성자 & 소멸자 문서화

◆ MitsubishiMcUdpSimulatorServer() [1/2]

Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.MitsubishiMcUdpSimulatorServer ( MitsubishiMcSimulatorServerOptions options)
inline

새 메모리와 옵션으로 UDP 서버를 초기화합니다.

매개변수
options옵션입니다.
예외
ArgumentNullException옵션이 null인 경우 발생합니다.

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

87 : this(options, new InMemoryPlcMemory())
88 {
89 }

◆ MitsubishiMcUdpSimulatorServer() [2/2]

Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.MitsubishiMcUdpSimulatorServer ( MitsubishiMcSimulatorServerOptions options,
InMemoryPlcMemory memory )
inline

공유 메모리와 옵션으로 UDP 서버를 초기화합니다.

매개변수
options옵션입니다.
memory공유 메모리입니다.
예외
ArgumentNullException옵션 또는 메모리가 null인 경우 발생합니다.

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

122 {
123 _options = options ?? throw new ArgumentNullException(nameof(options));
124 _protocol = new MitsubishiMcBinary3ESimulatorProtocol(memory ?? throw new ArgumentNullException(nameof(memory)), options);
125 _protocol.StatusChanged += OnProtocolStatusChanged;
126 }

다음을 참조함 : _options, _protocol, OnProtocolStatusChanged().

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

멤버 함수 문서화

◆ DisposeAsync()

async ValueTask Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.DisposeAsync ( )
inline

프로토콜 이벤트 구독을 해제하고 서버를 중지합니다.

반환값
비동기 해제 작업입니다.

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

252 {
253 _protocol.StatusChanged -= OnProtocolStatusChanged;
254 await StopAsync().ConfigureAwait(false);
255 }

다음을 참조함 : OnProtocolStatusChanged(), StopAsync().

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

◆ OnProtocolStatusChanged()

void Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.OnProtocolStatusChanged ( object? sender,
string e )
inlineprivate

프로토콜 상태 메시지를 서버 이벤트로 전달합니다.

매개변수
sender이벤트 원본입니다.
e상태 메시지입니다.

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

361 {
362 StatusChanged?.Invoke(this, e);
363 }

다음을 참조함 : StatusChanged.

다음에 의해서 참조됨 : DisposeAsync(), MitsubishiMcUdpSimulatorServer().

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

◆ ParseAddress()

IPAddress Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.ParseAddress ( string host)
inlinestaticprivate

바인딩 호스트를 IP 주소로 변환하며 잘못되면 Any를 사용합니다.

매개변수
host호스트입니다.
반환값
IP 주소입니다.

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

329 {
330 if (string.IsNullOrWhiteSpace(host) || host == "*" || host == "+")
331 {
332 return IPAddress.Any;
333 }
334
335 return IPAddress.TryParse(host, out var address) ? address : IPAddress.Any;
336 }

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

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

◆ ReceiveLoopAsync()

async Task Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.ReceiveLoopAsync ( CancellationToken cancellationToken)
inlineprivate

UDP 요청 데이터그램을 받아 실행하고 원격 끝점에 응답합니다.

매개변수
cancellationToken취소 토큰입니다.
반환값
수신 루프입니다.

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

280 {
281 while (!cancellationToken.IsCancellationRequested && _udpClient is not null)
282 {
283 UdpReceiveResult request;
284 try
285 {
286 request = await _udpClient.ReceiveAsync(cancellationToken).ConfigureAwait(false);
287 }
288 catch (OperationCanceledException)
289 {
290 break;
291 }
292 catch (ObjectDisposedException)
293 {
294 break;
295 }
296 catch (SocketException)
297 {
298 break;
299 }
300
301 var response = _protocol.Execute(request.Buffer);
302 await _udpClient.SendAsync(response, response.Length, request.RemoteEndPoint).ConfigureAwait(false);
303 }
304 }

다음을 참조함 : _protocol, _udpClient.

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

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

◆ StartAsync()

Task Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.StartAsync ( CancellationToken cancellationToken = default)
inline

UDP 수신기와 수신 루프를 시작합니다.

매개변수
cancellationToken서버 수명 토큰입니다.
반환값
시작 작업입니다.

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

172 {
173 if (_udpClient is not null)
174 {
175 return Task.CompletedTask;
176 }
177
178 var address = ParseAddress(_options.Host);
179 _udpClient = new UdpClient(new IPEndPoint(address, _options.Port));
180 _cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
181 _receiveTask = Task.Run(() => ReceiveLoopAsync(_cts.Token), CancellationToken.None);
182 StatusChanged?.Invoke(this, $"MC UDP simulator server started. {_options.Host}:{_options.Port}");
183 return Task.CompletedTask;
184 }

다음을 참조함 : _cts, _options, _receiveTask, _udpClient, ParseAddress(), ReceiveLoopAsync(), StatusChanged.

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

◆ StopAsync()

async Task Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.StopAsync ( )
inline

UDP 수신기를 중지하고 수신 작업 종료를 기다립니다.

반환값
중지 작업입니다.

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

203 {
204 if (_udpClient is null)
205 {
206 return;
207 }
208
209 _cts?.Cancel();
210 _udpClient.Close();
211 _udpClient.Dispose();
212 _udpClient = null;
213
214 if (_receiveTask is not null)
215 {
216 try
217 {
218 await _receiveTask.ConfigureAwait(false);
219 }
220 catch (OperationCanceledException)
221 {
222 }
223 catch (ObjectDisposedException)
224 {
225 }
226 catch (SocketException)
227 {
228 }
229 }
230
231 _cts?.Dispose();
232 _cts = null;
233 StatusChanged?.Invoke(this, "MC UDP simulator server stopped.");
234 }

다음을 참조함 : _cts, _receiveTask, _udpClient, StatusChanged.

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

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

멤버 데이터 문서화

◆ _cts

CancellationTokenSource? Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer._cts
private

cts 값을 보관합니다.

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

다음에 의해서 참조됨 : StartAsync(), StopAsync().

◆ _options

readonly MitsubishiMcSimulatorServerOptions Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer._options
private

options 값을 보관합니다.

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

다음에 의해서 참조됨 : MitsubishiMcUdpSimulatorServer(), StartAsync().

◆ _protocol

readonly MitsubishiMcBinary3ESimulatorProtocol Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer._protocol
private

protocol 값을 보관합니다.

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

다음에 의해서 참조됨 : MitsubishiMcUdpSimulatorServer(), ReceiveLoopAsync().

◆ _receiveTask

Task? Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer._receiveTask
private

receive Task 값을 보관합니다.

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

다음에 의해서 참조됨 : StartAsync(), StopAsync().

◆ _udpClient

UdpClient? Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer._udpClient
private

udp Client 값을 보관합니다.

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

다음에 의해서 참조됨 : ReceiveLoopAsync(), StartAsync(), StopAsync().

속성 문서화

◆ IsRunning

bool Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.IsRunning
get

서버 실행 여부를 가져옵니다.

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

이벤트 문서화

◆ StatusChanged

EventHandler<string>? Dreamine.PLC.Mitsubishi.MC.Simulation.MitsubishiMcUdpSimulatorServer.StatusChanged

서버 상태 메시지가 변경될 때 발생합니다.

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

다음에 의해서 참조됨 : OnProtocolStatusChanged(), StartAsync(), StopAsync().


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