10. WebAPP program use

10.1. Setting the default job program to load automatically on boot

Prototype

LoadDefaultProgConfig(flag,program_name)

Description

Sets the default job program to be automatically loaded on boot

Required parameters

  • flag: 1-automatically load the default program on power-up, 0-don’t automatically load the default program

  • program_name: the name of the job program and its path, e.g. “/fruser/movej.lua”, where /fruser/ is the fixed path for QX, and /usr/local/etc/controller/lua/ is the fixed path for LA

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.2. Load the specified job program

Prototype

ProgramLoad(program_name)

Description

Load the specified job program.

Mandatory parameters

  • program_name: name of the job program and path, e.g. “/fruser/movej.lua”, where /fruser/ is the fixed path for QX, and /usr/local/etc/controller/lua/ is the fixed path for LA

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.3. Get the name of the loaded job program

Prototype

GetLoadedProgram()

Description

Get the name of the loaded job program

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • program_name: the name of the loaded operating program.

10.4. Get the line number of the current robot job program

Prototype

GetCurrentLine()

Description

Get the execution line number of the current robot job program

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • line_num: the line number of the current robot job program execution

10.5. Run the currently loaded job program

Prototype

ProgramRun()

Description

Run the currently loaded job program

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.6. Suspend the currently running job program

Prototype

ProgramPause()

Description

Suspend the currently running job program.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.7. Resuming a currently suspended program

Prototype

ProgramResume()

Description

Resume the currently suspended job program

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.8. Terminate the currently running job program

Prototype

ProgramStop()

Description

Terminate the currently running job program.

Mandatory parameters

NULL

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.9. Obtaining robot job program execution status

Prototype

GetProgramState()

Description

Get robot job program execution status

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • state: state of execution of the robot’s operating program, 1 - program stopped or no program running, 2 - program running, 3 - program suspended

10.10. Robot LUA program operation code example

 1from fairino import Robot
 2import time
 3# Establish a connection with the robot controller and return a robot object if the connection is successful
 4robot = Robot.RPC('192.168.58.2')
 5program_name = "/fruser/test0610.lua"
 6loaded_name = ""
 7state = 0
 8line = 0
 9robot.Mode(0)
10robot.LoadDefaultProgConfig(0, program_name)
11robot.ProgramLoad(program_name)
12robot.ProgramRun()
13time.sleep(1)
14robot.ProgramPause()
15error,state = robot.GetProgramState()
16print(f"program state:{state}")
17error,line = robot.GetCurrentLine()
18print(f"current line:{line}")
19error,loaded_name = robot.GetLoadedProgram()
20print(f"program name:{loaded_name}")
21time.sleep(1)
22robot.ProgramResume()
23time.sleep(1)
24robot.ProgramStop()
25time.sleep(1)
26robot.CloseRPC()

10.11. Download Lua files

New in version python: SDK-v2.0.2

Prototype

LuaDownLoad(fileName, savePath)

Description

Download Lua File

Mandatory parameter

  • fileName: the name of the lua file to be downloaded, e.g. “test.lua”

  • savePath: the local path to save the file

e.g. “D://Down/””

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.12. Deleting Lua files

New in version python: SDK-v2.0.2

Prototype

LuaDelete(fileName)

Description

Deleting Lua files.

Required Parameters

  • fileName: the name of the lua file to be deleted, “test.lua”

Default parameters

NULL

Return Value

Error Code Success-0 Failure- errcode

10.13. Get the names of all current lua files

New in version python: SDK-v2.0.2

Prototype

GetLuaList()

Description

Get the names of all current lua files

Mandatory parameters

NULL

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • lua_num: number of lua files

  • luaNames: list of lua file names

10.14. Uploading Lua files

New in version python: SDK-v2.0.2

Prototype

LuaUpload(filePath)

Description

Uploading a Lua file

Mandatory parameter

  • filePath: full path name of the uploaded file e.g. D://test/test.lua

Default parameters

NULL

Return Value

  • errorcode Success-0 Failure- errcode

  • errorStr(lua file exists error returned)

10.15. Robot LUA file upload and download code examples

 1from fairino import Robot
 2# Establish a connection with the robot controller and return a robot object if the connection is successful
 3robot = Robot.RPC('192.168.58.2')
 4rtn,lua_num,luaNames = robot.GetLuaList()
 5print(f"res is:{rtn}")
 6print(f"size is:{lua_num}")
 7for name in luaNames:
 8    print(name)
 9rtn = robot.LuaDownLoad("test0610.lua", "D://zDOWN/")
10print(f"LuaDownLoad rtn is:{rtn}")
11rtn = robot.LuaUpload("D://zDOWN/test0610.lua")
12print(f"LuaUpload rtn is:{rtn}")
13rtn = robot.LuaDelete("test0610.lua")
14print(f"LuaDelete rtn is:{rtn}")
15robot.CloseRPC()