@dobot-plus/template 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dobot/components/DobotPlusApp.tsx +78 -78
- package/.dobot/http/axios.ts +52 -52
- package/.dobot/http/http.ts +22 -22
- package/.dobot/index.ts +2 -2
- package/.dobot/protocol/methodsHandler.ts +15 -15
- package/.dobot/protocol/postMessageHandler.ts +289 -289
- package/.dobot/shim.d.ts +3 -3
- package/.dobot/store/actions/toolActions.ts +69 -69
- package/.dobot/store/reducers/index.ts +8 -8
- package/.dobot/store/reducers/toolReducer.ts +152 -152
- package/.dobot/store/types.ts +240 -240
- package/.dobot/template/default.tsx.mustache +19 -19
- package/.dobot/template/entry.css +25 -25
- package/.dobot/template/entry.tsx +53 -53
- package/.dobot/template/index.html +23 -23
- package/.dobot/template/index.scss +5 -5
- package/.dobot/utils/i18n.ts +31 -31
- package/.dobot/utils/mqtt.ts +61 -61
- package/.dobot/utils/rem.js +21 -21
- package/.dobot/utils/tool.ts +15 -15
- package/.eslintrc.cjs +18 -18
- package/.luarc.json +8 -8
- package/.vscode/Api.schema.json +103 -103
- package/.vscode/Blocks.schema.json +94 -94
- package/.vscode/Main.schema.json +42 -42
- package/.vscode/Script.schema.json +22 -22
- package/.vscode/Toolbar.schema.json +19 -19
- package/.vscode/extensions.json +8 -8
- package/.vscode/settings.json +51 -51
- package/Resources/i18n/client/de.json +11 -11
- package/Resources/i18n/client/en.json +11 -11
- package/Resources/i18n/client/es.json +11 -11
- package/Resources/i18n/client/hk.json +11 -11
- package/Resources/i18n/client/ja.json +11 -11
- package/Resources/i18n/client/ko.json +11 -11
- package/Resources/i18n/client/ru.json +11 -11
- package/Resources/i18n/client/zh.json +11 -11
- package/Resources/i18n/plugin/de.json +3 -3
- package/Resources/i18n/plugin/en.json +3 -3
- package/Resources/i18n/plugin/es.json +3 -3
- package/Resources/i18n/plugin/hk.json +3 -3
- package/Resources/i18n/plugin/ja.json +3 -3
- package/Resources/i18n/plugin/ko.json +3 -3
- package/Resources/i18n/plugin/ru.json +3 -3
- package/Resources/i18n/plugin/zh.json +3 -3
- package/configs/Blocks.json +21 -21
- package/configs/Main.json +5 -5
- package/configs/Scripts.json +7 -7
- package/configs/Toolbar.json +5 -5
- package/dpt.json +4 -4
- package/lua/control.lua +18 -18
- package/lua/daemon.lua +22 -22
- package/lua/httpAPI.lua +66 -66
- package/lua/userAPI.lua +51 -51
- package/lua/utils/mqtt.lua +16 -16
- package/lua/utils/num_convert.lua +41 -41
- package/lua/utils/tcp.lua +30 -30
- package/lua/utils/util.lua +30 -30
- package/package.json +58 -49
- package/project.json +3 -3
- package/tsconfig.json +26 -26
- package/ui/Blocks.tsx +5 -5
- package/ui/Main.tsx +31 -31
- package/ui/Toolbar.tsx +5 -5
|
@@ -1,289 +1,289 @@
|
|
|
1
|
-
import { message } from 'antd'
|
|
2
|
-
import i18n from '../utils/i18n'
|
|
3
|
-
import store from '../store'
|
|
4
|
-
import { toolActions } from '../store/actions/toolActions'
|
|
5
|
-
import { communicator } from './postMessageCenter'
|
|
6
|
-
import PubSub from 'pubsub-js'
|
|
7
|
-
import { userMagamentActions } from '../store/actions/userMagamentActions'
|
|
8
|
-
import { jsonSafeParse } from '@dobot/utils/tool'
|
|
9
|
-
|
|
10
|
-
export class PostMessageHandler {
|
|
11
|
-
constructor() {
|
|
12
|
-
communicator.listen(this.listenCallback.bind(this))
|
|
13
|
-
}
|
|
14
|
-
private promiseId = 100
|
|
15
|
-
private promisesMap: any = {}
|
|
16
|
-
|
|
17
|
-
addPromises = (message: any, timeout: number = 1000) => {
|
|
18
|
-
return new Promise((resolve) => {
|
|
19
|
-
const promiseId = this.promiseId
|
|
20
|
-
message['promiseId'] = promiseId
|
|
21
|
-
communicator.send(message)
|
|
22
|
-
setTimeout(() => {
|
|
23
|
-
this.resolvePromise(promiseId, 'error')
|
|
24
|
-
}, timeout)
|
|
25
|
-
this.promisesMap[this.promiseId++] = resolve
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
resolvePromise = (promiseId: number, resoveData?: any) => {
|
|
30
|
-
const resolve = this.promisesMap[promiseId]
|
|
31
|
-
if (resolve) {
|
|
32
|
-
resolve(resoveData)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
listenCallback = (event: MessageEvent) => {
|
|
37
|
-
const data = jsonSafeParse(event.data)
|
|
38
|
-
let method = data.method
|
|
39
|
-
|
|
40
|
-
if (method) {
|
|
41
|
-
method = method.replace(/_(\w)/g, (_: any, match: string) => match.toUpperCase()) + 'Handler'
|
|
42
|
-
if ((this as any)[method]) {
|
|
43
|
-
;(this as any)[method](event)
|
|
44
|
-
} else {
|
|
45
|
-
throw `没有对应的 ${method} 处理方法, 请在 util/postMessageCenter 中进行定义`
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
console.error('不是自定义 message' + event)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
initHandler = (event: MessageEvent) => {
|
|
53
|
-
const data = jsonSafeParse(event.data)
|
|
54
|
-
communicator.registerSource(data.from || data.iframeName, event.source, event.origin)
|
|
55
|
-
const deviceInfo = event.data.data
|
|
56
|
-
if (deviceInfo) {
|
|
57
|
-
store.dispatch(toolActions.setPortIp(deviceInfo.portName))
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
syncJogInPausedHandler = (event: MessageEvent) => {
|
|
62
|
-
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
63
|
-
const data = JSON.parse(event.data).data
|
|
64
|
-
store.dispatch(toolActions.setJogInPaused(data))
|
|
65
|
-
}
|
|
66
|
-
syncIPHandler = (event: MessageEvent) => {
|
|
67
|
-
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
68
|
-
const data = JSON.parse(event.data).data
|
|
69
|
-
store.dispatch(toolActions.setPortIp(data.ip))
|
|
70
|
-
}
|
|
71
|
-
dobotPlusBlockDataHandler = (event: MessageEvent) => {
|
|
72
|
-
communicator.registerSource(JSON.parse(event.data).from, event.source, event.origin)
|
|
73
|
-
|
|
74
|
-
const data = JSON.parse(event.data).data
|
|
75
|
-
const locale = JSON.parse(event.data).locale
|
|
76
|
-
i18n.changeLanguage(locale.substr(0, 2))
|
|
77
|
-
PubSub.publish('dobotPlusBlockData', data)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
sendDobotPlusAlsonDataHandler = (event: MessageEvent) => {
|
|
81
|
-
communicator.registerSource(event.data.from || event.data.iframeName, event.source, event.origin)
|
|
82
|
-
const data = JSON.parse(event.data).data
|
|
83
|
-
|
|
84
|
-
if (data === 'break') {
|
|
85
|
-
message.success('断开连接')
|
|
86
|
-
store.dispatch(toolActions.setTcpStatus(false))
|
|
87
|
-
} else if (typeof data === 'object') {
|
|
88
|
-
PubSub.publish('connectInfo', data)
|
|
89
|
-
Object.keys(data).length === 0
|
|
90
|
-
? store.dispatch(toolActions.setTcpStatus(false))
|
|
91
|
-
: store.dispatch(toolActions.setTcpStatus(true))
|
|
92
|
-
} else if (data === 'err') {
|
|
93
|
-
message.error('连接失败')
|
|
94
|
-
} else if (data === 'close') {
|
|
95
|
-
} else {
|
|
96
|
-
data ? message.success('连接成功') : message.error('连接失败')
|
|
97
|
-
store.dispatch(toolActions.setTcpStatus(data))
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
dobotPlusAlsonTcpDataHandler = (event: MessageEvent) => {
|
|
101
|
-
communicator.registerSource(event.data.from || event.data.iframeName, event.source, event.origin)
|
|
102
|
-
const data = JSON.parse(event.data).data
|
|
103
|
-
PubSub.publish('dobotPlusTcpData', data)
|
|
104
|
-
}
|
|
105
|
-
dobotPlusAlsonSendStatusHandler = (event: MessageEvent) => {
|
|
106
|
-
communicator.registerSource(event.data.from || event.data.iframeName, event.source, event.origin)
|
|
107
|
-
const data = JSON.parse(event.data).data
|
|
108
|
-
PubSub.publish('sendStatus', data)
|
|
109
|
-
if (data) {
|
|
110
|
-
message.success('发送成功')
|
|
111
|
-
} else {
|
|
112
|
-
message.success('发送失败')
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
resetDobotPlusBlockData = (data: any, iframeName?: any) => {
|
|
116
|
-
console.log(data, iframeName)
|
|
117
|
-
communicator.send({
|
|
118
|
-
method: 'resetDobotPlusBlockData',
|
|
119
|
-
data,
|
|
120
|
-
iframeName: iframeName ? iframeName : 'alsontech',
|
|
121
|
-
to: 'blockly'
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
dobotPlusConnectTcp = (data: any) => {
|
|
125
|
-
communicator.send({
|
|
126
|
-
method: 'dobotPlusConnectTcp',
|
|
127
|
-
data,
|
|
128
|
-
iframeName: 'alsontech'
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
changeLocaleHandler = (event: MessageEvent) => {
|
|
132
|
-
console.log('changeLocaleHandler', event)
|
|
133
|
-
const data = jsonSafeParse(event.data)
|
|
134
|
-
communicator.registerSource(data.from || data.iframeName, event.source, event.origin)
|
|
135
|
-
const locale = data.data
|
|
136
|
-
i18n.changeLanguage(locale.substr(0, 2))
|
|
137
|
-
}
|
|
138
|
-
syncExchangeHandler = (event: MessageEvent) => {
|
|
139
|
-
const data = jsonSafeParse(event.data)
|
|
140
|
-
const deviceStateData = data.data
|
|
141
|
-
store.dispatch(toolActions.setDeviceStateData(deviceStateData))
|
|
142
|
-
}
|
|
143
|
-
syncUserPermissionHandler = (event: MessageEvent) => {
|
|
144
|
-
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
145
|
-
const level = JSON.parse(event.data).data
|
|
146
|
-
store.dispatch(userMagamentActions.setCurrentLevel(level))
|
|
147
|
-
}
|
|
148
|
-
syncCreditCardInfoHandler = (event: MessageEvent) => {
|
|
149
|
-
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
150
|
-
const userInfo = JSON.parse(event.data).data
|
|
151
|
-
store.dispatch(userMagamentActions.setCurrentUserInfo(userInfo))
|
|
152
|
-
}
|
|
153
|
-
dobotPlusLogout = () => {
|
|
154
|
-
communicator.send({
|
|
155
|
-
method: 'dobotPlusLogout',
|
|
156
|
-
iframeName: 'UserSetUp',
|
|
157
|
-
to: 'DobotStudio2020'
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
changeExitLoginTime = (time: any) => {
|
|
161
|
-
communicator.send({
|
|
162
|
-
method: 'changeExitLoginTime',
|
|
163
|
-
data: time,
|
|
164
|
-
iframeName: 'UserSetUp',
|
|
165
|
-
to: 'DobotStudio2020'
|
|
166
|
-
})
|
|
167
|
-
}
|
|
168
|
-
sendSkinState = (status: boolean) => {
|
|
169
|
-
communicator.send({
|
|
170
|
-
method: 'sendSkinState',
|
|
171
|
-
data: status,
|
|
172
|
-
iframeName: 'safeSkin',
|
|
173
|
-
to: 'DobotStudio2020'
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// -------------------------------码垛-------------------------------------
|
|
178
|
-
palleting3DInit = (window: any) => {
|
|
179
|
-
window && communicator.registerSource('palleting3D', window, '*')
|
|
180
|
-
const message = {
|
|
181
|
-
method: 'palleting3DInit',
|
|
182
|
-
iframeName: 'palleting3D'
|
|
183
|
-
}
|
|
184
|
-
communicator.send(message)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
changeLocale = () => {
|
|
188
|
-
const locale = i18n.language
|
|
189
|
-
const message = {
|
|
190
|
-
method: 'changeLocale',
|
|
191
|
-
iframeName: 'palleting3D',
|
|
192
|
-
data: locale
|
|
193
|
-
}
|
|
194
|
-
communicator.send(message)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
setPalletingData = (palletingData: any) => {
|
|
198
|
-
const message = {
|
|
199
|
-
method: 'setPalletingData',
|
|
200
|
-
data: palletingData,
|
|
201
|
-
iframeName: 'palleting3D'
|
|
202
|
-
}
|
|
203
|
-
communicator.send(message)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
setCameraViewKey = (key: string) => {
|
|
207
|
-
const message = {
|
|
208
|
-
method: 'setCameraViewKey',
|
|
209
|
-
data: key,
|
|
210
|
-
iframeName: 'palleting3D'
|
|
211
|
-
}
|
|
212
|
-
communicator.send(message)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// dobot+应用通讯
|
|
216
|
-
dobotplusQuit = () => {
|
|
217
|
-
communicator.send({
|
|
218
|
-
method: 'dobotplusQuit',
|
|
219
|
-
iframeName: 'dobotplusApp'
|
|
220
|
-
})
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
dobotplusCreateProject = (path: string, projectData: any) => {
|
|
224
|
-
return this.addPromises(
|
|
225
|
-
{
|
|
226
|
-
method: 'dobotplusCreateProject',
|
|
227
|
-
data: { path, projectData },
|
|
228
|
-
iframeName: 'dobotplusApp'
|
|
229
|
-
},
|
|
230
|
-
5000
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
dobotplusCreateProjectHandler = (event: MessageEvent) => {
|
|
235
|
-
console.log('dobotplusCreateProjectHandler', event)
|
|
236
|
-
const { promiseId, data } = event.data
|
|
237
|
-
this.resolvePromise(promiseId, data)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
dobotplusWriteProject = (path: string, projectData: any) => {
|
|
241
|
-
return this.addPromises(
|
|
242
|
-
{
|
|
243
|
-
method: 'dobotplusWriteProject',
|
|
244
|
-
data: { path, projectData },
|
|
245
|
-
iframeName: 'dobotplusApp'
|
|
246
|
-
},
|
|
247
|
-
5000
|
|
248
|
-
)
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
dobotplusWriteProjectHandler = (event: MessageEvent) => {
|
|
252
|
-
console.log('dobotplusWriteProjectHandler', event)
|
|
253
|
-
const { promiseId, data } = event.data
|
|
254
|
-
this.resolvePromise(promiseId, data)
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
dobotplusDeleteProject = (path: string) => {
|
|
258
|
-
return this.addPromises(
|
|
259
|
-
{
|
|
260
|
-
method: 'dobotplusDeleteProject',
|
|
261
|
-
data: { path },
|
|
262
|
-
iframeName: 'dobotplusApp'
|
|
263
|
-
},
|
|
264
|
-
5000
|
|
265
|
-
)
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
dobotplusDeleteProjectHandler = (event: MessageEvent) => {
|
|
269
|
-
console.log('dobotplusDeleteProjectHandler', event)
|
|
270
|
-
const { promiseId, data } = event.data
|
|
271
|
-
this.resolvePromise(promiseId, data)
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
syncToolCoodinateDataHandler = () => {}
|
|
275
|
-
syncUserCoodinateDataHandler = () => {}
|
|
276
|
-
syncPointDataHandler = () => {}
|
|
277
|
-
syncDeviceInfoHandler = () => {}
|
|
278
|
-
syncIoDataHandler = (event: MessageEvent) => {
|
|
279
|
-
const ioData = JSON.parse(event.data).data
|
|
280
|
-
store.dispatch(toolActions.setIoData(ioData))
|
|
281
|
-
}
|
|
282
|
-
updateBlocklyDataHandler = (event: MessageEvent) => {
|
|
283
|
-
console.log('postmessage updateBlocklyData', event)
|
|
284
|
-
const { data } = JSON.parse(event.data)
|
|
285
|
-
console.log(data)
|
|
286
|
-
|
|
287
|
-
store.dispatch(toolActions.setPointData(data.pointData))
|
|
288
|
-
}
|
|
289
|
-
}
|
|
1
|
+
import { message } from 'antd'
|
|
2
|
+
import i18n from '../utils/i18n'
|
|
3
|
+
import store from '../store'
|
|
4
|
+
import { toolActions } from '../store/actions/toolActions'
|
|
5
|
+
import { communicator } from './postMessageCenter'
|
|
6
|
+
import PubSub from 'pubsub-js'
|
|
7
|
+
import { userMagamentActions } from '../store/actions/userMagamentActions'
|
|
8
|
+
import { jsonSafeParse } from '@dobot/utils/tool'
|
|
9
|
+
|
|
10
|
+
export class PostMessageHandler {
|
|
11
|
+
constructor() {
|
|
12
|
+
communicator.listen(this.listenCallback.bind(this))
|
|
13
|
+
}
|
|
14
|
+
private promiseId = 100
|
|
15
|
+
private promisesMap: any = {}
|
|
16
|
+
|
|
17
|
+
addPromises = (message: any, timeout: number = 1000) => {
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
const promiseId = this.promiseId
|
|
20
|
+
message['promiseId'] = promiseId
|
|
21
|
+
communicator.send(message)
|
|
22
|
+
setTimeout(() => {
|
|
23
|
+
this.resolvePromise(promiseId, 'error')
|
|
24
|
+
}, timeout)
|
|
25
|
+
this.promisesMap[this.promiseId++] = resolve
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resolvePromise = (promiseId: number, resoveData?: any) => {
|
|
30
|
+
const resolve = this.promisesMap[promiseId]
|
|
31
|
+
if (resolve) {
|
|
32
|
+
resolve(resoveData)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
listenCallback = (event: MessageEvent) => {
|
|
37
|
+
const data = jsonSafeParse(event.data)
|
|
38
|
+
let method = data.method
|
|
39
|
+
|
|
40
|
+
if (method) {
|
|
41
|
+
method = method.replace(/_(\w)/g, (_: any, match: string) => match.toUpperCase()) + 'Handler'
|
|
42
|
+
if ((this as any)[method]) {
|
|
43
|
+
;(this as any)[method](event)
|
|
44
|
+
} else {
|
|
45
|
+
throw `没有对应的 ${method} 处理方法, 请在 util/postMessageCenter 中进行定义`
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
console.error('不是自定义 message' + event)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
initHandler = (event: MessageEvent) => {
|
|
53
|
+
const data = jsonSafeParse(event.data)
|
|
54
|
+
communicator.registerSource(data.from || data.iframeName, event.source, event.origin)
|
|
55
|
+
const deviceInfo = event.data.data
|
|
56
|
+
if (deviceInfo) {
|
|
57
|
+
store.dispatch(toolActions.setPortIp(deviceInfo.portName))
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
syncJogInPausedHandler = (event: MessageEvent) => {
|
|
62
|
+
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
63
|
+
const data = JSON.parse(event.data).data
|
|
64
|
+
store.dispatch(toolActions.setJogInPaused(data))
|
|
65
|
+
}
|
|
66
|
+
syncIPHandler = (event: MessageEvent) => {
|
|
67
|
+
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
68
|
+
const data = JSON.parse(event.data).data
|
|
69
|
+
store.dispatch(toolActions.setPortIp(data.ip))
|
|
70
|
+
}
|
|
71
|
+
dobotPlusBlockDataHandler = (event: MessageEvent) => {
|
|
72
|
+
communicator.registerSource(JSON.parse(event.data).from, event.source, event.origin)
|
|
73
|
+
|
|
74
|
+
const data = JSON.parse(event.data).data
|
|
75
|
+
const locale = JSON.parse(event.data).locale
|
|
76
|
+
i18n.changeLanguage(locale.substr(0, 2))
|
|
77
|
+
PubSub.publish('dobotPlusBlockData', data)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
sendDobotPlusAlsonDataHandler = (event: MessageEvent) => {
|
|
81
|
+
communicator.registerSource(event.data.from || event.data.iframeName, event.source, event.origin)
|
|
82
|
+
const data = JSON.parse(event.data).data
|
|
83
|
+
|
|
84
|
+
if (data === 'break') {
|
|
85
|
+
message.success('断开连接')
|
|
86
|
+
store.dispatch(toolActions.setTcpStatus(false))
|
|
87
|
+
} else if (typeof data === 'object') {
|
|
88
|
+
PubSub.publish('connectInfo', data)
|
|
89
|
+
Object.keys(data).length === 0
|
|
90
|
+
? store.dispatch(toolActions.setTcpStatus(false))
|
|
91
|
+
: store.dispatch(toolActions.setTcpStatus(true))
|
|
92
|
+
} else if (data === 'err') {
|
|
93
|
+
message.error('连接失败')
|
|
94
|
+
} else if (data === 'close') {
|
|
95
|
+
} else {
|
|
96
|
+
data ? message.success('连接成功') : message.error('连接失败')
|
|
97
|
+
store.dispatch(toolActions.setTcpStatus(data))
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
dobotPlusAlsonTcpDataHandler = (event: MessageEvent) => {
|
|
101
|
+
communicator.registerSource(event.data.from || event.data.iframeName, event.source, event.origin)
|
|
102
|
+
const data = JSON.parse(event.data).data
|
|
103
|
+
PubSub.publish('dobotPlusTcpData', data)
|
|
104
|
+
}
|
|
105
|
+
dobotPlusAlsonSendStatusHandler = (event: MessageEvent) => {
|
|
106
|
+
communicator.registerSource(event.data.from || event.data.iframeName, event.source, event.origin)
|
|
107
|
+
const data = JSON.parse(event.data).data
|
|
108
|
+
PubSub.publish('sendStatus', data)
|
|
109
|
+
if (data) {
|
|
110
|
+
message.success('发送成功')
|
|
111
|
+
} else {
|
|
112
|
+
message.success('发送失败')
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
resetDobotPlusBlockData = (data: any, iframeName?: any) => {
|
|
116
|
+
console.log(data, iframeName)
|
|
117
|
+
communicator.send({
|
|
118
|
+
method: 'resetDobotPlusBlockData',
|
|
119
|
+
data,
|
|
120
|
+
iframeName: iframeName ? iframeName : 'alsontech',
|
|
121
|
+
to: 'blockly'
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
dobotPlusConnectTcp = (data: any) => {
|
|
125
|
+
communicator.send({
|
|
126
|
+
method: 'dobotPlusConnectTcp',
|
|
127
|
+
data,
|
|
128
|
+
iframeName: 'alsontech'
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
changeLocaleHandler = (event: MessageEvent) => {
|
|
132
|
+
console.log('changeLocaleHandler', event)
|
|
133
|
+
const data = jsonSafeParse(event.data)
|
|
134
|
+
communicator.registerSource(data.from || data.iframeName, event.source, event.origin)
|
|
135
|
+
const locale = data.data
|
|
136
|
+
i18n.changeLanguage(locale.substr(0, 2))
|
|
137
|
+
}
|
|
138
|
+
syncExchangeHandler = (event: MessageEvent) => {
|
|
139
|
+
const data = jsonSafeParse(event.data)
|
|
140
|
+
const deviceStateData = data.data
|
|
141
|
+
store.dispatch(toolActions.setDeviceStateData(deviceStateData))
|
|
142
|
+
}
|
|
143
|
+
syncUserPermissionHandler = (event: MessageEvent) => {
|
|
144
|
+
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
145
|
+
const level = JSON.parse(event.data).data
|
|
146
|
+
store.dispatch(userMagamentActions.setCurrentLevel(level))
|
|
147
|
+
}
|
|
148
|
+
syncCreditCardInfoHandler = (event: MessageEvent) => {
|
|
149
|
+
communicator.registerSource(JSON.parse(event.data).from || event.data.iframeName, event.source, event.origin)
|
|
150
|
+
const userInfo = JSON.parse(event.data).data
|
|
151
|
+
store.dispatch(userMagamentActions.setCurrentUserInfo(userInfo))
|
|
152
|
+
}
|
|
153
|
+
dobotPlusLogout = () => {
|
|
154
|
+
communicator.send({
|
|
155
|
+
method: 'dobotPlusLogout',
|
|
156
|
+
iframeName: 'UserSetUp',
|
|
157
|
+
to: 'DobotStudio2020'
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
changeExitLoginTime = (time: any) => {
|
|
161
|
+
communicator.send({
|
|
162
|
+
method: 'changeExitLoginTime',
|
|
163
|
+
data: time,
|
|
164
|
+
iframeName: 'UserSetUp',
|
|
165
|
+
to: 'DobotStudio2020'
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
sendSkinState = (status: boolean) => {
|
|
169
|
+
communicator.send({
|
|
170
|
+
method: 'sendSkinState',
|
|
171
|
+
data: status,
|
|
172
|
+
iframeName: 'safeSkin',
|
|
173
|
+
to: 'DobotStudio2020'
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// -------------------------------码垛-------------------------------------
|
|
178
|
+
palleting3DInit = (window: any) => {
|
|
179
|
+
window && communicator.registerSource('palleting3D', window, '*')
|
|
180
|
+
const message = {
|
|
181
|
+
method: 'palleting3DInit',
|
|
182
|
+
iframeName: 'palleting3D'
|
|
183
|
+
}
|
|
184
|
+
communicator.send(message)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
changeLocale = () => {
|
|
188
|
+
const locale = i18n.language
|
|
189
|
+
const message = {
|
|
190
|
+
method: 'changeLocale',
|
|
191
|
+
iframeName: 'palleting3D',
|
|
192
|
+
data: locale
|
|
193
|
+
}
|
|
194
|
+
communicator.send(message)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
setPalletingData = (palletingData: any) => {
|
|
198
|
+
const message = {
|
|
199
|
+
method: 'setPalletingData',
|
|
200
|
+
data: palletingData,
|
|
201
|
+
iframeName: 'palleting3D'
|
|
202
|
+
}
|
|
203
|
+
communicator.send(message)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setCameraViewKey = (key: string) => {
|
|
207
|
+
const message = {
|
|
208
|
+
method: 'setCameraViewKey',
|
|
209
|
+
data: key,
|
|
210
|
+
iframeName: 'palleting3D'
|
|
211
|
+
}
|
|
212
|
+
communicator.send(message)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// dobot+应用通讯
|
|
216
|
+
dobotplusQuit = () => {
|
|
217
|
+
communicator.send({
|
|
218
|
+
method: 'dobotplusQuit',
|
|
219
|
+
iframeName: 'dobotplusApp'
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
dobotplusCreateProject = (path: string, projectData: any) => {
|
|
224
|
+
return this.addPromises(
|
|
225
|
+
{
|
|
226
|
+
method: 'dobotplusCreateProject',
|
|
227
|
+
data: { path, projectData },
|
|
228
|
+
iframeName: 'dobotplusApp'
|
|
229
|
+
},
|
|
230
|
+
5000
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
dobotplusCreateProjectHandler = (event: MessageEvent) => {
|
|
235
|
+
console.log('dobotplusCreateProjectHandler', event)
|
|
236
|
+
const { promiseId, data } = event.data
|
|
237
|
+
this.resolvePromise(promiseId, data)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
dobotplusWriteProject = (path: string, projectData: any) => {
|
|
241
|
+
return this.addPromises(
|
|
242
|
+
{
|
|
243
|
+
method: 'dobotplusWriteProject',
|
|
244
|
+
data: { path, projectData },
|
|
245
|
+
iframeName: 'dobotplusApp'
|
|
246
|
+
},
|
|
247
|
+
5000
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
dobotplusWriteProjectHandler = (event: MessageEvent) => {
|
|
252
|
+
console.log('dobotplusWriteProjectHandler', event)
|
|
253
|
+
const { promiseId, data } = event.data
|
|
254
|
+
this.resolvePromise(promiseId, data)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
dobotplusDeleteProject = (path: string) => {
|
|
258
|
+
return this.addPromises(
|
|
259
|
+
{
|
|
260
|
+
method: 'dobotplusDeleteProject',
|
|
261
|
+
data: { path },
|
|
262
|
+
iframeName: 'dobotplusApp'
|
|
263
|
+
},
|
|
264
|
+
5000
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
dobotplusDeleteProjectHandler = (event: MessageEvent) => {
|
|
269
|
+
console.log('dobotplusDeleteProjectHandler', event)
|
|
270
|
+
const { promiseId, data } = event.data
|
|
271
|
+
this.resolvePromise(promiseId, data)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
syncToolCoodinateDataHandler = () => {}
|
|
275
|
+
syncUserCoodinateDataHandler = () => {}
|
|
276
|
+
syncPointDataHandler = () => {}
|
|
277
|
+
syncDeviceInfoHandler = () => {}
|
|
278
|
+
syncIoDataHandler = (event: MessageEvent) => {
|
|
279
|
+
const ioData = JSON.parse(event.data).data
|
|
280
|
+
store.dispatch(toolActions.setIoData(ioData))
|
|
281
|
+
}
|
|
282
|
+
updateBlocklyDataHandler = (event: MessageEvent) => {
|
|
283
|
+
console.log('postmessage updateBlocklyData', event)
|
|
284
|
+
const { data } = JSON.parse(event.data)
|
|
285
|
+
console.log(data)
|
|
286
|
+
|
|
287
|
+
store.dispatch(toolActions.setPointData(data.pointData))
|
|
288
|
+
}
|
|
289
|
+
}
|
package/.dobot/shim.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
var COMPONENT_PATH: string
|
|
3
|
-
}
|
|
1
|
+
declare global {
|
|
2
|
+
var COMPONENT_PATH: string
|
|
3
|
+
}
|