main.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "mainwindow.h"
  2. #include "qmessagebox.h"
  3. #include <QApplication>
  4. #include "Process.h"
  5. #include "src/pathcreator.h"
  6. void InitGlog()
  7. {
  8. time_t tt = time(0);//时间cuo
  9. struct tm* t = localtime(&tt);
  10. char strYear[255]={0};
  11. char strMonth[255]={0};
  12. char strDay[255]={0};
  13. sprintf(strYear,"%04d", t->tm_year+1900);
  14. sprintf(strMonth,"%02d", t->tm_mon);
  15. sprintf(strDay,"%02d", t->tm_mday);
  16. char buf[255]={0};
  17. getcwd(buf,255);
  18. char strdir[255]={0};
  19. sprintf(strdir,"%s/log/%s/%s/%s", buf,strYear,strMonth,strDay);
  20. PathCreator creator;
  21. creator.Mkdir(strdir);
  22. char logPath[255] = { 0 };
  23. sprintf(logPath, "%s/", strdir);
  24. FLAGS_max_log_size = 100;
  25. FLAGS_logbufsecs = 0;
  26. google::InitGoogleLogging("GarageMeasurement");
  27. google::SetLogDestination(0, logPath);
  28. //google::InstallFailureSignalHandler();
  29. //google::InstallFailureWriter(0);
  30. }
  31. bool ReadProtoParam(std::string path, ::google::protobuf::Message& param)
  32. {
  33. int fd = open(path.c_str(), O_RDONLY);
  34. if (fd == -1) return false;
  35. FileInputStream* input = new FileInputStream(fd);
  36. bool success = google::protobuf::TextFormat::Parse(input, &param);
  37. delete input;
  38. close(fd);
  39. return success;
  40. }
  41. Automatic::stCalibParam m_laser_calib_param;
  42. CProcess* m_pProcess=0;
  43. int main(int argc, char *argv[])
  44. {
  45. std::cout<<" --------- Start ----------"<<std::endl;
  46. QApplication a(argc, argv);
  47. MainWindow w;
  48. w.show();
  49. InitGlog();
  50. char buf[255]={0};
  51. getcwd(buf,255);
  52. sprintf(buf,"%s/setting/calib.prototxt",buf);
  53. if(!ReadProtoParam(buf,m_laser_calib_param))
  54. {
  55. QMessageBox::about(NULL, "Error", "Read proto failed...");
  56. }
  57. m_pProcess=new CProcess(m_laser_calib_param,&w);
  58. if(m_pProcess->Init()==false)
  59. {
  60. QMessageBox::about(NULL, "Error", m_pProcess->LastError().c_str());
  61. }
  62. return a.exec();
  63. }