123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #ifndef PROCSM_H
- #define PROCSM_H
- #include <QThread>
- #include <QSharedMemory>
- #include <QDateTime>
- #include <QList>
- #include <QVariant>
- #ifdef USEDBUS
- #include <QtDBus/QDBusMessage>
- #include <QtDBus/QDBusConnection>
- #endif
- #include "ivmodulemsg_type.h"
- class ASM_PTR
- {
- public:
- qint64 mnUpdateTime;
- char mstrshmname[256];
- unsigned int mnshmsize;
- char mstrreserve[1000];
- };
- class procsm_info
- {
- public:
- unsigned int mFirst;
- unsigned int mNext;
- unsigned int mCap;
- unsigned int mLock;
- unsigned int mnBufSize;
- };
- class procsm_head
- {
- public:
- unsigned short mYear;
- unsigned char mMonth;
- unsigned char mDay;
- unsigned char mHour;
- unsigned char mMinute;
- unsigned char mSec;
- unsigned short mMSec;
- unsigned int mindex;
- unsigned int mnPos;
- unsigned int mnLen;
- public:
- void SetDate(QDateTime dt)
- {
- mYear = dt.date().year();
- mMonth = dt.date().month();
- mDay = dt.date().day();
- mHour = dt.time().hour();
- mMinute = dt.time().minute();
- mSec = dt.time().second();
- mMSec = dt.time().msec();
- }
- void GetDate(QDateTime * pdt)
- {
- QDate dt;
- dt.setDate(mYear,mMonth,mDay);
- QTime time;
- time.setHMS(mHour,mMinute,mSec,mMSec);
- pdt->setDate(dt);
- pdt->setTime(time);
- }
- };
- class procsm : public QObject
- {
- #ifdef USEDBUS
- Q_OBJECT
- #endif
- public:
- procsm(const char * strsmname,const unsigned int nBufSize,const unsigned int nMaxPacCount,const int nMode);
- int writemsg(const char * str,const unsigned int nSize);
- unsigned int getcurrentnext();
- int readmsg(unsigned int index,char * str,unsigned int nMaxSize,unsigned int * nRead,QDateTime * pdt);
- bool AttachMem();
- private:
- int MoveMem(const unsigned int nSize);
- QSharedMemory * mpASM = 0;
- QSharedMemory * mpASMPtr;
- unsigned int mnBufSize;
- unsigned int mnMaxPacCount;
- procsm_info * mpinfo;
- procsm_head * mphead;
- ASM_PTR mASM_State;
- bool mbAttach;
- char * mstrtem;
- public:
- const static int ModeRead = 1;
- const static int ModeWrite = 0;
- iv::modulemsg_type mmodulemsg_type;
- #ifdef USEDBUS
- private slots:
- void onQuery();
- #endif
- private:
- #ifdef USEDBUS
- QDBusMessage mmsg;
- QDBusMessage mmsgres; //Response Message Query;
- #endif
- private:
- void checkasm();
- void recreateasm(int nbufsize);
- private:
- char mstrsmname[256];
- };
- #endif // PROCSM_H
|