SampleSmart
1.0.0.0
SampleSmart 사용 방법을 보여 주는 예제 프로젝트입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
PlcSimulatorTab.xaml.Event.cs
이 파일의 문서화 페이지로 가기
1
namespace
SampleSmart.Pages.PageSub.PlcTabs
;
2
11
public
sealed
class
PlcSimulatorTabEvent
12
{
21
private
readonly
PlcSampleRuntime
_runtime
;
22
47
public
PlcSimulatorTabEvent
(
PlcSampleRuntime
runtime)
48
{
49
_runtime
= runtime ??
throw
new
ArgumentNullException(nameof(runtime));
50
}
51
60
public
string
Host
{
get
;
set
; } =
"127.0.0.1"
;
61
70
public
string
PortText
{
get
;
set
; } =
"55000"
;
71
80
public
void
StartServer
()
81
{
82
if
(!
TryGetPort
(out var port))
83
{
84
return
;
85
}
86
87
var bindHost =
Host
==
"127.0.0.1"
?
"0.0.0.0"
:
Host
;
88
_ =
_runtime
.StartSimulatorServerAsync(bindHost, port);
89
}
90
99
public
void
StopServer
()
100
{
101
_ =
_runtime
.StopSimulatorServerAsync();
102
}
103
112
public
void
UseTcpClient
()
113
{
114
if
(!
TryGetPort
(out var port))
115
{
116
return
;
117
}
118
119
_runtime
.UseSimulatorTcpClient(
Host
, port);
120
}
121
146
private
bool
TryGetPort
(out
int
port)
147
{
148
if
(!
int
.TryParse(
PortText
, out port) || port is <= 0 or > 65535)
149
{
150
_runtime.Monitor.StatusMessage =
"Port must be between 1 and 65535."
;
151
return
false
;
152
}
153
154
return
true
;
155
}
156
}
SampleSmart.Pages.PageSub.PlcTabs
Definition
InMemoryPlcTab.xaml.cs:3
SampleSmart.Pages.PageSub.PlcTabs.PlcSampleRuntime
Definition
PlcSampleRuntime.cs:29
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.Host
string Host
Definition
PlcSimulatorTab.xaml.Event.cs:60
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.PortText
string PortText
Definition
PlcSimulatorTab.xaml.Event.cs:70
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.UseTcpClient
void UseTcpClient()
Definition
PlcSimulatorTab.xaml.Event.cs:112
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent._runtime
readonly PlcSampleRuntime _runtime
Definition
PlcSimulatorTab.xaml.Event.cs:21
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.PlcSimulatorTabEvent
PlcSimulatorTabEvent(PlcSampleRuntime runtime)
Definition
PlcSimulatorTab.xaml.Event.cs:47
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.StartServer
void StartServer()
Definition
PlcSimulatorTab.xaml.Event.cs:80
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.StopServer
void StopServer()
Definition
PlcSimulatorTab.xaml.Event.cs:99
SampleSmart.Pages.PageSub.PlcTabs.PlcSimulatorTabEvent.TryGetPort
bool TryGetPort(out int port)
Definition
PlcSimulatorTab.xaml.Event.cs:146
Pages
PageSub
PlcTabs
PlcSimulatorTab.xaml.Event.cs
다음에 의해 생성됨 :
1.17.0