#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 "chassis.pb.h" #include void * gpacansend; void * gpadecition; void * gpachassis; std::string gstrmemdecition; std::string gstrmemcansend; std::string gstrmemchassis; bool gbSendRun = true; bool gbChassisEPS = false; 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::decition::Decition decition) //{ // std::cout<<"acc is"<accelerator<<" ang is "<wheel_angle<control_wheel(decition->wheel_angle); // controller_->control_accelerate(decition->accelerator); // if(!decition->leftlamp && !decition->rightlamp){ // ServiceControlStatus.set_turnsignals_control(0,0); // }else if(decition->leftlamp){ // ServiceControlStatus.set_turnsignals_control(decition->leftlamp,0); // }else if(decition->rightlamp){ // ServiceControlStatus.set_turnsignals_control(0,decition->rightlamp); // } //} // controller_->control_accelerate(decition->accelerator); void executeDecition(const iv::brain::decition decition) { // std::cout<<"acc is"<brakeType); //? ServiceControlStatus.set_door(decition.door()); ServiceControlStatus.set_driveMode(decition.mode()); ServiceControlStatus.set_dangwei_enable(true); ServiceControlStatus.set_angle_enable(true); ServiceControlStatus.set_brake_enable(true); //add by fjk // ServiceControlStatus.set_turnsignals_control(decition->left, decition->right); //add by fjk ServiceControlStatus.set_near_light(0); ServiceControlStatus.set_far_light(0); ServiceControlStatus.set_speaker(0); if(decition.leftlamp()){ ServiceControlStatus.set_turn_light(1); }else if(decition.rightlamp()){ ServiceControlStatus.set_turn_light(2); }else { ServiceControlStatus.set_turn_light(0); } // gcontroller->control_wheel(decition.wheelangle()); // // controller_->control_accelerate(decition->accelerator); // gcontroller->control_torque(decition.torque()); // gcontroller->control_brake(decition.brake()); // gcontroller->control_engine(decition.engine()); // gcontroller->control_grade(decition.grade()); // gcontroller->control_mode(decition.mode()); // gcontroller->control_handBrake(decition.handbrake()); // gcontroller->control_speaker(decition.speak()); // gcontroller->control_door(decition.door()); // gcontroller->control_engine(decition.engine()); // // gcontroller->control_light(decition.bri); // gcontroller->control_leftlight(decition.leftlamp()); // gcontroller->control_rightlight(decition.rightlamp()); // gcontroller->control_dangWei(decition.gear()); // qDebug("dangwei is %d mode is %d",decition.gear(),decition.mode()); } void UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname) { (void)index; (void)dt; (void)strmemname; iv::chassis xchassis; // static int ncount = 0; if(!xchassis.ParseFromArray(strdata,nSize)) { std::cout<<"iv::decition::BrainDecition::UpdateChassis ParseFrom Array 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"); gstrmemchassis = xp.GetParam("chassismsgname","chassis"); gpacansend = iv::modulecomm::RegisterSend(gstrmemcansend.data(),10000,1); gpadecition = iv::modulecomm::RegisterRecv(gstrmemdecition.data(),ListenDeciton); // gpachassis = iv::modulecomm::RegisterRecv(gstrmemchassis.data(),UpdateChassis); std::thread xthread(sendthread); return a.exec(); }