8. API description

8.1. act command

All the following act instructions use POST, and the URL is /action/act.

8.1.1. Save teaching points

Command name: save_point.

Command parameters:

1/**
2* @param  string name The name of the teaching point recorded by string name
3* @param  string speed speed
4* @param  string elbow_speed elbow speed
5* @param  string acc acceleration
6* @param  string elbow_acc elbow acceleration
7* @param  string toolnum Tool number
8* @param  string workpiecenum Workpiece number
9*/

Instruction example:

 1{
 2    cmd: "save_point",
 3    data:{
 4        name: "point1",
 5        speed: "100",
 6        elbow_speed: "100",
 7        acc: "100",
 8        elbow_acc: "100",
 9        toolnum: "1",
10        workpiecenum: "1"
11    }
12}

Command feedback:

1/**
2* @return status:200 "success"
3* @return status:404 "fail"
4*/

8.2. sta command

All the following sta instructions use POST, and the URL is /action/ sta .

8.2.1. Get robot status data

Command name: basic.

Command parameters: none.

Instruction example:

1{
2    cmd: "basic",
3}

Command feedback:

 1/**
 2* @return status:200
 3* @param  object joints joint position
 4* @param  object tcp Descartes pose
 5* @param  array exAxisPos External axis position
 6* @return status:404 "fail"
 7*/
 8{
 9    joints: {
10        j1: "90",
11        j2: "90",
12        j3: "90",
13        j4: "90",
14        j5: "90",
15        j6: "90",
16    },
17    tcp: {
18        x: "100",
19        x: "100",
20        z: "100",
21        rx: "90",
22        ry: "90",
23        rz: "90",
24    },
25    exAxisPos: [0,0,0,0]
26}

8.3. get command

All the following get instructions use POST, and the URL is /action/get.

8.3.1. Get teaching points

Command name: get_points().

Command parameters: none.

Instruction example:

1{
2    cmd: "get_points"
3}

Command feedback:

1/**
2* @return status:200 "success"
3* @param  ${point_name}: object teaching point related information
4* @return status:404 "fail"
5*/

Instruction feedback case:

 1{
 2    "localpoint1": {
 3        "name":"localpoint1",
 4        "elbow_speed":"1",
 5        "elbow_acc":"1",
 6        "x": "1",
 7        "y": "1",
 8        "z": "1",
 9        "rx": "1",
10        "ry": "1",
11        "rz": "1",
12        "j1": "1",
13        "j2": "1",
14        "j3": "1",
15        "j4": "1",
16        "j5": "1",
17        "j6": "1",
18        "toolnum": "1",
19        "workpiecenum": "1",
20        "speed": "1",
21        "acc": "1",
22        "E1": "1",
23        "E2: "1",
24        "E3": "1",
25        "E4": "1"
26    }
27}

8.3.2. Get system configuration

Command name: get_syscfg().

Command parameters: none.

Instruction example:

1{
2    cmd: "get_syscfg"
3}

Command feedback:

1/**
2* @return status:200 "success"
3* @param  string log_count Maximum number of log days recorded
4* @param  string language Currently using language pack
5* @param  string lifespan overtime time
6* * @return status:404 "fail"
7*/

Instruction feedback case:

1{
2    log_count:"10",
3    language:"zh",
4    lifespan:"1800"
5}

8.4. set command

All the following set instructions use POST, and the URL is /action/set.

8.4.1. Issue system variable instructions

Command name: 511.

Command parameters:

1/**
2* @param int index system variable serial number: 1-20
3* @param int value system variable value
4*/

Instruction example:

1{
2    cmd: 511,
3    data:{
4        content:"SetSysVarValue(2,1)"
5    }
6}

Command feedback:

1/**
2* @return status:200 1: represents success, 0: represents
3* @return status:404 "fail"
4*/

Instruction feedback case:

11

8.4.2. Get system variable instructions

Command name: 512.

Command parameters:

