main.cpp 707 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <QCoreApplication>
  2. #include "../ytDataCollectorDog/datacollector.h"
  3. #include "devicedatainfluxdbwriter.h"
  4. DataCollectorShm *dataColShm;
  5. bool load_shm()
  6. {
  7. int shmid;
  8. key_t key;
  9. if((key=ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1){
  10. return false;
  11. }
  12. if((shmid=shmget(key,sizeof(DataCollectorShm),IPC_CREAT|0666))==-1){
  13. return false;
  14. }
  15. dataColShm = static_cast<DataCollectorShm *>(shmat(shmid,nullptr,0));
  16. return true;
  17. }
  18. int main(int argc, char *argv[])
  19. {
  20. QCoreApplication a(argc, argv);
  21. if(load_shm()){
  22. DeviceDataInfluxdbWriter *core = new DeviceDataInfluxdbWriter(nullptr);
  23. core->start();
  24. }
  25. return a.exec();
  26. }