@dobot-plus/template 1.0.7 → 1.1.0
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/.luarc.json +3 -12
- package/CHANGELOG.md +2 -0
- package/lua/httpAPI.lua +8 -7
- package/lua/userAPI.lua +6 -6
- package/package.json +3 -12
- package/tsconfig.json +1 -2
- package/.dobot/.sftprc +0 -3
- package/.dobot/http/api.json +0 -11
- package/.dobot/http/api.ts +0 -26
- package/.dobot/http/api.ts.txt +0 -26
- package/.dobot/http/axios.ts.txt +0 -52
- package/.dobot/http/http.ts.txt +0 -22
- package/.dobot/index.txt +0 -2
- package/.dobot/protocol/keyBoard.ts.txt +0 -18
- package/.dobot/protocol/methodsHandler.ts.txt +0 -15
- package/.dobot/protocol/postMessageCenter.ts.txt +0 -38
- package/.dobot/protocol/postMessageHandler.ts.txt +0 -289
- package/.dobot/protocol/websocketHandler.ts.txt +0 -234
- package/.dobot/shim.d.ts.txt +0 -3
- package/.dobot/store/actions/toolActions.ts.txt +0 -69
- package/.dobot/store/actions/userMagamentActions.ts.txt +0 -25
- package/.dobot/store/index.ts.txt +0 -7
- package/.dobot/store/reducers/index.ts.txt +0 -8
- package/.dobot/store/reducers/toolReducer.ts.txt +0 -149
- package/.dobot/store/reducers/userMagamentReducer.ts.txt +0 -35
- package/.dobot/store/types.ts.txt +0 -237
- package/.dobot/utils/i18n.ts.txt +0 -31
- package/.dobot/utils/mqtt.ts.txt +0 -61
- package/.dobot/utils/rem.js.txt +0 -21
- package/.dobot/utils/tool.ts.txt +0 -15
- package/.dobot/webpack/build.js +0 -76
- package/.dobot/webpack/dev.js +0 -91
- package/.dobot/webpack/entry.js +0 -56
package/.luarc.json
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"workspace.library": [
|
|
3
|
-
|
|
4
|
-
],
|
|
5
|
-
"workspace.ignoreDir": [
|
|
6
|
-
".vscode",
|
|
7
|
-
"node_modules",
|
|
8
|
-
"configs",
|
|
9
|
-
"Resources",
|
|
10
|
-
"ui",
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
2
|
+
"workspace.library": [".node_modules/@dobot-plus/lua"],
|
|
3
|
+
"workspace.ignoreDir": [".vscode", "node_modules", "configs", "Resources", "ui", "dist"],
|
|
13
4
|
"runtime.version": "Lua 5.4",
|
|
14
5
|
"diagnostics": {
|
|
15
6
|
"enable": true
|
|
16
7
|
}
|
|
17
|
-
}
|
|
8
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.8](https://192.168.0.11:20022/IndustrialProducts/TPGroup/FrontEndpluginCollection/dobotplus/dobotpluginsworktile/compare/v1.3.0...v1.0.8) (2025-09-15)
|
|
6
|
+
|
|
5
7
|
### [1.0.6](https://192.168.0.11:20022/IndustrialProducts/TPGroup/FrontEndpluginCollection/dobotplus/dobotpluginsworktile/compare/v1.0.5...v1.0.6) (2025-09-15)
|
|
6
8
|
|
|
7
9
|
### [1.0.5](https://192.168.0.11:20022/IndustrialProducts/TPGroup/FrontEndpluginCollection/dobotplus/dobotpluginsworktile/compare/v1.0.2...v1.0.5) (2025-09-15)
|
package/lua/httpAPI.lua
CHANGED
|
@@ -32,9 +32,10 @@ end
|
|
|
32
32
|
--- 该方法会在http请求接收到后,自动执行,对应请求的 url为: http://<控制器ip>:<插件端口>/dobotPlus/[插件名]_[插件版本]/demoMethod1。
|
|
33
33
|
httpModule.demoMethod1 = function(params)
|
|
34
34
|
-- TODO 需要在接收到http请求后执行的操作
|
|
35
|
+
control.controlMethod1(params)
|
|
35
36
|
return {
|
|
36
37
|
--- Your responce data
|
|
37
|
-
|
|
38
|
+
status = true
|
|
38
39
|
}
|
|
39
40
|
end
|
|
40
41
|
|
|
@@ -43,10 +44,10 @@ end
|
|
|
43
44
|
--- @param params table
|
|
44
45
|
--- @return string
|
|
45
46
|
httpModule.demoMethod2 = function(params)
|
|
46
|
-
|
|
47
|
+
control.controlMethod2(params)
|
|
47
48
|
return {
|
|
48
49
|
--- Your responce data
|
|
49
|
-
|
|
50
|
+
status = true
|
|
50
51
|
}
|
|
51
52
|
end
|
|
52
53
|
|
|
@@ -55,11 +56,11 @@ end
|
|
|
55
56
|
--- @param params table
|
|
56
57
|
--- @return string The return value will response the http request, the return value is not necessory
|
|
57
58
|
httpModule.demoMethod3 = function(params)
|
|
58
|
-
|
|
59
|
+
control.controlMethod3(params)
|
|
59
60
|
return {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
--- Your responce data
|
|
62
|
+
status = true
|
|
63
|
+
}
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
return httpModule
|
package/lua/userAPI.lua
CHANGED
|
@@ -11,21 +11,21 @@ local userApiModule = {}
|
|
|
11
11
|
--- This function can be used in the httpAPI module also
|
|
12
12
|
---@param params table
|
|
13
13
|
function userApiModule.demoMethod1(params)
|
|
14
|
-
|
|
14
|
+
return control.controlMethod1(params)
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
--- This function will be called when you add it in the blockly programming or script programming
|
|
18
18
|
--- This function can be used in the httpAPI module also
|
|
19
19
|
---@param params table
|
|
20
20
|
function userApiModule.demoMethod2(params)
|
|
21
|
-
|
|
21
|
+
return control.controlMethod2(params)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
--- This function will be called when you add it in the blockly programming or script programming
|
|
25
25
|
--- This function can be used in the httpAPI module also
|
|
26
26
|
---@param params table
|
|
27
27
|
function userApiModule.demoMethod3(params)
|
|
28
|
-
|
|
28
|
+
return control.controlMethod3(params)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
-- This function will be called when the plugin is installed
|
|
@@ -36,9 +36,9 @@ end
|
|
|
36
36
|
function userApiModule.OnRegist()
|
|
37
37
|
EcoLog(" --- OnRegist .... --- ")
|
|
38
38
|
-- 0. 接口导出
|
|
39
|
-
local isErr = ExportFunction("
|
|
40
|
-
ExportFunction("
|
|
41
|
-
ExportFunction("
|
|
39
|
+
local isErr = ExportFunction("demoMethod1", userApiModule.demoMethod1) or
|
|
40
|
+
ExportFunction("demoMethod2", userApiModule.demoMethod2) or
|
|
41
|
+
ExportFunction("demoMethod3", userApiModule.demoMethod3)
|
|
42
42
|
-- 1. 错误的处理
|
|
43
43
|
if isErr then
|
|
44
44
|
EcoLog(" --- ERR to register .... --- ", isErr)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dobot-plus/template",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "20"
|
|
6
6
|
},
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"dependencies": {},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@dobot-plus/components": "latest",
|
|
15
|
+
"@dobot-plus/lua": "latest",
|
|
15
16
|
"antd": "^5.22.3",
|
|
16
17
|
"axios": "^1.3.3",
|
|
17
18
|
"i18next": "^23.12.2",
|
|
@@ -31,20 +32,10 @@
|
|
|
31
32
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
32
33
|
"@typescript-eslint/parser": "^7.17.0",
|
|
33
34
|
"add": "^2.0.6",
|
|
34
|
-
"css-loader": "^7.1.2",
|
|
35
35
|
"eslint": "^8.57.0",
|
|
36
36
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
37
37
|
"eslint-plugin-react-refresh": "^0.4.9",
|
|
38
|
-
"
|
|
39
|
-
"sass": "^1.77.8",
|
|
40
|
-
"sass-loader": "^16.0.0",
|
|
41
|
-
"style-loader": "^4.0.0",
|
|
42
|
-
"esbuild-loader": "2.21.0",
|
|
43
|
-
"typescript": "^5.5.4",
|
|
44
|
-
"url-loader": "^4.1.1",
|
|
45
|
-
"webpack": "^5.93.0",
|
|
46
|
-
"url": "^0.11.3",
|
|
47
|
-
"process": "^0.11.10"
|
|
38
|
+
"url": "^0.11.3"
|
|
48
39
|
},
|
|
49
40
|
"peerDependencies": {}
|
|
50
41
|
}
|
package/tsconfig.json
CHANGED
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
"noUnusedParameters": false,
|
|
20
20
|
"noFallthroughCasesInSwitch": true,
|
|
21
21
|
"paths": {
|
|
22
|
-
"@dobot/*": ["./.dobot/*"]
|
|
23
|
-
"@dobot-plus/components": ["./node_modules/@dobot-plus/components"]
|
|
22
|
+
"@dobot/*": ["./.dobot/*"]
|
|
24
23
|
}
|
|
25
24
|
},
|
|
26
25
|
"include": ["ui", ".dobot/**/*"]
|
package/.dobot/.sftprc
DELETED
package/.dobot/http/api.json
DELETED
package/.dobot/http/api.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios'
|
|
2
|
-
import apiConfig from './api.json'
|
|
3
|
-
import { request } from './axios'
|
|
4
|
-
|
|
5
|
-
type MethodName = keyof typeof apiConfig
|
|
6
|
-
export const http = {} as {
|
|
7
|
-
[key in MethodName]: (data?: object) => Promise<AxiosResponse<any, any>>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Object.entries(apiConfig).forEach(([key, value]) => {
|
|
11
|
-
const { url } = value
|
|
12
|
-
if (url) {
|
|
13
|
-
http[key as MethodName] = (data) => {
|
|
14
|
-
return request({
|
|
15
|
-
...value,
|
|
16
|
-
data
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
http[key as MethodName] = (data) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
console.warn('Please check your api config: ', key, data)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})
|
package/.dobot/http/api.ts.txt
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios'
|
|
2
|
-
import apiConfig from './api.json'
|
|
3
|
-
import { request } from './axios'
|
|
4
|
-
|
|
5
|
-
type MethodName = keyof typeof apiConfig
|
|
6
|
-
export const http = {} as {
|
|
7
|
-
[key in MethodName]: (data?: object) => Promise<AxiosResponse<any, any>>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
Object.entries(apiConfig).forEach(([key, value]) => {
|
|
11
|
-
const { url } = value
|
|
12
|
-
if (url) {
|
|
13
|
-
http[key as MethodName] = (data) => {
|
|
14
|
-
return request({
|
|
15
|
-
...value,
|
|
16
|
-
data
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
} else {
|
|
20
|
-
http[key as MethodName] = (data) => {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
console.warn('Please check your api config: ', key, data)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})
|
package/.dobot/http/axios.ts.txt
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
|
|
2
|
-
import dptConfig from '../../dpt.json'
|
|
3
|
-
import pluginConfig from '../../configs/Main.json'
|
|
4
|
-
import store from '@dobot/store'
|
|
5
|
-
|
|
6
|
-
const instance = axios.create()
|
|
7
|
-
|
|
8
|
-
instance.interceptors.request.use(
|
|
9
|
-
(config: InternalAxiosRequestConfig) => {
|
|
10
|
-
config.headers.AuthorizationToken = localStorage.getItem('AuthorizationToken') || ''
|
|
11
|
-
return config
|
|
12
|
-
},
|
|
13
|
-
(err: AxiosError) => Promise.reject(err)
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
instance.interceptors.response.use(
|
|
17
|
-
(res: AxiosResponse) => {
|
|
18
|
-
return res
|
|
19
|
-
},
|
|
20
|
-
(err: AxiosError) => {
|
|
21
|
-
return Promise.reject(err)
|
|
22
|
-
}
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
export function request(config: AxiosRequestConfig, port?: number) {
|
|
26
|
-
const { portData } = store.getState().toolReducer
|
|
27
|
-
|
|
28
|
-
const options: AxiosRequestConfig = {
|
|
29
|
-
...config,
|
|
30
|
-
withCredentials: true,
|
|
31
|
-
baseURL: `http://${portData.ip}:${port}/dobotPlus/${pluginConfig.name}_v${pluginConfig.version}`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
35
|
-
options.baseURL = `/dobotPlus/${pluginConfig.name}_v${pluginConfig.version}`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return instance.request({
|
|
39
|
-
...options,
|
|
40
|
-
method: 'post'
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getPluginPort() {
|
|
45
|
-
return instance.request({
|
|
46
|
-
baseURL: process.env.NODE_ENV !== 'production' ? `` : `http://${dptConfig.ip}:22001`,
|
|
47
|
-
url: '/dobotPlus/getPorts',
|
|
48
|
-
method: 'get'
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default instance
|
package/.dobot/http/http.ts.txt
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { request } from './axios'
|
|
2
|
-
|
|
3
|
-
export const demoMethod1 = (data: any) => {
|
|
4
|
-
return request({
|
|
5
|
-
url: 'demoMethod1',
|
|
6
|
-
data
|
|
7
|
-
})
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const demoMethod2 = (data: any) => {
|
|
11
|
-
return request({
|
|
12
|
-
url: 'demoMethod2',
|
|
13
|
-
data
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const demoMethod3 = (data: any) => {
|
|
18
|
-
return request({
|
|
19
|
-
url: 'demoMethod3',
|
|
20
|
-
data
|
|
21
|
-
})
|
|
22
|
-
}
|
package/.dobot/index.txt
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { isInIframe } from '@dobot/utils/tool'
|
|
2
|
-
import keyboardLink from 'keyboard-link'
|
|
3
|
-
if (!isInIframe) {
|
|
4
|
-
const ws = new WebSocket('ws:127.0.0.1:10086')
|
|
5
|
-
ws.onopen = () => {
|
|
6
|
-
console.log('链接成功')
|
|
7
|
-
ws.close()
|
|
8
|
-
|
|
9
|
-
new keyboardLink({
|
|
10
|
-
host: 'ws:127.0.0.1',
|
|
11
|
-
port: 10086
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
ws.onerror = () => {
|
|
16
|
-
console.log('链接失败')
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PostMessageHandler } from './postMessageHandler'
|
|
2
|
-
import { WebSocketHandler } from './websocketHandler'
|
|
3
|
-
import './keyBoard'
|
|
4
|
-
import { isInIframe } from '@dobot/utils/tool'
|
|
5
|
-
|
|
6
|
-
let methodsHandler: any = undefined
|
|
7
|
-
const postMessageHandler = new PostMessageHandler()
|
|
8
|
-
// 根据环境判断
|
|
9
|
-
if (isInIframe) {
|
|
10
|
-
methodsHandler = postMessageHandler
|
|
11
|
-
} else {
|
|
12
|
-
methodsHandler = new WebSocketHandler()
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { methodsHandler, postMessageHandler }
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsonSafeParse } from '@dobot/utils/tool'
|
|
2
|
-
|
|
3
|
-
export class PostMessageCenter {
|
|
4
|
-
dest: { [iframeName: string]: any }
|
|
5
|
-
constructor() {
|
|
6
|
-
this.dest = {}
|
|
7
|
-
}
|
|
8
|
-
send(message: any) {
|
|
9
|
-
if (!message.iframeName) return
|
|
10
|
-
const iframe = this.dest[message.to || message.iframeName]
|
|
11
|
-
const origin = this.dest[`${message.to || message.iframeName}Origin`]
|
|
12
|
-
if (!iframe || !origin) {
|
|
13
|
-
throw 'please register source and origin firstly'
|
|
14
|
-
}
|
|
15
|
-
iframe.postMessage(message, origin)
|
|
16
|
-
}
|
|
17
|
-
listen(cb: Function) {
|
|
18
|
-
window.addEventListener('message', (event) => {
|
|
19
|
-
const data = jsonSafeParse(event.data)
|
|
20
|
-
|
|
21
|
-
const iframeName = data.from || data.iframeName
|
|
22
|
-
if (
|
|
23
|
-
iframeName &&
|
|
24
|
-
['blockly', 'DobotStudio2020', 'dobotPlus', 'dobotplusApp', 'palleting3D'].includes(iframeName)
|
|
25
|
-
) {
|
|
26
|
-
cb(event)
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
public addDest = (iframeName: string, source: HTMLIFrameElement, iframeOrigin: string, origin: string) => {
|
|
31
|
-
this.dest[iframeName] = source
|
|
32
|
-
this.dest[iframeOrigin] = origin
|
|
33
|
-
}
|
|
34
|
-
registerSource(iframeName: string, source: any, origin: string) {
|
|
35
|
-
this.addDest(iframeName, source, `${iframeName}Origin`, origin)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export const communicator = new PostMessageCenter()
|
|
@@ -1,289 +0,0 @@
|
|
|
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
|
-
}
|