DIOS.Dev.Mech.OTCStitch.hpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #pragma once
  2. #include <string>
  3. #include <deque>
  4. #include "DIOS.Dev.IODevice.Detail.hpp"
  5. #include "DiosThread.h"
  6. #include "IODeviceWithSCF.tlh"
  7. #include "IODeviceWithSCF.tli"
  8. #include "DIOS.Dev.MSGMould.hpp"
  9. #include "DIOS.Dev.MECH.Mould.hpp"
  10. //#include "ATLComTime.h"
  11. #include "DeliverModule.h"
  12. #ifdef DIOSDEVMECHOTCSTITCH_EXPORTS
  13. #define _DIOSDEVMECHOTCSTITCH_API __declspec(dllexport)
  14. #else
  15. #define _DIOSDEVMECHOTCSTITCH_API __declspec(dllimport)
  16. #endif
  17. namespace DIOS::Dev::Detail::MECH
  18. {
  19. enum OTC_MG_REGULATION_LEVEL { //故障等级
  20. REG_ERRO,
  21. REG_WARN
  22. };
  23. enum StitchingDirection //拼接方向
  24. {
  25. UP_TO_DOWN = 1, // 上->下
  26. DOWN_TO_UP = 2 // 下->上
  27. };
  28. namespace nsDev = DIOS::Dev;
  29. namespace nsSerialGPM = DIOS::Dev::MODLE::SerialGPM;
  30. class _DIOSDEVMECHOTCSTITCH_API OTCStitchDevice : public IODeviceWithSCF <IODeviceDetail>, public MECHMould
  31. {
  32. using super = IODeviceWithSCF <IODeviceDetail>;
  33. using superMech = MECHMould;
  34. public:
  35. OTCStitchDevice(std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF,string configfile="");
  36. ~OTCStitchDevice();
  37. virtual std::string GetGUID() const override;
  38. static void __stdcall ProcessClientData(const char* pData, unsigned long DataLength, void* lparam);
  39. static void __stdcall WriteLog(const char* pData, nsSerialGPM::LOG_V2_LEVEL level);
  40. int FormatCommand(string& command);
  41. int FormatCommand(string inuputcommand, char* poutputcommand);
  42. virtual RET_STATUS SetStudyInfo(ResDataObject& pParam) override;
  43. virtual RET_STATUS SetPatientInfo(ResDataObject& pParam) override;
  44. virtual RET_STATUS SetViewInfo(ResDataObject& pParam) override;
  45. virtual RET_STATUS SetSID(float value) override;
  46. virtual RET_STATUS BeginStitching() override;
  47. virtual RET_STATUS EndStitching() override;
  48. virtual RET_STATUS SetupStitching(string& value) override;
  49. virtual RET_STATUS AcceptStitchingImage() override;
  50. virtual RET_STATUS RejectStitchingImage() override;
  51. virtual RET_STATUS CancelStitching() override;
  52. virtual RET_STATUS CompleteStitching() override;
  53. virtual RET_STATUS NewExtraView() override;
  54. virtual RET_STATUS RepeatStitching() override;
  55. virtual RET_STATUS SetAutoPosiitonNo(int nPN) override;
  56. virtual RET_STATUS SetExpEnable(bool nExpEnabled) override;
  57. virtual RET_STATUS SetWS(int nWS) override;
  58. virtual RET_STATUS SetFO(int nFO) override;
  59. virtual RET_STATUS SetTechMode(int nET) override;
  60. virtual RET_STATUS SetKV(int nKV) override;
  61. virtual RET_STATUS SetMA(float fMA) override;
  62. virtual RET_STATUS SetMS(float fMS) override;
  63. virtual RET_STATUS SetMAS(float fMAS) override;
  64. virtual RET_STATUS SetAECField(int nAECFieldSel) override;
  65. virtual RET_STATUS SetDensity(float nAECDensity) override;
  66. virtual RET_STATUS SetCollimator(ECOM_COLLIMATOR_INFO& curCollimator) override;
  67. virtual RET_STATUS SetFilter(int nFilter) override;
  68. nsSerialGPM::CDeliverModule Delivermodule;
  69. ECOM_COLLIMATOR_INFO m_Collimator;
  70. string m_strOTCType;
  71. string m_strcurrentcmd;
  72. int m_nImageCount; // total number of stitching images
  73. int m_nCurrentImage; //Current stitching procedure image
  74. bool m_bStitchingInProgress;
  75. string m_strOTCError;
  76. string m_strOTCWarning;
  77. private:
  78. void OnCallBack(); //处理指令回调函数
  79. void Register(); //注册对外提供的属性、方法
  80. //bool StartHardwareStatusThread(); //启动轮询线程
  81. //static DWORD HardwareStatusThread(LPVOID pParam); //定时查询状态信息
  82. void FireNotify(std::string key, std::string context); //向上层上报消息
  83. void FireNotify(std::string key, int context); //向上层上报消息
  84. void FireErrorMessage(const bool Act, const int Code, const char* ResInfo = ""); //上报错误消息
  85. void FireWarnMessage(const bool Act, const int Code, const char* ResInfo = ""); //上报告警消息
  86. std::unique_ptr<nsDetail::MSGUnit> m_MSGUnit;
  87. int m_ConvertFlag; // is m_strReserved2 in V2
  88. protected:
  89. void Convert(const char* strIn, string& strOut, int sourceCodepage, int targetCodepage);
  90. std::shared_ptr <DIOS::Dev::IOEventCenter> m_EventCenter;
  91. ResDataObject m_GenConfig;
  92. ECOM_PATIENT m_sPATIENTInfo;
  93. vector<ECOM_PROCEDURE_VIEW> m_tempProcedureViewList;
  94. };
  95. }
  96. //-----------------------------------------------------------------------------
  97. // DEMODriver
  98. //-----------------------------------------------------------------------------
  99. namespace DIOS::Dev::Detail::MECH
  100. {
  101. class _DIOSDEVMECHOTCSTITCH_API OTCStitchDriver : public IODriverWithSCF <DriverMould>
  102. {
  103. using super = IODriverWithSCF <DriverMould>;
  104. ResDataObject m_GenConfig;
  105. public:
  106. OTCStitchDriver();
  107. virtual ~OTCStitchDriver();
  108. virtual void Prepare() override;
  109. virtual bool Connect() override;
  110. virtual void Disconnect() override;
  111. virtual bool isConnected() const override;
  112. virtual void Dequeue(const char* Packet, DWORD Length) override;
  113. virtual void FireNotify(int code, std::string key, std::string content) override;
  114. virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override;
  115. virtual std::string DriverProbe() override;
  116. virtual std::string GetResource() override;
  117. virtual std::string DeviceProbe() override;
  118. virtual bool GetDeviceConfig(std::string& Cfg) override;
  119. virtual bool SetDeviceConfig(std::string Cfg) override;
  120. OTCStitchDevice* m_pDriGenDev;// = nullptr;
  121. private:
  122. static PACKET_RET callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength);
  123. bool m_bDemoInitDataFlag; //是否存在初始化数据
  124. ResDataObject m_InitDataFile;
  125. //for webconfig
  126. ResDataObject m_DeviceConfigSend;
  127. ResDataObject m_DeviceConfig;
  128. string g_strAppPath;
  129. ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
  130. ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
  131. std::unique_ptr <ResDataObject> m_pAttribute;
  132. std::unique_ptr <ResDataObject> m_pDescription;
  133. bool SaveConfigFile(bool bSendNotify);
  134. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  135. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  136. };
  137. }