DIOS.Dev.Generator.Delta_50KCXAF.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. #pragma once
  2. #include "IODeviceWithSCF.tlh"
  3. #include "IODeviceWithSCF.tli"
  4. #include "CCOS.Dev.IODevice.Detail.hpp"
  5. #include "CCOS.Dev.MSGMould.hpp"
  6. #include "CCOS.Dev.Generator.Mould.hpp"
  7. #include "DAP.BasicMoulds.hpp"
  8. #include "DeliverModule.h"
  9. #include "LogicClient.h"
  10. #ifdef CCOSDEVGENDelta_EXPORTS
  11. #define _CCOSDEVGENDelta_API __declspec(dllexport)
  12. #else
  13. #define _CCOSDEVGENDelta_API __declspec(dllimport)
  14. #endif
  15. enum DELTA_MOBILE_ABNORMAL_LEVEL { //故障等级
  16. REG_ERRO,
  17. REG_WARN
  18. };
  19. enum TransToType
  20. {
  21. tochar = 0,
  22. toint,
  23. tohex
  24. };
  25. struct AECINFORM
  26. {
  27. int Chamber;
  28. int Field;
  29. int Density;
  30. int FilmScreenSpeed;
  31. };
  32. namespace nsSerialGPM = CCOS::Dev::MODLE::SerialGPM;
  33. static const int TIMEOUTVALUE = 100;
  34. static int m_nCountTimes = 0;
  35. //-----------------------------------------------------------------------------
  36. // DeltaMobileDevice
  37. //-----------------------------------------------------------------------------
  38. namespace CCOS::Dev::Detail::Generator
  39. {
  40. namespace nDev = CCOS::Dev;
  41. namespace DevDAP = CCOS::Dev::Detail::DAP;
  42. class _CCOSDEVGENDelta_API DeltaMobileDevice : public IODeviceWithSCF <IODeviceDetail>,public GeneratorMould
  43. {
  44. using super = IODeviceWithSCF <IODeviceDetail>;
  45. using superGen = GeneratorMould;
  46. public:
  47. DeltaMobileDevice(std::shared_ptr <IOEventCenter> center, nsSCF::SCF SCF,string configfile);
  48. ~DeltaMobileDevice ();
  49. bool DecodeFrame(const char* strPackage, int nLength);
  50. virtual std::string GetGUID() const override;
  51. virtual RET_STATUS IncKV() override;
  52. virtual RET_STATUS DecKV() override;
  53. virtual RET_STATUS SetKV(float value) override;
  54. virtual RET_STATUS IncMA() override;
  55. virtual RET_STATUS DecMA() override;
  56. virtual RET_STATUS SetMA(float value) override;
  57. virtual RET_STATUS IncMS() override;
  58. virtual RET_STATUS DecMS() override;
  59. virtual RET_STATUS SetMS(float value) override;
  60. virtual RET_STATUS IncMAS() override;
  61. virtual RET_STATUS DecMAS() override;
  62. virtual RET_STATUS SetMAS(float value) override;
  63. virtual RET_STATUS SetTechmode(int value) override; //0x01--AEC mode 0x02--Ms mode 0x03--mAs mode
  64. virtual RET_STATUS SetFocus(int value) override; //0x01--large:0x02--small:0x03--auto
  65. virtual RET_STATUS SetAECDensity(int value) override;
  66. virtual RET_STATUS SetAECField(int value) override;
  67. virtual RET_STATUS SetAECFilm(int value) override;
  68. virtual RET_STATUS SetWS(const std::string value) override;
  69. virtual RET_STATUS SetAPR(const _tAPRArgs& t) override;
  70. virtual RET_STATUS QueryHE(int& value) override;
  71. virtual RET_STATUS QueryPostKV(float& value) override;
  72. virtual RET_STATUS QueryPostMA(float& value) override;
  73. virtual RET_STATUS QueryPostMS(float& value) override;
  74. virtual RET_STATUS QueryPostMAS(float& value) override;
  75. virtual RET_STATUS SetGenSynState(int value) override;
  76. virtual RET_STATUS SetGenState(int value) override;
  77. virtual RET_STATUS SetExpEnable() override;
  78. virtual RET_STATUS SetExpDisable()override;
  79. virtual RET_STATUS Reset()override;
  80. virtual RET_STATUS SetExpMode(std::string value) override;
  81. virtual RET_STATUS SetFrameRate(FLOAT frameRate) override;
  82. virtual RET_STATUS SetFLFMode(std::string value) override;
  83. virtual RET_STATUS SetEXAMMode(std::string value) override;
  84. virtual RET_STATUS ActiveSyncMode(_tSyncModeArgs value) override;
  85. virtual RET_STATUS ResetFluTimer(int ntype) override;
  86. virtual RET_STATUS SetPPS(float frameRate) override;
  87. static DeltaMobileDevice* g_GenDevice;
  88. //串口处理层
  89. static nsSerialGPM::CDeliverModule m_tDelivermodule;
  90. int m_nCMDType_ACK{ 0 };
  91. int m_nCMDType_WaitTime{ 0 };
  92. int m_nCMDType_WaitACK{ 0 };
  93. int m_nCMDType_WaitSELF{ 0 };
  94. static void __stdcall ProcessClientData(const char* pData, unsigned long DataLength, void* lparam);
  95. static void __stdcall WriteLog(const char* pData, nsSerialGPM::LOG_V2_LEVEL level);
  96. RET_STATUS HWSendWaitACKCMD(string strCommand, int headLengh = 1);
  97. //轮询处理
  98. static atomic<int> m_iLoopTime; //循环间隔时间(毫秒)
  99. HANDLE m_hArrayEvent[4];
  100. HANDLE m_hExitEvent{ NULL };
  101. HANDLE m_hHUstatus{ NULL };
  102. HANDLE m_hGENstatus{ NULL };
  103. HANDLE m_hLoopEvent{ NULL };
  104. void StartHardwareStatusThread();
  105. static DWORD HardwareStatusThread(LPVOID pParam);
  106. HANDLE m_pHardwareStatusThread{ NULL };
  107. bool m_nProcessXrayon{ false };
  108. private:
  109. void Register();
  110. RET_STATUS RefreshData();
  111. //发送消息
  112. RET_STATUS HWSend(const char * strCommand, int lengh, int nTimeOut = TIMEOUTVALUE);
  113. //上报消息
  114. void FireNotify(std::string key, std::string context);
  115. void FireErrorMessage(const bool Act, const int Code, const char* ResInfo = ""); //上报错误消息
  116. void FireWarnMessage(const bool Act, const int Code, const char* ResInfo = ""); //上报告警消息
  117. void GetConfData();
  118. _tSyncModeArgs m_cfgCurrentWSSYN; //当前选中的工作位和对应的同步模式
  119. _tAPRArgs m_tAPRdata; //保存服务传入的参数
  120. ResDataObject m_GenConfig; //driver's config file
  121. std::unique_ptr<DevDAP::DOSEMould> m_DAP; //DAP值
  122. std::unique_ptr<nsDetail::MSGUnit> m_MSGUnit; //错误消息处理对象
  123. string m_ErrorCode; //错误码,防止重复发送
  124. //lsy
  125. bool ChangeGenParam(int kv, float fma, float fms, float fmas);
  126. int FormatCommand(char* buf, int len);
  127. int GetFacFloatValue(vector<float> Index, float& value);
  128. string m_strCommand;
  129. string uint8ArrayToHexStr(const UINT8* array, size_t length);
  130. string m_strKV;
  131. vector<int> m_vecKV;
  132. string m_strMAS;
  133. vector<float> m_vecMAS;
  134. string m_strMA;
  135. vector<float> m_vecMA;
  136. string m_strMS;
  137. vector<float> m_vecMS;
  138. int m_nTubeMaSFMaxValue{ 160 };
  139. int m_nTubeMaBFMinValue{ 180 };
  140. bool m_nTableUsePanelAEC{ false };
  141. bool m_nWallUsePanelAEC{ false };
  142. bool m_nFreeUsePanelAEC{ false };
  143. bool m_nTableUsePanelDDR{ false };
  144. bool m_nWallUsePanelDDR{ false };
  145. bool m_nFreeUsePanelDDR{ false };
  146. bool SetDAECEnable(int enable);//打开关闭DAEC功能
  147. int m_nChamberIndex{ 1 };
  148. int m_nAecFiled{2};
  149. int m_nAecDensity{0};
  150. int m_nAecFilm{ 0 };
  151. bool SetDualEnergyCommand(const _tAPRArgs& t);
  152. bool m_bIsDualExp{ false };
  153. int m_nExposureNumber{ 0 };
  154. bool SetAPRForDual(int nWS, int nFO, int nET, int nAECFieldSel, int nAECFilmSel, float fAECDensity, float fKV, float fMA, float fMS, float fMAS);
  155. std::unordered_map<std::string, std::string> m_ErrorMessages;
  156. std::unordered_map<std::string, std::string> m_WarnMessages;
  157. LogicClient* m_pDetectorClient;
  158. int m_nDEFrameRate{ 1 };
  159. //0x01--Low Level Reset Function 用于复位3开头的错误
  160. //0x02--Clear setup 清除所有曝光参数
  161. //0x03--High Level Reset Function 用于复位4开头的错误
  162. int m_nCurErrLevel{ 0 };
  163. bool m_bXronMsg{ false };
  164. void SeleckDetectorNumber(int detectorID);
  165. void SetNoDrMode();
  166. void SetSyncOutMode();
  167. void GetHE();
  168. //common
  169. string AnalysisCommand(int number, const char* chdigital, int type);
  170. //LSY
  171. void RetrieveFirewareVersion();
  172. void RetrieveModelName();
  173. void RetrieveSerialNumber();
  174. void RetrieveMaxRating();
  175. int m_nMaxKW{ 0 };
  176. int m_nMaxMA{ 0 };
  177. int m_nMaxMAS{ 0 };
  178. int m_nMaxKV{ 0 };
  179. void RetrieveGeneratroDerating();
  180. void RetrieveAECDAPFirmwareVersion();
  181. void RetrieveTubePartNumber();
  182. void RetrieveTubeMaxPower();
  183. void RetrieveTubeFilamentCurrent();
  184. void RetrieveTubeHULimit();
  185. void RetrieveTubeDeratingInformation();
  186. void RetrieveRunningMode();//AEC 1 MS 2 MAS 3
  187. void RetrieveDataAndTime();
  188. void RetrieveErrorCode();
  189. void RetrieveErrorParameters();//待补充
  190. void RetrieveExposureResult();//获取曝光后的参数
  191. void RetrieveRadioMode();//获取当前点片模式 单帧序列 单能双能
  192. void RetrieveFluMode();//获取当前透视模式
  193. void RetrieveAECInformation();//获取AEC信息
  194. //AEC相关
  195. void UpdataAECInformation(AECINFORM aec);//通过发生器返回的参数更新AEC数据
  196. AECINFORM m_AECinformation;
  197. //void RetrieveHU();
  198. void CheckGeneratorStatus();
  199. //曝光前的最后有效参数
  200. void ReportRadExposurePostParam();
  201. void ReportFluExposurePostParam();
  202. //
  203. void RetrieveFocalSpot();
  204. void RetrieveTubeID();
  205. //
  206. //void RetrieveFluStopTime();
  207. void SetRadMode(int radmode, int desmode);
  208. //void SetRunMode(int radmode, int desmode);
  209. bool SetRADKV_MA_MS(int kv, float ma, float ms);//设置rad模式的三点模式的KV MA MS
  210. bool SetRADKV_MAS(int kv, float mas);
  211. //
  212. string m_strFKV;
  213. vector<int> m_vecFKV;
  214. string m_strFMA;
  215. vector<float> m_vecFMA;
  216. string m_strFMAS;
  217. vector<float> m_vecFMAS;
  218. void SetFLUKV_MA_MAS(int fkv, float fma, float fmas);//设置flu模式下的曝光参数
  219. void SetTubeDeratingPower();
  220. //
  221. void RetrieveBucky();
  222. void SelectBucky(int bucky);
  223. //
  224. void SetGeneratorOperateStatus(int status);//不知道是啥
  225. void SelectTubeID(int TubeID);//不知道是啥
  226. //void TubeCalibrationCommand();
  227. //void TubeCalibrationDataReport();
  228. //void RestoreFactorySettings();
  229. //void TubeSeasoning();
  230. //void SetFluStopTime();
  231. //
  232. void RetrieveDAPValue();//5801
  233. //void RetrieveDAPRate();//5802
  234. //void ClearDAPValue();//58A1
  235. //void SetAECCalibrationStartAndStop();//F06A
  236. //void SetAECCalibrationDefaultPara();//F06A
  237. //void SetORRetrieveCurrentAECCurve();
  238. //
  239. //
  240. //
  241. //void RetrieveBatteryManuInformation();
  242. void RetrieveBatteryRunningInformation();
  243. void SetAECInformation(int chamber, int field, int density, int film);
  244. void SetAECKV_MA_MS(int kv, float ma, float ms);
  245. //ABS相关
  246. virtual RET_STATUS SetABSMode(int nMode) override; //设置自动亮度调节(ABS)模式
  247. virtual RET_STATUS SetABSCurve(int curveNum) override; //ABS曲线调节
  248. //设置线长短
  249. void SetCableLngth(int lenght);
  250. //Set or retrieve mask function 61A8
  251. //Set or retrieve mask function 61A9
  252. //获取版本号
  253. std::string GetFileVersion(std::string strFilePathName);
  254. std::string GetDynamicLibraryPath();
  255. string m_strConfigPath{ "" };
  256. };
  257. }
  258. //-----------------------------------------------------------------------------
  259. // DeltaDriver
  260. //-----------------------------------------------------------------------------
  261. namespace CCOS::Dev::Detail::Generator
  262. {
  263. class _CCOSDEVGENDelta_API DeltaDriver : public IODriverWithSCF <DriverMould>
  264. {
  265. using super = IODriverWithSCF <DriverMould>;
  266. public:
  267. DeltaDriver ();
  268. virtual ~DeltaDriver ();
  269. public:
  270. //virtual bool DriverEntry (std::string CfgFileName); //设置配制文件路径,对外接口最先调用
  271. virtual void Prepare() override; //在 DriverEntry 之后执行;选择与物理设备通信方式(串口、TCP)
  272. virtual std::string DriverProbe() override; //在 Prepare 之后执行;读取配置文件模块参数,供上层创建驱动work路径
  273. virtual bool DATA_ACTION Connect() override; //在 DriverProbe 之后执行;根据通信方式与物理设备进行连接
  274. virtual auto CreateDevice(int index)->std::unique_ptr <IODevice> override; //在 Connect 之后执行;创建逻辑设备,供上层创建驱动树节点
  275. virtual bool isConnected() const override; //检查驱动与物理设备连接状态
  276. virtual std::string GetResource() override; //获取配置文件的值
  277. virtual std::string DeviceProbe() override; //读取配置文件模块参数,供上层创建设备work路径
  278. virtual void Disconnect() override; //断开驱动与物理设备连接状态
  279. virtual void Dequeue(const char* Packet, DWORD Length) override; //在super::Connect中轮询,调用 DecodeFrame:查找指令操作对照表,通过对应操作更新数据并调用FireNotify上报更新
  280. virtual void FireNotify(int code, std::string key, std::string content) override; //向监听者上报事件
  281. static PACKET_RET callbackPackageProcess(const char* RecData, DWORD nLength, DWORD& PacketLength); //判断从设备读到的数据有没有可用的数据包,有则最终调度到 Dequeue
  282. private:
  283. bool SaveConfigFile(bool bSendNotify);
  284. virtual bool GetDeviceConfig(std::string& Cfg) override;
  285. virtual bool SetDeviceConfig(std::string Cfg) override;
  286. bool GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue);
  287. bool SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue);
  288. ResDataObject m_DeviceConfig;
  289. ResDataObject m_ConfigAll; //存储当前的配置,用于修改配置时写回文件
  290. ResDataObject m_Configurations; //存储当前配置中“CONFIGURATION”节点的内容
  291. bool m_bDemoConnected; // 在 DEMO 模式下, 是否调用过 Connect
  292. //webconfig使用
  293. ResDataObject m_DeviceConfigSend;
  294. string g_strAppPath;
  295. std::unique_ptr <ResDataObject> m_pAttribute;
  296. std::unique_ptr <ResDataObject> m_pDescription;
  297. };
  298. }