1/**
2* @param int index system variable serial number: 1-20
3* /

Instruction example:

1{
2    cmd: 512,
3    data:{
4        content:"GetSysVarValue(2)"
5    }
6}

Command feedback:

1/**
2* @return status:200
3* @param int value system variable value
4* @return status:404 "fail"
5* /

Instruction feedback case:

11

8.5. better-sqlite3 directive

8.5.1. Query the first row of records in the database

Command parameters:

1/**
2* @param string db_name Database name (including absolute path)
3* @param string sql sql statement
4* @return string result The first row of records queried
5*/

Instruction content:

1queryget(string db_name, string sql);

8.5.2. Query all records in the database

Command parameters:

1/**
2* @param string db_name Database name (including absolute path)
3* @param string sql sql statement
4* @return string result All records queried
5*/

Instruction content:

1queryall(string db_name, string sql);

8.5.3. Execute database statements

1/**
2* @param string db_name Database name (including absolute path)
3* @param string sql sql statement
4* @param object obj sql Parameters required for sql statement execution
5* @return \
6*/

Command parameters:

1exec(string db_name, string sql, object obj);

Instruction content:

8.6. socket command

8.6.1. socket send

Command parameters:

1/**
2* @param string send_content socket Socket communication command sends content
3* @return \
4*/

Instruction content:

1socket_cmd.send(string send_content);//8065
2socket_file.send(string send_content);//8067

8.6.2. socket recv

Command parameters:

1/**
2* @return string recv_content socket Socket communication command reply content
3*/

Instruction content:

1socket_cmd.recv();//8065
2socket_file.recv();//8067

8.7. File Operation Commands

8.7.1. Write File Content

1/**
2* @param String filename File path
3* @param string content Content to write
4* @param Function callback Callback function with (error) parameter (not needed for LA version)
5* @return true/false
6*/
7
8write(filename, content, callback);

8.7.2. Read File Content

1/**
2* @param String filename File path
3* @param string content Content to write
4* @param Function callback Callback function with (error) parameter (not needed for LA version)
5* @return String File content
6*/
7
8read(filename, callback);

8.7.3. Modify File Permissions

1/**
2* @param String filename File path
3* @param Number mode Permission mode (e.g. 0644)
4* @param Function callback Callback function with (error) parameter (not needed for LA version)
5* @return true/false
6*/
7
8chmod(filename, mode, callback);

8.7.4. Read Directory Contents (Including Subdirectories)

1/**
2* @param String path File path
3* @param Function callback Callback function with (error) parameter (not needed for LA version)
4* @return Array Filename array
5*/
6
7readdir(path, callback);

8.8. Compression/Decompression Commands

Note

Distinguish between LA and QX versions (LA version doesn’t need callback parameter).

LA module import: var execSync = require(‘child_process’).execSync;

QX module import: var tar_utils = require(‘/usr/local/etc/node/sys/tools/tar_utils’);

8.8.1. Create tar.gz Archive

Create tar.gz example (LA):

1var cmd = 'cd / && tar -zcvf ' + FILENAME + '-C ' + DIR;
2execSync(cmd);

Create tar.gz command description (QX):

1/**
2* @param {Array|String} sourcePaths Source file/directory path array or single path
3* @param String targetFile Target archive path
4* @param Function callback Callback function with (error) parameter (not needed for LA version)
5* @param String basePath Base path, defaults to '/'
6* @return \
7*/
8
9createTarGz(sourcePaths, targetFile, callback, basePath);

8.8.2. Extract tar.gz File

Extract tar.gz example (LA):

1var cmd = 'cd / && tar -zxvf ' + FILENAME;
2execSync(cmd);

Extract tar.gz command description (QX):

1/**
2* @param String sourceFile Source archive path
3* @param String targetDir Target extraction directory
4* @param Function callback Callback function with (error) parameter (not needed for LA version)
5* @return \
6*/
7extractTarGz(sourceFile, targetDir, callback);