Skip to main content

Secondary development static library introduction

Function introduction

It provides complete teach pendant functions, supports adding user-defined interfaces, and supports communication between the teach pendant and the controller through specific fields.

Static library directory structure

avatar

"NextpLib" is the main folder

The "include" folder contains header files

The "Library" folder contains static library files, including linux platform and ARM platform library files

The nrc.out in the "nrc" folder is the controller program matching the current demo program, and the program cross-compiled using the ARM platform is only applicable to the T30 teach pendant of iNexBot

Static library structure description

  1. Nextp.h header file interface description:

//Create a Nextp class object

static QPointer<Nextp> getInstance();

//Get system font

QString getSystemFont();

//Transfer user-defined form to the main program

void setWidgetParentLocation(QPointer <QWidget> widget);

//Send message to controller

void sendMessage(const quint16 &command,const QByteArray &data);

//Notify the teach program that a custom form has been opened

widgetShowFinish()

//Signal to receive controller messages

void signal_receiveMessage(const quint16 &command,const QByteArray
&data);

//Signal to open a custom form

void signal_openWidget();

//Signal to close a custom form

void signal_closeWidget();

//Hide other buttons in the process main interface except the custom buttons

void hideTechnologyToolbuttons();

//The command words in the static library that support the communication between the teach pendant and the controller

enum CommandList
{
SetFirstUserParaCommand = 0x9200,
GetFirstUserCommand = 0x9201,
ReceivedFirstUserCommand = 0x9202,
SetSecondUserParaCommand = 0x9203,
GetSecondUserCommand = 0x9204,
ReceivedSecondUserCommand = 0x9205,
SetThirdUserParaCommand = 0x9206,
GetThirdUserCommand = 0x9207,
ReceivedThirdUserCommand = 0x92,
ReceivedThirdUserCommand = 0x9208,
SetFourthUserParaCommand = 0x9209,
GetFourthUserCommand = 0x920a,
ReceivedFourthUserCommand = 0x920b,
SetFifthUserParaCommand = 0x920c,
GetFifthUserCommand = 0x920d,
ReceivedFifthUserCommand = 0x920e,
};
  1. The json/json.h header file provides assembly and parsing of the JSON data format

Example of assembling json data:

Json::Value root;
Json::FastWriter wt;
root["robot"] =1;
root["booldata"] =true;
root["data"] = 1.1;
root["name"] ="nihao";

Example of parsing json data:

QByteArray jsonData //Data sent by the controller
Json::Value root;
Json::Reader reader;
QString jsonData = param.data();
if(reader.parse(jsonData.toStdString(), root))
{
int robot = root["robot"].asInt();
bool booldata= root["booldata"].asBool();
Int data= root["data"].asDouble();
Std::string name = root["name "].asString();
}
  1. Digitallineedit.h provides a digital input box

It supports promoting the QLineEdit control to a digital input box

Promotion method: right-click to select a QLineEdit control --->Promote to --->DigitalLineEdit

avatar

In the tree structure on the right, you can see that the Classes property of the control has changed to DigitLineEdit

avatar

The effect of the control after the program is run: clicking on the control will bring up the numeric keypad:

avatar

  1. Lineeditwidget.h provides an alphanumeric input box

It supports promoting the QLineEdit control to an alphanumeric input box

Promotion method: right-click to select a QLineEdit control --->Promote to --->LineEditWidget

avatar

In the tree structure on the right, you can see that the Classes property of the control has changed to LineEditWidget

avatar

The effect of the control after the program is run: clicking on the control will bring up the alphanumeric keypad:

avatar

Demo description

  1. Demo structure diagram Demo folder name: NextpMode

avatar

  1. Demo file class description

2.1 Settingparawidget.h, settingparawidget.cpp and settingparawidget.ui are user-defined forms

avatar

2.2 Widgetmanager.h and widgetmanager.cpp are used to manage the connection between user-defined forms and static libraries

2.3 The static library folder nextplib needs to be placed under the NextpMode folder of demod

2.4 Run Demo (Use QtCreator to directly open the NextpMode.pro file under the NextpMode folder)

Run the Demo program: click [Operator], select "Administrator", and then enter the password 123456 to log in

avatar

Click the [Process] button on the left > User to enter the custom window

avatar

avatar

Click the "Modify" button to modify the parameters. Click "Save" to send the parameters to the controller

avatar

The QtCreator console will print the data sent to the controller

avatar

avatar

If the function void hideTechnologyToolbuttons(); is called, it will hide other buttons in the process main interface except the custom buttons

avatar