wanshenmean
2026-03-19 c493779a8504fe1eb548c865ff268a7f7436ec01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// 实例状态枚举
export enum InstanceStatus {
  Stopped = 'Stopped',
  Starting = 'Starting',
  Running = 'Running',
  Stopping = 'Stopping',
  Error = 'Error'
}
 
// PLC 型号枚举
export enum SiemensPLCType {
  S7200Smart = 'S7200Smart',
  S71200 = 'S71200',
  S71500 = 'S71500',
  S7300 = 'S7300',
  S7400 = 'S7400'
}
 
// 内存区域配置
export interface MemoryRegionConfig {
  mRegionSize: number
  dbBlockCount: number
  dbBlockNumbers: number[]
  dbBlockSize: number
  iRegionSize: number
  qRegionSize: number
  tRegionCount: number
  cRegionCount: number
}
 
// 实例配置
export interface InstanceConfig {
  id: string
  name: string
  plcType: SiemensPLCType
  port: number
  activationKey: string
  autoStart: boolean
  protocolTemplateId: string
  memoryConfig: MemoryRegionConfig
}
 
// 客户端连接信息
export interface ClientConnection {
  endpoint: string
  connectTime: string
  lastActivityTime: string
}
 
// 实例状态
export interface InstanceState {
  instanceId: string
  name: string
  plcType: string
  port: number
  status: InstanceStatus
  clientCount: number
  totalRequests: number
  startTime: string | null
  lastActivityTime: string | null
  errorMessage: string | null
}
 
// 实例列表项
export interface InstanceListItem {
  instanceId: string
  name: string
  plcType: string
  port: number
  status: string
  clientCount: number
  totalRequests: number
  startTime: string | null
  lastActivityTime: string | null
  errorMessage: string | null
}
 
// 创建实例输入
export interface CreateInstanceInput {
  id: string
  name: string
  plcType: SiemensPLCType
  port: number
  activationKey?: string
  autoStart: boolean
  mRegionSize: number
  dbBlockCount: number
  dbBlockNumbers: number[]
  dbBlockSize: number
  iRegionSize: number
  qRegionSize: number
  tRegionCount: number
  cRegionCount: number
}
 
export type ProtocolDataType = 'Byte' | 'Int' | 'DInt' | 'String' | 'Bool'
export type ProtocolFieldDirection = 'WcsToPlc' | 'PlcToWcs' | 'Bidirectional'
 
export interface ProtocolFieldMapping {
  fieldKey: string
  dbNumber: number
  offset: number
  bit?: number
  dataType: ProtocolDataType
  length: number
  direction: ProtocolFieldDirection
}
 
export interface ProtocolTemplate {
  id: string
  name: string
  version: string
  fields: ProtocolFieldMapping[]
}
 
export interface RobotClientStartRequest {
  serverId: string
  listenIp: string
  listenPort: number
  localPort: number
}
 
export interface RobotClientSendRequest {
  serverId: string
  clientId?: number | null
  message: string
}
 
export interface RobotClientStatusItem {
  clientId: number
  remoteEndPoint: string | null
  connected: boolean
  connectedAt: string | null
  lastReceivedMessage: string | null
  lastError: string | null
  lastReceivedAt: string | null
  lastSentAt: string | null
}
 
export interface RobotServerReceivedMessageItem {
  receivedAt: string
  clientId: number
  remoteEndPoint: string | null
  message: string
}
 
export interface RobotServerSentMessageItem {
  sentAt: string
  clientId: number
  remoteEndPoint: string | null
  message: string
}
 
export interface RobotServerStatusItem {
  serverId: string
  running: boolean
  listenIp: string
  listenPort: number
  localPort: number
  connectedCount: number
  clients: RobotClientStatusItem[]
  receivedMessages: RobotServerReceivedMessageItem[]
  sentMessages: RobotServerSentMessageItem[]
}
 
export interface RobotClientStatusResponse {
  runningServerCount: number
  servers: RobotServerStatusItem[]
}