@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
package/lua/utils/tcp.lua
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
--- 通用TCP连接函数
|
|
2
|
-
---@param ip string
|
|
3
|
-
---@param port number
|
|
4
|
-
---@param timeout number
|
|
5
|
-
---@return table result
|
|
6
|
-
function CreateTCPConnection(ip, port, timeout)
|
|
7
|
-
-- 初始化错误码和socket对象
|
|
8
|
-
local SUCCESS = 0
|
|
9
|
-
local FAIL = 1
|
|
10
|
-
local err = SUCCESS
|
|
11
|
-
local Socket = nil
|
|
12
|
-
|
|
13
|
-
-- 创建TCP客户端
|
|
14
|
-
err, Socket = TCPCreate(false, ip, port)
|
|
15
|
-
if err ~= SUCCESS then
|
|
16
|
-
print("Create TCP Client failed, code:", err)
|
|
17
|
-
return { errorCode = err, socket = nil }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
-- 尝试建立TCP连接
|
|
21
|
-
err = TCPStart(Socket, timeout or 10) -- 使用传入的timeout,默认10秒
|
|
22
|
-
if err ~= SUCCESS then
|
|
23
|
-
print("Connect TCP Client failed, code:", err)
|
|
24
|
-
TCPDestroy(Socket)
|
|
25
|
-
return { errorCode = err, socket = nil }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
-- 连接成功,返回成功状态和socket对象
|
|
29
|
-
print("Connect TCP Client Success!")
|
|
30
|
-
return { errorCode = nil, socket = Socket }
|
|
1
|
+
--- 通用TCP连接函数
|
|
2
|
+
---@param ip string
|
|
3
|
+
---@param port number
|
|
4
|
+
---@param timeout number
|
|
5
|
+
---@return table result
|
|
6
|
+
function CreateTCPConnection(ip, port, timeout)
|
|
7
|
+
-- 初始化错误码和socket对象
|
|
8
|
+
local SUCCESS = 0
|
|
9
|
+
local FAIL = 1
|
|
10
|
+
local err = SUCCESS
|
|
11
|
+
local Socket = nil
|
|
12
|
+
|
|
13
|
+
-- 创建TCP客户端
|
|
14
|
+
err, Socket = TCPCreate(false, ip, port)
|
|
15
|
+
if err ~= SUCCESS then
|
|
16
|
+
print("Create TCP Client failed, code:", err)
|
|
17
|
+
return { errorCode = err, socket = nil }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
-- 尝试建立TCP连接
|
|
21
|
+
err = TCPStart(Socket, timeout or 10) -- 使用传入的timeout,默认10秒
|
|
22
|
+
if err ~= SUCCESS then
|
|
23
|
+
print("Connect TCP Client failed, code:", err)
|
|
24
|
+
TCPDestroy(Socket)
|
|
25
|
+
return { errorCode = err, socket = nil }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
-- 连接成功,返回成功状态和socket对象
|
|
29
|
+
print("Connect TCP Client Success!")
|
|
30
|
+
return { errorCode = nil, socket = Socket }
|
|
31
31
|
end
|
package/lua/utils/util.lua
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
local modbusIDS = {}
|
|
2
|
-
--- 使用modbus协议修改或读取数据
|
|
3
|
-
---@param cb function 创建modbus成功后执行的回调
|
|
4
|
-
---@param id number modebus链接的id
|
|
5
|
-
function HandleByModbus(cb, id, baudRate)
|
|
6
|
-
local DEFAULT_BAUDRATE = 115200
|
|
7
|
-
local MODBUS_IP = "127.0.0.1"
|
|
8
|
-
local MODBUS_PORT = 60000
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if type(id) ~= "number" then
|
|
12
|
-
return nil
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
if modbusIDS[id] == nil then
|
|
16
|
-
local err, _modbus = ModbusCreate(MODBUS_IP, MODBUS_PORT, id, true)
|
|
17
|
-
if err ~= 0 then
|
|
18
|
-
return nil
|
|
19
|
-
else
|
|
20
|
-
modbusIDS[tonumber(id)] = _modbus
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
local res = nil
|
|
25
|
-
|
|
26
|
-
if type(cb) == "function" then
|
|
27
|
-
res = cb(modbusIDS[id])
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
return res
|
|
1
|
+
local modbusIDS = {}
|
|
2
|
+
--- 使用modbus协议修改或读取数据
|
|
3
|
+
---@param cb function 创建modbus成功后执行的回调
|
|
4
|
+
---@param id number modebus链接的id
|
|
5
|
+
function HandleByModbus(cb, id, baudRate)
|
|
6
|
+
local DEFAULT_BAUDRATE = 115200
|
|
7
|
+
local MODBUS_IP = "127.0.0.1"
|
|
8
|
+
local MODBUS_PORT = 60000
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if type(id) ~= "number" then
|
|
12
|
+
return nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if modbusIDS[id] == nil then
|
|
16
|
+
local err, _modbus = ModbusCreate(MODBUS_IP, MODBUS_PORT, id, true)
|
|
17
|
+
if err ~= 0 then
|
|
18
|
+
return nil
|
|
19
|
+
else
|
|
20
|
+
modbusIDS[tonumber(id)] = _modbus
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
local res = nil
|
|
25
|
+
|
|
26
|
+
if type(cb) == "function" then
|
|
27
|
+
res = cb(modbusIDS[id])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
return res
|
|
31
31
|
end
|
package/package.json
CHANGED
|
@@ -1,49 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@dobot-plus/template",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"engines": {
|
|
5
|
-
"node": "20"
|
|
6
|
-
},
|
|
7
|
-
"scripts": {
|
|
8
|
-
"dev": "dpt dev",
|
|
9
|
-
"build": "dpt build",
|
|
10
|
-
"release": "
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"@dobot-plus/components": "latest",
|
|
15
|
-
"@dobot-plus/lua": "latest",
|
|
16
|
-
"@dobot-plus/gui": "latest",
|
|
17
|
-
"antd": "^5.22.3",
|
|
18
|
-
"axios": "^1.3.3",
|
|
19
|
-
"i18next": "^23.12.2",
|
|
20
|
-
"keyboard-link": "^0.2.3",
|
|
21
|
-
"mqtt": "5.1.3",
|
|
22
|
-
"pubsub-js": "^1.9.3",
|
|
23
|
-
"react": "^18.3.1",
|
|
24
|
-
"react-dom": "^18.3.1",
|
|
25
|
-
"react-i18next": "^15.0.0",
|
|
26
|
-
"react-redux": "^9.1.2",
|
|
27
|
-
"redux": "^5.0.1",
|
|
28
|
-
"@types/node": "^20.14.12",
|
|
29
|
-
"@types/pubsub-js": "^1.8.6",
|
|
30
|
-
"@types/react": "^18.3.3",
|
|
31
|
-
"@types/react-dom": "^18.3.0",
|
|
32
|
-
"@types/react-redux": "^7.1.33",
|
|
33
|
-
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
34
|
-
"@typescript-eslint/parser": "^7.17.0",
|
|
35
|
-
"add": "^2.0.6",
|
|
36
|
-
"eslint": "^8.57.0",
|
|
37
|
-
"eslint-plugin-react-hooks": "^4.6.2",
|
|
38
|
-
"eslint-plugin-react-refresh": "^0.4.9",
|
|
39
|
-
"url": "^0.11.3",
|
|
40
|
-
"next": "14.2.5",
|
|
41
|
-
"process": "^0.11.10",
|
|
42
|
-
"sass-loader": "^16.0.0",
|
|
43
|
-
"style-loader": "^4.0.0",
|
|
44
|
-
"url-loader": "^4.1.1",
|
|
45
|
-
"sass": "^1.77.8",
|
|
46
|
-
"postcss-loader": "^8.1.1"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@dobot-plus/template",
|
|
3
|
+
"version": "1.2.8",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": "20"
|
|
6
|
+
},
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "dpt dev",
|
|
9
|
+
"build": "dpt build",
|
|
10
|
+
"release": "npm publish --access public"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@dobot-plus/components": "latest",
|
|
15
|
+
"@dobot-plus/lua": "latest",
|
|
16
|
+
"@dobot-plus/gui": "latest",
|
|
17
|
+
"antd": "^5.22.3",
|
|
18
|
+
"axios": "^1.3.3",
|
|
19
|
+
"i18next": "^23.12.2",
|
|
20
|
+
"keyboard-link": "^0.2.3",
|
|
21
|
+
"mqtt": "5.1.3",
|
|
22
|
+
"pubsub-js": "^1.9.3",
|
|
23
|
+
"react": "^18.3.1",
|
|
24
|
+
"react-dom": "^18.3.1",
|
|
25
|
+
"react-i18next": "^15.0.0",
|
|
26
|
+
"react-redux": "^9.1.2",
|
|
27
|
+
"redux": "^5.0.1",
|
|
28
|
+
"@types/node": "^20.14.12",
|
|
29
|
+
"@types/pubsub-js": "^1.8.6",
|
|
30
|
+
"@types/react": "^18.3.3",
|
|
31
|
+
"@types/react-dom": "^18.3.0",
|
|
32
|
+
"@types/react-redux": "^7.1.33",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
34
|
+
"@typescript-eslint/parser": "^7.17.0",
|
|
35
|
+
"add": "^2.0.6",
|
|
36
|
+
"eslint": "^8.57.0",
|
|
37
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
38
|
+
"eslint-plugin-react-refresh": "^0.4.9",
|
|
39
|
+
"url": "^0.11.3",
|
|
40
|
+
"next": "14.2.5",
|
|
41
|
+
"process": "^0.11.10",
|
|
42
|
+
"sass-loader": "^16.0.0",
|
|
43
|
+
"style-loader": "^4.0.0",
|
|
44
|
+
"url-loader": "^4.1.1",
|
|
45
|
+
"sass": "^1.77.8",
|
|
46
|
+
"postcss-loader": "^8.1.1",
|
|
47
|
+
"webpack": "^5.93.0",
|
|
48
|
+
"webpack-dev-server": "^5.0.4",
|
|
49
|
+
"webpack-merge": "^5.8.0",
|
|
50
|
+
"html-webpack-plugin": "^5.6.0",
|
|
51
|
+
"html-inline-script-webpack-plugin": "^3.2.1",
|
|
52
|
+
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
53
|
+
"css-loader": "^7.1.2",
|
|
54
|
+
"esbuild-loader": "2.21.0",
|
|
55
|
+
"webpack-cli": "^5.1.4"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {}
|
|
58
|
+
}
|
package/project.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "template"
|
|
3
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "template"
|
|
3
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"baseUrl": "./",
|
|
4
|
-
"composite": false,
|
|
5
|
-
"declaration": false,
|
|
6
|
-
"target": "ES2020",
|
|
7
|
-
"useDefineForClassFields": true,
|
|
8
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
9
|
-
"module": "ESNext",
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"moduleResolution": "Bundler",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"moduleDetection": "force",
|
|
15
|
-
"noEmit": false,
|
|
16
|
-
"jsx": "react-jsx",
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": false,
|
|
19
|
-
"noUnusedParameters": false,
|
|
20
|
-
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"paths": {
|
|
22
|
-
"@dobot/*": ["./.dobot/*"]
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"include": ["ui", ".dobot/**/*"]
|
|
26
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "./",
|
|
4
|
+
"composite": false,
|
|
5
|
+
"declaration": false,
|
|
6
|
+
"target": "ES2020",
|
|
7
|
+
"useDefineForClassFields": true,
|
|
8
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
9
|
+
"module": "ESNext",
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"moduleResolution": "Bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": false,
|
|
16
|
+
"jsx": "react-jsx",
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUnusedLocals": false,
|
|
19
|
+
"noUnusedParameters": false,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"paths": {
|
|
22
|
+
"@dobot/*": ["./.dobot/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": ["ui", ".dobot/**/*"]
|
|
26
|
+
}
|
package/ui/Blocks.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function App() {
|
|
2
|
-
return <div className="app">这是点击积木时的弹窗页面</div>
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export default App
|
|
1
|
+
function App() {
|
|
2
|
+
return <div className="app">这是点击积木时的弹窗页面</div>
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default App
|
package/ui/Main.tsx
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { Button } from '@dobot-plus/components'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
import { http, DobotPlusApp } from '@dobot/index'
|
|
4
|
-
|
|
5
|
-
function App() {
|
|
6
|
-
const { t } = useTranslation()
|
|
7
|
-
|
|
8
|
-
function handleButton1Click() {
|
|
9
|
-
http.demoMethod1({})
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function handleButton2Click() {
|
|
13
|
-
http.demoMethod2({})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<div className="app">
|
|
18
|
-
<DobotPlusApp>
|
|
19
|
-
<div>{t('testKey')}</div>
|
|
20
|
-
<Button type="primary" onClick={handleButton1Click}>
|
|
21
|
-
Demo method 1
|
|
22
|
-
</Button>
|
|
23
|
-
<Button type="primary" onClick={handleButton2Click}>
|
|
24
|
-
Demo method 2
|
|
25
|
-
</Button>
|
|
26
|
-
</DobotPlusApp>
|
|
27
|
-
</div>
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default App
|
|
1
|
+
import { Button } from '@dobot-plus/components'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
3
|
+
import { http, DobotPlusApp } from '@dobot/index'
|
|
4
|
+
|
|
5
|
+
function App() {
|
|
6
|
+
const { t } = useTranslation()
|
|
7
|
+
|
|
8
|
+
function handleButton1Click() {
|
|
9
|
+
http.demoMethod1({})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function handleButton2Click() {
|
|
13
|
+
http.demoMethod2({})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="app">
|
|
18
|
+
<DobotPlusApp>
|
|
19
|
+
<div>{t('testKey')}</div>
|
|
20
|
+
<Button type="primary" onClick={handleButton1Click}>
|
|
21
|
+
Demo method 1
|
|
22
|
+
</Button>
|
|
23
|
+
<Button type="primary" onClick={handleButton2Click}>
|
|
24
|
+
Demo method 2
|
|
25
|
+
</Button>
|
|
26
|
+
</DobotPlusApp>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default App
|
package/ui/Toolbar.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function App() {
|
|
2
|
-
return <div className="app">这是导航栏界面</div>
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export default App
|
|
1
|
+
function App() {
|
|
2
|
+
return <div className="app">这是导航栏界面</div>
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export default App
|