main.cpp 935 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <QCoreApplication>
  2. #include "dmpdatacore.h"
  3. #include "datashm.h"
  4. ServerDogShm *dogshm;
  5. DMPDevList *datashm;
  6. bool load_shm()
  7. {
  8. int shmid;
  9. key_t key;
  10. if((key=ftok(SHM_PATH,static_cast<int>(SHM_PORT)))==-1){
  11. return false;
  12. }
  13. if((shmid=shmget(key,sizeof(ServerDogShm),IPC_CREAT|0666))==-1){
  14. return false;
  15. }
  16. dogshm=static_cast<ServerDogShm*>(shmat(shmid,nullptr,0));
  17. if((key=ftok(DATA_PATH,static_cast<int>(DATA_PORT)))==-1){
  18. return false;
  19. }
  20. if((shmid=shmget(key,sizeof (DMPDevList),IPC_CREAT|0666))==-1){
  21. return false;
  22. }
  23. printf("dmp dataserver shmid = %d\n",shmid);
  24. datashm=static_cast<DMPDevList*>(shmat(shmid,nullptr,0));
  25. return true;
  26. }
  27. int main(int argc, char *argv[])
  28. {
  29. QCoreApplication a(argc, argv);
  30. if(load_shm()){
  31. DmpDataCore *core = new DmpDataCore(nullptr);
  32. core->start();
  33. }
  34. return a.exec();
  35. }