Skip to main content

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

SymbolDescription
XPLUGIN_REGISTER(KEY, CLASS_NAME)Plugin registration; KEY must match PLUGIN_NAME and deployment directory name
xPluginFactory()Global PluginRegister singleton
PluginBaseUser 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

EnumValuesPurpose
enLanguageEnglish=0, Chinese=1, OtherLanguage=0xFFLanguage type (translation via Qt .qm; no RegistLanguage export API)
enThrowLogLevelInfo, Warning, Error, NoneLogTypeThrowLog popup level

2. Global Functions

FunctionReturnDescription
GetPluginVersion()QStringFour-part version; current 1.0.2.6
CreateCenterWidget(pluginName, widget)intRegister center main view; 0 success, -1 plugin name, -2 not initialized
CreateStatusBar(pluginName, widget, index=1)intBottom status bar slot
CreateRightExpandWidgte(pluginName, widget, name="")intRight-side persistent expand panel
SwitchRightExpandWidgte(pluginName="", name="")intSwitch expand panel; empty name closes
CreatePhyButtonList(pluginName, type, left, right, center_texts)intPhysical key layout
ChangePhyButtonStatus(pluginName, type, enable)intEnable/disable physical keys
ChangeModelWindowStatus(pluginName, status)intModal state; controls whether physical keys respond
ChangeFullScreen(pluginName, isFull)intFullscreen
GetRightExpandSideBar(QWidget **out)intGet right expand sidebar pointer
ThrowLog(pluginName, level, msg)intBottom-right notification
GetPluginDataPath(dataPath, pluginName)intGet plugin data storage path

PhysicalButton

FieldTypeDescription
textQStringDisplay text
touched_icon / untouched_iconQStringPressed/released icon paths
exec_functionstd::function<void(bool)>Press callback; true = pressed

3. Interface Functions

  • Obtained via xPluginInterface(). Unless noted, call on the UI thread.

3.1 Signals

SignalDescription
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

MethodReturnDescription
getNodeData(key)QJsonValueGet node data
getXServiceData(key)QJsonValueRead node data
getXServiceData(key, subKey)QJsonValueRead node data
setXServiceData(key, var)boolSet data (sync)
setXServiceData(key, subKey, var)boolSet data (sync)
commandXServiceData(key, var)boolSet data (async command)
execCommandXServiceData(key, var)QJsonValueSet data (sync command)
connectXServiceData(pluginName, serviceKey, callback, key="")boolSubscribe to changes
disconnectXServiceData(pluginName, serviceKey, key="")boolUnsubscribe

3.4 RC

MethodDescription
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

MethodDescription
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

MethodReturnDescription
getRobotConnected()boolWhether robot is connected
getRobotID()QStringRobot ID
getRobotEleStatus()boolPower-on state
getRobotOperateIsHand()boolWhether in manual mode
getRobotPhyStatus()QStringCurrent run state description
getUserOperateLevel()intPermission level 1~5
getRobotIP()QStringCurrent controller IP
getRobotType()QStringCurrent model
getRobotModelType()intKinematics/device enum
changeRobotPowerStatue(status, isRsync=true)boolChange power state; isRsync defaults to sync call
changeRobotModelStatue(isHand, isRsync=true)boolChange manual/auto; isRsync defaults to sync call

3.7 Program Run Filters and Start/Stop

MethodDescription
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

MethodDescription
getCurTool() / getCurWobj()Current tool and workobject
getToolList() / getWobjList()Lists
getSpeedList() / getZoneList()Speed and zone lists

3.9 Variables

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

MethodDescription
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

RangeMeaning
0x0000~0x0FFFSystem events
0x1000~0x1FFFHardware events
0x2000~0x2FFFNetwork events
0x3000~0x3FFFXService events
0x4000~0x4FFFRC events
0x5000~0x5FFFUI events
0x8000~0xFFFFUser-defined events

5.2 Event APIs

APIDescription
subscribe(type, handler, pluginName, context=nullptr)Subscribe; returns subscription ID
subscribeFilteredSubscribe with filter; returns subscription ID
subscribeOnceOne-shot subscription (auto-unsubscribe after first delivery)
unsubscribe(id)Cancel subscription by ID
unsubscribeByPluginCancel all subscriptions for plugin
unsubscribeByTypeCancel all subscriptions for event type
unsubscribeByTypeAndPluginCancel 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:

MacroLevel
DLOG / ILOG / WLOG / ELOG / SLOGDebug / Info / Warning / Error / Sudo
DSLOG / ISLOG / WSLOG / ESLOG / SSLOGInsert spaces between output characters
  • Default log directory: ./log/xplugin/<PLUGIN_NAME>/.

7. Sync Tool

MethodDescription
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