123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include "mainwindow.h"
- #include <QApplication>
- #include <vector>
- #include <yaml-cpp/yaml.h>
- #include <QDebug>
- #include "moduleunit.h"
- #include "QtDBus/QDBusConnection"
- #include "I
- std::vector<moduleunit> gvecmodule;
- void dec_yaml(const char * stryamlpath)
- {
- YAML::Node config;
- try
- {
- config = YAML::LoadFile(stryamlpath);
- }
- catch(YAML::BadFile e)
- {
- qDebug("load error.");
- return;
- }
- int i;
- int nmodulesize;
- std::vector<std::string> vecmodulename;
- if(config["module"])
- {
- qDebug("have module size is %d",config["module"].size());
- nmodulesize = config["module"].size();
- for(i=0;i<nmodulesize;i++)
- {
- std::string strname = config["module"][i].as<std::string>();
- vecmodulename.push_back(strname);
- }
- }
- else
- {
- return;
- }
- if(nmodulesize <1)return;
- std::string strmodulename;
- std::string strmoduletitle;
- for(i=0;i<nmodulesize;i++)
- {
- if(config[vecmodulename[i].data()])
- {
- if((config[vecmodulename[i].data()]["modulename"])&&(config[vecmodulename[i].data()]["title"]))
- {
- strmodulename = config[vecmodulename[i].data()]["modulename"].as<std::string>();
- strmoduletitle = config[vecmodulename[i].data()]["title"].as<std::string>();
- moduleunit mu;
- mu.mstrmodulename = strmodulename;
- mu.mstrmoduletitle = strmoduletitle;
- gvecmodule.push_back(mu);
- // iv::radar_data xradardata;
- // xradardata.foff_x = atof(stroffset_x.data());
- // xradardata.foff_y = atof(stroffset_y.data());
- // xradardata.frotation = atof(strrotation.data()) * M_PI/180.0;
- // strncpy(xradardata.strmemname,strmemname.data(),255);
- // gvectorradar.push_back(xradardata);
- // qDebug("name is %s ",strmemname.data());
- }
- }
- }
- return;
- }
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- //获取可执行程序的绝对路径
- char abs_path[256];
- int cnt = readlink("/proc/self/exe", abs_path, 256);
- for(int i = cnt; i >= 0; --i)
- {
- if(abs_path[i]=='/')
- {
- abs_path[i + 1]='\0';
- break;
- }
- }
- qDebug()<<"路径: "<<abs_path;
- char yaml_name[] = "ivdiagnosis.yaml";
- char *abs_ymlpath = new char[strlen(abs_path)+strlen(yaml_name)+1];
- if (abs_ymlpath == NULL) exit (1);
- strcpy(abs_ymlpath, abs_path);
- strcat(abs_ymlpath, yaml_name);
- //add tjc
- QDBusConnection::sessionBus().connect(QString(),"/catarc/adc", "adciv.sys.interface","ivdiagnosis",&a,SLOT(quit()));
- char stryamlpath[256];
- if(argc<2)
- {
- // snprintf(stryamlpath,255,"ivdiagnosis.yaml");
- strncpy(stryamlpath,abs_ymlpath,255);
- }
- else
- {
- strncpy(stryamlpath,argv[1],255);
- }
- dec_yaml(stryamlpath);
- MainWindow w;
- w.show();
- return a.exec();
- }
|