|
@@ -28,21 +28,29 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
ui->lineEdit_brake->setText(QString::number(mfbrake,'g'));
|
|
|
|
|
|
QString styleLabel = "QLabel {"
|
|
|
- " background-color: rgb(10, 90, 160);" // 背景颜色
|
|
|
+ " background-color: rgb(72, 116, 203);" // 背景颜色
|
|
|
" color: white;" // 字体颜色
|
|
|
"}";
|
|
|
QString styleEdit = "QLineEdit {"
|
|
|
- " background-color: rgb(0, 160, 50);" // 背景颜色
|
|
|
+ " background-color: rgb(90, 141, 52);" // 背景颜色
|
|
|
" color: white;" // 字体颜色
|
|
|
"}";
|
|
|
QString styleCheck = "QCheckBox {"
|
|
|
- " background-color: rgb(0, 160, 50);" // 背景颜色
|
|
|
+ " background-color: rgb(90, 141, 52);" // 背景颜色
|
|
|
" color: white;" // 字体颜色
|
|
|
"}";
|
|
|
+
|
|
|
+ QString styleMainWindow = "QMainWindow {"
|
|
|
+ " background-color: rgb(223, 226, 241);" // 背景颜色
|
|
|
+ "}";
|
|
|
ui->label_1->setStyleSheet(styleLabel);
|
|
|
ui->label_2->setStyleSheet(styleLabel);
|
|
|
ui->label_3->setStyleSheet(styleLabel);
|
|
|
ui->label_4->setStyleSheet(styleLabel);
|
|
|
+ ui->label_1->setAlignment(Qt::AlignCenter);
|
|
|
+ ui->label_2->setAlignment(Qt::AlignCenter);
|
|
|
+ ui->label_3->setAlignment(Qt::AlignCenter);
|
|
|
+ ui->label_4->setAlignment(Qt::AlignCenter);
|
|
|
|
|
|
ui->checkBox_left->setStyleSheet(styleCheck);
|
|
|
ui->checkBox_right->setStyleSheet(styleCheck);
|
|
@@ -51,14 +59,28 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
ui->lineEdit_drive->setStyleSheet(styleEdit);
|
|
|
ui->lineEdit_brake->setStyleSheet(styleEdit);
|
|
|
|
|
|
+ setStyleSheet(styleMainWindow);
|
|
|
+
|
|
|
updatevalue();
|
|
|
|
|
|
+ mpadecision = iv::modulecomm::RegisterSend("deciton",1000,1);
|
|
|
+
|
|
|
+ mbthreadrun = true;
|
|
|
+ mpthreadsend = new std::thread(&MainWindow::threadsend,this);
|
|
|
+
|
|
|
+ mpTimer =new QTimer(this);
|
|
|
+ connect(mpTimer,SIGNAL(timeout()),this,SLOT(onTimer()));
|
|
|
+ mpTimer->start(10);
|
|
|
+
|
|
|
setWindowTitle(tr("线控底盘检测项目"));
|
|
|
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
{
|
|
|
+ mbthreadrun = false;
|
|
|
+ mpthreadsend->join();
|
|
|
+ iv::modulecomm::Unregister(mpadecision);
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
@@ -116,7 +138,7 @@ void MainWindow::updatevalue()
|
|
|
{
|
|
|
const double MAXWHEEL = 430.0;
|
|
|
const double MINWHEEL = -430.0;
|
|
|
- const double MAXTORQUE = 100;
|
|
|
+ const double MAXTORQUE = 260;
|
|
|
const double MAXBRAKE = -3.0;
|
|
|
|
|
|
if(ui->checkBox_left->isChecked())mbleft = true;
|
|
@@ -166,3 +188,55 @@ void MainWindow::updatevalue()
|
|
|
mbleft,mbright,mfwheel,mftorque,mfbrake);
|
|
|
mpLabelInfo->setText(strout);
|
|
|
}
|
|
|
+
|
|
|
+void MainWindow::onTimer()
|
|
|
+{
|
|
|
+ static int ntorquebig = 0;
|
|
|
+ if(mftorque>30)ntorquebig++;
|
|
|
+ else ntorquebig = 0;
|
|
|
+ if(ntorquebig>1000)
|
|
|
+ {
|
|
|
+ ui->lineEdit_drive->setText("0");
|
|
|
+ updatevalue();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::threadsend()
|
|
|
+{
|
|
|
+ while(mbthreadrun)
|
|
|
+ {
|
|
|
+ iv::brain::decition xdecition;
|
|
|
+ if(mftorque>0)
|
|
|
+ xdecition.set_accelerator(0.1);
|
|
|
+ else
|
|
|
+ xdecition.set_accelerator(0.0);
|
|
|
+ xdecition.set_brake(mfbrake);
|
|
|
+ xdecition.set_leftlamp(mbleft);
|
|
|
+ xdecition.set_rightlamp(mbright);
|
|
|
+ xdecition.set_speed(3);
|
|
|
+ xdecition.set_wheelangle(mfwheel);
|
|
|
+ xdecition.set_wheelspeed(300);
|
|
|
+ xdecition.set_torque(mftorque);
|
|
|
+ xdecition.set_mode(1);
|
|
|
+ xdecition.set_gear(1);
|
|
|
+ xdecition.set_handbrake(0);
|
|
|
+ xdecition.set_grade(1);
|
|
|
+ xdecition.set_engine(0);
|
|
|
+ xdecition.set_brakelamp(false);
|
|
|
+ xdecition.set_ttc(15);
|
|
|
+ xdecition.set_roof_light(0);
|
|
|
+ xdecition.set_home_light(0);
|
|
|
+ xdecition.set_door(0);
|
|
|
+ xdecition.set_dippedlight(0);
|
|
|
+
|
|
|
+ int nbytesize = (int)xdecition.ByteSize();
|
|
|
+ std::shared_ptr<char> pstr_ptr = std::shared_ptr<char>(new char[nbytesize]);
|
|
|
+ if(!xdecition.SerializeToArray(pstr_ptr.get(),nbytesize))
|
|
|
+ {
|
|
|
+ std::cout<<" ctrlcmd2decition::ListenCtrlCmd Serialize Fail. "<<std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ iv::modulecomm::ModuleSendMsg(mpadecision,pstr_ptr.get(),nbytesize);
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
+ }
|
|
|
+}
|