run_blockly

1. Introduction

Initialize the parameter of the robot before running the Blockly project.

2. Request & Response

{
    "cmd": "run_blockly",
    "data": {
        "userId":"test",
        "version":"850",
        "category":"myapp",
        "appName":"/laohua"
    },
    "id": "1"
}

3. Code Example

background

user_id = data.get('userId', 'test')
xarm_version = data.get('version', GLOBAL.XArm.xarm_type)
category = data.get('category', 'myapp')
app_name = data.get('appName', '')
app_name = convert_path(app_name)
path = os.path.join(projects_path, user_id, xarm_version, 'app', category, app_name)
check_is_pause = GLOBAL.XArm.xarm._arm._check_is_pause
check_cmdnum_limit = GLOBAL.XArm.xarm._arm._check_cmdnum_limit
try:
    GLOBAL.XArm.xarm._arm._check_is_pause = True
    GLOBAL.XArm.xarm._arm._check_cmdnum_limit = True
    logger.info('start run blockly')
    GLOBAL.Connect.blockly_task_client = client
    code = yield self._run_blockly(path, client, cmd_id)
    logger.info('run blockly finish, code={}'.format(code))
except:
    code = 1
finally:
    GLOBAL.XArm.xarm._arm._check_is_pause = check_is_pause
    GLOBAL.XArm.xarm._arm._check_cmdnum_limit = check_cmdnum_limit
    GLOBAL.Connect.blockly_task_client = None
if client:
    response(client, cmd_id, code)
else:
    return code

front_end

self.runBlockly = (name, callback) => {
  const params = window.GlobalConstant.INIT_CMD_PARAMS_COMMON_DATA();
  Object.assign(params.data, {
    category: 'myapp', // 'myapp',
    appName: name,
  });
  window.GlobalUtil.model.localAppsMgr.taskId = self.sendCmd(window.GlobalConstant.RUN_BLOCKLY, params, (dict) => {
    if (callback) {
      callback(dict);
    }
  })
};

Last updated