@dobot-plus/template 1.2.16 → 1.2.17
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/lua/daemon.lua +6 -0
- package/lua/userAPI.lua +7 -0
- package/package.json +1 -1
package/lua/daemon.lua
CHANGED
|
@@ -9,7 +9,13 @@ local function handleInLoop()
|
|
|
9
9
|
mqtt.publish(data)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
function StopHandler()
|
|
13
|
+
print('program is stopped')
|
|
14
|
+
-- 在这里执行任何需要在程序停止时的操作
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
local function EventLoop()
|
|
18
|
+
RegisteStopHandler('StopHandler')
|
|
13
19
|
while true do
|
|
14
20
|
handleInLoop()
|
|
15
21
|
Wait(1000)
|
package/lua/userAPI.lua
CHANGED
|
@@ -7,6 +7,11 @@ local control = require("control")
|
|
|
7
7
|
|
|
8
8
|
local userApiModule = {}
|
|
9
9
|
|
|
10
|
+
function PauseHandler()
|
|
11
|
+
--- 程序运行暂停时的回调函数
|
|
12
|
+
print(" --- PauseHandler .... --- ")
|
|
13
|
+
end
|
|
14
|
+
|
|
10
15
|
--- This function will be called when you add it in the blockly programming or script programming
|
|
11
16
|
--- This function can be used in the httpAPI module also
|
|
12
17
|
---@param params table
|
|
@@ -35,6 +40,8 @@ end
|
|
|
35
40
|
-- 在脚本编程和积木编程中可以使用 A 来使用该函数
|
|
36
41
|
function userApiModule.OnRegist()
|
|
37
42
|
EcoLog(" --- OnRegist .... --- ")
|
|
43
|
+
--- 程序运行暂停时的回调函数
|
|
44
|
+
RegistePauseHandler('PauseHandler')
|
|
38
45
|
-- 0. 接口导出
|
|
39
46
|
local isErr = ExportFunction("demoMethod1", userApiModule.demoMethod1) or
|
|
40
47
|
ExportFunction("demoMethod2", userApiModule.demoMethod2) or
|