123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- #pragma once
- //#include "DIOSLogicDeviceStructure.h"
- #include "ShareMemClientInterface.h"
- #include "Definitions.h"
- #define SM_API_BLOCK_COUNT (15)
- class ImgDataInfo : public BaseJsonDataObject<bool>
- {
- public:
- BaseJsonDataObject<unsigned int> nImageType;
- BaseJsonDataObject<unsigned int> nViewType;
- BaseJsonDataObject<unsigned long long> nShareMemID;
- BaseJsonDataObject<unsigned long long> nImageID;
- BaseJsonDataObject<unsigned int> nWidth;
- BaseJsonDataObject<unsigned int> nHeight;
- BaseJsonDataObject<unsigned int> nBit;
- ImgDataInfo(void)
- {
- const char* keystring = "ImageType";
- nImageType.SetKey(keystring);
- keystring = "Viewtype";
- nViewType.SetKey(keystring);
- keystring = "Sharememid";
- nShareMemID.SetKey(keystring);
- keystring = "Imageid";
- nImageID.SetKey(keystring);
- keystring = "Width";
- nWidth.SetKey(keystring);
- keystring = "Height";
- nHeight.SetKey(keystring);
- keystring = "Bit";
- nBit.SetKey(keystring);
- }
- virtual ~ImgDataInfo(void)
- {
- }
- virtual void GetResDataObject(ResDataObject &obj)
- {
- //ResDataObject loca1;
- obj.add(nImageType.GetKey(), nImageType.GetVal());
- obj.add(nViewType.GetKey(), nViewType.GetVal());
- obj.add(nShareMemID.GetKey(), nShareMemID.GetVal());
- obj.add(nImageID.GetKey(), nImageID.GetVal());
- obj.add(nWidth.GetKey(), nWidth.GetVal());
- obj.add(nHeight.GetKey(), nHeight.GetVal());
- obj.add(nBit.GetKey(), nBit.GetVal());
- //obj.add(GetKey(), loca1);
- };
- virtual bool SetResDataObject(ResDataObject &obj)
- {
- bool ret = true;
- try {
- nImageType = obj[nImageType.GetKey()];
- nViewType = obj[nViewType.GetKey()];
- nShareMemID = obj[nShareMemID.GetKey()];
- nImageID = obj[nImageID.GetKey()];
- nWidth = obj[nWidth.GetKey()];
- nHeight = obj[nHeight.GetKey()];
- nBit = obj[nBit.GetKey()];
- }
- catch (...)
- {
- ret = false;
- }
- return ret;
- };
- virtual const char *GetVal()
- {
- ResDataObject obj;
- obj.add(nImageType.GetKey(), nImageType.GetVal());
- obj.add(nViewType.GetKey(), nViewType.GetVal());
- obj.add(nShareMemID.GetKey(), nShareMemID.GetVal());
- obj.add(nImageID.GetKey(), nImageID.GetVal());
- obj.add(nWidth.GetKey(), nWidth.GetVal());
- obj.add(nHeight.GetKey(), nHeight.GetVal());
- obj.add(nBit.GetKey(), nBit.GetVal());
- (m_ValString) = obj.encode();
- return m_ValString.c_str();
- };
- virtual bool SetVal(const char* pValString)
- {
- ResDataObject obj;
- if (obj.decode(pValString))
- {
- int idx;
- idx = obj.GetFirstOf(nImageType.GetKey());
- if (idx >= 0)
- {
- nImageType.SetVal(obj[idx]);
- }
- idx = obj.GetFirstOf(nViewType.GetKey());
- if (idx >= 0)
- {
- nViewType.SetVal(obj[idx]);
- }
- idx = obj.GetFirstOf(nShareMemID.GetKey());
- if (idx >= 0)
- {
- nShareMemID.SetVal(obj[idx]);
- }
- idx = obj.GetFirstOf(nImageID.GetKey());
- if (idx >= 0)
- {
- nImageID.SetVal(obj[idx]);
- }
- idx = obj.GetFirstOf(nWidth.GetKey());
- if (idx >= 0)
- {
- nWidth.SetVal(obj[idx]);
- }
- idx = obj.GetFirstOf(nHeight.GetKey());
- if (idx >= 0)
- {
- nHeight.SetVal(obj[idx]);
- }
- idx = obj.GetFirstOf(nBit.GetKey());
- if (idx >= 0)
- {
- nBit.SetVal(obj[idx]);
- }
- return true;
- }
- return false;
- };
- virtual void SetKey(const char* pKeyString)
- {
- BaseJsonDataObject<bool>::SetKey(pKeyString);
- //make key
- const char* keystring = "ImageType";
- nImageType.SetKey(keystring);
- keystring = "Viewtype";
- nViewType.SetKey(keystring);
- keystring = "Sharememid";
- nShareMemID.SetKey(keystring);
- keystring = "Imageid";
- nImageID.SetKey(keystring);
- keystring = "Width";
- nWidth.SetKey(keystring);
- keystring = "Height";
- nHeight.SetKey(keystring);
- keystring = "Bit";
- nBit.SetKey(keystring);
- };
- };
- class ShareMemWR {
- unsigned short*m_pDataPtr;
- CShareMemClient m_shareMemclient;
- C2DGrayImageData *m_pImgFull;
- C2DGrayImageData *m_pImgPrev;
- CBaseFunctionDataElement *m_pElement;
- unsigned int m_dwShareMemIdFullIdx;
- unsigned long long m_dwShareMemIdFull[SM_API_BLOCK_COUNT];
- unsigned long long m_dwShareMemIdPreview;
- ImgDataInfo *pImgData;
-
- bool GetShareMemBuf(ImgDataInfo *pImgData);
- int WriteImageToShareMem(unsigned long long &dwShareMemId);
- unsigned long long &GetNextSmId();
- public:
- ShareMemWR(void);
- virtual ~ShareMemWR(void);
- void * GetDataBuf(unsigned long long nShareMemID, char *&pBuff,DWORD &Size);
- void ReleaseDataBuf(void * Handle);
- RET_STATUS BufferToNotify(void * pOemImage, DWORD ImageSize, ImgDataInfo* PImgDataInfo);
- };
|