Get Interface

You are currently viewing the documentation for the latest version (2.1.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Get Steps Used in the Current Mech-Viz Project

The function to get Steps used in the current Mech-Viz project is as follows.

def get_viz_task_names(self, msg={}, timeout=None):
    result = self.call_viz("getAllTaskNames", msg, timeout)
    logging.info("Property result: {}".format(json.loads(result)))
    return result

After get_viz_task_names() is called, a string in JSON format that represents all obtained Steps will be returned.

Get Parameters in Mech-Viz or Mech-Vision Project

The function to get parameters in Mech-Viz or Mech-Vision project is as follows.

def get_property_info(self, msg={}, get_viz=True, timeout=None):
    result = (self.call_viz if get_viz else self.call_vision)("getPropertyInfo", msg, timeout)
    logging.info("{0} property result: {1}".format("Viz" if get_viz else "Vision", json.loads(result)))
    return result

When the function is called with no “type” specified for the “msg” parameter, all parameters will be obtained. If a certain type is specified, only parameters of the corresponding Step will be obtained. For example, after get_property_info(msg={"type": "move"}) is called, a string in JSON format that represents parameters of the Fixed-Point Move Step will be returned.

Get Running Status of Mech-Vision or Mech-Viz Project

The on_exec_status_changed() function in the Adapter class obtains the running status of the Mech-Vision or Mech-Viz project. Each time the Mech-Vision or Mech-Viz project stops running, the running status is sent to Adapter by using the on_exec_status_changed() function. As such, the on_exec_status_changed() function is called after the Mech-Vision or Mech-Viz project stops running. The code snippet to call the on_exec_status_changed() function is as follows.

def on_exec_status_changed(self, req_dict, err_dict=None):
    project_dir = req_dict.get(jk.project_dir, "")
    source_app = req_dict.get(jk.source_app, "")
    exit_info = req_dict.get(jk.exit_info, {})
    error_code = exit_info.get(jk.error_code, "")
    msg = exit_info.get(jk.msg, "")
    project_dict = self.get_vision_projects_dict()
    if source_app == jk.mech_vision and project_dir in project_dict.values():
        project_num = list(project_dict.keys())[list(project_dict.values()).index(project_dir)]
    elif source_app == jk.mech_viz:
        project_num = 0
    else:
        return
    self.err_dict[project_num] = [error_code, msg] if error_code and error_code[-4:] != "0000" else None
    if err_dict:
        err_dict[project_num] = [error_code, msg] if error_code and error_code[-4:] != "0000" else None

The table below explains the variables used in the above code snippet.

Variable name Description

jk.project_dir

The path of the project.

jk.source_app

The source of the status. The value can be Mech-Vision or Mech-Viz.

jk.exit_info

The software exit information. The data type is DICTIONARY.

jk.error_code

The status code.

jk.msg

The detailed information corresponding to the status code.

project_dict

The project information. The data type is DICTIONARY. For example, {1:"simulate_vis"} indicates that the ID of the Mech-Vision project is 1 and the name of the project is simulate_vis.

0 indicates that the project is a Mech-Viz project.

Status codes (indicated by jk.error_code) can be divided into two categories: Mech-Vision status codes and Mech-Viz status codes, as shown in the figure below.

Category Status code Brief info

Mech-Vision status codes

CV-EXXXX

VISION_RUN_ERROR

CV-E0201

VISION_CAMERA_CONNECT_FAIL

CV-E0401

VISION_RECIPE_NOT_SET

CV-E0403

VISION_RECP_NUM_OUT_RANGE

MP-EXXXX

VISION_PLANNER_RUN_ERROR

MP-E0001

VISION_PLANNER_PLAN_FAILED

MP-E0005

VISION_PLANNER_NOT_REACHABLE

MP-E0008

VISION_PLANNER_SINGULARITY

MP-E0011

VISION_PLANNER_COLLISION

MP-E0019

VISION_PLANNER_NO_TARGET_IN_VISUALMOVE

MP-E0021

VISION_PLANNER_VISION_SERVER_NOT_REGISTED

MP-E0022

VISION_PLANNER_SET_TOOL_INVALID

Mech-Viz status codes

MP-EXXXX

VIZ_RUN_ERROR

MP-E0001

VIZ_PLAN_FAILED

MP-E0005

VIZ_NOT_REACHABLE

MP-E0008

VIZ_SINGULARITY

MP-E0011

VIZ_COLLISION

MP-E0016

VIZ_VISION_NO_RESULT

MP-E0017

VIZ_VISION_NOT_CALLED

MP-E0018

VIZ_VISION_NO_CLOUD_IN_ROI

MP-E0019

VIZ_NO_TARGET_IN_VISUALMOVE

MP-E0020

VIZ_VISION_REUSE_PLAN_FAILED

MP-E0021

VIZ_VISION_SERVER_NOT_REGISTED

MP-E0022

VIZ_SET_TOOL_INVALID

MP-E0023

VIZ_BRANCH_OUTPORT_ERROR

In addition, you can inherit the on_exec_status_changed() function to process self.err_dict. Sample code snippet:

def on_exec_status_changed(self, req_dict, err_dict=None):
    super().on_exec_status_changed(req_dict, err_dict)
    err_list = self.err_dict.get(0, [])
    if err_list and err_list[0] not in ["MP-E0020"]:
        self.handle_viz_error()

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.