@dobot-plus/template 1.0.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.
Files changed (98) hide show
  1. package/.dobot/.sftprc +3 -0
  2. package/.dobot/components/DobotPlusApp.tsx +78 -0
  3. package/.dobot/http/api.json +11 -0
  4. package/.dobot/http/api.ts +26 -0
  5. package/.dobot/http/api.ts.txt +26 -0
  6. package/.dobot/http/axios.ts +52 -0
  7. package/.dobot/http/axios.ts.txt +52 -0
  8. package/.dobot/http/http.ts +22 -0
  9. package/.dobot/http/http.ts.txt +22 -0
  10. package/.dobot/index.ts +2 -0
  11. package/.dobot/index.txt +2 -0
  12. package/.dobot/protocol/keyBoard.ts +18 -0
  13. package/.dobot/protocol/keyBoard.ts.txt +18 -0
  14. package/.dobot/protocol/methodsHandler.ts +15 -0
  15. package/.dobot/protocol/methodsHandler.ts.txt +15 -0
  16. package/.dobot/protocol/postMessageCenter.ts +50 -0
  17. package/.dobot/protocol/postMessageCenter.ts.txt +38 -0
  18. package/.dobot/protocol/postMessageHandler.ts +289 -0
  19. package/.dobot/protocol/postMessageHandler.ts.txt +289 -0
  20. package/.dobot/protocol/websocketHandler.ts +234 -0
  21. package/.dobot/protocol/websocketHandler.ts.txt +234 -0
  22. package/.dobot/shim.d.ts +3 -0
  23. package/.dobot/shim.d.ts.txt +3 -0
  24. package/.dobot/store/actions/toolActions.ts +69 -0
  25. package/.dobot/store/actions/toolActions.ts.txt +69 -0
  26. package/.dobot/store/actions/userMagamentActions.ts +25 -0
  27. package/.dobot/store/actions/userMagamentActions.ts.txt +25 -0
  28. package/.dobot/store/index.ts +7 -0
  29. package/.dobot/store/index.ts.txt +7 -0
  30. package/.dobot/store/reducers/index.ts +8 -0
  31. package/.dobot/store/reducers/index.ts.txt +8 -0
  32. package/.dobot/store/reducers/toolReducer.ts +152 -0
  33. package/.dobot/store/reducers/toolReducer.ts.txt +149 -0
  34. package/.dobot/store/reducers/userMagamentReducer.ts +38 -0
  35. package/.dobot/store/reducers/userMagamentReducer.ts.txt +35 -0
  36. package/.dobot/store/types.ts +240 -0
  37. package/.dobot/store/types.ts.txt +237 -0
  38. package/.dobot/template/default.tsx.mustache +20 -0
  39. package/.dobot/template/entry.css +26 -0
  40. package/.dobot/template/entry.tsx +53 -0
  41. package/.dobot/template/index.html +23 -0
  42. package/.dobot/template/index.scss +5 -0
  43. package/.dobot/utils/i18n.ts +31 -0
  44. package/.dobot/utils/i18n.ts.txt +31 -0
  45. package/.dobot/utils/mqtt.ts +61 -0
  46. package/.dobot/utils/mqtt.ts.txt +61 -0
  47. package/.dobot/utils/rem.js +21 -0
  48. package/.dobot/utils/rem.js.txt +21 -0
  49. package/.dobot/utils/tool.ts +15 -0
  50. package/.dobot/utils/tool.ts.txt +15 -0
  51. package/.eslintrc.cjs +18 -0
  52. package/.luarc.json +17 -0
  53. package/.vscode/Api.schema.json +103 -0
  54. package/.vscode/Blocks.schema.json +94 -0
  55. package/.vscode/Main.schema.json +42 -0
  56. package/.vscode/Script.schema.json +22 -0
  57. package/.vscode/Toolbar.schema.json +19 -0
  58. package/.vscode/extensions.json +8 -0
  59. package/.vscode/settings.json +52 -0
  60. package/Resources/document/config.json +0 -0
  61. package/Resources/i18n/client/de.json +11 -0
  62. package/Resources/i18n/client/en.json +11 -0
  63. package/Resources/i18n/client/es.json +11 -0
  64. package/Resources/i18n/client/hk.json +11 -0
  65. package/Resources/i18n/client/ja.json +11 -0
  66. package/Resources/i18n/client/ko.json +11 -0
  67. package/Resources/i18n/client/ru.json +11 -0
  68. package/Resources/i18n/client/zh.json +11 -0
  69. package/Resources/i18n/plugin/de.json +3 -0
  70. package/Resources/i18n/plugin/en.json +3 -0
  71. package/Resources/i18n/plugin/es.json +3 -0
  72. package/Resources/i18n/plugin/hk.json +3 -0
  73. package/Resources/i18n/plugin/ja.json +3 -0
  74. package/Resources/i18n/plugin/ko.json +3 -0
  75. package/Resources/i18n/plugin/ru.json +3 -0
  76. package/Resources/i18n/plugin/zh.json +3 -0
  77. package/Resources/images/pallet.svg +1 -0
  78. package/configs/Blocks.json +21 -0
  79. package/configs/Main.json +5 -0
  80. package/configs/Scripts.json +7 -0
  81. package/configs/Toolbar.json +5 -0
  82. package/dpt.json +4 -0
  83. package/lua/control.lua +19 -0
  84. package/lua/daemon.lua +22 -0
  85. package/lua/httpAPI.lua +65 -0
  86. package/lua/userAPI.lua +51 -0
  87. package/lua/utils/await485.lua +55 -0
  88. package/lua/utils/mqtt.lua +17 -0
  89. package/lua/utils/num_convert.lua +41 -0
  90. package/lua/utils/tcp.lua +31 -0
  91. package/lua/utils/util.lua +31 -0
  92. package/lua/utils/variables.lua +0 -0
  93. package/package.json +51 -0
  94. package/project.json +3 -0
  95. package/tsconfig.json +27 -0
  96. package/ui/Blocks.tsx +5 -0
  97. package/ui/Main.tsx +31 -0
  98. package/ui/Toolbar.tsx +5 -0
