├── .gitignore
├── Image.qrc
├── Image
├── RESET.png
├── STEP.png
├── connect.png
├── connect2.png
├── connect3.png
├── exit.png
├── gamehandle.png
├── home.png
├── home1.png
├── load.png
├── load2.png
├── load3.png
├── machine.png
├── pause2.png
├── pause3.png
├── robot.jpg
├── safe.png
├── save.png
├── save2.png
├── send.png
├── send2.png
├── send3.png
├── start2.png
├── start3.png
├── statu.png
├── stop2.png
├── stop3.png
├── swift.png
├── tutorial.png
└── tutorial1.png
├── actionFun.cpp
├── applicationHeader.h
├── commandFun.cpp
├── enumHeader.h
├── evenFilterBox.cpp
├── groupBoxFun1.cpp
├── groupBoxFun2.cpp
├── groupBoxFun3.cpp
├── groupBoxFun4.cpp
├── groupBoxFun5.cpp
├── homesettings.h
├── main.cpp
├── mechanicalarm.cpp
├── mechanicalarm.h
├── otherFun.cpp
├── otherHeader.h
├── serialFun.cpp
├── serialHeader.h
├── timerFun.cpp
├── uppermachine.cpp
├── uppermachine.h
├── uppermachine.pro
├── uppermachine.ui
├── uppermachine_zh_SG.ts
├── upperserial.cpp
├── upperserial.h
└── upperstruct.h
/.gitignore:
--------------------------------------------------------------------------------
1 | *.filters
2 | *.user
3 | *.txt
4 | *.stash
5 | release
6 | debug
7 | .vs
8 | *.vcxproj
9 |
--------------------------------------------------------------------------------
/Image.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | Image/gamehandle.png
4 | Image/robot.jpg
5 | Image/machine.png
6 | Image/pause2.png
7 | Image/start2.png
8 | Image/start3.png
9 | Image/stop2.png
10 | Image/stop3.png
11 | Image/STEP.png
12 | Image/RESET.png
13 | Image/exit.png
14 | Image/home.png
15 | Image/home1.png
16 | Image/load.png
17 | Image/safe.png
18 | Image/save.png
19 | Image/save2.png
20 | Image/send.png
21 | Image/send2.png
22 | Image/connect.png
23 | Image/connect2.png
24 | Image/connect3.png
25 | Image/load2.png
26 | Image/load3.png
27 | Image/statu.png
28 | Image/send3.png
29 | Image/swift.png
30 | Image/pause3.png
31 | Image/tutorial.png
32 | Image/tutorial1.png
33 |
34 |
35 |
--------------------------------------------------------------------------------
/Image/RESET.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/RESET.png
--------------------------------------------------------------------------------
/Image/STEP.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/STEP.png
--------------------------------------------------------------------------------
/Image/connect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/connect.png
--------------------------------------------------------------------------------
/Image/connect2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/connect2.png
--------------------------------------------------------------------------------
/Image/connect3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/connect3.png
--------------------------------------------------------------------------------
/Image/exit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/exit.png
--------------------------------------------------------------------------------
/Image/gamehandle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/gamehandle.png
--------------------------------------------------------------------------------
/Image/home.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/home.png
--------------------------------------------------------------------------------
/Image/home1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/home1.png
--------------------------------------------------------------------------------
/Image/load.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/load.png
--------------------------------------------------------------------------------
/Image/load2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/load2.png
--------------------------------------------------------------------------------
/Image/load3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/load3.png
--------------------------------------------------------------------------------
/Image/machine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/machine.png
--------------------------------------------------------------------------------
/Image/pause2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/pause2.png
--------------------------------------------------------------------------------
/Image/pause3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/pause3.png
--------------------------------------------------------------------------------
/Image/robot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/robot.jpg
--------------------------------------------------------------------------------
/Image/safe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/safe.png
--------------------------------------------------------------------------------
/Image/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/save.png
--------------------------------------------------------------------------------
/Image/save2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/save2.png
--------------------------------------------------------------------------------
/Image/send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/send.png
--------------------------------------------------------------------------------
/Image/send2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/send2.png
--------------------------------------------------------------------------------
/Image/send3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/send3.png
--------------------------------------------------------------------------------
/Image/start2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/start2.png
--------------------------------------------------------------------------------
/Image/start3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/start3.png
--------------------------------------------------------------------------------
/Image/statu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/statu.png
--------------------------------------------------------------------------------
/Image/stop2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/stop2.png
--------------------------------------------------------------------------------
/Image/stop3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/stop3.png
--------------------------------------------------------------------------------
/Image/swift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/swift.png
--------------------------------------------------------------------------------
/Image/tutorial.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/tutorial.png
--------------------------------------------------------------------------------
/Image/tutorial1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2782694792/arduinoArmSystem/c9f475c540dd7851826634b35b221e846f966a04/Image/tutorial1.png
--------------------------------------------------------------------------------
/actionFun.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 |
4 |
5 | /*
6 | * 判断下一行是否为空
7 | */
8 | bool UpperMachine :: NextItemEmpty(QTableWidget *t, int x, int y)
9 | {
10 | return t->item(x+1,y) == NULL || (t->item(x+1,y) && t->item(x+1,y)->text() == tr(""));
11 | }
12 |
13 | /*
14 | * 判断当前行是否为空
15 | */
16 | bool UpperMachine :: CurrentItemEmpty(QTableWidget *t, int x, int y)
17 | {
18 | return t->item(x,y) == NULL || (t->item(x,y) && t->item(x,y)->text() == tr(""));
19 | }
20 |
21 | /*
22 | * 判断是否选中行
23 | */
24 | bool UpperMachine::selectRow()
25 | {
26 | QList items = ui->tableWidget->selectedItems();
27 | if(items.empty())
28 | // qDebug()<<"选中了某行";
29 | return false;
30 | return true;
31 | }
32 |
33 | /*
34 | * 首位获取
35 | */
36 | QString UpperMachine :: readFirstAction()
37 | {
38 | if(ui->tableWidget->selectedItems().count() != 0)
39 | {
40 | QString sendCommand;
41 | sendCommand
42 | .append("a" + QString("%1").arg(ui->tableWidget->item(0,0)->text(), 3, QLatin1Char('0')))
43 | .append("b" + QString("%1").arg(ui->tableWidget->item(0,1)->text(), 3, QLatin1Char('0')))
44 | .append("c" + QString("%1").arg(ui->tableWidget->item(0,2)->text(), 3, QLatin1Char('0')))
45 | .append("d" + QString("%1").arg(ui->tableWidget->item(0,3)->text(), 3, QLatin1Char('0')));
46 | return sendCommand;
47 | }
48 | else {
49 | QMessageBox::critical(this,"恢复首位","首位数据为空,无法获取数据!");
50 | return "";
51 | }
52 | }
53 |
54 | /*
55 | * 获取行数据
56 | */
57 | QString UpperMachine :: readItems(int currentIndex)
58 | {
59 | if(!CurrentItemEmpty(ui->tableWidget,0,0))
60 | {
61 | QString sendCommand;
62 | sendCommand
63 | .append("a" + QString("%1").arg(ui->tableWidget->item(currentIndex,0)->text(), 3, QLatin1Char('0')))
64 | .append("b" + QString("%1").arg(ui->tableWidget->item(currentIndex,1)->text(), 3, QLatin1Char('0')))
65 | .append("c" + QString("%1").arg(ui->tableWidget->item(currentIndex,2)->text(), 3, QLatin1Char('0')))
66 | .append("d" + QString("%1").arg(ui->tableWidget->item(currentIndex,3)->text(), 3, QLatin1Char('0')));
67 | return sendCommand;
68 | }
69 | else {
70 | QMessageBox::critical(this,"示教运行","数据为空,无法获取数据进行示教!");
71 | return "";
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/applicationHeader.h:
--------------------------------------------------------------------------------
1 | #ifndef APPLICATIONHEADER_H
2 | #define APPLICATIONHEADER_H
3 |
4 |
5 |
6 | //主程序
7 | #include "ui_uppermachine.h"
8 | #include "uppermachine.h"
9 |
10 | //日志打印与消息框提示
11 | #include
12 | #include
13 |
14 |
15 |
16 |
17 | #endif // APPLICATIONHEADER_H
18 |
--------------------------------------------------------------------------------
/commandFun.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 |
4 |
5 | //获取当前坐标
6 | void UpperMachine :: doDOWN(QString command)
7 | {
8 | setLocation(command);
9 |
10 | //显示爪子坐标
11 | ui->textEdit_ClowObtain->setText(mechanicalArm.getClowLocation());
12 |
13 | //显示小臂坐标
14 | ui->textEdit_SArmObtain->setText(mechanicalArm.getSmallArmLocation());
15 |
16 | //显示大臂坐标
17 | ui->textEdit_BArmObtain->setText(mechanicalArm.getBigArmLocation());
18 |
19 | //显示转台坐标
20 | ui->textEdit_RevolvingStageObtain->setText(mechanicalArm.getRevolvingStageLocation());
21 | }
22 |
23 | //定义获取的位置
24 | void UpperMachine :: setLocation(QString command)
25 | {
26 |
27 | //指令例子 a:12,b:119,c:45,d:70\r\n a:爪子 b:小臂 c:大臂 d:转台
28 | /*字符串进行按“,“分隔成多个元素结果,存入字符串数组*/
29 | QStringList elem = command.split(',');
30 | // qDebug() << "转换后的字符一维列表:" << elem;
31 |
32 | //设置爪子
33 | mechanicalArm.setClowLocation(elem[0].split(':')[1]);
34 |
35 | //设置小臂
36 | mechanicalArm.setSmallArmLocation(elem[1].split(':')[1]);
37 |
38 | //设置大臂
39 | mechanicalArm.setBigArmLocation(elem[2].split(':')[1]);
40 |
41 | //设置转台
42 | mechanicalArm.setRevolvingStageLocation(elem[3].split(':')[1]);
43 | }
44 |
--------------------------------------------------------------------------------
/enumHeader.h:
--------------------------------------------------------------------------------
1 | #ifndef GROUPBOXFUNCTION_H
2 | #define GROUPBOXFUNCTION_H
3 |
4 | // 动作指令集
5 | enum RobotAction
6 | {
7 | UP = 1,
8 | DOWN, //读取当前坐标
9 | RESET, //复位
10 | ADD_ACTION, //添加动作
11 | REMOVE, //删除动作
12 | REVOLVING_STAGE_LEFT, //转台左转
13 | REVOLVING_STAGE_RIGHT, //转台右转
14 | SMALL_ARM_OUTREACH, //小臂外展
15 | SMALL_ARM_ADDUCTION, //小臂内收
16 | BIG_ARM_OUTREACH, //大臂外展
17 | BIG_ARM_ADDUCTION, //大臂内收
18 | CLOW_GRAB, //爪头抓取
19 | CLOW_RELEASE //爪头释放
20 | };
21 |
22 | //示教状态指令集
23 | enum PlayStatus
24 | {
25 | PLAY = 1, //播放
26 | PAUSE, //暂停
27 | STOP //停止
28 | };
29 |
30 |
31 |
32 |
33 |
34 | #endif // GROUPBOXFUNCTION_H
35 |
--------------------------------------------------------------------------------
/evenFilterBox.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 |
4 | void UpperMachine::groupbox2_eventFilter(QObject *object){
5 | if (object==ui->textEdit_ClowMin)
6 | {
7 | checkSoftLimit(1);
8 | }
9 | if (object==ui->textEdit_ClowMax)
10 | {
11 | checkSoftLimit(2);
12 | }
13 | if (object==ui->textEdit_SArmMin)
14 | {
15 | checkSoftLimit(3);
16 | }
17 | if (object==ui->textEdit_SArmMax)
18 | {
19 | checkSoftLimit(4);
20 | }
21 | if (object==ui->textEdit_BArmMin)
22 | {
23 | checkSoftLimit(5);
24 | }
25 | if (object==ui->textEdit_BArmMax)
26 | {
27 | checkSoftLimit(6);
28 | }
29 | if (object==ui->textEdit_RStageMin)
30 | {
31 | checkSoftLimit(7);
32 | }
33 | if (object==ui->textEdit_RStageMax)
34 | {
35 | checkSoftLimit(8);
36 | }
37 | }
38 |
39 | /*
40 | * 按键事件
41 | */
42 | void UpperMachine::groupbox4_eventFilter(QObject *object){
43 | if (object == ui->pushButton_W) {
44 | // qDebug() <<"W:爪头抓取";
45 | robotAction = RobotAction::CLOW_GRAB;
46 | key_SerialWrite("M2000");
47 | }
48 | if (object == ui->pushButton_A) {
49 | // qDebug() <<"A:小臂内收";
50 | robotAction = RobotAction::SMALL_ARM_ADDUCTION;
51 | key_SerialWrite("M0100");
52 | }
53 | if (object == ui->pushButton_X) {
54 | // qDebug() <<"X:爪头释放";
55 | robotAction = RobotAction::CLOW_RELEASE;
56 | key_SerialWrite("M1000");
57 | }
58 | if (object == ui->pushButton_D) {
59 | // qDebug() <<"D:小臂外展";
60 | robotAction = RobotAction::SMALL_ARM_OUTREACH;
61 | key_SerialWrite("M0200");
62 | }
63 | if (object == ui->pushButton_I) {
64 | // qDebug() <<"I:转台右转";
65 | robotAction = RobotAction::REVOLVING_STAGE_RIGHT;
66 | key_SerialWrite("M0002");
67 | }
68 | if (object == ui->pushButton_J) {
69 | // qDebug() <<"J:大臂内收";
70 | robotAction = RobotAction::BIG_ARM_ADDUCTION;
71 | key_SerialWrite("M0010");
72 | }
73 | if (object == ui->pushButton_M) {
74 | // qDebug() <<"M:转台左转";
75 | robotAction = RobotAction::REVOLVING_STAGE_LEFT;
76 | key_SerialWrite("M0001");
77 | }
78 | if (object == ui->pushButton_L) {
79 | // qDebug() <<"L:大臂外展";
80 | robotAction = RobotAction::BIG_ARM_OUTREACH;
81 | key_SerialWrite("M0020");
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/groupBoxFun1.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 |
6 |
7 | /*获取当前位置*/
8 | void UpperMachine::readCurrentLocation()
9 | {
10 | if (upperSerial.getL_isOpen()) {
11 | // 清空缓存
12 | // tempBuffer.clear();
13 | arrayBuffer.clear();
14 | // 1、设置当前指令为读取当前坐标
15 | robotAction = RobotAction::DOWN;
16 | qDebug() << "++++++++++++++++++++++++++++++++++++++";
17 | qDebug() << "执行当前指令:" << UpperMachine::robotAction;
18 | // 2、判断串口设备是否可读写
19 | if (upperSerial.getL_isOpen())
20 | {
21 | try{
22 | // 3、打开串口元对象所指向的串口设备
23 | // upperSerialPort.open(QIODevice::ReadWrite);
24 | // upperSerial.setL_isOpen(upperSerialPort.isOpen());
25 | try
26 | {
27 | // 4、发送指定指令
28 | upperSerialPort.write(QString(strAddLine("DOWN")).toUtf8());
29 | // upperSerialPort.write("DOWN\n");
30 | qDebug() << "UTF8发送:" << strAddLine("DOWN").toUtf8();
31 | }
32 | catch (exception ex_write)
33 | {
34 | QMessageBox::critical(this, "发送指令异常", ex_write.what());
35 | }
36 | }
37 | catch (exception ex_open)
38 | {
39 | QMessageBox::critical(this, "串口设备异常", ex_open.what());
40 | }
41 | }
42 | else
43 | {
44 | QMessageBox::warning(this,"获取位置","串口不可读写,请重新打开串口或更换串口号");
45 | return;
46 | }
47 |
48 | }
49 | else {
50 | QMessageBox::warning(this,"获取位置","当前未连接,请进行设备连接!");
51 | }
52 | }
53 |
54 |
55 | /*
56 | * 关闭当前串口设备
57 | */
58 | void UpperMachine :: closeSerialDevice()
59 | {
60 | if(upperSerial.getL_isOpen() == 1){
61 | upperSerialPort.close();
62 | upperSerialPort.setPortName("");
63 | upperSerialPort.setBaudRate(QSerialPort::UnknownBaud);
64 | upperSerialPort.setDataBits(QSerialPort::UnknownDataBits);
65 | upperSerialPort.setStopBits(QSerialPort::UnknownStopBits);
66 | upperSerialPort.setFlowControl(QSerialPort::UnknownFlowControl);
67 | upperSerialPort.setParity(QSerialPort::UnknownParity);
68 |
69 | upperSerial.setL_c_protName("");
70 | upperSerial.setDeviceName("");
71 |
72 | ui->label_deviceName->setStyleSheet("color:red;");
73 | ui->label_deviceName->setText("设备已关闭");
74 | ui->label_connectInfo->setStyleSheet("color:red;");
75 | ui->label_connectInfo->setText("请进行连接");
76 | ui->label_StatusInfo->setStyleSheet("color:red;");
77 | ui->label_StatusInfo->setText("无法获取状态");
78 |
79 | ui->textEdit_BArmObtain->setText("");
80 | ui->textEdit_ClowObtain->setText("");
81 | ui->textEdit_SArmObtain->setText("");
82 | ui->textEdit_RevolvingStageObtain->setText("");
83 |
84 | arrayBuffer.clear();
85 | tempBuffer.clear();
86 |
87 | upperSerial.setL_isOpen(0);
88 | upperSerial.setWriteSuccess(0);
89 |
90 | QMessageBox::about(this,"关闭串口","串口连接已关闭");
91 | }
92 | else {
93 | QMessageBox::information(this,"关闭串口","当前未连接,请进行设备连接!");
94 | }
95 | }
96 |
97 |
98 | /*
99 | * 切换操纵状态
100 | */
101 | void UpperMachine :: switchSteerStatus()
102 | {
103 | if (upperSerial.getL_isOpen()) {
104 | // 切换状态
105 | robotAction = RobotAction::UP;
106 | // 写入切换指令
107 | upperSerialPort.write(QString(strAddLine("UP")).toUtf8());
108 | }
109 | else {
110 | QMessageBox::warning(this,"切换状态","当前未连接,请进行设备连接!");
111 | }
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/groupBoxFun2.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 |
7 | /*
8 | * 检查软限位
9 | */
10 | void UpperMachine::checkSoftLimit(int steerNum)
11 | {
12 | if(mechanicalArm.getStartCheck()){
13 | // 聚焦更改文本框背景颜色
14 | // QPalette in = QPalette(),out = QPalette();
15 | // in.setColor(QPalette::Base,Qt::green);
16 | // out.setColor(QPalette::Base,Qt::white);
17 | switch (steerNum) {
18 | case 1:
19 | // 爪头最小软限位
20 | checkSoftLimit_Clow(1);
21 | break;
22 | case 2:
23 | // 爪头最大软限位
24 | checkSoftLimit_Clow(2);
25 | break;
26 | case 3:
27 | // 小臂最小软限位
28 | checkSoftLimit_SArm(1);
29 | break;
30 | case 4:
31 | // 小臂最大软限位
32 | checkSoftLimit_SArm(2);
33 | break;
34 | case 5:
35 | // 大臂最小软限位
36 | checkSoftLimit_BArm(1);
37 | break;
38 | case 6:
39 | // 大臂最大软限位
40 | checkSoftLimit_BArm(2);
41 | break;
42 | case 7:
43 | // 转台最小软限位
44 | checkSoftLimit_RStage(1);
45 | break;
46 | case 8:
47 | // 转台最大软限位
48 | checkSoftLimit_RStage(2);
49 | break;
50 | default:
51 | currentsoftlimitSettings();
52 | break;
53 | }
54 | }
55 | }
56 |
57 |
58 | /*
59 | * 软限位读取
60 | */
61 | void UpperMachine :: loadSoftLitmit()
62 | {
63 | QStringList infoList;
64 | QFile file("./softlimit.txt");
65 | try {
66 | // 1、打开文件读写权限
67 | file.open(QIODevice::ReadWrite | QIODevice::Text);
68 | // 2、文件流指向文本输出流
69 | QTextStream txtInput(&file);
70 | int i = 0;
71 | // 3、指向最后一个指针位置
72 | while (!txtInput.atEnd())
73 | {
74 | // 4、读取数据
75 | infoList.append(txtInput.readLine());
76 | QMessageBox::about(this,"文本流读取","\r开始文件写入 \n第 " +QString::number(i) +" 行:"+infoList[i]);
77 | i++;
78 | }
79 |
80 | ui->textEdit_ClowMin->setText(infoList[0].split("=")[1].split(";")[0]);
81 | ui->textEdit_ClowMax->setText(infoList[1].split("=")[1].split(";")[0]);
82 | ui->textEdit_SArmMin->setText(infoList[2].split("=")[1].split(";")[0]);
83 | ui->textEdit_SArmMax->setText(infoList[3].split("=")[1].split(";")[0]);
84 | ui->textEdit_BArmMin->setText(infoList[4].split("=")[1].split(";")[0]);
85 | ui->textEdit_BArmMax->setText(infoList[5].split("=")[1].split(";")[0]);
86 | ui->textEdit_RStageMin->setText(infoList[6].split("=")[1].split(";")[0]);
87 | ui->textEdit_RStageMax->setText(infoList[7].split("=")[1].split(";")[0]);
88 | // ui->textEdit_Sleep->setText( info[8].split('=')[1]);
89 | } catch (exception &ex_fileLoad) {
90 | QMessageBox::critical(this,"文件警告","文件打开或写入失败,原因:"+QString(ex_fileLoad.what()));
91 | }
92 | }
93 |
94 | /*
95 | * 软限位写入
96 | */
97 | void UpperMachine :: saveSoftLimit(void)
98 | {
99 | QString txt = ("ClowMin=" + ui->textEdit_ClowMin->toPlainText() + ";\n" +
100 | "ClowMax=" + ui->textEdit_ClowMax->toPlainText() + ";\n" +
101 | "SmallArmMin=" + ui->textEdit_SArmMin->toPlainText() + ";\n" +
102 | "SmallArmMax=" + ui->textEdit_SArmMax->toPlainText() + ";\n" +
103 | "BigArmMin=" + ui->textEdit_BArmMin->toPlainText() + ";\n" +
104 | "BigArmMax=" + ui->textEdit_BArmMax->toPlainText() + ";\n" +
105 | "RevolvingStageMin=" + ui->textEdit_RStageMin->toPlainText() + ";\n" +
106 | "RevolvingStageMax=" + ui->textEdit_RStageMax->toPlainText() + ";");
107 | // + "\r\n" +
108 | // "Sleep=" + ui->textEdit_Sleep->toPlainText();
109 | QFile file("./softlimit.txt");
110 | try {
111 | file.open(QIODevice::ReadWrite | QIODevice::Text);
112 | file.write(txt.toUtf8());
113 | QMessageBox::about(this,"文件打开成功","文件写入成功,内容:\n"+txt);
114 | } catch (exception &ex_fileWrite) {
115 | QMessageBox::about(this,"文件打开失败","文件写入失败,原因:\n"+QString(ex_fileWrite.what()));
116 | }
117 | }
118 |
119 | /*
120 | * 复位
121 | */
122 | void UpperMachine :: resetLocation()
123 | {
124 | if (upperSerial.getL_isOpen()) {
125 |
126 | QByteArray command = QString(strAddLine("LEFT")).toUtf8();
127 | robotAction = RobotAction::RESET;
128 | // try {
129 | upperSerialPort.write(command);
130 | qDebug() << "发送命令:" << command;
131 | }
132 | else {
133 | QMessageBox::warning(this,"切换状态","当前未连接,请进行设备连接!");
134 | }
135 |
136 | // sleep_MS(50);
137 | // if (upperSerial.getWriteSuccess() == true) {
138 | // QMessageBox::about(this,"复位命令","复位成功!");
139 | // }else {
140 | // throw exception();
141 | // }
142 | // } catch (exception &ex_reset) {
143 | // QMessageBox::critical(this,"复位命令","复位失败!"+ QString(ex_reset.what()));
144 | // upperSerialPort.write(QString(strAddLine("UP")).toUtf8());
145 | // }
146 | }
147 |
148 | /*
149 | * 手爪软限位
150 | */
151 | void UpperMachine :: checkSoftLimit_Clow(int i){
152 | if(i == 1){
153 | //1、属于软限位默认范围
154 | // 1.1、设置最小值 >= 默认最小值
155 | if (ui->textEdit_ClowMin->toPlainText().toInt() < mechanicalArm.getClowMin()) {
156 | QMessageBox::critical(this,"手爪警告","手爪最小软限位 不能小于 默认最小软限位:须 ≥ " + QString::number(mechanicalArm.getClowMin()) + "°");
157 | i=0;
158 | }
159 | // 1.2、设置最小值 <= 设置最大值
160 | else if (ui->textEdit_ClowMin->toPlainText().toInt() > ui->textEdit_ClowMax->toPlainText().toInt() ) {
161 | QMessageBox::critical(this,"手爪警告","手爪最小软限位 不能大于 设置的最大软限位:须 ≤ " + QString::number(ui->textEdit_ClowMax->toPlainText().toInt()) + "°");
162 | i = 0;
163 | }
164 | if(i == 0)
165 | // 设置默认软限位
166 | ui->textEdit_ClowMin->setText(QString::number(mechanicalArm.getClowMin()));
167 | else
168 | mechanicalArm.setCurrent_CMin(QString::number(mechanicalArm.getClowMin()));
169 | }
170 | else{
171 | // 1.3、设置最大值 <= 默认最大值
172 | if (ui->textEdit_ClowMax->toPlainText().toInt() > mechanicalArm.getClowMax()) {
173 | QMessageBox::critical(this,"手爪警告","手爪最大软限位 不能大于 默认最大软限位:须 ≤ " + QString::number(mechanicalArm.getClowMax()) + "°");
174 | i=0;
175 | }
176 | // 1.4、设置最大值 >= 设置最小值
177 | else if (ui->textEdit_ClowMax->toPlainText().toInt() < ui->textEdit_ClowMin->toPlainText().toInt() ) {
178 | QMessageBox::critical(this,"手爪警告","手爪最大软限位 不能小于 设置的最小软限位:须 ≥ " + QString::number(ui->textEdit_ClowMin->toPlainText().toInt()) + "°");
179 | i=0;
180 | }
181 | if(i == 0)
182 | // 设置默认软限位
183 | ui->textEdit_ClowMax->setText(QString::number(mechanicalArm.getClowMax()));
184 | else
185 | mechanicalArm.setCurrent_CMax(QString::number(mechanicalArm.getClowMax()));
186 | }
187 | }
188 |
189 | /*
190 | * 小臂软限位
191 | */
192 | void UpperMachine :: checkSoftLimit_SArm(int i){
193 | if(i == 1){
194 | //1、属于软限位默认范围内
195 | // 1.1、设置最小值 >= 默认最小值
196 | if (ui->textEdit_SArmMin->toPlainText().toInt() < mechanicalArm.getSArmMin()) {
197 | QMessageBox::critical(this," 小臂警告"," 小臂最小软限位 不能小于 默认最小软限位:须 ≥ " + QString::number(mechanicalArm.getSArmMin()) + "°");
198 | i=0;
199 | }
200 | // 1.2、设置最小值 <= 设置最大值
201 | else if (ui->textEdit_SArmMin->toPlainText().toInt() > ui->textEdit_SArmMax->toPlainText().toInt() ) {
202 | QMessageBox::critical(this," 小臂警告"," 小臂最小软限位 不能大于 设置的最大软限位:须 ≤ " + QString::number(ui->textEdit_SArmMax->toPlainText().toInt()) + "°");
203 | i=0;
204 | }
205 | if(i == 0)
206 | // 设置默认软限位
207 | ui->textEdit_SArmMin->setText(QString::number(mechanicalArm.getSArmMin()));
208 | else
209 | mechanicalArm.setCurrent_SAMin(QString::number(mechanicalArm.getSArmMin()));
210 | }
211 | else{
212 | // 1.3、设置最大值 <= 默认最大值
213 | if (ui->textEdit_SArmMax->toPlainText().toInt() > mechanicalArm.getSArmMax()) {
214 | QMessageBox::critical(this," 小臂警告"," 小臂最大软限位 不能大于 默认最大软限位:须 ≤ " + QString::number(mechanicalArm.getSArmMax()) + "°");
215 | i=0;
216 | }
217 | // 1.4、设置最大值 >= 设置最小值
218 | else if (ui->textEdit_SArmMax->toPlainText().toInt() < ui->textEdit_SArmMin->toPlainText().toInt() ) {
219 | QMessageBox::critical(this," 小臂警告"," 小臂最大软限位 不能小于 设置的最小软限位:须 ≥ " + QString::number(ui->textEdit_SArmMin->toPlainText().toInt()) + "°");
220 | i=0;
221 | }
222 | if(i == 0)
223 | // 设置默认软限位
224 | ui->textEdit_SArmMax->setText(QString::number(mechanicalArm.getSArmMax()));
225 | else
226 | mechanicalArm.setCurrent_SAMax(QString::number(mechanicalArm.getSArmMax()));
227 | }
228 | }
229 |
230 | /*
231 | * 大臂软限位
232 | */
233 | void UpperMachine :: checkSoftLimit_BArm(int i){
234 | if(i == 1){
235 | //1、属于软限位默认范围内
236 | // 1.1、设置最小值 >= 默认最小值
237 | if (ui->textEdit_BArmMin->toPlainText().toInt() < mechanicalArm.getBArmMin()) {
238 | QMessageBox::critical(this,"大臂警告","大臂最小软限位 不能小于 默认最小软限位:须 ≥ " + QString::number(mechanicalArm.getBArmMin()) + "°");
239 | i=0;
240 | }
241 | // 1.2、设置最小值 <= 设置最大值
242 | else if (ui->textEdit_BArmMin->toPlainText().toInt() > ui->textEdit_BArmMax->toPlainText().toInt() ) {
243 | QMessageBox::critical(this,"大臂警告","大臂最小软限位 不能大于 设置的最大软限位:须 ≤ " + QString::number(ui->textEdit_BArmMax->toPlainText().toInt()) + "°");
244 | i=0;
245 | }
246 | if(i == 0)
247 | // 设置默认软限位
248 | ui->textEdit_BArmMin->setText(QString::number(mechanicalArm.getBArmMin()));
249 | else
250 | mechanicalArm.setCurrent_BAMin(QString::number(mechanicalArm.getBArmMin()));
251 | }
252 | else{
253 | // 1.3、设置最大值 <= 默认最大值
254 | if (ui->textEdit_BArmMax->toPlainText().toInt() > mechanicalArm.getBArmMax()) {
255 | QMessageBox::critical(this,"大臂警告","大臂最大软限位 不能大于 默认最大软限位:须 ≤ " + QString::number(mechanicalArm.getBArmMax()) + "°");
256 | i=0;
257 | }
258 | // 1.4、设置最大值 >= 设置最小值
259 | else if (ui->textEdit_BArmMax->toPlainText().toInt() < ui->textEdit_BArmMin->toPlainText().toInt() ) {
260 | QMessageBox::critical(this,"大臂警告","大臂最大软限位 不能小于 设置的最小软限位:须 ≥ " + QString::number(ui->textEdit_BArmMin->toPlainText().toInt()) + "°");
261 | i=0;
262 | }
263 | if(i == 0)
264 | // 设置默认软限位
265 | ui->textEdit_BArmMax->setText(QString::number(mechanicalArm.getBArmMax()));
266 | else
267 | mechanicalArm.setCurrent_BAMax(QString::number(mechanicalArm.getBArmMax()));
268 | }
269 | }
270 |
271 |
272 | /*
273 | * 转台软限位
274 | */
275 | void UpperMachine :: checkSoftLimit_RStage(int i){
276 | if(i == 1){
277 | //1、属于软限位默认范围内
278 | // 1.1、设置最小值 >= 默认最小值
279 | if (ui->textEdit_RStageMin->toPlainText().toInt() < mechanicalArm.getRStageMin()) {
280 | QMessageBox::critical(this,"转台警告","转台最小软限位 不能小于 默认最小软限位:须 ≥ " + QString::number(mechanicalArm.getRStageMin()) + "°");
281 | i=0;
282 | }
283 | // 1.2、设置最小值 <= 设置最大值
284 | else if (ui->textEdit_RStageMin->toPlainText().toInt() > ui->textEdit_RStageMax->toPlainText().toInt() ) {
285 | QMessageBox::critical(this,"转台警告","转台最小软限位 不能大于 设置的最大软限位:须 ≤ " + QString::number(ui->textEdit_RStageMax->toPlainText().toInt()) + "°");
286 | i=0;
287 | }
288 | if(i == 0)
289 | // 设置默认软限位
290 | ui->textEdit_RStageMin->setText(QString::number(mechanicalArm.getRStageMin()));
291 | else
292 | mechanicalArm.setCurrent_RSMin(QString::number(mechanicalArm.getRStageMin()));
293 | }
294 | else{
295 | // 1.3、设置最大值 <= 默认最大值
296 | if (ui->textEdit_RStageMax->toPlainText().toInt() > mechanicalArm.getRStageMax()) {
297 | QMessageBox::critical(this,"转台警告","转台最大软限位 不能大于 默认最大软限位:须 ≤ " + QString::number(mechanicalArm.getRStageMax()) + "°");
298 | i=0;
299 | }
300 | // 1.4、设置最大值 >= 设置最小值
301 | else if (ui->textEdit_RStageMax->toPlainText().toInt() < ui->textEdit_RStageMin->toPlainText().toInt() ) {
302 | QMessageBox::critical(this,"转台警告","转台最大软限位 不能小于 设置的最小软限位:须 ≥ " + QString::number(ui->textEdit_RStageMin->toPlainText().toInt()) + "°");
303 | i=0;
304 | }
305 | if(i == 0)
306 | // 设置默认软限位
307 | ui->textEdit_RStageMax->setText(QString::number(mechanicalArm.getRStageMax()));
308 | else
309 | mechanicalArm.setCurrent_RSMax(QString::number(mechanicalArm.getRStageMax()));
310 | }
311 | }
312 |
313 |
314 | /*
315 | * 当前软限位
316 | */
317 | void UpperMachine :: currentsoftlimitSettings()
318 | {
319 | mechanicalArm.setCurrent_CMin(ui->textEdit_ClowMin->toPlainText());
320 | mechanicalArm.setCurrent_CMax(ui->textEdit_ClowMax->toPlainText());
321 |
322 | mechanicalArm.setCurrent_SAMin(ui->textEdit_SArmMin->toPlainText());
323 | mechanicalArm.setCurrent_SAMax(ui->textEdit_SArmMax->toPlainText());
324 |
325 | mechanicalArm.setCurrent_BAMin(ui->textEdit_BArmMin->toPlainText());
326 | mechanicalArm.setCurrent_BAMax(ui->textEdit_BArmMax->toPlainText());
327 |
328 | mechanicalArm.setCurrent_RSMin(ui->textEdit_RStageMin->toPlainText());
329 | mechanicalArm.setCurrent_RSMax(ui->textEdit_RStageMax->toPlainText());
330 | }
331 |
332 |
--------------------------------------------------------------------------------
/groupBoxFun3.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include
5 |
6 | /*
7 | * 发送位置
8 | */
9 | void UpperMachine :: sendLocation()
10 | {
11 | if (upperSerial.getL_isOpen()) {
12 | currentsoftlimitSettings();
13 |
14 | QString sendCommand;
15 | if (ui->textEdit_SendClow->toPlainText().trimmed().size() <= 0
16 | || ui->textEdit_SendClow->toPlainText().toInt() < mechanicalArm.getCurrent_CMin().toInt() || ui->textEdit_SendClow->toPlainText().toInt() > mechanicalArm.getCurrent_CMax().toInt()) {
17 | QMessageBox::critical(this,"发送位置","爪头角度超出当前软限位(" + mechanicalArm.getCurrent_CMin() + "-" + mechanicalArm.getCurrent_CMax() + "),请重新设置!");
18 | ui->textEdit_SendClow->setText(mechanicalArm.getClowLocation());
19 | // ui->textEdit_SendClow->setText("45");
20 | }
21 | else if (ui->textEdit_SendSArm->toPlainText().trimmed().size() <= 0
22 | || ui->textEdit_SendSArm->toPlainText().toInt() < mechanicalArm.getCurrent_SAMin().toInt() || ui->textEdit_SendSArm->toPlainText().toInt() > mechanicalArm.getCurrent_SAMax().toInt()) {
23 | QMessageBox::critical(this,"发送位置","小臂角度超出当前软限位(" + mechanicalArm.getCurrent_SAMin() + "-" + mechanicalArm.getCurrent_SAMax() + "),请重新设置!");
24 | ui->textEdit_SendSArm->setText(mechanicalArm.getSmallArmLocation());
25 | // ui->textEdit_SendSArm->setText("45");
26 | }
27 | else if (ui->textEdit_SendBArm->toPlainText().trimmed().size() <= 0
28 | || ui->textEdit_SendBArm->toPlainText().toInt() < mechanicalArm.getCurrent_BAMin().toInt() || ui->textEdit_SendBArm->toPlainText().toInt() > mechanicalArm.getCurrent_BAMax().toInt()) {
29 | QMessageBox::critical(this,"发送位置","大臂角度超出当前软限位(" + mechanicalArm.getCurrent_BAMin() + "-" + mechanicalArm.getCurrent_BAMax() + "),请重新设置!");
30 | ui->textEdit_SendBArm->setText(mechanicalArm.getBigArmLocation());
31 | // ui->textEdit_SendBArm->setText("45");
32 | }
33 | else if (ui->textEdit_SendRStage->toPlainText().trimmed().size() <= 0
34 | || ui->textEdit_SendRStage->toPlainText().toInt() < mechanicalArm.getCurrent_RSMin().toInt() || ui->textEdit_SendRStage->toPlainText().toInt() > mechanicalArm.getCurrent_RSMax().toInt() ) {
35 | QMessageBox::critical(this,"发送位置","转台角度超出当前软限位(" + mechanicalArm.getCurrent_RSMin() + "-" + mechanicalArm.getCurrent_RSMax() + "),请重新设置!");
36 | ui->textEdit_SendRStage->setText(mechanicalArm.getRevolvingStageLocation());
37 | // ui->textEdit_SendRStage->setText("45");
38 | }
39 | else{
40 | QString clowSend = ui->textEdit_SendClow->toPlainText();
41 | QString sArmSend = ui->textEdit_SendSArm->toPlainText();
42 | QString bArmSend = ui->textEdit_SendBArm->toPlainText();
43 | QString rStageSend = ui->textEdit_SendRStage->toPlainText();
44 | sendCommand
45 | .append("a" + QString("%1").arg(clowSend, 3, QLatin1Char('0')))
46 | .append("b" + QString("%1").arg(sArmSend, 3, QLatin1Char('0')))
47 | .append("c" + QString("%1").arg(bArmSend, 3, QLatin1Char('0')))
48 | .append("d" + QString("%1").arg(rStageSend, 3, QLatin1Char('0')));
49 | QByteArray command = QString(strAddLine(sendCommand)).toUtf8();
50 | qDebug() << "发送命令:" << command;
51 | upperSerialPort.write(command);
52 | QMessageBox::about(this,"发送命令","命令:" + command + "发送成功!");
53 | }
54 |
55 | }
56 | else {
57 | QMessageBox::warning(this,"切换状态","当前未连接,请进行设备连接!");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/groupBoxFun4.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | /*
7 | * 键盘按下事件
8 | */
9 | void UpperMachine::keyPressEvent(QKeyEvent * event)
10 | {
11 | if(upperSerial.getL_isOpen()) {
12 |
13 | // 单个按键
14 | switch (event->key())
15 | {
16 | // W键
17 | case Qt::Key_W:
18 | // qDebug() <<"W:爪头抓取";
19 | robotAction = RobotAction::CLOW_GRAB;
20 | key_SerialWrite("M2000");
21 | break;
22 | // A键
23 | case Qt::Key_A:
24 | // qDebug() <<"A:小臂内收";
25 | robotAction = RobotAction::SMALL_ARM_ADDUCTION;
26 | key_SerialWrite("M0100");
27 | break;
28 | // X键
29 | case Qt::Key_X:
30 | // qDebug() <<"X:爪头释放";
31 | robotAction = RobotAction::CLOW_RELEASE;
32 | key_SerialWrite("M1000");
33 | break;
34 | // D键
35 | case Qt::Key_D:
36 | // qDebug() <<"D:小臂外展";
37 | robotAction = RobotAction::SMALL_ARM_OUTREACH;
38 | key_SerialWrite("M0200");
39 | break;
40 | // I键
41 | case Qt::Key_I:
42 | // qDebug() <<"I:转台右转";
43 | robotAction = RobotAction::REVOLVING_STAGE_RIGHT;
44 | key_SerialWrite("M0002");
45 | break;
46 | // J键
47 | case Qt::Key_J:
48 | // qDebug() <<"J:大臂内收";
49 | robotAction = RobotAction::BIG_ARM_ADDUCTION;
50 | key_SerialWrite("M0010");
51 | break;
52 | // M键
53 | case Qt::Key_M:
54 | // qDebug() <<"M:转台左转";
55 | robotAction = RobotAction::REVOLVING_STAGE_LEFT;
56 | key_SerialWrite("M0001");
57 | break;
58 | // L键
59 | case Qt::Key_L:
60 | // qDebug() <<"L:大臂外展";
61 | robotAction = RobotAction::BIG_ARM_OUTREACH;
62 | key_SerialWrite("M0020");
63 | break;
64 | default:
65 | break;
66 | }
67 |
68 | // 两键组合
69 | if(event->modifiers() == Qt::ControlModifier) {
70 | if(event->key() == Qt::Key_R){
71 | // Ctrl+R =》 复位
72 | robotAction = RobotAction::RESET;
73 | key_SerialWrite("LEFT");
74 | }
75 | }
76 | if(event->modifiers() == Qt::ControlModifier) {
77 | if(event->key() == Qt::Key_Q){
78 | // Ctrl+Q =》 关闭连接
79 | closeSerialDevice();
80 | }
81 | }
82 | if(event->modifiers() == Qt::ControlModifier) {
83 | if(event->key() == Qt::Key_U){
84 | // Ctrl+U =》 切换状态
85 | switchSteerStatus();
86 | }
87 | }
88 | if(event->modifiers() == Qt::ControlModifier) {
89 | if(event->key() == Qt::Key_L){
90 | // Ctrl+L =》 连接串口
91 | connectUM();
92 | }
93 | }
94 |
95 | // // 三键组合Shift + Ctrl + A的实现
96 | // if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier) && event->key() == Qt::Key_A) {
97 | // qDebug() << "CTRL + Shift + A";
98 | // }
99 |
100 | }
101 | else{
102 | QMessageBox::critical(NULL,"串口异常","请先打开串口!");
103 | upperSerial.setL_isOpen(0);
104 | }
105 | }
106 |
107 | /*
108 | * 键盘释放事件
109 | */
110 | void UpperMachine::keyReleaseEvent(QKeyEvent *event)
111 | {
112 | // 键释放
113 | switch (event->key()) {
114 | case Qt::Key_W:
115 | case Qt::Key_A:
116 | case Qt::Key_X:
117 | case Qt::Key_D:
118 | case Qt::Key_I:
119 | case Qt::Key_J:
120 | case Qt::Key_M:
121 | case Qt::Key_L:
122 | case Qt::Key_Enter:
123 | case Qt::Key_Tab:
124 | case Qt::Key_Delete:
125 | case Qt::Key_R:
126 | key_SerialWrite("M0000");//发送数据
127 | // actionCount = 0;
128 | // qDebug() << ">> 舵机停下";
129 | break;
130 | default:
131 | break;
132 | }
133 |
134 | }
135 |
136 | void UpperMachine :: key_SerialWrite(QString keyValue)
137 | {
138 | upperSerialPort.write(QString(strAddLine(keyValue)).toUtf8());
139 | // QThread::sleep(1);
140 | }
141 |
142 |
--------------------------------------------------------------------------------
/groupBoxFun5.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | /*
6 | * 添加动作
7 | */
8 | void UpperMachine :: addAction()
9 | {
10 | if (upperSerial.getL_isOpen()) {
11 | robotAction = RobotAction::ADD_ACTION;
12 | // 发送指定指令
13 | upperSerialPort.write(QString(strAddLine("DOWN")).toUtf8());
14 | }
15 | else {
16 | QMessageBox::warning(this,"添加动作","当前未连接,请进行设备连接!");
17 | }
18 | }
19 |
20 | /*
21 | * 添加机械臂动作
22 | */
23 | void UpperMachine::addUMAction(QString command)
24 | {
25 | setLocation(command);
26 | QString msg = "";
27 | //判断当前位置是否安全
28 | if (mechanicalArm.getClowLocation().toInt() < mechanicalArm.getCurrent_CMin().toInt() || mechanicalArm.getClowLocation().toInt() > mechanicalArm.getCurrent_CMax().toInt()) {
29 | msg += "爪头超出设置范围,";
30 | // qDebug() << mechanicalArm.getClowLocation().toInt() << "_" << mechanicalArm.getCurrent_CMin() << "_" << mechanicalArm.getCurrent_CMax();
31 | }
32 | if (mechanicalArm.getSmallArmLocation().toInt() < mechanicalArm.getCurrent_SAMin().toInt() || mechanicalArm.getSmallArmLocation().toInt() > mechanicalArm.getCurrent_SAMax().toInt()) {
33 | msg += "小臂超出设置范围,";
34 | }
35 | if (mechanicalArm.getBigArmLocation().toInt() < mechanicalArm.getCurrent_BAMin().toInt() || mechanicalArm.getBigArmLocation().toInt() > mechanicalArm.getCurrent_BAMax().toInt()) {
36 | msg += "大臂超出设置范围,";
37 | }
38 | if (mechanicalArm.getRevolvingStageLocation().toInt() < mechanicalArm.getCurrent_RSMin().toInt() || mechanicalArm.getRevolvingStageLocation().toInt() > mechanicalArm.getCurrent_RSMax().toInt()) {
39 | msg += "转台超出设置范围,";
40 | }
41 |
42 | if (msg != "")
43 | {
44 | QMessageBox::critical(this,"添加动作",msg + "添加失败!");
45 | return;
46 | }
47 |
48 | // ListViewItem lvi = new ListViewItem(new string[] {
49 | // actionIndex.ToString(),
50 | // robot.ClowLocation.ToString(),
51 | // robot.SmallArmLocation.ToString(),
52 | // robot.BigArmLocation.ToString(),
53 | // robot.RevolvingStageLocation.ToString()
54 | // });
55 | // qDebug() << "::" << ui->tableWidget->item() << "——" << ui->tableWidget->columnCount();
56 |
57 | int add_row = 0,add_column = 0;
58 | int add_index = -1;
59 | QModelIndex current_index = ui->tableWidget->currentIndex();
60 | qDebug() << "添加前:" << current_index.row();
61 |
62 | // 以首个单元格作为标记
63 | if ( ui->tableWidget->item(0,0) == NULL )
64 | {
65 | addAction_Location(add_row,add_column);
66 | }
67 | else
68 | {
69 | if(NextItemEmpty(ui->tableWidget,current_index.row(),current_index.column())
70 | && !CurrentItemEmpty(ui->tableWidget,current_index.row(),current_index.column())){
71 | qDebug() << "添加前:" << current_index.row();
72 | add_index = current_index.row()+1;
73 | addAction_Location(add_index,add_column);
74 | // ui->tableWidget->select
75 | // tableWidget->setCurrentItem(NULL);
76 | // for(int j = 0;j < 4;j++){
77 | // ui->tableWidget->item(current_index.row(), j)->setFlags(Qt::NoItemFlags);
78 | // }
79 | // key_SerialWrite("DOWN");
80 | // ui->tableWidget->;
81 | // qDebug() << ui->tableWidget->currentIndex();
82 | // 取消选中行
83 | ui->tableWidget->clearSelection();
84 | // 更换选中行,确保只可添加一次
85 | }
86 | else{
87 | QMessageBox::critical(this,"添加动作","不可空行或重复添加,请重新选择添加的位置");
88 | return;
89 | }
90 | }
91 | // int index = lstAction.SelectedItems[0].Index;
92 | // lstAction.Items.Insert(index + 1, lvi);
93 | // lstAction.SelectedItems[0].Selected = false;
94 | }
95 |
96 | /*
97 | * 删除动作
98 | */
99 | void UpperMachine :: deleteAction()
100 | {
101 | if (ui->tableWidget->selectedItems().count() == 0 ) {
102 | QMessageBox::information(this,"删除动作","请先选中行再进行删除操作!");
103 | qDebug() << "删除失败,选中行:" << ui->tableWidget->currentRow();
104 | return;
105 | }
106 | else
107 | {
108 | // qDebug() << "删除前:" << ui->tableWidget->currentRow();
109 | // ui->tableWidget->removeRow(ui->tableWidget->currentRow());
110 | if(selectRow())
111 | {
112 | QMessageBox::StandardButton btn = QMessageBox::question(this,"删除动作","确认删除当前选中行:第"+ QString::number(ui->tableWidget->currentRow()+1) +"行的动作记录",QMessageBox::Yes|QMessageBox::No);
113 | if (btn == QMessageBox::Yes) {
114 | // 1.1 重新排列
115 | // 1、获取当前索引
116 | // 2、取往下行数据内容
117 | // 3、取往上行数据内容
118 | // 4、合并数据内容
119 | // 5、清空所有数据
120 | // 6、重新赋值
121 | // 1.2 删除行
122 | ui->tableWidget->removeRow(ui->tableWidget->currentRow());
123 | qDebug() << "删除动作记录:" << ui->tableWidget->currentRow();
124 | // 1.2.1 补充行数
125 | int row = ui->tableWidget->rowCount();
126 | ui->tableWidget->insertRow(row);
127 | }
128 | // else
129 | // {
130 | // return;
131 | // }
132 | }
133 | else{
134 | QMessageBox::critical(this,"删除动作","请先选中非空行,再进行删除操作!");
135 | return;
136 | }
137 | }
138 | }
139 |
140 | /*
141 | * 清空动作
142 | */
143 | void UpperMachine :: clearAction()
144 | {
145 | QMessageBox::StandardButton btn = QMessageBox::question(this,"清空轨迹","确认清空当前所有动作记录",QMessageBox::Yes|QMessageBox::No);
146 | if (btn == QMessageBox::Yes) {
147 | ui->tableWidget->clearContents();
148 | }
149 | }
150 |
151 | /*
152 | * 恢复首位
153 | */
154 | void UpperMachine :: firstAction()
155 | {
156 | QByteArray command = QString(strAddLine(readFirstAction())).toUtf8();
157 | qDebug() << "恢复首位:" << command;
158 | upperSerialPort.write(command);
159 | QMessageBox::about(this,"恢复首位","恢复首位:" + command + "成功!");
160 | }
161 |
162 | /*
163 | * 示教启动
164 | */
165 | void UpperMachine::playActions()
166 | {
167 | if(!CurrentItemEmpty(ui->tableWidget,0,0))
168 | {
169 | playStatus = PlayStatus::PLAY;
170 |
171 | // m_pTimer->start(1000); // 1秒
172 | m_pTimer->start(ui->textEdit_timeOut->toPlainText().toInt());
173 | }
174 | else {
175 | QMessageBox::critical(this,"示教运行","数据为空,无法获取数据进行示教!");
176 | return;
177 | }
178 | }
179 |
180 | /*
181 | * 示教暂停
182 | */
183 | void UpperMachine::pauseActions()
184 | {
185 | if(!CurrentItemEmpty(ui->tableWidget,0,0))
186 | {
187 | if(m_pTimer->isActive() && playStatus == PlayStatus :: PLAY){
188 | playStatus = PlayStatus::PAUSE;
189 | m_pTimer->stop();
190 | ui->tableWidget->setFocus();
191 | // 选中当前行
192 | ui->tableWidget->setCurrentCell(playIndex,QItemSelectionModel::Select);
193 | }
194 | else {
195 | QMessageBox::information(this,"示教暂停","当前不存在示教活动");
196 | }
197 | }
198 | else {
199 | QMessageBox::critical(this,"示教运行","数据为空,无法获取数据进行示教!");
200 | return ;
201 | }
202 | }
203 |
204 | /*
205 | * 示教停止
206 | */
207 | void UpperMachine::stopActions()
208 | {
209 | if(!CurrentItemEmpty(ui->tableWidget,0,0))
210 | {
211 | if(m_pTimer->isActive() && playStatus == PlayStatus :: PLAY){
212 | playIndex = 0;
213 | playStatus = PlayStatus::STOP;
214 | m_pTimer->stop();
215 | ui->tableWidget->setFocus();
216 | // 选中当前行
217 | ui->tableWidget->setCurrentCell(playIndex,QItemSelectionModel::Select);
218 | }
219 | else {
220 | QMessageBox::information(this,"示教停止","当前不存在示教活动");
221 | }
222 | }
223 | else {
224 | QMessageBox::critical(this,"示教运行","数据为空,无法获取数据进行示教!");
225 | return ;
226 | }
227 | }
228 |
229 | /*
230 | * 单步运行
231 | */
232 | void UpperMachine::stepActions()
233 | {
234 | if(!CurrentItemEmpty(ui->tableWidget,0,0))
235 | {
236 | if(!m_pTimer->isActive() && (playStatus == PlayStatus :: PAUSE || playStatus == PlayStatus::STOP)){
237 | if (playIndex >= actionCount) {
238 | playIndex = 0;
239 | }
240 | else {
241 | ui->tableWidget->setFocus();
242 | // 选中当前行
243 | ui->tableWidget->setCurrentCell(playIndex,QItemSelectionModel::Select);
244 | QByteArray command = QString(strAddLine(readItems(playIndex))).toUtf8();
245 | qDebug()<<"单步运行,当前索引:" << playIndex;
246 | upperSerialPort.write(command);
247 | playIndex ++;
248 | // 超出范围跳转并停止
249 | // m_pTimer->stop();
250 | }
251 | qDebug() << "当前行:" << ui->tableWidget->currentItem();
252 | }
253 | else {
254 | QMessageBox::information(this,"单步运行","示教活动正在运行或当前不存在示教活动");
255 | }
256 | }
257 | else {
258 | QMessageBox::critical(this,"示教运行","数据为空,无法获取数据进行示教!");
259 | return;
260 | }
261 | }
262 |
--------------------------------------------------------------------------------
/homesettings.h:
--------------------------------------------------------------------------------
1 | #ifndef HOMESETTINGS_H
2 | #define HOMESETTINGS_H
3 |
4 | #include
5 | #include
6 |
7 | void UpperMachine :: application_UISettings(void)
8 | {
9 | mechanicalArm.setStartCheck(0);
10 | // 菜单栏背景色
11 | ui->menubar->setStyleSheet("background-color:rgb(195, 197, 198)");
12 |
13 |
14 | // 获取位置只读
15 | ui->textEdit_BArmObtain->setReadOnly(true);
16 | ui->textEdit_ClowObtain->setReadOnly(true);
17 | ui->textEdit_SArmObtain->setReadOnly(true);
18 | ui->textEdit_RevolvingStageObtain->setReadOnly(true);
19 |
20 | // 配置文本框事件过滤器
21 | ui->textEdit_ClowMin->installEventFilter(this);
22 | ui->textEdit_ClowMax->installEventFilter(this);
23 | ui->textEdit_SArmMin->installEventFilter(this);
24 | ui->textEdit_SArmMax->installEventFilter(this);
25 | ui->textEdit_BArmMin->installEventFilter(this);
26 | ui->textEdit_BArmMax->installEventFilter(this);
27 | ui->textEdit_RStageMin->installEventFilter(this);
28 | ui->textEdit_RStageMax->installEventFilter(this);
29 |
30 |
31 | // 配置按钮事件过滤器
32 | ui->pushButton_W->installEventFilter(this);
33 | ui->pushButton_A->installEventFilter(this);
34 | ui->pushButton_X->installEventFilter(this);
35 | ui->pushButton_D->installEventFilter(this);
36 | ui->pushButton_I->installEventFilter(this);
37 | ui->pushButton_J->installEventFilter(this);
38 | ui->pushButton_M->installEventFilter(this);
39 | ui->pushButton_L->installEventFilter(this);
40 |
41 |
42 | // 居中显示
43 | ui->textEdit_ClowObtain->setAlignment(Qt::AlignCenter);
44 | ui->textEdit_SArmObtain->setAlignment(Qt::AlignCenter);
45 | ui->textEdit_BArmObtain->setAlignment(Qt::AlignCenter);
46 | ui->textEdit_RevolvingStageObtain->setAlignment(Qt::AlignCenter);
47 | ui->textEdit_ClowMin->setAlignment(Qt::AlignCenter);
48 | ui->textEdit_ClowMax->setAlignment(Qt::AlignCenter);
49 | ui->textEdit_SArmMin->setAlignment(Qt::AlignCenter);
50 | ui->textEdit_SArmMax->setAlignment(Qt::AlignCenter);
51 | ui->textEdit_BArmMin->setAlignment(Qt::AlignCenter);
52 | ui->textEdit_BArmMax->setAlignment(Qt::AlignCenter);
53 | ui->textEdit_RStageMin->setAlignment(Qt::AlignCenter);
54 | ui->textEdit_RStageMax->setAlignment(Qt::AlignCenter);
55 | ui->textEdit_SendClow->setAlignment(Qt::AlignCenter);
56 | ui->textEdit_SendSArm->setAlignment(Qt::AlignCenter);
57 | ui->textEdit_SendBArm->setAlignment(Qt::AlignCenter);
58 | ui->textEdit_SendRStage->setAlignment(Qt::AlignCenter);
59 |
60 |
61 |
62 | ///设置表格
63 | // 设置列数:限定5列
64 | ui->tableWidget->setColumnCount(4);
65 | // 设置行数:限定10行
66 | ui->tableWidget->setRowCount(10);
67 | // 设置标题
68 | ui->tableWidget->setWindowTitle("示教表格");
69 | // 设置表头
70 | QStringList tableHeader;
71 | tableHeader << QString("爪头") << QString("小臂") << QString("大臂") << QString("转台");
72 | ui->tableWidget->setHorizontalHeaderLabels(tableHeader);
73 | // 表头可视化
74 | ui->tableWidget->verticalHeader()->setVisible(true);
75 | ui->tableWidget->horizontalHeader()->setVisible(true);
76 | // 隐藏栅格
77 | // ui->tableWidget->setShowGrid(false);
78 |
79 | // 设置可编辑
80 | // ui->tableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers);
81 | ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
82 |
83 | // 设置表格选择方式:设置表格为整列选中
84 | ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
85 | // 选择目标方式
86 | ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
87 | // 设置选中颜色:粉色
88 | ui->tableWidget->setStyleSheet("selection-background-color:gray");
89 | // 设置水平滚动条
90 | ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
91 | // 设置垂直滚动条
92 | ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
93 | // 只能选中一行,不可多行
94 | ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
95 | // 去掉每行的行号
96 | // QHeaderView *headerView = ui->tableWidget->verticalHeader();
97 | // headerView->setHidden(true);
98 |
99 | // 获取单元格的内容
100 | // QString strText = ui->tableWidget->item(1, 1)->text();
101 | // 输出单元格内容
102 | // qDebug()<<"单元格内容:"<pushButton_STEP->setFlat(1);
107 | // ui->pushButton_STEP->setStyleSheet("outline: none");
108 | ui->pushButton_PAUSE->setFlat(1);
109 | // ui->pushButton_PAUSE->setStyleSheet("outline: none");
110 | ui->pushButton_STOP->setFlat(1);
111 | // ui->pushButton_STOP->setStyleSheet("outline: none");
112 | ui->pushButton_PLAY->setFlat(1);
113 | // ui->pushButton_PLAY->setStyleSheet("outline: none");
114 |
115 |
116 |
117 |
118 | for(int rows=0;rowstableWidget->rowCount();rows++)
119 | {
120 | for(int columns=0;columnstableWidget->columnCount();columns++)
121 | {
122 | ui->tableWidget->setRowHeight(rows,30);
123 | ui->tableWidget->setColumnWidth(columns,100);
124 | // // 居中显示
125 | // ui->tableWidget->item(rows,columns)->setTextAlignment(Qt::AlignCenter);
126 | // 设置前景颜色
127 | // ui->tableWidget->item(rows,columns)->setBackground(QColor(85,170,255));
128 | // ui->tableWidget->item(rows,columns)->setTextColor();//设置文本颜色
129 | // 设置字体为黑体
130 | // ui->tableWidget->item(rows,columns)->setFont(QFont("Helvetica"));
131 | }
132 | }
133 |
134 |
135 | // 文本框默认软限位
136 | ui->textEdit_ClowMin->setText(QString::number(mechanicalArm.getClowMin()));
137 | ui->textEdit_ClowMax->setText(QString::number(mechanicalArm.getClowMax()));
138 | ui->textEdit_SArmMin->setText(QString::number(mechanicalArm.getSArmMin()));
139 | ui->textEdit_SArmMax->setText(QString::number(mechanicalArm.getSArmMax()));
140 | ui->textEdit_BArmMin->setText(QString::number(mechanicalArm.getBArmMin()));
141 | ui->textEdit_BArmMax->setText(QString::number(mechanicalArm.getBArmMax()));
142 | ui->textEdit_RStageMin->setText(QString::number(mechanicalArm.getRStageMin()));
143 | ui->textEdit_RStageMax->setText(QString::number(mechanicalArm.getRStageMax()));
144 |
145 | mechanicalArm.setStartCheck(1);
146 |
147 | // 设置软限位默认值
148 | currentsoftlimitSettings();
149 |
150 | // 默认间隔时间
151 | ui->textEdit_timeOut->setText("2500");
152 |
153 |
154 |
155 |
156 | }
157 |
158 | //void UpperMachine :: controlsSettings(bool tf)
159 | //{
160 | // if (upperSerial.getL_isOpen() == true) {
161 |
162 | // }
163 | // else
164 | // {
165 |
166 | // }
167 | // ui->pushButton_CloseSerial->setEnabled(1);
168 | // ui->pushButton_ReadLocation->setEnabled(1);
169 | // ui->pushButton_SwitchStatus->setEnabled(1);
170 | //}
171 |
172 |
173 | #endif // HOMESETTINGS_H
174 |
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | #include "uppermachine.h"
2 |
3 | #include
4 | #include
5 |
6 | int main(int argc, char *argv[])
7 | {
8 | QApplication a(argc, argv);
9 | // 主程序类
10 | UpperMachine upperMachine;
11 | upperMachine.setWindowTitle("上位机349");
12 | upperMachine.show();
13 | QMessageBox::aboutQt(NULL, "QtAbout");
14 | return a.exec();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/mechanicalarm.cpp:
--------------------------------------------------------------------------------
1 | #include "mechanicalarm.h"
2 |
3 | //机械臂类
4 | MechanicalArm::MechanicalArm()
5 | {
6 |
7 | }
8 |
9 | MechanicalArm::~MechanicalArm()
10 | {
11 |
12 | }
13 |
14 | QString MechanicalArm::getCurrent_SAMin() const
15 | {
16 | return current_SAMin;
17 | }
18 |
19 | void MechanicalArm::setCurrent_SAMin(const QString &value)
20 | {
21 | current_SAMin = value;
22 | }
23 |
24 | QString MechanicalArm::getCurrent_BAMin() const
25 | {
26 | return current_BAMin;
27 | }
28 |
29 | void MechanicalArm::setCurrent_BAMin(const QString &value)
30 | {
31 | current_BAMin = value;
32 | }
33 |
34 | QString MechanicalArm::getCurrent_RSMin() const
35 | {
36 | return current_RSMin;
37 | }
38 |
39 | void MechanicalArm::setCurrent_RSMin(const QString &value)
40 | {
41 | current_RSMin = value;
42 | }
43 |
44 | QString MechanicalArm::getCurrent_RSMax() const
45 | {
46 | return current_RSMax;
47 | }
48 |
49 | void MechanicalArm::setCurrent_RSMax(const QString &value)
50 | {
51 | current_RSMax = value;
52 | }
53 |
54 | QString MechanicalArm::getCurrent_BAMax() const
55 | {
56 | return current_BAMax;
57 | }
58 |
59 | void MechanicalArm::setCurrent_BAMax(const QString &value)
60 | {
61 | current_BAMax = value;
62 | }
63 |
64 | QString MechanicalArm::getCurrent_SAMax() const
65 | {
66 | return current_SAMax;
67 | }
68 |
69 | void MechanicalArm::setCurrent_SAMax(const QString &value)
70 | {
71 | current_SAMax = value;
72 | }
73 |
74 | QString MechanicalArm::getCurrent_CMax() const
75 | {
76 | return current_CMax;
77 | }
78 |
79 | void MechanicalArm::setCurrent_CMax(const QString &value)
80 | {
81 | current_CMax = value;
82 | }
83 |
84 | QString MechanicalArm::getCurrent_CMin() const
85 | {
86 | return current_CMin;
87 | }
88 |
89 | void MechanicalArm::setCurrent_CMin(const QString &value)
90 | {
91 | current_CMin = value;
92 | }
93 |
94 | int MechanicalArm::getStartCheck() const
95 | {
96 | return startCheck;
97 | }
98 |
99 | void MechanicalArm::setStartCheck(int value)
100 | {
101 | startCheck = value;
102 | }
103 |
104 |
105 | QString MechanicalArm::getRevolvingStageLocation() const
106 | {
107 | return RevolvingStageLocation;
108 | }
109 |
110 | void MechanicalArm::setRevolvingStageLocation(const QString &value)
111 | {
112 | RevolvingStageLocation = value;
113 | }
114 |
115 | QString MechanicalArm::getBigArmLocation() const
116 | {
117 | return BigArmLocation;
118 | }
119 |
120 | void MechanicalArm::setBigArmLocation(const QString &value)
121 | {
122 | BigArmLocation = value;
123 | }
124 |
125 | QString MechanicalArm::getSmallArmLocation() const
126 | {
127 | return SmallArmLocation;
128 | }
129 |
130 | void MechanicalArm::setSmallArmLocation(const QString &value)
131 | {
132 | SmallArmLocation = value;
133 | }
134 |
135 | QString MechanicalArm::getClowLocation() const
136 | {
137 | return ClowLocation;
138 | }
139 |
140 | void MechanicalArm::setClowLocation(const QString &value)
141 | {
142 | ClowLocation = value;
143 | }
144 |
145 | int MechanicalArm::getRStageMin() const
146 | {
147 | return RStageMin;
148 | }
149 |
150 | int MechanicalArm::getRStageMax() const
151 | {
152 | return RStageMax;
153 | }
154 |
155 | int MechanicalArm::getBArmMax() const
156 | {
157 | return BArmMax;
158 | }
159 |
160 | int MechanicalArm::getBArmMin() const
161 | {
162 | return BArmMin;
163 | }
164 |
165 | int MechanicalArm::getSArmMin() const
166 | {
167 | return SArmMin;
168 | }
169 |
170 | int MechanicalArm::getSArmMax() const
171 | {
172 | return SArmMax;
173 | }
174 |
175 | int MechanicalArm::getClowMax() const
176 | {
177 | return ClowMax;
178 | }
179 |
180 | int MechanicalArm::getClowMin() const
181 | {
182 | return ClowMin;
183 | }
184 |
--------------------------------------------------------------------------------
/mechanicalarm.h:
--------------------------------------------------------------------------------
1 | #ifndef MECHANICALARM_H
2 | #define MECHANICALARM_H
3 | #include
4 |
5 | //机械臂类
6 | class MechanicalArm
7 | {
8 |
9 | public:
10 | MechanicalArm();
11 | ~MechanicalArm();
12 |
13 | int startCheck = 0;
14 |
15 | //手爪位置
16 | QString ClowLocation;
17 | // 手爪软限位
18 | const int ClowMin=0,ClowMax=180;
19 | // 当前软限位
20 | QString current_CMin = QString(ClowMin),current_CMax = QString(ClowMax);
21 |
22 | //小臂位置
23 | QString SmallArmLocation;
24 | // 手爪软限位
25 | const int SArmMin= 45 ,SArmMax= 105 ;
26 | // 当前软限位
27 | QString current_SAMin = QString(SArmMin),current_SAMax = QString(SArmMax);
28 |
29 | //大臂位置
30 | QString BigArmLocation;
31 | // 手爪软限位
32 | const int BArmMin= 40 ,BArmMax= 135 ;
33 | // 当前软限位
34 | QString current_BAMin = QString(BArmMin),current_BAMax = QString(BArmMax);
35 |
36 | //转台
37 | QString RevolvingStageLocation;
38 | // 手爪软限位
39 | const int RStageMin= 0 ,RStageMax= 180 ;
40 | // 当前软限位
41 | QString current_RSMin = QString(RStageMin),current_RSMax = QString(RStageMax);
42 |
43 |
44 |
45 | int getClowMin() const;
46 | int getClowMax() const;
47 | int getSArmMax() const;
48 | int getSArmMin() const;
49 | int getBArmMin() const;
50 | int getBArmMax() const;
51 | int getRStageMax() const;
52 | int getRStageMin() const;
53 | QString getClowLocation() const;
54 | void setClowLocation(const QString &value);
55 | QString getSmallArmLocation() const;
56 | void setSmallArmLocation(const QString &value);
57 | QString getBigArmLocation() const;
58 | void setBigArmLocation(const QString &value);
59 | QString getRevolvingStageLocation() const;
60 | void setRevolvingStageLocation(const QString &value);
61 | int getStartCheck() const;
62 | void setStartCheck(int value);
63 | QString getCurrent_CMin() const;
64 | void setCurrent_CMin(const QString &value);
65 | QString getCurrent_CMax() const;
66 | void setCurrent_CMax(const QString &value);
67 | QString getCurrent_SAMax() const;
68 | void setCurrent_SAMax(const QString &value);
69 | QString getCurrent_BAMax() const;
70 | void setCurrent_BAMax(const QString &value);
71 | QString getCurrent_RSMax() const;
72 | void setCurrent_RSMax(const QString &value);
73 | QString getCurrent_RSMin() const;
74 | void setCurrent_RSMin(const QString &value);
75 | QString getCurrent_BAMin() const;
76 | void setCurrent_BAMin(const QString &value);
77 | QString getCurrent_SAMin() const;
78 | void setCurrent_SAMin(const QString &value);
79 | int getIndex_mark() const;
80 | void setIndex_mark(int value);
81 | int getPlayIndex() const;
82 | void setPlayIndex(int value);
83 | };
84 |
85 | #endif // MECHANICALARM_H
86 |
--------------------------------------------------------------------------------
/otherFun.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | /*
8 | * 添加换行
9 | */
10 | QString strAddLine(QString str)
11 | {
12 | return str+"\n";
13 | }
14 |
15 |
16 | /*
17 | * 去除末尾
18 | */
19 | QString strDelLast(QByteArray command)
20 | {
21 | return command.replace("\r\n","");
22 | }
23 |
24 |
25 |
26 | /*
27 | * 自定义延时
28 | */
29 | void sleep_MS(int msec)
30 | {
31 | QTime dieTime = QTime::currentTime().addMSecs(msec);
32 | while( QTime::currentTime() < dieTime )
33 | QCoreApplication::processEvents(QEventLoop::AllEvents, 50);
34 | }
35 |
36 |
37 |
38 | /*
39 | * 查询状态编码
40 | */
41 | int findModelNum(QByteArray arrayBuffer)
42 | {
43 | QString command = QString(strDelLast(arrayBuffer));
44 | QStringList arrayList = command.split("式");
45 | return arrayList[1].left(1).toInt();
46 | }
47 |
48 |
49 |
50 | /*
51 | * 查询状态信息
52 | */
53 | int findModelInfo(QByteArray arrayBuffer)
54 | {
55 | qDebug() << "当前操纵状态:" << QString(arrayBuffer);
56 | QString command = QString(strDelLast(arrayBuffer));
57 | QStringList arrayList = command.split("模式");
58 | QMessageBox::StandardButton btn = QMessageBox::question(NULL,"操纵状态",arrayList[1].right(6)+",继续切换?",QMessageBox::Yes|QMessageBox::No);
59 | if (btn == QMessageBox::Yes) {
60 | return 1;
61 | }
62 | else
63 | {
64 | return 0;
65 | }
66 | }
67 |
68 |
69 |
--------------------------------------------------------------------------------
/otherHeader.h:
--------------------------------------------------------------------------------
1 | #ifndef OTHERHEADER_H
2 | #define OTHERHEADER_H
3 |
4 | #include
5 |
6 |
7 | //休眠
8 | void sleep_MS(int);
9 | //加换行
10 | QString strAddLine(QString);
11 | //除去末尾
12 | QString strDelLast(QByteArray);
13 | //寻找状态编码
14 | int findModelNum(QByteArray);
15 | //查询状态信息
16 | int findModelInfo(QByteArray);
17 |
18 | #endif // OTHERHEADER_H
19 |
--------------------------------------------------------------------------------
/serialFun.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 |
6 | /*
7 | * 设备连接--获取全称
8 | */
9 | void UpperMachine::connectUM()
10 | {
11 | if (upperSerial.getL_isOpen() == 1) {
12 | QMessageBox::about(this,"打开串口","当前串口已经打开,设备:"+upperSerial.getDeviceName());
13 | }
14 | else{
15 | //获取设备全称,获取则说明连接成功 Arduino Uno (COM4)
16 | upperSerial.setDeviceName(GetDeviceFullName());
17 | /*Console.WriteLine("设备信息" + deviceFullName);*/
18 | if (upperSerial.getDeviceName().contains(upperSerial.getL_deviceFlag()))
19 | {
20 | try {
21 | upperSerialPort.setPortName(QString(upperSerial.getL_c_protName()));
22 | upperSerialPort.setBaudRate(upperSerial.getL_c_baudRate());
23 | // upperSerialPort.setDataBits(upperSerial.getL_c_dataBits());
24 | // upperSerialPort.setStopBits(upperSerial.getL_c_stopBits());
25 | // upperSerialPort.setParity(upperSerial.getL_c_parity());
26 | upperSerialPort.setDataBits(QSerialPort::Data8);
27 | upperSerialPort.setStopBits(QSerialPort::OneStop);
28 | upperSerialPort.setParity(QSerialPort::NoParity);
29 | upperSerialPort.setFlowControl(QSerialPort::NoFlowControl);
30 | connect(&upperSerialPort, &QSerialPort::readyRead, this, &UpperMachine::serialPort_ReadAvailable);
31 | // do {
32 | upperSerialPort.open(QIODevice::ReadWrite);
33 | // } while ( upperSerialPort.open(QIODevice::ReadWrite) != true);
34 |
35 | // QMessageBox *btn2 = new QMessageBox(QMessageBox::Information,QString("打开串口中"),QString("串口打开中,请稍后......"));
36 | // sleep_MS(10);
37 | // btn2->exec();
38 | QMessageBox::about(this,"打开串口","串口打开成功");
39 | upperSerial.setL_isOpen(1);
40 | upperSerial.setL_isOpen(upperSerialPort.isOpen());
41 | ui->label_deviceName->setText(upperSerial.getDeviceName());
42 | ui->label_connectInfo->setStyleSheet("color:green;");
43 | ui->label_connectInfo->setText("连接成功");
44 | ui->label_StatusInfo->setStyleSheet("color:black;");
45 | ui->label_StatusInfo->setText("默认状态");
46 | qDebug() << upperSerial.getL_isOpen() << "\\" << upperSerialPort.portName()
47 | << "\\" << upperSerialPort.baudRate() << "\\" << upperSerialPort.dataBits()
48 | << "\\" << upperSerialPort.stopBits()
49 | << "\\RW:" << upperSerialPort.open(QIODevice::ReadWrite);
50 | // sp.DataReceived += Sp_DataReceived;
51 | // sp.Open();
52 | //探测一次当前状态
53 | //切换响应状态
54 | // robotAction = RobotAction::UP;
55 | //发送数据
56 | //sp.Write("UP\n");
57 |
58 | } catch (exception ex_rw) {
59 | qDebug() << "打开串口失败" << QString(ex_rw.what());
60 | ui->label_deviceName->setText("设备配置有误");
61 | ui->label_connectInfo->setStyleSheet("color:red;");
62 | ui->label_connectInfo->setText("打开设备失败!");
63 | }
64 | }
65 | else
66 | {
67 | qDebug() << "打开串口失败,不存在类似设备名称";
68 | ui->label_deviceName->setText("不存在类似设备名称");
69 | ui->label_connectInfo->setStyleSheet("color:red;");
70 | ui->label_connectInfo->setText("连接设备失败!");
71 | }
72 | }
73 | }
74 |
75 |
76 |
77 | /*
78 | * 读取接收数据
79 | */
80 | void UpperMachine :: readAvailableInfo()
81 | {
82 | //接收设备返回的命令
83 | QString command_Recept;
84 | try {
85 | QByteArray buffer;
86 | // arrayBuffer.clear();
87 | // 1、读取缓冲字节
88 | if (upperSerialPort.bytesAvailable()) {
89 | // 串口收到的数据并非连续的,需要进行缓存在进行解析
90 | // 从串口接收缓冲区中读取所有数据
91 | buffer = upperSerialPort.readAll();
92 | qDebug() << "已接收:" << buffer;
93 | }
94 | // 2、将字节加入自定义接收输入缓冲区列
95 | // tempBuffer.append(buffer);
96 | arrayBuffer.append(buffer);
97 | qDebug() << "已存入:" << arrayBuffer << "——" + QString::number(arrayBuffer.count(),10);
98 |
99 | // 2.1、接收数据完整,执行指令
100 | if (arrayBuffer.contains("\n"))
101 | {
102 | // 3、解析当前操纵指令
103 | switch (robotAction) {
104 | /*
105 | * 获取当前坐标
106 | */
107 | case RobotAction::DOWN:
108 | //最小软限位 a:0,b:45,c:40,d:0\n 总共18个字节数
109 | // if (tempBuffer.count() >= 18)
110 | if (arrayBuffer.count() >= 18)
111 | {
112 | //除去换行符
113 | command_Recept = QString(strDelLast(arrayBuffer));
114 | //清空缓存
115 | arrayBuffer.clear();
116 | //执行命令
117 | doDOWN(command_Recept);
118 | qDebug() << "操纵指令" << RobotAction::DOWN << "执行成功!";
119 | qDebug() << "++++++++++++++++++++++++++++++++++++++";
120 | upperSerial.setWriteSuccess(1);
121 | }else{
122 | qDebug() << "返回数据长度过低,数据有误,请检查主控制器指令处理与设备安全状态!";
123 | upperSerial.setWriteSuccess(0);
124 | }
125 | break;
126 | /*
127 | * 状态切换
128 | */
129 | case RobotAction::UP:
130 | if (arrayBuffer.count() == 27)
131 | {
132 | int modelNum = findModelNum(arrayBuffer);
133 | qDebug() << "状态编码:" << modelNum;
134 | // isBlueLight = modelNum == 0? true:false;
135 | int switchContinue = findModelInfo(arrayBuffer);
136 | if (switchContinue == 1) {
137 | arrayBuffer.clear();
138 | // 切换状态
139 | robotAction = RobotAction::UP;
140 | // 写入切换指令
141 | upperSerialPort.write(QString(strAddLine("UP")).toUtf8());
142 | }
143 | else {
144 | QString info = QString(strDelLast(arrayBuffer)).split("模式")[1].right(4);
145 | qDebug() << "切换后的状态:" << info;
146 | arrayBuffer.clear();
147 | ui->label_StatusInfo->setText(info);
148 | QMessageBox::about(this,"切换命令","状态:" + info + "切换成功!");
149 | upperSerial.setWriteSuccess(1);
150 | }
151 | }
152 | else{
153 | qDebug() << "获取信息有误!" << arrayBuffer;
154 | upperSerial.setWriteSuccess(0);
155 | }
156 | break;
157 | case RobotAction::RESET:
158 | // qDebug() << arrayBuffer.count() << isBlueLight;
159 | // if (arrayBuffer.count() == 8 && isBlueLight == true)
160 | if (arrayBuffer.count() == 8 )
161 | {
162 | qDebug() << "复位成功!";
163 | QMessageBox::about(this,"复位命令","复位成功!");
164 | arrayBuffer.clear();
165 | upperSerial.setWriteSuccess(1);
166 | }
167 | else
168 | QMessageBox::critical(this,"复位命令","复位失败!");
169 | upperSerial.setWriteSuccess(0);
170 | break;
171 | case RobotAction::ADD_ACTION:
172 | if (arrayBuffer.count() >= 18)
173 | {
174 | //除去末尾符 \r\n
175 | command_Recept = QString(strDelLast(arrayBuffer));
176 | arrayBuffer.clear();
177 | // 执行命令,单单获取不进行坐标设置
178 | // doDOWN(command_Recept);
179 | addUMAction(command_Recept);
180 | }
181 | else {
182 | upperSerial.setWriteSuccess(0);
183 | }
184 | break;
185 | default:
186 | // tempBuffer.clear();
187 | // arrayBuffer.clear();
188 | // upperSerial.setWriteSuccess(false);
189 | break;
190 | }
191 | }
192 | else {
193 | qDebug() << "数据不完整(元数据以换行符号结束)";
194 | }
195 | } catch (exception &ex) {
196 | qDebug() << ex.what();
197 | QMessageBox::critical(this, "串口返回数据解析异常", QString(ex.what()));
198 | }
199 | }
200 |
201 |
202 |
203 | /*
204 | * 获取设备全称、查询可用串口
205 | */
206 | QString UpperMachine :: GetDeviceFullName()
207 | {
208 | upperSerialPort.reset();
209 | upperSerialPort.close();
210 | upperSerial.setL_isOpen(false);
211 | // ui->textEdit_Receipt->append("查询可用串口中......");
212 | qDebug("查询可用串口中......");
213 | sleep_MS(50);
214 | int i = QSerialPortInfo::availablePorts().count() , j = i;
215 | // 通过QSerialPortInfo类进行遍历,查找可用串口设备
216 | foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
217 | {
218 | QString infoMain = info.portName() + ":" + info.description();
219 | i--;
220 | QMessageBox::StandardButton btn;
221 | if (info.isBusy()) {
222 | QMessageBox::question(this, "可用串口提示", infoMain + "被占用!寻找下一串口?", QMessageBox::Yes|QMessageBox::No);
223 | }
224 | else{
225 | if (info.description().contains(upperSerial.getL_deviceFlag())) {
226 | btn = QMessageBox::information(this,"匹配信息","相似设备匹配到一台:"+infoMain+"!\n匹配成功!",QMessageBox::Yes);
227 | upperSerial.setL_c_protName(info.portName());
228 | qDebug() << "相似设备匹配到一台:" << j - i << "、" << infoMain;
229 | return info.description();
230 | }
231 | else {
232 | qDebug() << "未找到指定匹配串口设备: " << upperSerial.getL_deviceFlag();
233 | btn = QMessageBox::question(this,"未匹配到相似设备:"+upperSerial.getL_deviceFlag()+"!\n匹配失败!", "串口"+ infoMain + "不匹配!继续查询?",QMessageBox::Yes|QMessageBox::No);
234 | }
235 | }
236 | if (btn == QMessageBox::Yes) {
237 | if (i != 0) {
238 | qDebug() << j - i << "、" << infoMain;
239 | continue;
240 | }else{
241 | qDebug() << j - i << "、" << infoMain;
242 | QMessageBox :: information(this,"搜索提示","结束可用串口设备搜索!",QMessageBox::Ok);
243 | break;
244 | }
245 | }else {
246 | QMessageBox :: information(this,"搜索提示","结束可用串口设备搜索!",QMessageBox::Ok);
247 | break;
248 | }
249 | }
250 | return "";
251 | }
252 |
253 |
254 |
255 | /*
256 | * 添加动作记录
257 | */
258 | void UpperMachine :: addAction_Location(int add_row,int add_column)
259 | {
260 | ui->tableWidget->setItem(add_row,add_column + 0,new QTableWidgetItem(mechanicalArm.getClowLocation()));
261 | ui->tableWidget->setItem(add_row,add_column + 1,new QTableWidgetItem(mechanicalArm.getSmallArmLocation()));
262 | ui->tableWidget->setItem(add_row,add_column + 2,new QTableWidgetItem(mechanicalArm.getBigArmLocation()));
263 | ui->tableWidget->setItem(add_row,add_column + 3,new QTableWidgetItem(mechanicalArm.getRevolvingStageLocation()));
264 | qDebug() << "添加成功!";
265 | upperSerial.setWriteSuccess(1);
266 | QMessageBox::about(this,"添加动作","动作: 添加成功!");
267 | actionCount ++;
268 | }
269 |
270 |
--------------------------------------------------------------------------------
/serialHeader.h:
--------------------------------------------------------------------------------
1 | #ifndef BASICHEADER_H
2 | #define BASICHEADER_H
3 |
4 | //串口与类
5 | #include
6 | #include "upperserial.h"
7 | #include
8 |
9 |
10 | #endif // BASICHEADER_H
11 |
--------------------------------------------------------------------------------
/timerFun.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 |
6 | /*
7 | * 计时器超时处理
8 | */
9 | void UpperMachine::handleTimeout()
10 | {
11 | if (playStatus == PlayStatus::PLAY) {
12 | qDebug()<<"示教启动,当前索引:" << playIndex;
13 | ui->tableWidget->setFocus();
14 | // 选中当前行
15 | ui->tableWidget->setCurrentCell(playIndex,QItemSelectionModel::Select);
16 | qDebug() << "当前行:" << ui->tableWidget->currentItem();
17 | // 发送指令
18 | QByteArray command = QString(strAddLine(readItems(playIndex))).toUtf8();
19 | // qDebug() << "恢复首位:" << command;
20 | upperSerialPort.write(command);
21 | qDebug() << command;
22 | // QMessageBox::about(this,"恢复首位","命令:" + command + "发送成功!");
23 | playIndex ++;
24 | if (playIndex >= actionCount) {
25 | playIndex = 0;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/uppermachine.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include
6 | #include
7 | #include "enumHeader.h"
8 |
9 | UpperMachine::UpperMachine(QWidget *parent) :
10 | QMainWindow(parent),
11 | ui(new Ui::UpperMachine)
12 | {
13 | ui->setupUi(this);
14 | // 连接信号和槽:连接函数(指定类《控件》,信号,主体应用,槽函数)
15 | connect(ui->menubar,SIGNAL(triggered(QAction*)), this, SLOT(menuBar_Action(QAction*)));
16 | // connect(&upperSerialPort, &QSerialPort::readyRead, this, &UpperMachine::serialPort_ReadAvailable);
17 | this->setWindowIcon(QIcon(".\\Image\\machine.png"));
18 | // 主程序界面
19 | application_UISettings();
20 | // qDebug() << "进入主页";`
21 |
22 | //定时器实例化
23 | m_pTimer = new QTimer(this);
24 | //超时槽函数
25 | connect(m_pTimer, SIGNAL(timeout()), this, SLOT(handleTimeout()));
26 |
27 | }
28 |
29 | UpperMachine::~UpperMachine()
30 | {
31 | delete ui;
32 | }
33 |
34 | /*
35 | * 接收串口读取的数据
36 | */
37 | void UpperMachine::serialPort_ReadAvailable()
38 | {
39 | readAvailableInfo();
40 | }
41 |
42 | /*
43 | * 获取当前位置
44 | */
45 | void UpperMachine::on_pushButton_ReadLocation_clicked()
46 | {
47 | readCurrentLocation();
48 | }
49 |
50 | /*
51 | * 关闭当前串口设备
52 | */
53 | void UpperMachine::on_pushButton_CloseSerial_clicked()
54 | {
55 | closeSerialDevice();
56 | }
57 |
58 | /*
59 | * 操纵状态切换
60 | */
61 | void UpperMachine::on_pushButton_SwitchStatus_clicked()
62 | {
63 | switchSteerStatus();
64 | }
65 |
66 | /*
67 | * 软限位
68 | */
69 | bool UpperMachine::eventFilter(QObject *object, QEvent *event)
70 | {
71 | // if (upperSerial.getL_isOpen()) {
72 | // 输入聚焦
73 | if (event->type()==QEvent::FocusOut){
74 | groupbox2_eventFilter(object);
75 | }
76 | // 鼠标按压
77 | if (event->type()==QEvent::MouseButtonPress){
78 | groupbox4_eventFilter(object);
79 | }
80 | if (event->type()==QEvent::MouseButtonRelease){
81 | key_SerialWrite("M0000");
82 | }
83 |
84 |
85 |
86 | return false;
87 | // }
88 | // else {
89 | // QMessageBox::warning(this,"添加动作","当前未连接,请进行设备连接!");
90 | // return false;
91 | // }
92 | }
93 |
94 | /*
95 | * 复位
96 | */
97 | void UpperMachine::on_pushButton_Reset_clicked()
98 | {
99 | resetLocation();
100 | }
101 |
102 | /*
103 | * 发送位置
104 | */
105 | void UpperMachine::on_pushButton_SendLocation_clicked()
106 | {
107 | sendLocation();
108 | }
109 |
110 | /*
111 | * 爪头抓取
112 | */
113 | void UpperMachine::on_pushButton_W_clicked()
114 | {
115 | groupbox4_eventFilter(ui->pushButton_W);
116 | // qDebug() <<"W:爪头抓取";
117 | // robotAction = RobotAction::CLOW_GRAB;
118 | // key_SerialWrite("M2000");
119 | }
120 |
121 | void UpperMachine::on_pushButton_W_released()
122 | {
123 | key_SerialWrite("M0000");
124 | }
125 |
126 | /*
127 | * 爪头释放
128 | */
129 | void UpperMachine::on_pushButton_X_clicked()
130 | {
131 | groupbox4_eventFilter(ui->pushButton_X);
132 | }
133 |
134 | void UpperMachine::on_pushButton_X_released()
135 | {
136 | key_SerialWrite("M0000");
137 | }
138 |
139 | /*
140 | * 小臂外展
141 | */
142 | void UpperMachine::on_pushButton_A_clicked()
143 | {
144 | groupbox4_eventFilter(ui->pushButton_A);
145 | }
146 |
147 | void UpperMachine::on_pushButton_A_released()
148 | {
149 | key_SerialWrite("M0000");
150 | }
151 |
152 | /*
153 | * 小臂内收
154 | */
155 | void UpperMachine::on_pushButton_D_clicked()
156 | {
157 | groupbox4_eventFilter(ui->pushButton_D);
158 | }
159 |
160 | void UpperMachine::on_pushButton_D_released()
161 | {
162 | key_SerialWrite("M0000");
163 | }
164 |
165 | /*
166 | * 大臂外展
167 | */
168 | void UpperMachine::on_pushButton_J_clicked()
169 | {
170 | groupbox4_eventFilter(ui->pushButton_J);
171 | }
172 |
173 | void UpperMachine::on_pushButton_J_released()
174 | {
175 | key_SerialWrite("M0000");
176 | }
177 |
178 | /*
179 | * 大臂内收
180 | */
181 | void UpperMachine::on_pushButton_L_clicked()
182 | {
183 | groupbox4_eventFilter(ui->pushButton_L);
184 | }
185 |
186 | void UpperMachine::on_pushButton_L_released()
187 | {
188 | key_SerialWrite("M0000");
189 | }
190 |
191 |
192 | /*
193 | * 转台左移
194 | */
195 | void UpperMachine::on_pushButton_I_clicked()
196 | {
197 | groupbox4_eventFilter(ui->pushButton_I);
198 | }
199 |
200 | void UpperMachine::on_pushButton_I_released()
201 | {
202 | key_SerialWrite("M0000");
203 | }
204 |
205 | /*
206 | * 转台右移
207 | */
208 | void UpperMachine::on_pushButton_M_clicked()
209 | {
210 | groupbox4_eventFilter(ui->pushButton_M);
211 | }
212 |
213 | void UpperMachine::on_pushButton_M_released()
214 | {
215 | key_SerialWrite("M0000");
216 | }
217 |
218 | /*
219 | * 添加动作
220 | */
221 | void UpperMachine::on_pushButton_AddAction_clicked()
222 | {
223 | addAction();
224 | }
225 |
226 | /*
227 | * 删除动作
228 | */
229 | void UpperMachine::on_pushButton_deleteAction_clicked()
230 | {
231 | deleteAction();
232 | }
233 |
234 | /*
235 | * 清空轨迹
236 | */
237 | void UpperMachine::on_pushButton_clearAction_clicked()
238 | {
239 | clearAction();
240 | }
241 |
242 | /*
243 | * 恢复首位
244 | */
245 | void UpperMachine::on_pushButton_FirstAction_clicked()
246 | {
247 | firstAction();
248 | }
249 |
250 | /*
251 | * 示教启动
252 | */
253 | void UpperMachine::on_pushButton_PLAY_clicked()
254 | {
255 | playActions();
256 | }
257 |
258 | /*
259 | * 示教暂停
260 | */
261 | void UpperMachine::on_pushButton_PAUSE_clicked()
262 | {
263 | pauseActions();
264 | }
265 |
266 | /*
267 | * 示教停止
268 | */
269 | void UpperMachine::on_pushButton_STOP_clicked()
270 | {
271 | stopActions();
272 | }
273 |
274 | /*
275 | * 单步运行
276 | */
277 | void UpperMachine::on_pushButton_STEP_clicked()
278 | {
279 | stepActions();
280 | }
281 |
282 |
283 |
284 |
285 |
286 | //菜单栏Home回调槽函数
287 | void UpperMachine::menuBar_Action(QAction* a)
288 | {
289 | if(a->text() == "Home"){
290 | UpperMachine().show();
291 | qDebug("进入主页");
292 | }else if(a->text() == "Exit"){
293 | upperSerialPort.close();
294 | upperSerial.setL_isOpen(false);
295 | qDebug("退出程序");
296 | this->close();
297 | }else if (a->text() == "ConnectUM") {
298 | connectUM();
299 | qDebug("连接设备");
300 | }else if (a->text() == "Load") {
301 | loadSoftLitmit();
302 | qDebug("载入软限位");
303 | }else if (a->text() == "Save") {
304 | saveSoftLimit();
305 | qDebug("保存软限位");
306 | }else if (a->text() == "Tutorial") {
307 | // openTutorial();
308 | QString qtManulFile = "F:\\机械臂\\0论文资料\\201835010349_郑烁彬_基于Qt技术的机械臂系统的设计与实现_定稿.pdf";
309 | QDesktopServices::openUrl(QUrl::fromLocalFile(qtManulFile));
310 | qDebug("打开教程");
311 | }
312 |
313 |
314 |
315 | }
316 |
317 |
318 |
--------------------------------------------------------------------------------
/uppermachine.h:
--------------------------------------------------------------------------------
1 | #ifndef UPPERMACHINE_H
2 | #define UPPERMACHINE_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "enumHeader.h"
9 | #include "upperserial.h"
10 | #include "mechanicalarm.h"
11 |
12 | //#include
13 | //#include
14 |
15 | QT_BEGIN_NAMESPACE
16 | namespace Ui { class UpperMachine; }
17 | using namespace std;
18 | QT_END_NAMESPACE
19 |
20 | class UpperMachine : public QMainWindow
21 | {
22 | Q_OBJECT
23 |
24 | public:
25 | /*
26 | * 主程序----------------------------------
27 | */
28 | Ui::UpperMachine *ui;
29 | explicit UpperMachine(QWidget *parent = nullptr);
30 | ~UpperMachine();
31 |
32 | /*
33 | * 类实例-----------------------------------------------------------------------------------------------------
34 | */
35 | // 串口通讯
36 | QSerialPort upperSerialPort;
37 | // 串口实体类
38 | UpperSerial upperSerial;
39 | // 机械臂实体类
40 | MechanicalArm mechanicalArm;
41 | // 表格视图
42 | // QStandardItemModel *standItemModel;
43 |
44 | // 创建子类
45 | // class upperserial1 : public UpperSerial{};
46 |
47 | // 定时器
48 | QTimer *m_pTimer;
49 |
50 |
51 | /*
52 | * 机械臂参数-----------------------------------------------------------------------------------------------------
53 | */
54 | // 蓝灯:手动模式
55 | bool isBlueLight = false;
56 | // 示教保留文件工程名称
57 | string projectName = "";
58 | // 机械臂动作指令集
59 | RobotAction robotAction;
60 | // 枚举宏定义
61 | Q_ENUM(RobotAction);
62 | /*
63 | * 定义包装枚举
64 | Q_DECLARE_FLAGS(robotAction,RobotAction);
65 | // 注册枚举元对象
66 | Q_FLAG(robotAction);
67 | QMetaEnum qRobotAction = QMetaEnum::fromType();
68 | */
69 | // 播放状态
70 | PlayStatus playStatus;
71 | Q_ENUM(PlayStatus);
72 |
73 |
74 | /*
75 | * 运行方法-----------------------------------------------------------------------------------------------------
76 | */
77 | ///主页程序
78 | // 主程序界面设置
79 | void application_UISettings();
80 |
81 | ///0、串口方法
82 | // 0.1、进行设备连接
83 | void connectUM();
84 | // 0.2、获取设备全称、查询可用串口
85 | QString GetDeviceFullName();
86 | // 0.3、读取接收数据
87 | void readAvailableInfo();
88 |
89 | ///1、groupbox1
90 | // 1.1、读取当前位置
91 | void readCurrentLocation();
92 | // 1.1.1、获取当前坐标
93 | void doDOWN(QString);
94 | void setLocation(QString);
95 | // 1.2、关闭当前串口设备
96 | void closeSerialDevice();
97 | // 1.3、切换操纵状态
98 | void switchSteerStatus();
99 |
100 | ///2、groupbox2
101 | void groupbox2_eventFilter(QObject *object);
102 | // 2.0、当前软限位设置
103 | void currentsoftlimitSettings();
104 | // 2.1、软限位控制
105 | void checkSoftLimit(int);
106 | void checkSoftLimit_Clow(int);
107 | void checkSoftLimit_SArm(int);
108 | void checkSoftLimit_BArm(int);
109 | void checkSoftLimit_RStage(int);
110 | // 2.2、保留软限位文件
111 | void saveSoftLimit();
112 | // 2.3、读取软限位文件
113 | void loadSoftLitmit();
114 | // 2.4、复位
115 | void resetLocation();
116 |
117 | ///3、groupbox3
118 | // 3、发送位置
119 | void sendLocation();
120 |
121 | ///4、groupbox4
122 | void groupbox4_eventFilter(QObject *object);
123 | // 4.0、按键串口写入函数
124 | void key_SerialWrite(QString);
125 | // 4.1、手柄爪头抓取
126 | void handle_Clow_Grab();
127 | // 4.2、手柄爪头释放
128 | void handle_Clow_Release();
129 | // 4.3、手柄小臂外展
130 | void handle_SArm_OutReach();
131 | // 4.4、手柄小臂内收
132 | void handle_SArm_Adduction();
133 | // 4.5、手柄大臂外展
134 | void handle_BArm_OutReach();
135 | // 4.6、手柄大臂臂内收
136 | void handle_BArm_Adduction();
137 | // 4.7、手柄转台左转
138 | void handle_RStage_Left();
139 | // 4.7、手柄转台左右转
140 | void handle_RStage_Right();
141 |
142 | ///groupBox5
143 | // 5.1、添加动作
144 | void addAction();
145 | void addUMAction(QString);
146 | // 5.2、添加、判断记录
147 | void addAction_Location(int add_row, int add_column);
148 | bool NextItemEmpty(QTableWidget *t, int x, int y);
149 | bool CurrentItemEmpty(QTableWidget *t, int x, int y);
150 | // 5.3、删除动作
151 | void deleteAction();
152 | bool selectRow();
153 | // 5.4、清空轨迹
154 | void clearAction();
155 | // 5.5、恢复首位
156 | void firstAction();
157 | QString readFirstAction();
158 |
159 | // 5.6、示教启动
160 | void playActions();
161 | // 5.7、示教暂停
162 | void pauseActions();
163 | QString readItems(int);
164 | // 5.8、示教停止
165 | void stopActions();
166 | // 5.9、单步运行
167 | void stepActions();
168 |
169 |
170 | private:
171 | // 当前按下的是那个键
172 | // label currLabel = null;
173 | // 指令序列索引
174 | const int actionIndex = 1;
175 | // 播放索引
176 | int playIndex = 0;
177 | // 接收输入缓冲区列表
178 | QList tempBuffer;
179 | // 接收输入缓冲区字节数组
180 | QByteArray arrayBuffer;
181 | // 机械臂操纵状态提醒
182 | // FrmWarning frmWarning;
183 | // 动作添加次数
184 | int actionCount = -1;
185 |
186 | private slots:
187 | ///菜单栏
188 | // 菜单栏监听回调
189 | void menuBar_Action(QAction *a);
190 | // 接收串口读取的数据
191 | void serialPort_ReadAvailable();
192 | ///groupbox1
193 | // 读取位置
194 | void on_pushButton_ReadLocation_clicked();
195 | // 关闭当前串口和设备
196 | void on_pushButton_CloseSerial_clicked();
197 | // 操纵状态切换
198 | void on_pushButton_SwitchStatus_clicked();
199 | ///groupbox2
200 | // 软限位
201 | bool eventFilter(QObject *object,QEvent *event) ;
202 | // 复位
203 | void on_pushButton_Reset_clicked();
204 | ///groupbox3
205 | // 发送位置
206 | void on_pushButton_SendLocation_clicked();
207 | ///groupbox4
208 | // 爪头抓取
209 | void on_pushButton_W_clicked();
210 | void on_pushButton_W_released();
211 | // 爪头释放
212 | void on_pushButton_X_clicked();
213 | void on_pushButton_X_released();
214 | // 小臂外展
215 | void on_pushButton_A_clicked();
216 | void on_pushButton_A_released();
217 | // 小臂内收
218 | void on_pushButton_D_clicked();
219 | void on_pushButton_D_released();
220 | // 转台左移
221 | void on_pushButton_I_clicked();
222 | void on_pushButton_I_released();
223 | // 转台右移
224 | void on_pushButton_M_clicked();
225 | void on_pushButton_M_released();
226 | // 大臂外展
227 | void on_pushButton_J_clicked();
228 | void on_pushButton_J_released();
229 | // 大臂内收
230 | void on_pushButton_L_clicked();
231 | void on_pushButton_L_released();
232 | ///groupbox5
233 | // 超时处理函数
234 | void handleTimeout();
235 | // 添加动作
236 | void on_pushButton_AddAction_clicked();
237 | // 删除动作
238 | void on_pushButton_deleteAction_clicked();
239 | // 清空轨迹
240 | void on_pushButton_clearAction_clicked();
241 | // 恢复首位
242 | void on_pushButton_FirstAction_clicked();
243 | // 示教启动
244 | void on_pushButton_PLAY_clicked();
245 | // 示教停止
246 | void on_pushButton_STOP_clicked();
247 | // 示教暂停
248 | void on_pushButton_PAUSE_clicked();
249 | // 示教单步运行
250 | void on_pushButton_STEP_clicked();
251 |
252 | protected:
253 | // 保护类,作用为其对象,不能访问,只能由内部类或派生类访问
254 | // 键盘按键按压事件
255 | void keyPressEvent(QKeyEvent *);
256 | // 键盘按键放松事件
257 | void keyReleaseEvent(QKeyEvent *);
258 |
259 | };
260 | #endif // UPPERMACHINE_H
261 |
--------------------------------------------------------------------------------
/uppermachine.pro:
--------------------------------------------------------------------------------
1 | QT += core gui widgets serialport
2 |
3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
4 |
5 | CONFIG += c++11
6 |
7 | # The following define makes your compiler emit warnings if you use
8 | # any Qt feature that has been marked deprecated (the exact warnings
9 | # depend on your compiler). Please consult the documentation of the
10 | # deprecated API in order to know how to port your code away from it.
11 | DEFINES += QT_DEPRECATED_WARNINGS
12 |
13 | # You can also make your code fail to compile if it uses deprecated APIs.
14 | # In order to do so, uncomment the following line.
15 | # You can also select to disable deprecated APIs only up to a certain version of Qt.
16 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
17 |
18 | SOURCES += \
19 | actionFun.cpp \
20 | commandFun.cpp \
21 | evenFilterBox.cpp \
22 | groupBoxFun1.cpp \
23 | groupBoxFun2.cpp \
24 | groupBoxFun3.cpp \
25 | groupBoxFun4.cpp \
26 | groupBoxFun5.cpp \
27 | main.cpp \
28 | mechanicalarm.cpp \
29 | otherFun.cpp \
30 | serialFun.cpp \
31 | timerFun.cpp \
32 | uppermachine.cpp \
33 | upperserial.cpp
34 |
35 | HEADERS += \
36 | applicationHeader.h \
37 | enumHeader.h \
38 | homesettings.h \
39 | mechanicalarm.h \
40 | otherHeader.h \
41 | serialHeader.h \
42 | uppermachine.h \
43 | upperserial.h
44 |
45 | FORMS += \
46 | uppermachine.ui
47 |
48 | TRANSLATIONS += \
49 | uppermachine_zh_SG.ts
50 |
51 | # Default rules for deployment.
52 | qnx: target.path = /tmp/$${TARGET}/bin
53 | else: unix:!android: target.path = /opt/$${TARGET}/bin
54 | !isEmpty(target.path): INSTALLS += target
55 |
56 | RESOURCES += \
57 | Image.qrc
58 |
--------------------------------------------------------------------------------
/uppermachine.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | UpperMachine
4 |
5 |
6 |
7 | 0
8 | 0
9 | 1055
10 | 754
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 | UpperMachine
21 |
22 |
23 |
24 |
25 |
26 |
27 | 30
28 | 30
29 |
30 |
31 |
32 |
33 |
34 | 0
35 | 0
36 |
37 |
38 |
39 |
40 | 16777215
41 | 16777215
42 |
43 |
44 |
45 | true
46 |
47 |
48 | -
49 |
50 |
-
51 |
52 |
53 | QLayout::SetDefaultConstraint
54 |
55 |
-
56 |
57 |
58 | QLayout::SetNoConstraint
59 |
60 |
-
61 |
62 |
63 | true
64 |
65 |
66 |
67 | 0
68 | 0
69 |
70 |
71 |
72 |
73 | 16777215
74 | 220
75 |
76 |
77 |
78 |
79 | 50
80 | false
81 | false
82 |
83 |
84 |
85 |
86 |
87 |
88 | 当前位置
89 |
90 |
91 | false
92 |
93 |
94 | false
95 |
96 |
97 |
-
98 |
99 |
100 | 0
101 |
102 |
103 | 0
104 |
105 |
-
106 |
107 |
108 |
109 | 0
110 | 0
111 |
112 |
113 |
114 |
115 | 100
116 | 35
117 |
118 |
119 |
120 | 获取位置
121 |
122 |
123 |
124 | -
125 |
126 |
127 |
128 | 30
129 | 20
130 |
131 |
132 |
133 | 爪头
134 |
135 |
136 |
137 | -
138 |
139 |
140 |
141 | 0
142 | 0
143 |
144 |
145 |
146 |
147 | 40
148 | 25
149 |
150 |
151 |
152 | true
153 |
154 |
155 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
156 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
157 | p, li { white-space: pre-wrap; }
158 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
159 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
160 |
161 |
162 |
163 | -
164 |
165 |
166 |
167 | 30
168 | 20
169 |
170 |
171 |
172 | 小臂
173 |
174 |
175 |
176 | -
177 |
178 |
179 |
180 | 0
181 | 0
182 |
183 |
184 |
185 |
186 | 40
187 | 25
188 |
189 |
190 |
191 | true
192 |
193 |
194 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
195 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
196 | p, li { white-space: pre-wrap; }
197 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
198 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
199 |
200 |
201 |
202 |
203 |
204 | -
205 |
206 |
207 | 0
208 |
209 |
-
210 |
211 |
212 |
213 | 0
214 | 0
215 |
216 |
217 |
218 |
219 | 100
220 | 35
221 |
222 |
223 |
224 | 切换状态
225 |
226 |
227 |
228 | -
229 |
230 |
231 |
232 | 0
233 | 0
234 |
235 |
236 |
237 |
238 | 30
239 | 20
240 |
241 |
242 |
243 | 大臂
244 |
245 |
246 |
247 | -
248 |
249 |
250 |
251 | 0
252 | 0
253 |
254 |
255 |
256 |
257 | 40
258 | 25
259 |
260 |
261 |
262 | true
263 |
264 |
265 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
266 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
267 | p, li { white-space: pre-wrap; }
268 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
269 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
270 |
271 |
272 |
273 | -
274 |
275 |
276 |
277 | 0
278 | 0
279 |
280 |
281 |
282 |
283 | 30
284 | 20
285 |
286 |
287 |
288 | 转台
289 |
290 |
291 |
292 | -
293 |
294 |
295 |
296 | 0
297 | 0
298 |
299 |
300 |
301 |
302 | 40
303 | 25
304 |
305 |
306 |
307 | true
308 |
309 |
310 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
311 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
312 | p, li { white-space: pre-wrap; }
313 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
314 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 | -
324 |
325 |
326 |
327 | 0
328 | 0
329 |
330 |
331 |
332 |
333 | 150
334 | 220
335 |
336 |
337 |
338 |
339 | 50
340 | false
341 |
342 |
343 |
344 | true
345 |
346 |
347 |
348 |
349 |
350 | 设备信息
351 |
352 |
353 |
-
354 |
355 |
-
356 |
357 |
358 |
359 | 0
360 | 0
361 |
362 |
363 |
364 |
365 | 16777215
366 | 24
367 |
368 |
369 |
370 | <html><head/><body><p align="center">设备信息</p></body></html>
371 |
372 |
373 | Qt::RichText
374 |
375 |
376 | Qt::AlignCenter
377 |
378 |
379 | 6
380 |
381 |
382 |
383 |
384 |
385 | -
386 |
387 |
-
388 |
389 |
390 |
391 | 0
392 | 0
393 |
394 |
395 |
396 |
397 | 16777215
398 | 28
399 |
400 |
401 |
402 | <html><head/><body><p align="center">连接信息</p></body></html>
403 |
404 |
405 | Qt::AlignCenter
406 |
407 |
408 | 7
409 |
410 |
411 |
412 |
413 |
414 | -
415 |
416 |
-
417 |
418 |
419 |
420 | 0
421 | 0
422 |
423 |
424 |
425 |
426 | 16777215
427 | 24
428 |
429 |
430 |
431 | <html><head/><body><p align="center">状态信息</p></body></html>
432 |
433 |
434 | Qt::AlignCenter
435 |
436 |
437 | 6
438 |
439 |
440 |
441 |
442 |
443 | -
444 |
445 |
446 | 0
447 |
448 |
449 | QLayout::SetDefaultConstraint
450 |
451 |
-
452 |
453 |
454 |
455 | 0
456 | 0
457 |
458 |
459 |
460 |
461 | 100
462 | 16777215
463 |
464 |
465 |
466 | 关闭连接
467 |
468 |
469 | 0
470 |
471 |
472 | 0
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 | -
484 |
485 |
486 | QLayout::SetDefaultConstraint
487 |
488 |
-
489 |
490 |
491 |
492 | 0
493 | 0
494 |
495 |
496 |
497 |
498 | 16777215
499 | 300
500 |
501 |
502 |
503 | 0
504 |
505 |
506 | true
507 |
508 |
509 |
510 |
511 |
512 | 软限位
513 |
514 |
515 |
-
516 |
517 |
-
518 |
519 |
-
520 |
521 |
522 |
523 | 60
524 | 16777215
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 | -
533 |
534 |
535 |
536 | 0
537 | 0
538 |
539 |
540 |
541 |
542 | 35
543 | 50
544 |
545 |
546 |
547 | Min
548 |
549 |
550 | 8
551 |
552 |
553 |
554 | -
555 |
556 |
557 |
558 | 12
559 | 16777215
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 | -
568 |
569 |
570 |
571 | 0
572 | 0
573 |
574 |
575 |
576 |
577 | 35
578 | 50
579 |
580 |
581 |
582 | Max
583 |
584 |
585 | 8
586 |
587 |
588 |
589 | -
590 |
591 |
592 |
593 | 8
594 | 16777215
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 | -
605 |
606 |
-
607 |
608 |
609 |
610 | 60
611 | 16777215
612 |
613 |
614 |
615 | 爪头
616 |
617 |
618 |
619 | -
620 |
621 |
622 |
623 | 0
624 | 0
625 |
626 |
627 |
628 |
629 | 40
630 | 30
631 |
632 |
633 |
634 | true
635 |
636 |
637 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
638 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
639 | p, li { white-space: pre-wrap; }
640 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
641 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
642 |
643 |
644 |
645 | -
646 |
647 |
648 |
649 | 8
650 | 3333
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 | -
659 |
660 |
661 |
662 | 0
663 | 0
664 |
665 |
666 |
667 |
668 | 40
669 | 30
670 |
671 |
672 |
673 | true
674 |
675 |
676 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
677 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
678 | p, li { white-space: pre-wrap; }
679 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
680 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
681 |
682 |
683 |
684 | -
685 |
686 |
687 |
688 | 5
689 | 16777215
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 | -
700 |
701 |
-
702 |
703 |
704 |
705 | 60
706 | 16777215
707 |
708 |
709 |
710 | 大臂
711 |
712 |
713 |
714 | -
715 |
716 |
717 |
718 | 0
719 | 0
720 |
721 |
722 |
723 |
724 | 40
725 | 30
726 |
727 |
728 |
729 | true
730 |
731 |
732 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
733 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
734 | p, li { white-space: pre-wrap; }
735 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
736 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
737 |
738 |
739 |
740 | -
741 |
742 |
743 |
744 | 8
745 | 16777215
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 | -
754 |
755 |
756 |
757 | 0
758 | 0
759 |
760 |
761 |
762 |
763 | 40
764 | 30
765 |
766 |
767 |
768 | true
769 |
770 |
771 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
772 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
773 | p, li { white-space: pre-wrap; }
774 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
775 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
776 |
777 |
778 |
779 | -
780 |
781 |
782 |
783 | 5
784 | 16777215
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 | -
797 |
798 |
-
799 |
800 |
-
801 |
802 |
803 |
804 | 60
805 | 16777215
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 | -
814 |
815 |
816 |
817 | 35
818 | 50
819 |
820 |
821 |
822 | Min
823 |
824 |
825 |
826 | -
827 |
828 |
829 |
830 | 12
831 | 16777215
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 | -
840 |
841 |
842 |
843 | 35
844 | 16777215
845 |
846 |
847 |
848 | Max
849 |
850 |
851 |
852 | -
853 |
854 |
855 |
856 | 8
857 | 16777215
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 | -
868 |
869 |
-
870 |
871 |
872 |
873 | 60
874 | 16777215
875 |
876 |
877 |
878 | 小臂
879 |
880 |
881 |
882 | -
883 |
884 |
885 |
886 | 0
887 | 0
888 |
889 |
890 |
891 |
892 | 40
893 | 30
894 |
895 |
896 |
897 | true
898 |
899 |
900 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
901 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
902 | p, li { white-space: pre-wrap; }
903 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
904 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
905 |
906 |
907 |
908 | -
909 |
910 |
911 |
912 | 8
913 | 16777215
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 | -
922 |
923 |
924 |
925 | 0
926 | 0
927 |
928 |
929 |
930 |
931 | 40
932 | 30
933 |
934 |
935 |
936 | true
937 |
938 |
939 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
940 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
941 | p, li { white-space: pre-wrap; }
942 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
943 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
944 |
945 |
946 |
947 | -
948 |
949 |
950 |
951 | 5
952 | 16777215
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 | -
963 |
964 |
-
965 |
966 |
967 |
968 | 60
969 | 16777215
970 |
971 |
972 |
973 | 转台
974 |
975 |
976 |
977 | -
978 |
979 |
980 |
981 | 0
982 | 0
983 |
984 |
985 |
986 |
987 | 40
988 | 30
989 |
990 |
991 |
992 | true
993 |
994 |
995 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
996 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
997 | p, li { white-space: pre-wrap; }
998 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
999 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
1000 |
1001 |
1002 |
1003 | -
1004 |
1005 |
1006 |
1007 | 8
1008 | 16777215
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 | -
1017 |
1018 |
1019 |
1020 | 0
1021 | 0
1022 |
1023 |
1024 |
1025 |
1026 | 40
1027 | 30
1028 |
1029 |
1030 |
1031 | true
1032 |
1033 |
1034 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
1035 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
1036 | p, li { white-space: pre-wrap; }
1037 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
1038 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
1039 |
1040 |
1041 |
1042 | -
1043 |
1044 |
1045 |
1046 | 5
1047 | 16777215
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 | -
1063 |
1064 |
1065 |
1066 | 0
1067 | 0
1068 |
1069 |
1070 |
1071 |
1072 | 135
1073 | 300
1074 |
1075 |
1076 |
1077 | 默认位置
1078 |
1079 |
1080 |
1081 | 5
1082 |
1083 |
1084 | 5
1085 |
1086 |
1087 | 9
1088 |
1089 |
1090 | 9
1091 |
1092 |
-
1093 |
1094 |
1095 | 0
1096 |
1097 |
1098 | QLayout::SetNoConstraint
1099 |
1100 |
1101 | 30
1102 |
1103 |
-
1104 |
1105 |
1106 |
1107 | 0
1108 | 0
1109 |
1110 |
1111 |
1112 |
1113 | 50
1114 | 50
1115 |
1116 |
1117 |
1118 | Qt::DefaultContextMenu
1119 |
1120 |
1121 | border-image: url(:/Image/Image/RESET.png);
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 | 0
1129 | 0
1130 |
1131 |
1132 |
1133 | 0
1134 |
1135 |
1136 | 0
1137 |
1138 |
1139 | false
1140 |
1141 |
1142 | false
1143 |
1144 |
1145 | false
1146 |
1147 |
1148 |
1149 |
1150 |
1151 | -
1152 |
1153 |
-
1154 |
1155 |
1156 |
1157 | 0
1158 | 0
1159 |
1160 |
1161 |
1162 |
1163 | 16777215
1164 | 40
1165 |
1166 |
1167 |
1168 |
1169 | 50
1170 | false
1171 | false
1172 | true
1173 |
1174 |
1175 |
1176 | <html><head/><body><p align="center">修改主控制器</p><p align="center">进行初始位置更改</p></body></html>
1177 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1185 |
1186 |
1187 | -
1188 |
1189 |
-
1190 |
1191 |
1192 |
1193 | 0
1194 | 0
1195 |
1196 |
1197 |
1198 |
1199 | 16777215
1200 | 16777215
1201 |
1202 |
1203 |
1204 | 指定位置
1205 |
1206 |
1207 |
1208 | 9
1209 |
1210 |
1211 | 9
1212 |
1213 |
1214 | 10
1215 |
1216 |
1217 | 9
1218 |
1219 |
1220 | 9
1221 |
1222 |
-
1223 |
1224 |
1225 | QLayout::SetDefaultConstraint
1226 |
1227 |
-
1228 |
1229 |
1230 |
1231 | 16777215
1232 | 30
1233 |
1234 |
1235 |
1236 | 爪头
1237 |
1238 |
1239 |
1240 | -
1241 |
1242 |
1243 |
1244 | 0
1245 | 0
1246 |
1247 |
1248 |
1249 |
1250 | 50
1251 | 30
1252 |
1253 |
1254 |
1255 | 2
1256 |
1257 |
1258 | true
1259 |
1260 |
1261 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
1262 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
1263 | p, li { white-space: pre-wrap; }
1264 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
1265 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
1266 |
1267 |
1268 |
1269 | -
1270 |
1271 |
1272 |
1273 | 8
1274 | 16777215
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 | -
1283 |
1284 |
1285 |
1286 | 16777215
1287 | 30
1288 |
1289 |
1290 |
1291 | 小臂
1292 |
1293 |
1294 |
1295 | -
1296 |
1297 |
1298 |
1299 | 0
1300 | 0
1301 |
1302 |
1303 |
1304 |
1305 | 50
1306 | 30
1307 |
1308 |
1309 |
1310 | true
1311 |
1312 |
1313 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
1314 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
1315 | p, li { white-space: pre-wrap; }
1316 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
1317 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
1318 |
1319 |
1320 |
1321 | -
1322 |
1323 |
1324 |
1325 |
1326 |
1327 |
1328 | -
1329 |
1330 |
1331 |
1332 | 16777215
1333 | 30
1334 |
1335 |
1336 |
1337 | 大臂
1338 |
1339 |
1340 |
1341 | -
1342 |
1343 |
1344 |
1345 | 0
1346 | 0
1347 |
1348 |
1349 |
1350 |
1351 | 50
1352 | 30
1353 |
1354 |
1355 |
1356 | true
1357 |
1358 |
1359 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
1360 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
1361 | p, li { white-space: pre-wrap; }
1362 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
1363 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
1364 |
1365 |
1366 |
1367 | -
1368 |
1369 |
1370 |
1371 | 16777215
1372 | 16777215
1373 |
1374 |
1375 |
1376 |
1377 |
1378 |
1379 |
1380 | -
1381 |
1382 |
1383 |
1384 | 16777215
1385 | 30
1386 |
1387 |
1388 |
1389 | 转台
1390 |
1391 |
1392 |
1393 | -
1394 |
1395 |
1396 |
1397 | 0
1398 | 0
1399 |
1400 |
1401 |
1402 |
1403 | 50
1404 | 30
1405 |
1406 |
1407 |
1408 | true
1409 |
1410 |
1411 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
1412 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
1413 | p, li { white-space: pre-wrap; }
1414 | </style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
1415 | <p align="center" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html>
1416 |
1417 |
1418 |
1419 | -
1420 |
1421 |
1422 |
1423 |
1424 |
1425 |
1426 | -
1427 |
1428 |
1429 |
1430 | 0
1431 | 0
1432 |
1433 |
1434 |
1435 |
1436 | 40
1437 | 35
1438 |
1439 |
1440 |
1441 | false
1442 |
1443 |
1444 | border-image: url(:/Image/Image/send.png);
1445 |
1446 |
1447 |
1448 |
1449 |
1450 |
1451 | -
1452 |
1453 |
1454 |
1455 | 0
1456 | 0
1457 |
1458 |
1459 |
1460 |
1461 | 5
1462 | 16777215
1463 |
1464 |
1465 |
1466 |
1467 |
1468 |
1469 |
1470 |
1471 |
1472 |
1473 |
1474 |
1475 |
1476 |
1477 | -
1478 |
1479 |
-
1480 |
1481 |
-
1482 |
1483 |
1484 |
1485 | 0
1486 | 0
1487 |
1488 |
1489 |
1490 |
1491 | 16777215
1492 | 16777215
1493 |
1494 |
1495 |
1496 | 操纵手柄
1497 |
1498 |
1499 |
1500 | true
1501 |
1502 |
1503 |
1504 | 10
1505 | 10
1506 | 491
1507 | 311
1508 |
1509 |
1510 |
1511 |
1512 | 0
1513 | 0
1514 |
1515 |
1516 |
1517 |
1518 | 16777215
1519 | 16777215
1520 |
1521 |
1522 |
1523 |
1524 |
1525 |
1526 |
1527 |
1528 |
1529 | Qt::RichText
1530 |
1531 |
1532 | :/Image/Image/gamehandle.png
1533 |
1534 |
1535 | true
1536 |
1537 |
1538 |
1539 |
1540 |
1541 | 100
1542 | 50
1543 | 51
1544 | 41
1545 |
1546 |
1547 |
1548 |
1549 | 0
1550 | 0
1551 |
1552 |
1553 |
1554 |
1555 |
1556 |
1557 | false
1558 |
1559 |
1560 | false
1561 |
1562 |
1563 | false
1564 |
1565 |
1566 | false
1567 |
1568 |
1569 | true
1570 |
1571 |
1572 |
1573 |
1574 |
1575 | 100
1576 | 130
1577 | 51
1578 | 41
1579 |
1580 |
1581 |
1582 |
1583 | 0
1584 | 0
1585 |
1586 |
1587 |
1588 |
1589 |
1590 |
1591 | false
1592 |
1593 |
1594 | false
1595 |
1596 |
1597 | false
1598 |
1599 |
1600 | false
1601 |
1602 |
1603 | true
1604 |
1605 |
1606 |
1607 |
1608 |
1609 | 60
1610 | 90
1611 | 41
1612 | 41
1613 |
1614 |
1615 |
1616 |
1617 | 0
1618 | 0
1619 |
1620 |
1621 |
1622 |
1623 |
1624 |
1625 | false
1626 |
1627 |
1628 | false
1629 |
1630 |
1631 | false
1632 |
1633 |
1634 | false
1635 |
1636 |
1637 | true
1638 |
1639 |
1640 |
1641 |
1642 |
1643 | 360
1644 | 50
1645 | 51
1646 | 41
1647 |
1648 |
1649 |
1650 |
1651 | 0
1652 | 0
1653 |
1654 |
1655 |
1656 |
1657 |
1658 |
1659 | false
1660 |
1661 |
1662 | false
1663 |
1664 |
1665 | false
1666 |
1667 |
1668 | false
1669 |
1670 |
1671 | true
1672 |
1673 |
1674 |
1675 |
1676 |
1677 | 320
1678 | 90
1679 | 41
1680 | 41
1681 |
1682 |
1683 |
1684 |
1685 | 0
1686 | 0
1687 |
1688 |
1689 |
1690 |
1691 |
1692 |
1693 | false
1694 |
1695 |
1696 | false
1697 |
1698 |
1699 | false
1700 |
1701 |
1702 | false
1703 |
1704 |
1705 | true
1706 |
1707 |
1708 |
1709 |
1710 |
1711 | 410
1712 | 90
1713 | 41
1714 | 41
1715 |
1716 |
1717 |
1718 |
1719 | 0
1720 | 0
1721 |
1722 |
1723 |
1724 |
1725 |
1726 |
1727 | false
1728 |
1729 |
1730 | false
1731 |
1732 |
1733 | false
1734 |
1735 |
1736 | false
1737 |
1738 |
1739 | true
1740 |
1741 |
1742 |
1743 |
1744 |
1745 | 360
1746 | 130
1747 | 51
1748 | 41
1749 |
1750 |
1751 |
1752 |
1753 | 0
1754 | 0
1755 |
1756 |
1757 |
1758 |
1759 |
1760 |
1761 | false
1762 |
1763 |
1764 | false
1765 |
1766 |
1767 | false
1768 |
1769 |
1770 | false
1771 |
1772 |
1773 | true
1774 |
1775 |
1776 |
1777 |
1778 |
1779 | 150
1780 | 90
1781 | 41
1782 | 41
1783 |
1784 |
1785 |
1786 |
1787 | 0
1788 | 0
1789 |
1790 |
1791 |
1792 |
1793 |
1794 |
1795 | false
1796 |
1797 |
1798 | false
1799 |
1800 |
1801 | false
1802 |
1803 |
1804 | false
1805 |
1806 |
1807 | true
1808 |
1809 |
1810 |
1811 |
1812 |
1813 |
1814 |
1815 |
1816 |
1817 |
1818 | -
1819 |
1820 |
-
1821 |
1822 |
1823 | QLayout::SetMinimumSize
1824 |
1825 |
-
1826 |
1827 |
-
1828 |
1829 |
1830 |
1831 | 0
1832 | 0
1833 |
1834 |
1835 |
1836 |
1837 | 16777215
1838 | 16777215
1839 |
1840 |
1841 |
1842 | true
1843 |
1844 |
1845 | Qt::ImhNone
1846 |
1847 |
1848 | false
1849 |
1850 |
1851 | 10
1852 |
1853 |
1854 | 4
1855 |
1856 |
1857 | true
1858 |
1859 |
1860 | 35
1861 |
1862 |
1863 | 128
1864 |
1865 |
1866 | true
1867 |
1868 |
1869 | true
1870 |
1871 |
1872 | false
1873 |
1874 |
1875 | false
1876 |
1877 |
1878 | false
1879 |
1880 |
1881 | false
1882 |
1883 |
1884 |
1885 |
1886 |
1887 |
1888 |
1889 |
1890 |
1891 |
1892 |
1893 |
1894 |
1895 |
1896 |
1897 | -
1898 |
1899 |
1900 |
1901 |
1902 | AlignCenter
1903 |
1904 |
1905 |
1906 |
1907 |
1908 |
1909 |
1910 |
1911 | -
1912 |
1913 |
1914 | QLayout::SetMinimumSize
1915 |
1916 |
-
1917 |
1918 |
1919 | 动作间隔时间
1920 |
1921 |
1922 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
1923 |
1924 |
1925 |
1926 | -
1927 |
1928 |
1929 |
1930 | 0
1931 | 0
1932 |
1933 |
1934 |
1935 |
1936 | 60
1937 | 30
1938 |
1939 |
1940 |
1941 |
1942 | -
1943 |
1944 |
1945 |
1946 | 0
1947 | 0
1948 |
1949 |
1950 |
1951 | 单位(毫秒)
1952 |
1953 |
1954 |
1955 |
1956 |
1957 | -
1958 |
1959 |
1960 | QLayout::SetMinimumSize
1961 |
1962 |
-
1963 |
1964 |
-
1965 |
1966 |
1967 | true
1968 |
1969 |
1970 |
1971 | 0
1972 | 0
1973 |
1974 |
1975 |
1976 |
1977 | 16777215
1978 | 250
1979 |
1980 |
1981 |
1982 | false
1983 |
1984 |
1985 | false
1986 |
1987 |
1988 | Qt::LeftToRight
1989 |
1990 |
1991 | true
1992 |
1993 |
1994 |
1995 |
1996 |
1997 | Qt::ImhNone
1998 |
1999 |
2000 | 示教操纵
2001 |
2002 |
2003 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
2004 |
2005 |
2006 | false
2007 |
2008 |
2009 | false
2010 |
2011 |
2012 |
-
2013 |
2014 |
-
2015 |
2016 |
2017 |
2018 |
2019 | -
2020 |
2021 |
2022 | QLayout::SetFixedSize
2023 |
2024 |
-
2025 |
2026 |
2027 | 6
2028 |
2029 |
2030 | 6
2031 |
2032 |
-
2033 |
2034 |
2035 |
2036 | 0
2037 | 0
2038 |
2039 |
2040 |
2041 |
2042 | 50
2043 | 50
2044 |
2045 |
2046 |
2047 | false
2048 |
2049 |
2050 | border-image: url(:/Image/Image/start2.png);
2051 |
2052 |
2053 |
2054 |
2055 |
2056 |
2057 |
2058 |
2059 | -
2060 |
2061 |
2062 | Qt::Horizontal
2063 |
2064 |
2065 | QSizePolicy::Fixed
2066 |
2067 |
2068 |
2069 | 40
2070 | 30
2071 |
2072 |
2073 |
2074 |
2075 | -
2076 |
2077 |
2078 | 6
2079 |
2080 |
2081 | 6
2082 |
2083 |
-
2084 |
2085 |
2086 |
2087 | 0
2088 | 0
2089 |
2090 |
2091 |
2092 |
2093 | 53
2094 | 53
2095 |
2096 |
2097 |
2098 | false
2099 |
2100 |
2101 | border-image: url(:/Image/Image/pause3.png);
2102 |
2103 |
2104 | Qt::ImhNone
2105 |
2106 |
2107 |
2108 |
2109 |
2110 | false
2111 |
2112 |
2113 | false
2114 |
2115 |
2116 |
2117 |
2118 |
2119 | -
2120 |
2121 |
2122 | Qt::Horizontal
2123 |
2124 |
2125 | QSizePolicy::Fixed
2126 |
2127 |
2128 |
2129 | 30
2130 | 20
2131 |
2132 |
2133 |
2134 |
2135 | -
2136 |
2137 |
2138 | 6
2139 |
2140 |
2141 | QLayout::SetDefaultConstraint
2142 |
2143 |
2144 | 10
2145 |
2146 |
-
2147 |
2148 |
2149 |
2150 | 0
2151 | 0
2152 |
2153 |
2154 |
2155 |
2156 | 60
2157 | 60
2158 |
2159 |
2160 |
2161 | false
2162 |
2163 |
2164 | border-image: url(:/Image/Image/stop2.png);
2165 |
2166 |
2167 |
2168 |
2169 |
2170 |
2171 |
2172 |
2173 | -
2174 |
2175 |
2176 | Qt::Horizontal
2177 |
2178 |
2179 | QSizePolicy::Fixed
2180 |
2181 |
2182 |
2183 | 35
2184 | 20
2185 |
2186 |
2187 |
2188 |
2189 | -
2190 |
2191 |
2192 | 6
2193 |
2194 |
2195 | 2
2196 |
2197 |
-
2198 |
2199 |
2200 |
2201 | 0
2202 | 0
2203 |
2204 |
2205 |
2206 |
2207 | 60
2208 | 60
2209 |
2210 |
2211 |
2212 | false
2213 |
2214 |
2215 |
2216 | border-image: url(:/Image/Image/STEP.png);
2217 |
2218 |
2219 |
2220 |
2221 |
2222 |
2223 |
2224 |
2225 |
2226 |
2227 | -
2228 |
2229 |
2230 | 6
2231 |
2232 |
-
2233 |
2234 |
-
2235 |
2236 |
2237 |
2238 | 0
2239 | 0
2240 |
2241 |
2242 |
2243 |
2244 | 16777215
2245 | 35
2246 |
2247 |
2248 |
2249 | 添加动作
2250 |
2251 |
2252 |
2253 |
2254 |
2255 | -
2256 |
2257 |
2258 | Qt::Horizontal
2259 |
2260 |
2261 | QSizePolicy::Fixed
2262 |
2263 |
2264 |
2265 | 20
2266 | 20
2267 |
2268 |
2269 |
2270 |
2271 | -
2272 |
2273 |
-
2274 |
2275 |
2276 |
2277 | 0
2278 | 0
2279 |
2280 |
2281 |
2282 |
2283 | 16777215
2284 | 35
2285 |
2286 |
2287 |
2288 | 删除动作
2289 |
2290 |
2291 |
2292 |
2293 |
2294 | -
2295 |
2296 |
2297 | Qt::Horizontal
2298 |
2299 |
2300 | QSizePolicy::Fixed
2301 |
2302 |
2303 |
2304 | 20
2305 | 20
2306 |
2307 |
2308 |
2309 |
2310 | -
2311 |
2312 |
-
2313 |
2314 |
2315 |
2316 | 0
2317 | 0
2318 |
2319 |
2320 |
2321 |
2322 | 16777215
2323 | 35
2324 |
2325 |
2326 |
2327 | 清空轨迹
2328 |
2329 |
2330 |
2331 |
2332 |
2333 | -
2334 |
2335 |
2336 | Qt::Horizontal
2337 |
2338 |
2339 | QSizePolicy::Fixed
2340 |
2341 |
2342 |
2343 | 20
2344 | 20
2345 |
2346 |
2347 |
2348 |
2349 | -
2350 |
2351 |
-
2352 |
2353 |
2354 |
2355 | 0
2356 | 0
2357 |
2358 |
2359 |
2360 |
2361 | 16777215
2362 | 35
2363 |
2364 |
2365 |
2366 | 恢复首位
2367 |
2368 |
2369 |
2370 |
2371 |
2372 |
2373 |
2374 |
2375 |
2376 |
2377 |
2378 |
2379 |
2380 |
2381 |
2382 |
2383 |
2384 |
2385 |
2386 |
2387 |
2429 |
2430 |
2431 |
2432 |
2433 | :/Image/Image/home.png:/Image/Image/home.png
2434 |
2435 |
2436 | Home
2437 |
2438 |
2439 |
2440 |
2441 |
2442 | :/Image/Image/statu.png:/Image/Image/statu.png
2443 |
2444 |
2445 | Status
2446 |
2447 |
2448 |
2449 |
2450 |
2451 | :/Image/Image/exit.png:/Image/Image/exit.png
2452 |
2453 |
2454 | Exit
2455 |
2456 |
2457 |
2458 |
2459 |
2460 | :/Image/Image/safe.png:/Image/Image/safe.png
2461 |
2462 |
2463 | SerialPort
2464 |
2465 |
2466 |
2467 |
2468 |
2469 | :/Image/Image/connect3.png:/Image/Image/connect3.png
2470 |
2471 |
2472 | ConnectUM
2473 |
2474 |
2475 |
2476 |
2477 |
2478 | :/Image/Image/load2.png:/Image/Image/load2.png
2479 |
2480 |
2481 | Load
2482 |
2483 |
2484 |
2485 |
2486 |
2487 | :/Image/Image/save.png:/Image/Image/save.png
2488 |
2489 |
2490 | Save
2491 |
2492 |
2493 |
2494 |
2495 |
2496 | :/Image/Image/tutorial1.png:/Image/Image/tutorial1.png
2497 |
2498 |
2499 | Tutorial
2500 |
2501 |
2502 |
2503 |
2504 |
2505 |
2506 |
2507 |
2508 |
--------------------------------------------------------------------------------
/uppermachine_zh_SG.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/upperserial.cpp:
--------------------------------------------------------------------------------
1 | #include "upperserial.h"
2 |
3 | UpperSerial::UpperSerial()
4 | {
5 | }
6 |
7 | UpperSerial::~UpperSerial()
8 | {
9 |
10 | }
11 |
12 | bool UpperSerial::getL_isOpen() const
13 | {
14 | return l_isOpen;
15 | }
16 |
17 | void UpperSerial::setL_isOpen(bool value)
18 | {
19 | l_isOpen = value;
20 | }
21 |
22 | string UpperSerial::getL_devicePattern() const
23 | {
24 | return l_devicePattern;
25 | }
26 |
27 | void UpperSerial::setL_devicePattern(const string &value)
28 | {
29 | l_devicePattern = value;
30 | }
31 |
32 | int UpperSerial::getL_c_baudRate() const
33 | {
34 | return l_c_baudRate;
35 | }
36 |
37 | int UpperSerial::getL_c_dataBits() const
38 | {
39 | return l_c_dataBits;
40 | }
41 |
42 | int UpperSerial::getL_c_stopBits() const
43 | {
44 | return l_c_stopBits;
45 | }
46 |
47 | string UpperSerial::getConnectInfo() const
48 | {
49 | return connectInfo;
50 | }
51 |
52 | void UpperSerial::setConnectInfo(const string &value)
53 | {
54 | connectInfo = value;
55 | }
56 |
57 | QString UpperSerial::getL_deviceFlag() const
58 | {
59 | return l_deviceFlag;
60 | }
61 |
62 | void UpperSerial::setL_deviceFlag(const QString &value)
63 | {
64 | l_deviceFlag = value;
65 | }
66 |
67 | QString UpperSerial::getDeviceName() const
68 | {
69 | return deviceName;
70 | }
71 |
72 | void UpperSerial::setDeviceName(const QString &value)
73 | {
74 | deviceName = value;
75 | }
76 |
77 | QString UpperSerial::getL_c_protName() const
78 | {
79 | return l_c_protName;
80 | }
81 |
82 | void UpperSerial::setL_c_protName(const QString &value)
83 | {
84 | l_c_protName = value;
85 | }
86 |
87 | int UpperSerial::getL_c_flowControl() const
88 | {
89 | return l_c_flowControl;
90 | }
91 |
92 | bool UpperSerial::getWriteSuccess() const
93 | {
94 | return writeSuccess;
95 | }
96 |
97 | void UpperSerial::setWriteSuccess(bool value)
98 | {
99 | writeSuccess = value;
100 | }
101 |
102 | int UpperSerial::getL_c_parity() const
103 | {
104 | return l_c_parity;
105 | }
106 |
--------------------------------------------------------------------------------
/upperserial.h:
--------------------------------------------------------------------------------
1 | #ifndef UPPERSERIAL_H
2 | #define UPPERSERIAL_H
3 | #include
4 | #include
5 |
6 | using namespace std;
7 |
8 | class UpperSerial
9 | {
10 | public:
11 | UpperSerial();
12 | ~UpperSerial();
13 |
14 | bool getL_isOpen() const;
15 | void setL_isOpen(bool value);
16 |
17 | string getL_devicePattern() const;
18 | void setL_devicePattern(const string &value);
19 |
20 | int getL_c_baudRate() const;
21 |
22 | int getL_c_dataBits() const;
23 |
24 | int getL_c_stopBits() const;
25 |
26 | int getL_c_parity() const;
27 |
28 | string getConnectInfo() const;
29 | void setConnectInfo(const string &value);
30 |
31 | QString getL_deviceFlag() const;
32 | void setL_deviceFlag(const QString &value);
33 |
34 | QString getDeviceName() const;
35 | void setDeviceName(const QString &value);
36 |
37 | QString getL_c_protName() const;
38 | void setL_c_protName(const QString &value);
39 |
40 |
41 | int getL_c_flowControl() const;
42 |
43 | bool getWriteSuccess() const;
44 | void setWriteSuccess(bool value);
45 |
46 | private:
47 | //设备串口名称正则表达式
48 | string l_devicePattern = "Arduino Uno (.*)";
49 |
50 | //设备全名称标志
51 | QString l_deviceFlag = "Arduino Uno";
52 |
53 | // 设备全名称
54 | QString deviceName = "";
55 |
56 | //正则表达式
57 | QRegExp l_reg();
58 |
59 | //串口号
60 | QString l_c_protName = "";
61 |
62 | //波特率
63 | // const int l_c_baudRate = 57600;
64 | const int l_c_baudRate = QSerialPort::Baud57600;
65 |
66 | //数据位
67 | // const int l_c_dataBits = 8;
68 | const int l_c_dataBits = QSerialPort::Data8;
69 |
70 | //停止位
71 | // const int l_c_stopBits = 1;
72 | const int l_c_stopBits = QSerialPort::OneStop;
73 |
74 | // 校验位
75 | const int l_c_parity = QSerialPort::NoParity;
76 |
77 | // 流控制
78 | const int l_c_flowControl = QSerialPort::NoFlowControl;
79 |
80 |
81 | //串口是否已经打开
82 | bool l_isOpen = false;
83 |
84 | // 连接信息
85 | string connectInfo = "设备未连接";
86 |
87 | // 接收状态
88 | bool writeSuccess = false;
89 |
90 | };
91 |
92 |
93 |
94 | #endif // UPPERSERIAL_H
95 |
--------------------------------------------------------------------------------
/upperstruct.h:
--------------------------------------------------------------------------------
1 | #ifndef UPPERSTRUCT_H
2 | #define UPPERSTRUCT_H
3 | #include
4 |
5 | struct serial
6 | {
7 |
8 |
9 |
10 | };
11 |
12 |
13 |
14 | #endif // UPPERSTRUCT_H
15 |
--------------------------------------------------------------------------------