10. The use of robot WebAPP programs

10.1. Set the default job program to be automatically loaded upon startup

1/ * *
2* @brief set the default job program to be automatically loaded upon startup
3* @param [in] flag 0- Default programs are not automatically loaded upon startup, 1- Default programs are automatically loaded upon startup
4* @param [in] program_name job program name and path, such as "/fruser/movej.lua", where "/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(byte flag, string program_name);

10.2. Load the specified job program

1/ * *
2* @brief Load the specified job program
3* @param [in] program_name job program name and path, such as "/fruser/movej.lua", where "/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 the name of the loaded job program

1/ * *
2* @brief Get the name of the loaded job program
3* @param [out] program_name job program name and path, such as "/fruser/movej.lua", where "/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(ref string program_name);

10.4. Obtain the execution line number of the current robot operation program

1/ * *
2* @brief get the line number of the current robot job program being executed
3* @param [out] line number
4* @return error code
5* /
6int GetCurrentLine(ref int line);

10.5. Run the currently loaded job program

1/ * *
2* @brief run the currently loaded job program
3* @return error code
4* /
5int ProgramRun();

10.6. Pause the currently running job program

1/ * *
2* @brief Suspend the currently running job program
3* @return error code
4* /
5int ProgramPause();

10.7. Resume the currently suspended job procedure

1/ * *
2* @brief Resume the currently suspended operation procedure
3* @return error code
4* /
5int ProgramResume();

10.8. Terminate the currently running job program

1/ * *
2* @brief Terminate the currently running job program
3* @return error code
4* /
5int ProgramStop();

10.9. Obtain the execution status of the robot’s operation program

1/ * *
2* @brief Get the execution status of the robot operation program
3* @param [out] state 1- The program stops or no program runs, 2- the program is running, 3- the program is paused
4* @return error code
5* /
6int GetProgramState(ref byte state);

10.10. Example of robot LUA program operation code

 1private void btnWebApp_Click(object sender, EventArgs e)
 2{
 3    string program_name = "/fruser/Text1.lua";
 4    string loaded_name = "";
 5    byte state=0;
 6    int line=0;
 7
 8    robot.Mode(0);
 9    robot.LoadDefaultProgConfig(0, program_name);
10    robot.ProgramLoad(program_name);
11    robot.ProgramRun();
12    Thread.Sleep(1000);
13    robot.ProgramPause();
14    robot.GetProgramState(ref state);
15    Console.WriteLine("program state:{0}\n", state);
16    robot.GetCurrentLine(ref line);
17    Console.WriteLine("current line:{0}\n", line);
18    robot.GetLoadedProgram(ref loaded_name);
19    Console.WriteLine("program name:{0}\n", loaded_name);
20    Thread.Sleep(1000);
21    robot.ProgramResume();
22    Thread.Sleep(1000);
23    robot.ProgramStop();
24    Thread.Sleep(1000);
25}

10.11. Download the Lua file

New in version C#SDK-v1.0.5.

1/ * *
2* @brief Download Lua files
3* @param [in] fileName The job program to be downloaded is "test.lua" or "test.tar.gz"
4* @param [in] savePath save the local path of the job program "D://Down/"
5* @return error code
6* /
7int LuaDownLoad(string fileName, string savePath);

10.12. Upload the Lua file

New in version C#SDK-v1.0.5.

1/ * *
2* @brief Upload the Lua file
3* @param [in] filePath local job path name "... /test.lua" or "... /test.tar.gz"
4* @param [out] errStr error message
5* @return error code
6* /
7int LuaUpload(string filePath, ref string errStr);

10.13. Delete the Lua file

New in version C#SDK-v1.0.5.

1/ * *
2* @brief Delete the Lua file
3* @param [in] fileName Name of the job program to be deleted "test.lua"
4* @return error code
5* /
6int LuaDelete(string fileName);

10.14. Get the names of all current lua files

New in version C#SDK-v1.0.5.

1/ * *
2* @brief Get the names of all current lua files
3* @param [out] luaNames list of job program names
4* @return error code
5* /
6int GetLuaList(ref List<string> luaNames) ;

10.15. Code example for uploading and downloading robot LUA files

New in version C#SDK-v1.0.5.

 1private void btnUploadLua_Click(object sender, EventArgs e)
 2{
 3    int rtn;
 4    List<string> luaNames = new List<string>();
 5    rtn = robot.GetLuaList(ref luaNames);
 6    Console.WriteLine("res is: {0}", rtn);
 7    Console.WriteLine("size is: {0}", luaNames.Count);
 8    foreach (var name in luaNames)
 9    {
10    Console.WriteLine(name);
11    }
12    rtn = robot.LuaDownLoad("TT.lua", "D://zDOWN/");
13    Console.WriteLine("LuaDownLoad rtn is {0}", rtn);
14    string errStr = "";
15    Thread.Sleep(2000);
16
17    rtn = robot.LuaUpload("D://zUP/airlab.lua", ref errStr);
18    Console.WriteLine("LuaUpload rtn is {0}", errStr);
19    Thread.Sleep(2000);
20    rtn = robot.LuaDelete("TT.lua");
21    Console.WriteLine("LuaDelete rtn is {0}", rtn);
22}