@@ -0,0 +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 }
31
+ end
@@ -0,0 +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
31
+ end
File without changes
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@dobot-plus/template",
3
+ "version": "1.0.0",
4
+ "engines": {
5
+ "node": "20"
6
+ },
7
+ "scripts": {
8
+ "dev": "dpt dev",
9
+ "build": "dpt build"
10
+ },
11
+ "dependencies": {
12
+ "@dobot-plus/components": "latest",
13
+ "antd": "^5.22.3",
14
+ "axios": "^1.3.3",
15
+ "i18next": "^23.12.2",
16
+ "keyboard-link": "^0.2.3",
17
+ "mqtt": "5.1.3",
18
+ "pubsub-js": "^1.9.3",
19
+ "react": "^18.3.1",
20
+ "react-dom": "^18.3.1",
21
+ "react-i18next": "^15.0.0",
22
+ "react-redux": "^9.1.2",
23
+ "redux": "^5.0.1"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.14.12",
27
+ "@types/pubsub-js": "^1.8.6",
28
+ "@types/react": "^18.3.3",
29
+ "@types/react-dom": "^18.3.0",
30
+ "@types/react-redux": "^7.1.33",
31
+ "@typescript-eslint/eslint-plugin": "^7.17.0",
32
+ "@typescript-eslint/parser": "^7.17.0",
33
+ "add": "^2.0.6",
34
+ "css-loader": "^7.1.2",
35
+ "eslint": "^8.57.0",
36
+ "eslint-plugin-react-hooks": "^4.6.2",
37
+ "eslint-plugin-react-refresh": "^0.4.9",
38
+ "postcss-loader": "^8.1.1",
39
+ "sass": "^1.77.8",
40
+ "sass-loader": "^16.0.0",
41
+ "style-loader": "^4.0.0",
42
+ "ts-loader": "^9.5.1",
43
+ "typescript": "^5.5.4",
44
+ "url-loader": "^4.1.1",
45
+ "webpack": "^5.93.0",
46
+ "url": "^0.11.3"
47
+ },
48
+ "peerDependencies": {
49
+ "process": "^0.11.10"
50
+ }
51
+ }
package/project.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "@dobot-plus/template"
3
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
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
+ "@dobot-plus/components": ["./node_modules/@dobot-plus/components"]
24
+ }
25
+ },
26
+ "include": ["ui", ".dobot/**/*"]
27
+ }
package/ui/Blocks.tsx ADDED
@@ -0,0 +1,5 @@
1
+ function App() {
2
+ return <div className="app">这是点击积木时的弹窗页面</div>
3
+ }
4
+
5
+ export default App
package/ui/Main.tsx ADDED
@@ -0,0 +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
package/ui/Toolbar.tsx ADDED
@@ -0,0 +1,5 @@
1
+ function App() {
2
+ return <div className="app">这是导航栏界面</div>
3
+ }
4
+
5
+ export default App