API Reference
Access patterns:
- Data and robot:
xplugin::xPluginInterface()->InterfaceManager - Events:
xplugin::xPluginEvent()->XPluginEventSystem - RL instructions: stack or member
xplugin::RLManager
1. Base Library
1.1 Registration and Lifecycle
| Symbol | Description |
|---|---|
| XPLUGIN_REGISTER(KEY, CLASS_NAME) | Plugin registration; KEY must match PLUGIN_NAME and deployment directory name |
| xPluginFactory() | Global PluginRegister singleton |
| PluginBase | User plugin base class; override init / afterInit / render / idle / detach |
| setDefaultGlobalSheet(bool) | Set whether to use global stylesheet in constructor |
| setPluginLabel(const QString &) | Set plugin display label in constructor |
1.2 Enumerations
| Enum | Values | Purpose |
|---|---|---|
| enLanguage | English=0, Chinese=1, OtherLanguage=0xFF | Language type (translation via Qt .qm; no RegistLanguage export API) |
| enThrowLogLevel | Info, Warning, Error, NoneLogType | ThrowLog popup level |
2. Global Functions
| Function | Return | Description |
|---|---|---|
| GetPluginVersion() | QString | Four-part version; current 1.0.2.6 |
| CreateCenterWidget(pluginName, widget) | int | Register center main view; 0 success, -1 plugin name, -2 not initialized |
| CreateStatusBar(pluginName, widget, index=1) | int | Bottom status bar slot |
| CreateRightExpandWidgte(pluginName, widget, name="") | int | Right-side persistent expand panel |
| SwitchRightExpandWidgte(pluginName="", name="") | int | Switch expand panel; empty name closes |
| CreatePhyButtonList(pluginName, type, left, right, center_texts) | int | Physical key layout |
| ChangePhyButtonStatus(pluginName, type, enable) | int | Enable/disable physical keys |
| ChangeModelWindowStatus(pluginName, status) | int | Modal state; controls whether physical keys respond |
| ChangeFullScreen(pluginName, isFull) | int | Fullscreen |
| GetRightExpandSideBar(QWidget **out) | int | Get right expand sidebar pointer |
| ThrowLog(pluginName, level, msg) | int | Bottom-right notification |
| GetPluginDataPath(dataPath, pluginName) | int | Get plugin data storage path |
PhysicalButton
| Field | Type | Description |
|---|---|---|
| text | QString | Display text |
| touched_icon / untouched_icon | QString | Pressed/released icon paths |
| exec_function | std::function<void(bool)> | Press callback; true = pressed |
3. Interface Functions
- Obtained via
xPluginInterface(). Unless noted, call on the UI thread.
3.1 Signals
| Signal | Description |
|---|---|
| sigNetworkConnect() | Controller network connected |
| sigNetworkDisConnect(bool status) | Controller network disconnected; status: true = active disconnect |
3.2 commandCustomData (Controller Plugin Communication)
/*
* Description: Communicate with controller plugin (get custom data key)
* Parameter 1 obj: QObject performing the operation
* Parameter 2 pluginName: Controller plugin name
* Parameter 3 key: Controller plugin data key
* Return QJsonArray: Controller plugin data structure
*/
QJsonArray commandCustomData(QObject *obj, const QString &pluginName, const QString &key, const QString &val);
/*
* Description: Communicate with controller plugin (set custom data key)
* Parameter 1 obj: QObject performing the operation
* Parameter 2 pluginName: Controller plugin name
* Parameter 3 key: Controller plugin data key
* Parameter 4 val: Target value for key
* Return QJsonArray: Controller plugin data structure
*/
QJsonArray commandCustomData(QObject *obj, const QString &pluginName, const QString &key, const QString &val);
/*
* Description: Communicate with controller plugin (custom data structure)
* Parameter 1 obj: QObject performing the operation
* Parameter 2 pluginName: Plugin name
* Parameter 3 json: Custom data structure
* Return QJsonArray: Controller plugin data structure
*/
QJsonArray commandCustomData(QObject *obj, const QString &pluginName, const QJsonObject& json);
/*
* Description: Communicate with controller plugin (custom data structure)
* Parameter 1 obj: QObject performing the operation
* Parameter 2 json: Custom data structure (with plugin name)
* Return QJsonArray: Controller plugin data structure
*/
QJsonArray commandCustomData(QObject *obj, const QJsonObject& json);
/*
* Description: Communicate with controller plugin (custom data structure)
* Parameter 1 obj: QObject performing the operation
* Parameter 2 arr: Json array of custom data structures
* Return QJsonArray: Controller plugin data structure
*/
QJsonArray commandCustomData(QObject *obj, const QJsonArray& arr);
3.3 xservice
| Method | Return | Description |
|---|---|---|
| getNodeData(key) | QJsonValue | Get node data |
| getXServiceData(key) | QJsonValue | Read node data |
| getXServiceData(key, subKey) | QJsonValue | Read node data |
| setXServiceData(key, var) | bool | Set data (sync) |
| setXServiceData(key, subKey, var) | bool | Set data (sync) |
| commandXServiceData(key, var) | bool | Set data (async command) |
| execCommandXServiceData(key, var) | QJsonValue | Set data (sync command) |
| connectXServiceData(pluginName, serviceKey, callback, key="") | bool | Subscribe to changes |
| disconnectXServiceData(pluginName, serviceKey, key="") | bool | Unsubscribe |
3.4 RC
| Method | Description |
|---|---|
| rcRequest(module, command, data, timeout=4800) | Async request; default timeout 4800 ms |
| rcRequestFullCommand(full_command, request_val, timeout=4800) | Async request with full node path |
| rcExecRequest(module, command, true, timeout=1600) | Sync request; default timeout 1600 ms |
| rcExecRequestFullCommand(full_command, request_val, true, timeout=4800) | Sync full command |
3.5 Network Status
| Method | Description |
|---|---|
| connectNetworkStatus(isConnect, pluginName, obj, callback, id="") | Register connect/disconnect callback; returns id |
| disconnectNetworkStatus(isConnect, pluginName, id="") | Unregister by id |
3.6 Robot and HMI Status
| Method | Return | Description |
|---|---|---|
| getRobotConnected() | bool | Whether robot is connected |
| getRobotID() | QString | Robot ID |
| getRobotEleStatus() | bool | Power-on state |
| getRobotOperateIsHand() | bool | Whether in manual mode |
| getRobotPhyStatus() | QString | Current run state description |
| getUserOperateLevel() | int | Permission level 1~5 |
| getRobotIP() | QString | Current controller IP |
| getRobotType() | QString | Current model |
| getRobotModelType() | int | Kinematics/device enum |
| changeRobotPowerStatue(status, isRsync=true) | bool | Change power state; isRsync defaults to sync call |
| changeRobotModelStatue(isHand, isRsync=true) | bool | Change manual/auto; isRsync defaults to sync call |
3.7 Program Run Filters and Start/Stop
| Method | Description |
|---|---|
| startRunningFilter(doOpen) | Install start filter; call startRunning() manually after setup |
| stopRunningFilter(doOpen) | Install stop filter; call stopRunning() manually after setup |
| startRunning() / stopRunning() | Start/stop current program |
3.8 Tool, Workobject, Speed, Zone
| Method | Description |
|---|---|
| getCurTool() / getCurWobj() | Current tool and workobject |
| getToolList() / getWobjList() | Lists |
| getSpeedList() / getZoneList() | Speed and zone lists |
3.9 Variables
| Method | Description |
|---|---|
| getVarDataList(type="") | List variable names by type |
| addVarData(name, value, isPers=false) | Create variable |
| delVarData(name) / delVarData(names) | Delete variable(s) |
| updateVarData(name, value) | Update variable |
| getVarObjDataByName(name) | Structure as JSON |
| getValuesOfPERSVars(names) | Read PERS variables |
| setValuesOfPERSVars(names, values) | Set PERS variables |
| registPERSVars(names) | Register PERS variables for continuous refresh |
| getRegistedPERSVars() | Read current values of registered PERS |
3.10 Points
| Method | Description |
|---|---|
| getPointNameList() | Point name list |
| getPointObjDataByName(pointName) | Point structure |
| getPointDataByName(pointName) | Joint-space coordinates |
| getCurrentPointData(toolName="", wobjName="") | Current position |
| addCurrentPoint(pointName, isJoint, toolName, wobjName) | Create point from current pose; isJoint = joint point |
| changeCartPoint(pointName, xyz_abc) | Modify Cartesian point |
| checkPointMoveTo(from, to) | Reachability check; 0 ok, 1 same point, -2 singularity, etc. |
| checkPointSame(from, to) | Consistency check |
| moveToStart(errCode, pointTo, speed, isMoveJ) | Move to point; speed 1~100 |
| moveToStart(errCode, pointTo, speed, confCheck, isMoveJ) | Move with configuration check |
| moveToStop() | Stop motion |
3.11 Projects
| Method | Description |
|---|---|
| getProjectList() | Project list |
| createProject(name, desc="", isUsed=false) | Create project; 0 = success |
| changeProject(name) | Switch project |
| removeProject(name) | Delete project |
3.12 IO and Registers
| Method | Description |
|---|---|
| getIOHash() | IO values |
| getIOByType(sigType) | sigType: "DI/DO/GI/GO/AI/AO" or integer |
| setIOValue(name, sigType, value) | Set IO |
| getIOValue(name) | Get IO |
| getRegisterHash() | Register names and enum values |
| getRegisterValue() | All register values as JSON |
4. Auxiliary Programming
| Method | Description |
|---|---|
| createGroups(lab, groupName) | Create instruction group (UI label, internal name) |
| createTypeKey(type) | Create instruction type |
| createTypeToGroup(groupName, type) / (groupName, typeList) | Add instruction(s) to group |
| createSkeleton(type, str) | Parser match string |
| createInsDescribe(type, str) | Description text |
| createInsDefault(type, strDef) | Default output text |
| createPattern(type, str) | Regex for reverse parsing |
| createInsertWidget(type, func) | Edit window; returns RLContentBase subclass |
| createPropertyWidget(type, func) | Property window; returns RLContentBase subclass |
| createData(groupName, type, desc, func1, func2) | Quick-create standard instruction (insert + property factories) |
- RLContentBase: FillWith / ToString / CheckInsert / CheckReplace and related methods
5. Events (event/)
5.1 Event Type Ranges
| Range | Meaning |
|---|---|
| 0x0000~0x0FFF | System events |
| 0x1000~0x1FFF | Hardware events |
| 0x2000~0x2FFF | Network events |
| 0x3000~0x3FFF | XService events |
| 0x4000~0x4FFF | RC events |
| 0x5000~0x5FFF | UI events |
| 0x8000~0xFFFF | User-defined events |
5.2 Event APIs
| API | Description |
|---|---|
| subscribe(type, handler, pluginName, context=nullptr) | Subscribe; returns subscription ID |
| subscribeFiltered | Subscribe with filter; returns subscription ID |
| subscribeOnce | One-shot subscription (auto-unsubscribe after first delivery) |
| unsubscribe(id) | Cancel subscription by ID |
| unsubscribeByPlugin | Cancel all subscriptions for plugin |
| unsubscribeByType | Cancel all subscriptions for event type |
| unsubscribeByTypeAndPlugin | Cancel subscriptions for plugin + type |
| publish(event) / publish(type, data, source) | Publish synchronously |
| publish(type, data, source) | Quick synchronous publish |
| publishAsync(type, data, source) | Publish asynchronously |
| registerCustomEventType(name) | Register user-defined event type |
| registerAllEvents() | Register all built-in listeners (host side) |
See Event System.
6. Logging
After defining PLUGIN_NAME in .pro:
| Macro | Level |
|---|---|
| DLOG / ILOG / WLOG / ELOG / SLOG | Debug / Info / Warning / Error / Sudo |
| DSLOG / ISLOG / WSLOG / ESLOG / SSLOG | Insert spaces between output characters |
- Default log directory: ./log/xplugin/<PLUGIN_NAME>/.
7. Sync Tool
| Method | Description |
|---|---|
| SyncTool::instance() | Sync tool singleton |
| pushFile(from, to_module="hmi") | Push directory data to controller module |
| pushOneFile(from, to_module="hmi") | Push single file to controller module |
| pullFile(from_module="hmi", to_path="", has_dialog=true) | Pull data from controller module at path |