1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include "mainwindow.h"
- #include "qmessagebox.h"
- #include <QApplication>
- #include "Process.h"
- #include "src/pathcreator.h"
- void InitGlog()
- {
- time_t tt = time(0);//时间cuo
- struct tm* t = localtime(&tt);
- char strYear[255]={0};
- char strMonth[255]={0};
- char strDay[255]={0};
- sprintf(strYear,"%04d", t->tm_year+1900);
- sprintf(strMonth,"%02d", t->tm_mon);
- sprintf(strDay,"%02d", t->tm_mday);
- char buf[255]={0};
- getcwd(buf,255);
- char strdir[255]={0};
- sprintf(strdir,"%s/log/%s/%s/%s", buf,strYear,strMonth,strDay);
- PathCreator creator;
- creator.Mkdir(strdir);
- char logPath[255] = { 0 };
- sprintf(logPath, "%s/", strdir);
- FLAGS_max_log_size = 100;
- FLAGS_logbufsecs = 0;
- google::InitGoogleLogging("GarageMeasurement");
- google::SetLogDestination(0, logPath);
- //google::InstallFailureSignalHandler();
- //google::InstallFailureWriter(0);
- }
- bool ReadProtoParam(std::string path, ::google::protobuf::Message& param)
- {
- int fd = open(path.c_str(), O_RDONLY);
- if (fd == -1) return false;
- FileInputStream* input = new FileInputStream(fd);
- bool success = google::protobuf::TextFormat::Parse(input, ¶m);
- delete input;
- close(fd);
- return success;
- }
- Automatic::stCalibParam m_laser_calib_param;
- CProcess* m_pProcess=0;
- int main(int argc, char *argv[])
- {
- std::cout<<" --------- Start ----------"<<std::endl;
- QApplication a(argc, argv);
- MainWindow w;
- w.show();
- InitGlog();
- char buf[255]={0};
- getcwd(buf,255);
- sprintf(buf,"%s/setting/calib.prototxt",buf);
- if(!ReadProtoParam(buf,m_laser_calib_param))
- {
- QMessageBox::about(NULL, "Error", "Read proto failed...");
- }
- m_pProcess=new CProcess(m_laser_calib_param,&w);
- if(m_pProcess->Init()==false)
- {
- QMessageBox::about(NULL, "Error", m_pProcess->LastError().c_str());
- }
- return a.exec();
- }
|