1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492 |
- #include "adcintelligentshow.h"
- #include "ui_adcintelligentshow.h"
- #include <QSound>
- #include <QtMath>
- #include <QMessageBox>
- #include <QInputDialog>
- #include "pos_def.h"
- extern std::vector<iv::pos_def> gvectorpos;
- extern std::string gstrdefaultlane;
- ADCIntelligentShow * gAShow;
- #include "grpcclientthread.h"
- #ifdef Android
- extern grpcclientthread * ggt;
- #endif
- const double PI = 3.1415926535898;
- class xodrobj
- {
- public:
- double flatsrc;
- double flonsrc;
- double fhgdsrc;
- double flat;
- double flon;
- int lane;
- };
- void Listengpsimu(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- // ggpsimu->UpdateGPSIMU(strdata,nSize);
- iv::gps::gpsimu xgpsimu;
- if(!xgpsimu.ParseFromArray(strdata,nSize))
- {
- std::cout<<"ListenRaw Parse error."<<std::endl;
- return;
- }
- gAShow->UpdateGPSIMU(&xgpsimu);
- // qDebug(" gps time is %ld",QDateTime::currentMSecsSinceEpoch());
- }
- void ListenOBS(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- std::shared_ptr<std::vector<iv::ObstacleBasic>> lidar_obs(new std::vector<iv::ObstacleBasic>);
- iv::ObstacleBasic * pdata = (iv::ObstacleBasic *)strdata;
- int nCount = nSize/sizeof(iv::ObstacleBasic);
- int i;
- for(i=0;i<nCount;i++)
- {
- iv::ObstacleBasic temp;
- memcpy(&temp,pdata,sizeof(iv::ObstacleBasic));
- lidar_obs->push_back(temp);
- pdata++;
- }
- gAShow->UpdateOBS(lidar_obs);
- // gw->UpdateOBS(lidar_obs);
- }
- void ListenRadar(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- if(nSize<1)return;
- iv::radar::radarobjectarray xobj;
- if(false == xobj.ParseFromArray(strdata,nSize))
- {
- std::cout<<"ListenenRadar fail."<<std::endl;
- return;
- }
- gAShow->UpdateRADAR(&xobj);
- }
- void ListenDection(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- iv::brain::decition xdecision;
- if(!xdecision.ParseFromArray(strdata,nSize))
- {
- std::cout<<" ListenDection error. Parse error."<<std::endl;
- return;
- }
- gAShow->UpdateDection(xdecision);
- }
- void ListenFusion(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- iv::fusion::fusionobjectarray xfusionarray;
- if(!xfusionarray.ParseFromArray(strdata, static_cast<int>(nSize) ))
- {
- qDebug("listen fusion fail.");
- return;
- }
- gAShow->UpdateFusion(xfusionarray);
- }
- void ListenBrainState(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- iv::brain::brainstate xbrainstate;
- if(!xbrainstate.ParseFromArray(strdata,nSize))
- {
- std::cout<<"ListenBrainState Parse error."<<std::endl;
- return;
- }
- gAShow->UpdateBrainState(xbrainstate);
- }
- void ListenVehInfo(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- iv::veh::vehinfo xvehinfo;
- if(!xvehinfo.ParseFromArray(strdata,nSize))
- {
- std::cout<<"ListenVehInfo Parse error."<<std::endl;
- return;
- }
- gAShow->UpdateOTAVehInfo(xvehinfo);
- }
- void ListenTraceMap(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
- {
- (void)&index;
- (void)dt;
- (void)strmemname;
- gAShow->UpdateMap(strdata,nSize);
- }
- #ifdef Android
- void ADCIntelligentShow::AndroidSetMsg(const char * msgname , const char *strdata, const unsigned int nDataLen)
- {
- // qDebug("msg: %s ",msgname);
- if(strncmp(msgname,"hcp2_gpsimu",256) == 0)
- {
- Listengpsimu(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"tracemap",256) == 0)
- {
- ListenTraceMap(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"lidar_obs",256) == 0)
- {
- ListenOBS(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"brainstate",256) == 0)
- {
- ListenBrainState(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"deciton",256) == 0)
- {
- ListenDection(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"radar",256) == 0)
- {
- ListenRadar(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"otavehinfo",256) == 0)
- {
- ListenVehInfo(strdata,nDataLen,0,0,0);
- }
- if(strncmp(msgname,"li_ra_fusion",256) == 0)
- {
- // qDebug("li ra fusion.");
- ListenFusion(strdata,nDataLen,0,0,0);
- }
- }
- #endif
- ADCIntelligentShow::ADCIntelligentShow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::ADCIntelligentShow)
- {
- gAShow = this;
- ui->setupUi(this);
- ui->pushButton->setEnabled(false);
- mpivmapview = new ivmapview();
- mpivmapview->start();
- //样式 3-26
- qApp->setStyleSheet("QPushButton#pushButton_2\n{\nborder-image: url(:/new/pic/restart1.png);\n}"
- "QPushButton#pushButton_2:hover\n{border-image: url(:/new/pic/restart4.png);\n}"
- "QPushButton#pushButton_2:pressed\n{ border-image: url(:/new/pic/restart3.png); \n}"
- "QPushButton#park:pressed\n{border-image: url(:/new/pic/park_press.png);\n}"
- "QPushButton#pushButton_Setting\n{ border-image: url(:/new/pic/setting.png); \n}"
- "QPushButton#pushButton_Setting:pressed\n{ border-image: url(:/new/pic/setting2.png); \n}"
- "QCheckBox#checkBox::indicator\n{width: 110px;height: 110px;\n}"
- "QCheckBox#checkBox::indicator:unchecked\n{ border-image:url(:/new/pic/call_gray1.png);\n}"
- "QCheckBox#checkBox::indicator:checked\n{ border-image:url(:/new/pic/call1.png);\n}"
- "QCheckBox#checkBox_2::indicator\n{width: 110px;height: 110px;\n}"
- "QCheckBox#checkBox_2::indicator:unchecked\n{ border-image:url(:/new/pic/mulcar_gray.png);\n}"
- "QCheckBox#checkBox_2::indicator:checked\n{ border-image:url(:/new/pic/mulcar.png);\n}");
- QDesktopWidget *desktopWidget = QApplication::desktop();
- QRect screenRect = desktopWidget->screenGeometry();
- resize(screenRect.width(),screenRect.height());
- loadMapFromFile("map.txt");
- image = new QImage(900*2,900*2,QImage::Format_RGB32);
- painter = new QPainter(image);
- myview = new MyView(ui->widget_2);
- myview->setObjectName("graphicsView");
- myview->setGeometry(QRect(100,20,900,1000));
- myview->setCacheMode(myview->CacheBackground);
- scene = new QGraphicsScene;
- myview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- myview->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- DataUI = new DataToUI;
- socket = new QUdpSocket;
- socket->bind(9999,QUdpSocket::ShareAddress);
- // connect(socket,SIGNAL(readyRead()),this,SLOT(onRecv()));
- lidarsock = new QUdpSocket;
- lidarsock->bind(9997);
- // connect(lidarsock,SIGNAL(readyRead()),this,SLOT(onlidarRecv()));
- mbHaveData = false;
- recvFlag = 0;
- connect(&mTimer,SIGNAL(timeout()),this,SLOT(onTimer()));
- // mTimer.start(500);
- connect(&connTimer,SIGNAL(timeout()),this,SLOT(onconnTimer()));
- connTimer.start(1000);
- for(int i = 0;i<128;i++)
- {
- DataUI->mInfo.point[i] = 0.0;
- }
- mlidarpoint.lidar_size = 0;
- for(int i=0;i<10000;i++)
- {
- mlidarpoint.lidar_point[i] = 0.0;
- }
- //DataUI->mInfo.lidar_size = 0;
- ///added by kkcai, 2019-11-28
- // ui->label_3->hide();
- // ui->label_4->hide();
- ///////////////////////////////////////////////////////////////////////////
- ///added by kkcai, 2019-12-02
- soundAlarm = new QSound(":/new/pic/alarm.wav");
- connect(this, SIGNAL(sigAlarm()), this, SLOT(slotAlarm()));
- #ifndef Android
- void * pa;
- pa = iv::modulecomm::RegisterRecv("hcp2_gpsimu",Listengpsimu);
- mpagps = pa;
- pa = iv::modulecomm::RegisterRecv("tracemap",ListenTraceMap);
- mpatracemap = pa;
- pa = iv::modulecomm::RegisterRecv("lidar_obs",ListenOBS);
- mpalidarobs = pa;
- pa = iv::modulecomm::RegisterRecv("brainstate",ListenBrainState);
- mpabrainstate = pa;
- pa = iv::modulecomm::RegisterRecv("deciton",ListenDection);
- mpadecision = pa;
- pa = iv::modulecomm::RegisterRecv("radar",ListenRadar);
- mparadar = pa;
- pa = iv::modulecomm::RegisterRecv("otavehinfo",ListenVehInfo);
- pa = iv::modulecomm::RegisterRecv("li_ra_fusion",ListenFusion);
- mpadst = iv::modulecomm::RegisterSend("xodrreq",1000,1);
- mpapad = iv::modulecomm::RegisterSend("pad",1000,1);
- mndefaultlane = atoi(gstrdefaultlane.data());
- #endif
- connect(this,SIGNAL(signalGPSIMU()),this,SLOT(onUpdateGPSIMU()));
- connect(this,SIGNAL(signalbrainstate()),this,SLOT(onUpdateBrainState()));
- connect(this,SIGNAL(signaldection()),this,SLOT(onUpdateDection()));
- QTimer * timerpainter = new QTimer(this);
- connect(timerpainter,SIGNAL(timeout()),this,SLOT(onTimerPainter()));
- timerpainter->start(100);
- ui->pushButton_go->setStyleSheet("background: green; color: white;");
- ui->pushButton_AddStation->setStyleSheet("background: green; color: white;");
- ui->pushButton_DelStation->setStyleSheet("background: green; color: white;");
- // ui->pushButton_prestation->setStyleSheet("background: green; color: white;");
- // ui->pushButton_nextstation->setStyleSheet("background: green; color: white;border-image: url(:/new/pic/button_gray.png);");
- ui->label_station->setStyleSheet("background: transparent; color: white;font: 50px 'Arial';");
- ui->label_station->setText("");
- ui->label_vehinfo->setStyleSheet("color: rgb(220, 220, 220);font: 15px 'Arial';");
- ui->label_vehinfo->setText("No Vehicle Type & VIN Info");
- if(gvectorpos.size()>0)
- {
- mnStationIndex = 0;
- ui->label_station->setText(gvectorpos[0].mstrstationname.data());
- }
- mpDS = new DialogSetting(this);
- connect(mpDS,SIGNAL(signalswith(int)),this,SLOT(onSwitchClick(int)));
- connect(mpDS,SIGNAL(signalMode(int)),this,SLOT(onModeClick(int)));
- connect(this,SIGNAL(signalvehinfoupdate()),this,SLOT(onOTAVehInfoUpdate()));
- // ui->pushButton_go->setStyleSheet("color: red");
- ///////////////////////////////////////////////////////////////////////
- ///added by kkcai, 2019-12-02
- // ui->checkBox->hide();
- // ui->checkBox_2->hide();
- // ui->park->hide();
- ///////////////////////////////////////////////////////////////////////
- #ifdef ANDROID
- ui->run->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->map->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->can->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->local->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_9->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_11->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_12->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_13->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_14->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_15->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_16->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_17->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->label_6->setStyleSheet("font: 50px 'Arial';color: rgb(255, 255, 255);");
- ui->label->setStyleSheet("font: 75 150px '微软雅黑';color: rgb(238, 238, 238);");
- ui->radar->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->lidar->setStyleSheet("color: rgb(220, 220, 220);font: 30px 'Arial';");
- ui->acc->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->swerve->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->lng->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->lat->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->radarob->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->lidarob->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->allob->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- ui->break_1->setStyleSheet("color: rgb(255, 255, 255);background-color: transparent;border-radius:10px;font: 23px 'Arial';border:7px groove rgb(0,45,70);");
- #endif
- }
- ADCIntelligentShow::~ADCIntelligentShow()
- {
- iv::modulecomm::Unregister(mpabrainstate);
- iv::modulecomm::Unregister(mpadecision);
- iv::modulecomm::Unregister(mpagps);
- iv::modulecomm::Unregister(mpalidarobs);
- iv::modulecomm::Unregister(mpapad);
- iv::modulecomm::Unregister(mparadar);
- iv::modulecomm::Unregister(mpatracemap);
- iv::modulecomm::Unregister(mpadst);
- // std::this_thread::sleep_for(std::chrono::milliseconds(50));
- delete ui;
- if(soundAlarm){
- delete soundAlarm;
- soundAlarm = nullptr;
- }
- }
- void ADCIntelligentShow::resizeEvent(QResizeEvent *event)
- {
- (void)event;
- QSize sizemain = ui->centralWidget->size();
- ui->widget_2->setGeometry(730,0,sizemain.width()-730,sizemain.height()-0);
- myview->setGeometry(0,150,sizemain.width()-730-0,sizemain.height()-150);
- #ifndef Android
- ui->pushButton_prestation->setGeometry(50,30,100,50);
- ui->label_station->setGeometry(160,30,200,50);
- ui->pushButton_nextstation->setGeometry(380,30,100,50);
- ui->pushButton_go->setGeometry(490,30,100,50);
- ui->pushButton_AddStation->setGeometry(600,30,100,50);
- ui->pushButton_DelStation->setGeometry(730,30,100,50);
- #else
- // ui->pushButton_prestation->setGeometry(30,30,150,100);
- // ui->label_station->setGeometry(190,30,260,100);
- // ui->pushButton_nextstation->setGeometry(460,30,150,100);
- // ui->pushButton_go->setGeometry(630,30,150,100);
- ui->pushButton_prestation->setGeometry(50,30,100,100);
- ui->label_station->setGeometry(160,30,500,100);
- ui->pushButton_nextstation->setGeometry(680,30,100,100);
- ui->pushButton_go->setGeometry(830,30,150,100);
- ui->pushButton_AddStation->setGeometry(1050,30,150,100);
- ui->pushButton_DelStation->setGeometry(1230,30,150,100);
- #endif
- }
- void ADCIntelligentShow::onTimer()
- {
- if(!mbHaveData)
- {
- ui->pushButton->setEnabled(false);
- }
- mbHaveData = false;
- update();
- }
- void ADCIntelligentShow::on_pushButton_clicked()
- {
- std::cout<<"click "<<std::endl;
- iv::hmi::hmimsg xhmi;
- xhmi.set_mbbochemode(false);
- xhmi.set_mbbusmode(false);
- if(mbRunning)
- xhmi.set_mbpause(true);
- else
- xhmi.set_mbpause(false);
- int nsize = xhmi.ByteSize();
- char * str = new char[nsize];
- if(xhmi.SerializeToArray(str,1000))
- {
- #ifndef Android
- iv::modulecomm::ModuleSendMsg(mpapad,str,nsize);
- #else
- ggt->UpdateData(str,nsize,"pad");
- #endif
- }
- else
- {
- std::cout<<"ADCIntelligentShow::on_pushButton_clicked serialize error."<<std::endl;
- }
- delete str;
- QApplication::beep();
- return;
- if(DataUI->mInfo.is_run == 0x00)
- {
- int xRun = 1;
- socket->writeDatagram((char *)&xRun,4,QHostAddress::Broadcast,9998);
- }
- if(DataUI->mInfo.is_run == 0x01)
- {
- int xRun = 0;
- socket->writeDatagram((char *)&xRun,4,QHostAddress::Broadcast,9998);
- }
- QApplication::beep();
- }
- void ADCIntelligentShow::onRecv()
- {
- while(socket->hasPendingDatagrams())
- {
- QByteArray data;
- data.resize(socket->pendingDatagramSize());
- socket->readDatagram(data.data(),data.size());
- recvFlag++;
- // packageHead packHead;
- qDebug("size = %d",data.size());
- //if(data.size() == sizeof(DataToUI))
- //{
- memcpy(DataUI,data.data(),data.size());
- qDebug("size:%d",DataUI->mHead.size);
- ////////////////////////
- /// 程序状态/////////////
- ///////////////////////
- qDebug("speed:%g",DataUI->mInfo.speed);
- ui->label->setText(QString::number((DataUI->mInfo.speed),'f',1));
- if(DataUI->mInfo.is_mapLoad==0x01)
- ui->mapimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- else
- ui->mapimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- if(DataUI->mInfo.is_initSuccess==0x01)
- ui->canimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- else
- ui->canimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->acc->setText(QString::number(DataUI->mInfo.accelerate,'f',1));
- ui->swerve->setText(QString::number(DataUI->mInfo.swerve,'f',1));
- ui->lng->setText(QString::number(DataUI->mInfo.gps_lng,'f',6));
- ui->lat->setText(QString::number(DataUI->mInfo.gps_lat,'f',6));
- ui->radarob->setText(QString::number(DataUI->mInfo.radarobs,'f',2));
- ui->lidarob->setText(QString::number(DataUI->mInfo.lidarobs,'f',2));
- ui->allob->setText(QString::number(DataUI->mInfo.obs,'f',2));
- //add
- ui->break_1->setText(QString::number(DataUI->mInfo.brake,'f',2));
- if(DataUI->mInfo.lidarStatus == 0x01)
- ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- else
- ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- /*
- if(DataUI->mInfo.radarStatus == 0x01)
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- else
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- */
- if(DataUI->mInfo.radarStatus == 0x01)
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- else
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- if(DataUI->mInfo.RTKstatus == 6)
- {
- ui->local->setText(QStringLiteral("定位:")+QString::number(DataUI->mInfo.RTKstatus));
- ui->local->setStyleSheet("color: rgb(220, 220, 220); font: 15pt 'Arial';");
- ui->localimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- }
- else
- {
- ui->local->setText(QStringLiteral("定位:")+QString::number(DataUI->mInfo.RTKstatus));
- ui->local->setStyleSheet("color: rgb(220, 220, 220); font: 15pt 'Arial';");
- ui->localimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- }
- if(DataUI->mInfo.is_mapLoad==0x00||DataUI->mInfo.is_initSuccess==0x00)
- {
- ui->pushButton->setEnabled(false);
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_gray.png);");
- }
- else
- {
- ui->pushButton->setEnabled(true);
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_green.png);");
- if(DataUI->mInfo.is_run==0x01)
- {
- ui->runimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_stop.png);");
- }
- else
- {
- ui->runimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_green.png);");
- }
- }
- if(DataUI->mInfo.parkSatus == 0x00)
- {
- ui->park->setText(QStringLiteral("不可泊车"));
- ui->park->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->park->setEnabled(false);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park_gray.png)");
- }
- else if(DataUI->mInfo.parkSatus == 0x01)
- {
- ui->park->setText(QStringLiteral("可泊车"));
- ui->park->setStyleSheet("background-image: url(:/new/pic/green.png);");
- ui->park->setEnabled(true);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park.png)");
- }
- else if(DataUI->mInfo.parkSatus == 0x02)
- {
- ui->park->setText(QStringLiteral("泊车"));
- ui->park->setStyleSheet("background-color: rgb(211, 211, 0); font: 15pt 'Arial';");
- ui->park->setEnabled(false);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park_gray.png)");
- }
- mbHaveData = true;
- // if(p->mInfo.)
- data.clear();
- // }
- // memcpy(&packHead,data.data(),sizeof(packHead));
- }
- update();
- }
- void ADCIntelligentShow::onconnTimer()
- {
- qint64 xTime = QDateTime::currentMSecsSinceEpoch();
- if(recvFlag!=0)
- {
- //ui->connect->setText(QStringLiteral("已连接"));
- ui->connect->setStyleSheet("image: url(:/new/pic/connect.png);");
- if((abs(xTime - mnTimeGPS)>1000) &&(mnstylegps != 0))
- {
- ui->lng->setText(" ");
- ui->lat->setText(" ");
- ui->label->setText(QString::number(0));
- ui->localimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- mnstylegps = 0;
- }
- if((abs(xTime - mnTimeLidar)>1000) &&(mnstylelidar != 1))
- {
- ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- mnstylelidar = 1;
- }
- if((abs(xTime - mnTimeLidar)<1000) &&(mnstylelidar != 2))
- {
- ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- mnstylelidar = 2;
- }
- if((abs(xTime - mnTimeRADAR)>1000) && (mnstyleradar != 1))
- {
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- mnstyleradar = 1;
- }
- if((abs(xTime - mnTimeRADAR)<1000) && (mnstyleradar != 2))
- {
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- mnstyleradar = 2;
- }
- if(abs(xTime- mnTimeDection)>1000)
- {
- ui->acc->setText(" ");
- ui->swerve->setText(" ");
- ui->break_1->setText(" ");
- if(mnstylepark != 0)
- {
- ui->park->setText(QStringLiteral("不可泊车"));
- ui->park->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->park->setEnabled(false);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park_gray.png)");
- mnstylepark = 0;
- }
- }
- if(navigation_data.size()>0)
- {
- ui->mapimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- }
- else
- {
- ui->mapimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- }
- }
- else
- {
- //ui->connect->setText(QStringLiteral("未连接"));
- ui->connect->setStyleSheet("image: url(:/new/pic/connect_grey.png);");
- ui->pushButton->setEnabled(false);
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_gray.png);");
- ui->label->setText(QString::number(0));
- ui->runimg->setStyleSheet("background-image: url(:/new/pic/blue.png);");
- ui->mapimg->setStyleSheet("background-image: url(:/new/pic/blue.png);");
- ui->canimg->setStyleSheet("background-image: url(:/new/pic/blue.png);");
- ui->localimg->setStyleSheet("background-image: url(:/new/pic/blue.png);");
- ui->acc->setText(" ");
- ui->swerve->setText(" ");
- ui->lng->setText(" ");
- ui->lat->setText(" ");
- ui->radarob->setText(" ");
- ui->lidarob->setText(" ");
- ui->allob->setText(" ");
- ui->lidarimg->setStyleSheet("background-image: url(:/new/pic/blue.png);");
- ui->radarimg->setStyleSheet("background-image: url(:/new/pic/blue.png);");
- ui->park->setText(QStringLiteral("不可泊车"));
- ui->park->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->park->setEnabled(false);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park_gray.png)");
- mnstylegps = 0;
- mnstylelidar = 0;
- mnstylebrain = 0;
- mnstyleradar = 0;
- mnstylepark = 0;
- }
- // ui->acc->setText("-0.11111111");
- // ui->lat->setText("39.00000001");
- // ui->label_station->setText("TEXT.");
- recvFlag = 0;
- }
- void ADCIntelligentShow::onTimerPainter()
- {
- update();
- }
- //刷新
- void ADCIntelligentShow::paintEvent(QPaintEvent *)
- {
- // 绘制背景图
- mpainter_background = new QPainter(this);
- mpainter_background->drawPixmap(0, 0, this->width(), this->height(), QPixmap(":/new/pic/background2.jpg"));
- delete mpainter_background;
- if(mpivmapview->IsHaveNew())
- {
- QImage image = mpivmapview->GetImage();
- scene->clear();
- scene->addPixmap(QPixmap::fromImage(image));
- myview->setScene(scene);
- myview->show();
- }
- return;
- }
- bool ADCIntelligentShow::loadMapFromFile(std::string fileName) {
- std::ifstream fis(fileName);//获取文件
- std::string line;
- std::vector<std::string> des;
- if (fis.is_open() == false)
- return false;
- try {
- while (getline(fis, line)) {//开始一行一行的读数据
- des.clear();
- SplitString(line,des,"\t");
- //boost::split(des, line, boost::is_any_of("\t"));
- //if (des.size() != 10)
- // throw "error";
- if(des.size() < 10)
- throw "error";
- GPS_INS *data =new GPS_INS;
- data->index = atoi(des[0].c_str());
- data->gps_lng = atof(des[1].c_str());
- data->gps_lat = atof(des[2].c_str());
- data->speed_mode = atoi(des[3].c_str());
- data->mode2 = atoi(des[4].c_str());
- data->ins_heading_angle = atof(des[5].c_str());
- data->runMode = atoi(des[6].c_str());
- data->roadMode = atoi(des[7].c_str());
- data->roadSum = atoi(des[8].c_str());
- data->roadOri = atoi(des[9].c_str());
- //des[10].c_str() is the width of the road, and is no use.
- //Modified by map. 2019-12-02
- // gps2xy(data->gps_lat, data->gps_lng, &data->gps_x, &data->gps_y);
- GaussProjCal(data->gps_lng, data->gps_lat, &data->gps_x, &data->gps_y);
- //data->speed = 5; //调试用 所有点速度都设为5km/h
- //LOG2(data->gps_x, data->gps_y);
- //ODS("x %.20lf y %.20lf\n", data->gps_x, data->gps_y);
- // iv::decition::BLH2XYZ(*data); //重新转下大地坐标
- // navigation_data.push_back(data);
- }
- }
- catch (...) {
- fis.close();
- return false;
- }
- fis.close();
- return true;
- }
- //高斯投影由经纬度(Unit:DD)反算大地坐标(含带号,Unit:Metres)
- void ADCIntelligentShow::GaussProjCal(double longitude, double latitude, double *X, double *Y)
- {
- int ProjNo = 0; int ZoneWide; ////带宽
- double longitude1, latitude1, longitude0, X0, Y0, xval, yval;
- double a, f, e2, ee, NN, T, C, A, M, iPI;
- iPI = 0.0174532925199433; ////3.1415926535898/180.0;
- ZoneWide = 6; ////6度带宽
- a = 6378245.0; f = 1.0 / 298.3; //54年北京坐标系参数
- ////a=6378140.0; f=1/298.257; //80年西安坐标系参数
- ProjNo = (int)(longitude / ZoneWide);
- longitude0 = ProjNo * ZoneWide + ZoneWide / 2;
- longitude0 = longitude0 * iPI;
- //latitude0 = 0;
- longitude1 = longitude * iPI; //经度转换为弧度
- latitude1 = latitude * iPI; //纬度转换为弧度
- e2 = 2 * f - f * f;
- ee = e2 * (1.0 - e2);
- NN = a / sqrt(1.0 - e2 * sin(latitude1)*sin(latitude1));
- T = tan(latitude1)*tan(latitude1);
- C = ee * cos(latitude1)*cos(latitude1);
- A = (longitude1 - longitude0)*cos(latitude1);
- M = a * ((1 - e2 / 4 - 3 * e2*e2 / 64 - 5 * e2*e2*e2 / 256)*latitude1 -
- (3 * e2 / 8 + 3 * e2*e2 / 32 + 45 * e2*e2*e2 / 1024)*sin(2 * latitude1)
- + (15 * e2*e2 / 256 + 45 * e2*e2*e2 / 1024)*sin(4 * latitude1) -
- (35 * e2*e2*e2 / 3072)*sin(6 * latitude1));
- xval = NN * (A + (1 - T + C)*A*A*A / 6 + (5 - 18 * T + T * T + 72 * C - 58 * ee)*A*A*A*A*A / 120);
- yval = M + NN * tan(latitude1)*(A*A / 2 + (5 - T + 9 * C + 4 * C*C)*A*A*A*A / 24
- + (61 - 58 * T + T * T + 600 * C - 330 * ee)*A*A*A*A*A*A / 720);
- X0 = 1000000L * (ProjNo + 1) + 500000L;
- Y0 = 0;
- xval = xval + X0; yval = yval + Y0;
- *X = xval;
- *Y = yval;
- }
- void ADCIntelligentShow::SplitString(const string& s, vector<string>& v, const string& c)
- {
- string::size_type pos1, pos2;
- pos2 = s.find(c);
- pos1 = 0;
- while(string::npos != pos2)
- {
- v.push_back(s.substr(pos1, pos2-pos1));
- pos1 = pos2 + c.size();
- pos2 = s.find(c, pos1);
- }
- if(pos1 != s.length())
- v.push_back(s.substr(pos1));
- }
- void ADCIntelligentShow::on_park_clicked()
- {
- iv::hmi::hmimsg xhmi;
- xhmi.set_mbbochemode(true);
- xhmi.set_mbbusmode(false);
- xhmi.set_mbpause(false);
- // if(mbRunning)
- // xhmi.set_mbpause(true);
- // else
- // xhmi.set_mbpause(false);
- int nsize = xhmi.ByteSize();
- char * str = new char[nsize];
- if(xhmi.SerializeToArray(str,1000))
- {
- #ifndef Android
- iv::modulecomm::ModuleSendMsg(mpapad,str,nsize);
- #else
- ggt->UpdateData(str,nsize,"pad");
- #endif
- }
- else
- {
- std::cout<<"ADCIntelligentShow::on_pushButton_clicked serialize error."<<std::endl;
- }
- delete str;
- QApplication::beep();
- return;
- int xRun = 2;
- socket->writeDatagram((char *)&xRun,4,QHostAddress::Broadcast,9998);
- QApplication::beep();
- }
- void ADCIntelligentShow::onlidarRecv()
- {
- while(lidarsock->hasPendingDatagrams())
- {
- QByteArray data;
- data.resize(lidarsock->pendingDatagramSize());
- lidarsock->readDatagram(data.data(),data.size());
- // packageHead packHead;
- qDebug("size = %d",data.size());
- //if(data.size() == sizeof(DataToUI))
- //{
- memcpy(&mlidarpoint,data.data(),data.size());
- qDebug("size:%d",DataUI->mHead.size);
- }
- }
- ////一键叫车
- //void ADCIntelligentShow::on_onekey_clicked()
- //{
- // int res = QMessageBox::warning(NULL,"警告","确认是否一键叫车",QMessageBox::Yes,QMessageBox::No);
- // if(res==QMessageBox::Yes)
- // {
- // int xRun = 3;
- // socket->writeDatagram((char *)&xRun,4,QHostAddress::Broadcast,9998);
- // }
- // else
- // {
- // int xRun = 4;
- // socket->writeDatagram((char *)&xRun,4,QHostAddress::Broadcast,9998);
- // }
- //}
- void ADCIntelligentShow::on_pushButton_2_clicked()
- {
- std::cout<<"click "<<std::endl;
- iv::hmi::hmimsg xhmi;
- xhmi.set_mbbochemode(true);
- xhmi.set_mbbusmode(false);
- if(mbRunning)
- xhmi.set_mbpause(false);
- else
- xhmi.set_mbpause(true);
- int nsize = xhmi.ByteSize();
- char * str = new char[nsize];
- if(xhmi.SerializeToArray(str,1000))
- {
- #ifndef Android
- iv::modulecomm::ModuleSendMsg(mpapad,str,nsize);
- #else
- ggt->UpdateData(str,nsize,"pad");
- #endif
- }
- else
- {
- std::cout<<"ADCIntelligentShow::on_pushButton_clicked serialize error."<<std::endl;
- }
- delete str;
- QApplication::beep();
- return;
- //QMessageBox::styleSheet("background-color: rgb(140, 140, 140);");
- int res = QMessageBox::warning(NULL,"警告","确认是否重新启动",QMessageBox::Yes,QMessageBox::No);
- if(res==QMessageBox::Yes)
- {
- int xRun = 9;
- socket->writeDatagram((char *)&xRun,4,QHostAddress::Broadcast,9998);
- }
- }
- void ADCIntelligentShow::slotAlarm()
- {
- if(soundAlarm->isFinished())
- soundAlarm->play();
- }
- void ADCIntelligentShow::UpdateGPSIMU(iv::gps::gpsimu *pgpsimu)
- {
- iv::gps::gpsimu xgpsimu;
- xgpsimu.CopyFrom(*pgpsimu);
- mMutexGPSIMU.lock();
- mgpsimu.CopyFrom(*pgpsimu);
- mMutexGPSIMU.unlock();
- emit signalGPSIMU();
- mnTimeGPS = QDateTime::currentMSecsSinceEpoch();
- }
- void ADCIntelligentShow::UpdateOBS(std::shared_ptr<std::vector<iv::ObstacleBasic> > xobs)
- {
- recvFlag = 1;
- mpivmapview->setobs(xobs);
- mnTimeLidar = QDateTime::currentMSecsSinceEpoch();
- }
- void ADCIntelligentShow::onUpdateGPSIMU()
- {
- recvFlag = 1;
- iv::gps::gpsimu xgpsimu;
- mMutexGPSIMU.lock();
- xgpsimu.CopyFrom(mgpsimu);
- mMutexGPSIMU.unlock();
- mpivmapview->setgps(&xgpsimu);
- ui->lng->setText(QString::number(xgpsimu.lon(),'f',7));
- ui->lat->setText(QString::number(xgpsimu.lat(),'f',7));
- if(xgpsimu.rtk_state() == 6)
- {
- ui->local->setText(QStringLiteral("定位:")+QString::number(xgpsimu.rtk_state()));
- if(mnstylegps != 1)
- {
- ui->local->setStyleSheet("color: rgb(220, 220, 220); font: 30px 'Arial';");
- ui->localimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- mnstylegps = 1;
- }
- }
- else
- {
- ui->local->setText(QStringLiteral("定位:")+QString::number(xgpsimu.rtk_state()));
- if(mnstylegps != 2)
- {
- ui->local->setStyleSheet("color: rgb(220, 220, 220); font: 30px 'Arial';");
- ui->localimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- mnstylegps = 2;
- }
- }
- ui->label->setText(QString::number((sqrt(pow(xgpsimu.ve(),2)+pow(xgpsimu.vn(),2))*3.6),'f',1));
- }
- void ADCIntelligentShow::UpdateMap(const char *mapdata, const int mapdatasize)
- {
- std::cout<<"update map "<<std::endl;
- int gpsunitsize = sizeof(iv::MAP_GPS_INS);
- int nMapSize = mapdatasize/gpsunitsize;
- // std::cout<<"map size is "<<nMapSize<<std::endl;
- if(nMapSize < 1)return;
- bool bUpdate = false;
- if(nMapSize != navigation_data.size())
- {
- bUpdate = true;
- }
- else
- {
- iv::MAP_GPS_INS * p = (iv::MAP_GPS_INS *)mapdata;
- if((p->gps_lat == navigation_data.at(0).gps_lat)&&(p->ins_heading_angle == navigation_data.at(0).ins_heading_angle))
- {
- // qDebug("same map");
- bUpdate = false;
- }
- else
- {
- bUpdate = true;
- }
- }
- if(bUpdate)
- {
- int i;
- mMutexMap.lock();
- navigation_data.clear();
- for(i=0;i<nMapSize;i++)
- {
- iv::MAP_GPS_INS x;
- GaussProjCal(x.gps_lng,x.gps_lat,&x.gps_x,&x.gps_y);
- memcpy(&x,mapdata + i*gpsunitsize,gpsunitsize);
- navigation_data.push_back(x);
- }
- mMutexMap.unlock();
- mpivmapview->setmap(navigation_data);
- // mpasd->SaveState("map",mapdata,mapdatasize);
- }
- else
- {
- // qDebug("not need update");
- }
- }
- void ADCIntelligentShow::UpdateBrainState(iv::brain::brainstate xbrainstate)
- {
- recvFlag = 1;
- mMutexBrain.lock();
- mbrainstate.CopyFrom(xbrainstate);
- mMutexBrain.unlock();
- mnTimeBrain = QDateTime::currentMSecsSinceEpoch();
- emit signalbrainstate();
- }
- void ADCIntelligentShow::onUpdateBrainState()
- {
- recvFlag = 1;
- iv::brain::brainstate xbrainstate;
- mMutexBrain.lock();
- xbrainstate.CopyFrom(mbrainstate);
- mMutexBrain.unlock();
- ui->pushButton->setEnabled(true);
- if(xbrainstate.mbbrainrunning())
- {
- mbRunning = true;
- if(mnstylebrain != 2)
- {
- ui->runimg->setStyleSheet("background-image: url(:/new/pic/green.png);");
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_stop.png);");
- mnstylebrain = 2;
- }
- ui->radarob->setText(QString::number(xbrainstate.mfradarobs(),'f',2));
- ui->lidarob->setText(QString::number(xbrainstate.mflidarobs(),'f',2));
- ui->allob->setText(QString::number(xbrainstate.mfobs(),'f',2));
- }
- else
- {
- mbRunning = false;
- if(mnstylebrain != 1)
- {
- ui->runimg->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->pushButton->setStyleSheet("border-image: url(:/new/pic/button_green.png);");
- mnstylebrain = 1;
- }
- ui->radarob->setText(" ");
- ui->lidarob->setText(" ");
- ui->allob->setText(" ");
- }
- if(xbrainstate.mbbocheenable())
- {
- if(mnstylepark != 2)
- {
- mnstylepark = 2;
- ui->park->setText(QStringLiteral("可泊车"));
- ui->park->setStyleSheet("background-image: url(:/new/pic/green.png);");
- ui->park->setEnabled(true);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park.png)");
- }
- }
- else
- {
- if(mnstylepark != 1)
- {
- ui->park->setText(QStringLiteral("不可泊车"));
- ui->park->setStyleSheet("background-image: url(:/new/pic/red.png);");
- ui->park->setEnabled(false);
- ui->park->setStyleSheet("border-image: url(:/new/pic/park_gray.png)");
- mnstylepark = 1;
- }
- }
- }
- void ADCIntelligentShow::UpdateDection(iv::brain::decition xdecision )
- {
- mMutexDecision.lock();
- mdecision.CopyFrom(xdecision);
- mMutexDecision.unlock();
- emit signaldection();
- mnTimeDection = QDateTime::currentMSecsSinceEpoch();
- }
- void ADCIntelligentShow::onUpdateDection()
- {
- iv::brain::decition xdecision;
- mMutexDecision.lock();
- xdecision.CopyFrom(mdecision);
- mMutexDecision.unlock();
- ui->acc->setText(QString::number(xdecision.torque(),'f',1));
- ui->swerve->setText(QString::number(xdecision.wheelangle(),'f',1));
- ui->break_1->setText(QString::number(xdecision.brake(),'f',2));
- }
- void ADCIntelligentShow::UpdateRADAR(iv::radar::radarobjectarray *pxobj)
- {
- recvFlag = 1;
- mMutexRadar.lock();
- mradarobj.CopyFrom(*pxobj);
- mMutexRadar.unlock();
- mnTimeRADAR = QDateTime::currentMSecsSinceEpoch();
- mpivmapview->setradar(pxobj);
- }
- void ADCIntelligentShow::UpdateOTAVehInfo(iv::veh::vehinfo &pvehinfo)
- {
- mMutexVehInfo.lock();
- mvehinfo.CopyFrom(pvehinfo);
- mMutexVehInfo.unlock();
- mnVehInfoTime = QDateTime::currentMSecsSinceEpoch();
- emit signalvehinfoupdate();
- }
- void ADCIntelligentShow::on_pushButton_nextstation_clicked()
- {
- if(gvectorpos.size()<1)return;
- mnStationIndex++;
- if(mnStationIndex>=gvectorpos.size())mnStationIndex = 0;
- ui->label_station->setText(gvectorpos[mnStationIndex].mstrstationname.data());
- }
- void ADCIntelligentShow::on_pushButton_prestation_clicked()
- {
- if(gvectorpos.size()<1)return;
- mnStationIndex--;
- if(mnStationIndex<0)mnStationIndex = gvectorpos.size()-1;
- ui->label_station->setText(gvectorpos[mnStationIndex].mstrstationname.data());
- }
- void ADCIntelligentShow::on_pushButton_go_clicked()
- {
- if(gvectorpos.size()<1)return;
- qDebug("set plan.lon:%f lat:%f index:%d",gvectorpos[mnStationIndex].mflon,gvectorpos[mnStationIndex].mflat,mnStationIndex);
- xodrobj xo;
- xo.flon = gvectorpos[mnStationIndex].mflon;
- xo.flat = gvectorpos[mnStationIndex].mflat;
- xo.lane = mndefaultlane;
- #ifndef Android
- iv::modulecomm::ModuleSendMsg(mpadst,(char *)&xo,sizeof(xodrobj));
- #else
- ggt->UpdateData((char *)&xo,sizeof(xodrobj),"xodrreq");
- #endif
- }
- void ADCIntelligentShow::onSwitchClick(int nswitch)
- {
- iv::hmi::hmimsg xhmi;
- xhmi.set_mbbochemode(false);
- xhmi.set_mbbusmode(false);
- if(mbRunning)
- xhmi.set_mbpause(false);
- else
- xhmi.set_mbpause(true);
- switch (nswitch) {
- case 0:
- xhmi.set_mbchemen(true);
- break;
- case 1:
- xhmi.set_mbchemen(false);
- break;
- case 2:
- xhmi.set_mbjinguang(true);
- break;
- case 3:
- xhmi.set_mbjinguang(false);
- break;
- case 4:
- xhmi.set_mbyuanguang(true);
- break;
- case 5:
- xhmi.set_mbyuanguang(false);
- break;
- default:
- break;
- }
- int nsize = xhmi.ByteSize();
- std::shared_ptr<char> pstr = std::shared_ptr<char>(new char[nsize]);
- if(xhmi.SerializeToArray(pstr.get(),1000))
- {
- #ifndef Android
- iv::modulecomm::ModuleSendMsg(mpapad,pstr.get(),nsize);
- #else
- ggt->UpdateData(pstr.get(),nsize,"pad");
- #endif
- }
- else
- {
- std::cout<<"ADCIntelligentShow::on_pushButton_clicked serialize error."<<std::endl;
- }
- return;
- }
- void ADCIntelligentShow::onModeClick(int nMode)
- {
- iv::hmi::hmimsg xhmi;
- xhmi.set_mbbochemode(false);
- xhmi.set_mbbusmode(false);
- if(mbRunning)
- xhmi.set_mbpause(false);
- else
- xhmi.set_mbpause(true);
- xhmi.set_mmode(nMode);
- int nsize = xhmi.ByteSize();
- std::shared_ptr<char> pstr = std::shared_ptr<char>(new char[nsize]);
- if(xhmi.SerializeToArray(pstr.get(),1000))
- {
- #ifndef Android
- iv::modulecomm::ModuleSendMsg(mpapad,pstr.get(),nsize);
- #else
- ggt->UpdateData(pstr.get(),nsize,"pad");
- #endif
- }
- else
- {
- std::cout<<"ADCIntelligentShow::on_pushButton_clicked serialize error."<<std::endl;
- }
- return;
- }
- void ADCIntelligentShow::on_pushButton_Setting_clicked()
- {
- mpDS->show();
- }
- void ADCIntelligentShow::on_pushButton_AddStation_clicked()
- {
- bool ok;
- QString strpass = QInputDialog::getText(this,tr("Check PassWord"),tr("password:"),QLineEdit::Password,
- tr(""), &ok);
- if(ok == false)
- {
- return;
- }
- if(strpass != "adc")
- {
- QMessageBox::warning(this,tr("Warning"),tr("Password Error."),QMessageBox::YesAll);
- return;
- }
- QString strstationname = QInputDialog::getText(this,tr("Add Station"),tr("Station Name:"),QLineEdit::Normal,
- tr(""), &ok);
- if(ok == false)
- {
- return;
- }
- unsigned int i;
- for(i=0;i<gvectorpos.size();i++)
- {
- if(gvectorpos[i].mstrstationname == strstationname.toStdString())
- {
- QMessageBox::warning(this,tr("Warning"),tr("Have Same Name Station"),QMessageBox::YesAll);
- return;
- }
- }
- iv::pos_def xpos;
- if(mnTimeGPS == 0)
- {
- xpos.mflon = QInputDialog::getDouble(this,tr("Set Longitude"),tr("Longitude:"),119.0,0.0,180.0,7,&ok);
- if(ok == false)
- {
- return;
- }
- xpos.mflat = QInputDialog::getDouble(this,tr("Set Latitude"),tr("Latitude:"),39.0,0.0,90.0,7,&ok);
- if(ok == false)
- {
- return;
- }
- }
- else
- {
- iv::gps::gpsimu xgpsimu;
- mMutexGPSIMU.lock();
- xgpsimu.CopyFrom(mgpsimu);
- mMutexGPSIMU.unlock();
- xpos.mflat = xgpsimu.lat();
- xpos.mflon = xgpsimu.lon();
- }
- xpos.mstrstationname = strstationname.toStdString();
- gvectorpos.push_back(xpos);
- char strout[300];
- snprintf(strout,300,"Add Station %s, Lon:%11.7f, Lat:%11.7f",xpos.mstrstationname.data(),xpos.mflon,xpos.mflat);
- QMessageBox::information(this,tr("Info"),strout,QMessageBox::YesAll);
- if(gvectorpos.size() == 1)
- {
- mnStationIndex = 0;
- ui->label_station->setText(gvectorpos[0].mstrstationname.data());
- }
- WritePos();
- // QMessageBox::information(this,"info","info",QMessageBox::YesAll);
- }
- void ADCIntelligentShow::on_pushButton_DelStation_clicked()
- {
- if(gvectorpos.size() == 0)
- {
- QMessageBox::warning(this,tr("Warning"),tr("No Station."),QMessageBox::YesAll);
- return;
- }
- bool ok;
- QString strpass = QInputDialog::getText(this,tr("Check PassWord"),tr("password:"),QLineEdit::Password,
- tr(""), &ok);
- if(ok == false)
- {
- return;
- }
- if(strpass != "adc")
- {
- QMessageBox::warning(this,tr("Warning"),tr("Password Error."),QMessageBox::YesAll);
- return;
- }
- iv::pos_def xpos;
- if(mnStationIndex >= static_cast<int>(gvectorpos.size()) )
- {
- return;
- }
- if(mnStationIndex<0)
- {
- return;
- }
- xpos = gvectorpos[static_cast<unsigned long >(mnStationIndex) ];
- gvectorpos.erase(gvectorpos.begin()+mnStationIndex);
- WritePos();
- if(gvectorpos.size() == 0)
- {
- ui->label_station->setText("");
- return;
- }
- if(mnStationIndex >= static_cast<int>(gvectorpos.size()) )
- {
- mnStationIndex = 0;
- }
- if(mnStationIndex<0)mnStationIndex = static_cast<int>(gvectorpos.size()-1) ;
- ui->label_station->setText(gvectorpos[static_cast<unsigned long>(mnStationIndex)].mstrstationname.data());
- char strout[300];
- snprintf(strout,300,"Delete Station %s, Lon:%11.7f, Lat:%11.7f SuccessFully ",xpos.mstrstationname.data(),xpos.mflon,xpos.mflat);
- QMessageBox::information(this,tr("Info"),strout,QMessageBox::YesAll);
- }
- bool ADCIntelligentShow::WritePos()
- {
- QString strfilepath;
- // strfilepath = "pos.txt";
- #ifndef Android
- strfilepath = "pos.txt";
- #else
- strfilepath = "/storage/emulated/0/pos.txt";
- #endif
- QFile xFile;
- xFile.setFileName(strfilepath);
- if(!xFile.open(QIODevice::ReadWrite))
- {
- return false;
- }
- xFile.resize(0);
- unsigned int i;
- for(i=0;i<gvectorpos.size();i++)
- {
- char strline[1000];
- snprintf(strline,1000,"%s\t%11.7f\t%11.7f\n",gvectorpos[i].mstrstationname.data(),gvectorpos[i].mflon,gvectorpos[i].mflat);
- xFile.write(strline,static_cast<qint64>(strnlen(strline,1000)) );
- }
- xFile.close();
- return true;
- }
- void ADCIntelligentShow::onOTAVehInfoUpdate()
- {
- iv::veh::vehinfo xvehinfo;
- mMutexVehInfo.lock();
- xvehinfo.CopyFrom(mvehinfo);
- mMutexVehInfo.unlock();
- char strout[1000];
- snprintf(strout,1000,"Type:%s Version:%s VIN:%s",xvehinfo.type().data(),xvehinfo.version().data(),xvehinfo.vin().data());
- ui->label_vehinfo->setText(strout);
- }
- void ADCIntelligentShow::UpdateFusion(iv::fusion::fusionobjectarray &xfusion)
- {
- mpivmapview->setfusion(xfusion);
- mnTimeLidar = QDateTime::currentMSecsSinceEpoch();
- }
|