main.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <QCoreApplication>
  2. //#include "mainwindow.h"
  3. #include "databoardcore.h"
  4. #include "../ytDashBoardDog/dataprecess.h"
  5. #include "databoardmem.h"
  6. YtDashBoardShm *dataProcessShm;
  7. YtStationCount *ytStationCount;
  8. bool load_shm(){
  9. int shmid;
  10. key_t key;
  11. if((key = ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1)
  12. return false;
  13. if((shmid = shmget(key,sizeof(YtDashBoardShm),IPC_CREAT|0666))==-1)
  14. return false;
  15. dataProcessShm = static_cast<YtDashBoardShm *>(shmat(shmid,nullptr,0));
  16. if((key = ftok(MEM_PATH, static_cast<int>(MEM_PORT)))==-1)
  17. return false;
  18. if((shmid = shmget(key, sizeof (YtStationCount), IPC_CREAT|0666))==-1)
  19. return false;
  20. printf("****************shmid = %d",shmid);
  21. ytStationCount = static_cast<YtStationCount *>(shmat(shmid, nullptr, 0));
  22. return true;
  23. }
  24. int main(int argc, char *argv[])
  25. {
  26. QCoreApplication a(argc, argv);
  27. if(load_shm()){
  28. DataBoardCore *core = new DataBoardCore(nullptr);
  29. core->start();
  30. }else
  31. exit(1);
  32. return a.exec();
  33. }