@dobot-plus/template 1.2.16 → 1.3.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/lua/control.lua CHANGED
@@ -1,19 +1,19 @@
1
- --- @module control
1
+ --- @module $PLUGIN_NAME$
2
2
  --- @description This is the control module for the plugin.
3
3
  --- 该模块为插件的功能模块,用于实现各种控制功能。
4
4
 
5
- local control = {}
5
+ local $PLUGIN_NAME$ = {}
6
6
 
7
- control.controlMethod1 = function(params)
7
+ $PLUGIN_NAME$.controlMethod1 = function(params)
8
8
  -- TODO 实现函数逻辑
9
9
  end
10
10
 
11
- control.controlMethod2 = function(params)
11
+ $PLUGIN_NAME$.controlMethod2 = function(params)
12
12
  -- TODO 实现函数逻辑
13
13
  end
14
14
 
15
- control.controlMethod3 = function(params)
15
+ $PLUGIN_NAME$.controlMethod3 = function(params)
16
16
  -- TODO 实现函数逻辑
17
17
  end
18
18
 
19
- return control
19
+ return $PLUGIN_NAME$
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/httpAPI.lua CHANGED
@@ -2,7 +2,7 @@
2
2
  --- @description This is the http module for the plugin.
3
3
  --- 该模块为控制器处理插件的 http 请求提供接口
4
4
 
5
- local control = require("control")
5
+ local $PLUGIN_NAME$ = require("$PLUGIN_NAME$")
6
6
 
7
7
  local httpModule = {}
8
8
 
@@ -32,7 +32,7 @@ end
32
32
  --- 该方法会在http请求接收到后,自动执行,对应请求的 url为: http://<控制器ip>:<插件端口>/dobotPlus/[插件名]_[插件版本]/demoMethod1。
33
33
  httpModule.demoMethod1 = function(params)
34
34
  -- TODO 需要在接收到http请求后执行的操作
35
- control.controlMethod1(params)
35
+ $PLUGIN_NAME$.controlMethod1(params)
36
36
  return {
37
37
  --- Your responce data
38
38
  status = true
@@ -44,7 +44,7 @@ end
44
44
  --- @param params table
45
45
  --- @return string
46
46
  httpModule.demoMethod2 = function(params)
47
- control.controlMethod2(params)
47
+ $PLUGIN_NAME$.controlMethod2(params)
48
48
  return {
49
49
  --- Your responce data
50
50
  status = true
@@ -56,7 +56,7 @@ end
56
56
  --- @param params table
57
57
  --- @return string The return value will response the http request, the return value is not necessory
58
58
  httpModule.demoMethod3 = function(params)
59
- control.controlMethod3(params)
59
+ $PLUGIN_NAME$.controlMethod3(params)
60
60
  return {
61
61
  --- Your responce data
62
62
  status = true
package/lua/userAPI.lua CHANGED
@@ -3,29 +3,34 @@
3
3
  --- 该模块为脚本编程和积木编程提供插件接口
4
4
 
5
5
  require("utils.await485")
6
- local control = require("control")
6
+ local $PLUGIN_NAME$ = require("$PLUGIN_NAME$")
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
13
18
  function userApiModule.demoMethod1(params)
14
- return control.controlMethod1(params)
19
+ return $PLUGIN_NAME$.controlMethod1(params)
15
20
  end
16
21
 
17
22
  --- This function will be called when you add it in the blockly programming or script programming
18
23
  --- This function can be used in the httpAPI module also
19
24
  ---@param params table
20
25
  function userApiModule.demoMethod2(params)
21
- return control.controlMethod2(params)
26
+ return $PLUGIN_NAME$.controlMethod2(params)
22
27
  end
23
28
 
24
29
  --- This function will be called when you add it in the blockly programming or script programming
25
30
  --- This function can be used in the httpAPI module also
26
31
  ---@param params table
27
32
  function userApiModule.demoMethod3(params)
28
- return control.controlMethod3(params)
33
+ return $PLUGIN_NAME$.controlMethod3(params)
29
34
  end
30
35
 
31
36
  -- This function will be called when the plugin is installed
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dobot-plus/template",
3
- "version": "1.2.16",
3
+ "version": "1.3.0",
4
4
  "engines": {
5
5
  "node": "20"
6
6
  },