10. Robot WebAPP program usage
10.1. Set default program to load automatically on startup
1/**
2* @brief Set default program to load automatically on startup
3* @param [in] flag 0-Do not load default program automatically, 1-Load default program automatically
4* @param [in] program_name Program name and path, e.g., "/fruser/movej.lua" ("/fruser/" is the fixed path for QX, and "/usr/local/etc/controller/lua/" is the fixed path for LA)
5* @return Error code
6*/
7int LoadDefaultProgConfig(int flag, String program_name);
10.2. Load specified program
1/**
2* @brief Load specified program
3* @param [in] program_name Program name and path, e.g., "/fruser/movej.lua" ("/fruser/" is the fixed path for QX, and "/usr/local/etc/controller/lua/" is the fixed path for LA)
4* @return Error code
5*/
6int ProgramLoad(String program_name);
10.3. Get loaded program name
1/**
2* @brief Get loaded program name
3* @param [out] program_name program_name[0]: Program name and path, e.g., "/fruser/movej.lua" ("/fruser/" is the fixed path for QX, and "/usr/local/etc/controller/lua/" is the fixed path for LA)
4* @return Error code
5*/
6int GetLoadedProgram(String[] program_name);
10.4. Get current program execution line number
1/**
2* @brief Get current program execution line number
3* @param [out] List[0]: Error code; List[1]: int line - Line number
4* @return Error code
5*/
6List<Integer> GetCurrentLine();
10.5. Run currently loaded program
1/**
2* @brief Run currently loaded program
3* @return Error code
4*/
5int ProgramRun();
10.6. Pause current running program
1/**
2* @brief Pause current running program
3* @return Error code
4*/
5int PauseMotion();
10.7. Resume paused program
1/**
2* @brief Resume paused program
3* @return Error code
4*/
5int ResumeMotion();
10.8. Stop current running program
1/**
2* @brief Stop current running program
3* @return Error code
4*/
5int StopMotion();
10.9. Get robot program execution state
1/**
2* @brief Get robot program execution state
3* @param [out] state 1-Program stopped/no program running, 2-Program running, 3-Program paused
4* @return Error code
5*/
6public int GetProgramState(int[] state)
10.10. Robot LUA program operation code example
1public static int TestLuaOp(Robot robot)
2{
3 String program_name = "/fruser/Text1.lua";
4 String[] loaded_name = new String[]{""};
5 int[] state=new int[]{0};
6 List<Integer> line=new ArrayList<>();
7
8 robot.Mode(0);
9 robot.LoadDefaultProgConfig(0, program_name);
10 robot.ProgramLoad(program_name);
11 robot.ProgramRun();
12 robot.Sleep(1000);
13 robot.ProgramPause();
14 robot.GetProgramState(state);
15 System.out.println("program state:"+ state[0]);
16 line=robot.GetCurrentLine();
17 System.out.println("current line:"+ line);
18 robot.GetLoadedProgram(loaded_name);
19 System.out.println("program name:"+ loaded_name[0]);
20 robot.Sleep(1000);
21 robot.ProgramResume();
22 robot.Sleep(1000);
23 robot.ProgramStop();
24 robot.Sleep(1000);
25
26 robot.CloseRPC();
27 return 0;
28}
10.11. Download Lua program
1/**
2* @brief Download program
3* @param [in] fileName Lua file name to download ("test.lua" or "test.tar.gz")
4* @param [in] savePath Local save path ("D://Down/")
5* @return Error code
6*/
7int LuaDownLoad(String fileName, String savePath);
10.12. Delete Lua program
1/**
2* @brief Delete program
3* @param [in] fileName Program name to delete ("test.lua")
4* @return Error code
5*/
6int LuaDelete(String fileName);
10.13. Get all current Lua file names
1/**
2* @brief Get all current Lua file names
3* @param [out] luaNames Program name list
4* @return Error code
5*/
6int GetLuaList(List<String> luaNames);
10.14. Upload Lua program
1/**
2* @brief Upload program
3* @param [in] filePath Local Lua file path (".../test.lua" or ".../test.tar.gz")
4* @param [out] errStr Error message
5* @return Error code
6*/
7int LuaUpload(String filePath, String errStr);
10.15. Robot LUA file upload/download code example
1public static int TestLUAUpDownLoad(Robot robot)
2{
3 List<String> luaNames=new ArrayList<>();
4 int rtn = robot.GetLuaList(luaNames);
5 System.out.println("res is: "+rtn);
6 System.out.println("size is: "+luaNames.size());
7 for (int it =1; it < luaNames.size(); it++)
8 {
9 System.out.println(luaNames.get(it));
10 }
11
12 rtn = robot.LuaDownLoad("test.lua", "D://zDOWN/");
13 System.out.println("LuaDownLoad rtn is:"+rtn);
14
15 rtn = robot.LuaUpload("D://zUP/XG.lua","");
16 System.out.println("LuaUpload rtn is:"+ rtn);
17
18 rtn = robot.LuaDelete("XG.lua");
19 System.out.println("LuaDelete rtn is:"+ rtn);
20
21 return 0;
22}