procsm.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef PROCSM_H
  2. #define PROCSM_H
  3. #include <QThread>
  4. #include <QSharedMemory>
  5. #include <QDateTime>
  6. #include <QList>
  7. #include <QVariant>
  8. #ifdef USEDBUS
  9. #include <QtDBus/QDBusMessage>
  10. #include <QtDBus/QDBusConnection>
  11. #endif
  12. #include "ivmodulemsg_type.h"
  13. class ASM_PTR
  14. {
  15. public:
  16. qint64 mnUpdateTime;
  17. char mstrshmname[256];
  18. unsigned int mnshmsize;
  19. char mstrreserve[1000];
  20. };
  21. class procsm_info
  22. {
  23. public:
  24. unsigned int mFirst;
  25. unsigned int mNext;
  26. unsigned int mCap;
  27. unsigned int mLock;
  28. unsigned int mnBufSize;
  29. };
  30. class procsm_head
  31. {
  32. public:
  33. unsigned short mYear;
  34. unsigned char mMonth;
  35. unsigned char mDay;
  36. unsigned char mHour;
  37. unsigned char mMinute;
  38. unsigned char mSec;
  39. unsigned short mMSec;
  40. unsigned int mindex;
  41. unsigned int mnPos;
  42. unsigned int mnLen;
  43. public:
  44. void SetDate(QDateTime dt)
  45. {
  46. mYear = dt.date().year();
  47. mMonth = dt.date().month();
  48. mDay = dt.date().day();
  49. mHour = dt.time().hour();
  50. mMinute = dt.time().minute();
  51. mSec = dt.time().second();
  52. mMSec = dt.time().msec();
  53. }
  54. void GetDate(QDateTime * pdt)
  55. {
  56. QDate dt;
  57. dt.setDate(mYear,mMonth,mDay);
  58. QTime time;
  59. time.setHMS(mHour,mMinute,mSec,mMSec);
  60. pdt->setDate(dt);
  61. pdt->setTime(time);
  62. }
  63. };
  64. class procsm : public QObject
  65. {
  66. #ifdef USEDBUS
  67. Q_OBJECT
  68. #endif
  69. public:
  70. procsm(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode);
  71. int writemsg(const char * str,const unsigned int nSize);
  72. unsigned int getcurrentnext();
  73. int readmsg(unsigned int index,char * str,unsigned int nMaxSize,unsigned int * nRead,QDateTime * pdt);
  74. bool AttachMem();
  75. private:
  76. int MoveMem(const unsigned int nSize);
  77. QSharedMemory * mpASM = 0;
  78. QSharedMemory * mpASMPtr;
  79. unsigned int mnBufSize;
  80. unsigned int mnMaxPacCount;
  81. procsm_info * mpinfo;
  82. procsm_head * mphead;
  83. ASM_PTR mASM_State;
  84. bool mbAttach;
  85. char * mstrtem;
  86. public:
  87. const static int ModeRead = 1;
  88. const static int ModeWrite = 0;
  89. iv::modulemsg_type mmodulemsg_type;
  90. #ifdef USEDBUS
  91. private slots:
  92. void onQuery();
  93. #endif
  94. private:
  95. #ifdef USEDBUS
  96. QDBusMessage mmsg;
  97. QDBusMessage mmsgres; //Response Message Query;
  98. #endif
  99. private:
  100. void checkasm();
  101. void recreateasm(int nbufsize);
  102. private:
  103. char mstrsmname[256];
  104. };
  105. #endif // PROCSM_H