#include #include #include "control/control_status.h" #include "control/controller.h" #include "xmlparam.h" #include "modulecomm.h" #include "ivversion.h" #include "ivbacktrace.h" #include "canmsg.pb.h" #include "decition.pb.h" #include void * gpacansend; void * gpadecition; std::string gstrmemdecition; std::string gstrmemcansend; bool gbSendRun = true; iv::brain::decition gdecition_def; iv::brain::decition gdecition; QTime gTime; int gnLastSendTime = 0; int gnLastRecvDecTime = -1000; int gnDecitionNum = 0; //when is zero,send default; const int gnDecitionNumMax = 100; int gnIndex = 0; boost::shared_ptr gcontroller; //实际车辆控制器 void executeDecition(const iv::brain::decition decition) { std::cout<<"***************************"<inialize(); gcontroller->control_torque(decition.accelerator()); gcontroller->control_wheel(decition.wheelangle()); gcontroller->control_braking(decition.brake()); gcontroller->control_speed_limit(decition.speed()); gcontroller->control_dangWei(decition.gear()); //gcontroller->control_zhuche(int P_zhuche); //++ gcontroller->control_drivemode(true); gcontroller->control_brakemode(true); gcontroller->control_torquemode(true); gcontroller->control_dangweimode(true); //++ gcontroller->control_turnmode(true); gcontroller->control_turnLight(decition.leftlamp(), decition.rightlamp()); //++ gcontroller->control_nearLight(0); //++ gcontroller->control_beep(decition.speak()); //++ gcontroller->control_brakeLight(decition.brakelamp());//++ } void ListenDeciton(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 xdecition; if(!xdecition.ParseFromArray(strdata,nSize)) { std::cout<<"ListenDecition parse error."<CopyFrom(xraw); xmsg.set_channel(0); xmsg.set_index(gnIndex); gnIndex++; xmsg.set_mstime(QDateTime::currentMSecsSinceEpoch()); int ndatasize = xmsg.ByteSize(); char * strser = new char[ndatasize]; std::shared_ptr pstrser; pstrser.reset(strser); if(xmsg.SerializePartialToArray(strser,ndatasize)) { iv::modulecomm::ModuleSendMsg(gpacansend,strser,ndatasize); } else { std::cout<<"MainWindow::onTimer serialize error."<(new iv::control::Controller()); iv::xmlparam::Xmlparam xp(strpath.toStdString()); gstrmemcansend = xp.GetParam("cansend","cansend0"); gstrmemdecition = xp.GetParam("dection","deciton"); const char * strx = gstrmemcansend.data(); gpacansend = iv::modulecomm::RegisterSend(gstrmemcansend.data(),10000,3); gpadecition = iv::modulecomm::RegisterRecv(gstrmemdecition.data(),ListenDeciton); std::thread xthread(sendthread); return a.exec(); }