DIOS.Dev.FPD.iRayDM.cpp 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041
  1. #include "stdafx.h"
  2. #include "CCOS.Dev.FPD.iRayDM.h"
  3. #include "IRayDMCtrl.h"
  4. #include "FileVersion.hpp"
  5. #include "DICOMImageHeadKey.h"
  6. #pragma comment(lib, "Version.lib")
  7. namespace nsFPD = CCOS::Dev::Detail::Detector;
  8. Log4CPP::Logger* //mLog::gLogger = nullptr;
  9. static nsFPD::IRayDriver gIODriver;
  10. //=================================================================================================================================================================================
  11. // GetIODriver & CreateIODriver
  12. //=================================================================================================================================================================================
  13. extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  14. {
  15. return &gIODriver;
  16. }
  17. extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  18. {
  19. return new nsFPD::IRayDriver();
  20. }
  21. //==============================================================================
  22. // 驱动对象
  23. //==============================================================================
  24. nsFPD::IRayDriver::IRayDriver()
  25. {
  26. dev = NULL;
  27. m_bConnect = false;
  28. m_pAttribute.reset(new ResDataObject());
  29. m_pDescription.reset(new ResDataObject());
  30. }
  31. nsFPD::IRayDriver::~IRayDriver()
  32. {
  33. }
  34. //驱动准备
  35. void nsFPD::IRayDriver::Prepare()
  36. {
  37. string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)";
  38. Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.iRayDM");
  39. bool bRet = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  40. if (bRet == false)
  41. {
  42. return;
  43. }
  44. //mLog::gLogger = Log4CPP::LogManager::GetLogger("FPD.iRayDM");
  45. string szMouldPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\IRayDM\CCOS.Dev.FPD.iRayDM.dll)";
  46. #ifdef _WIN64
  47. //mLog::Force("------------------------ Version: {$} (64-bit) ------------------------", FileVersion(szMouldPath.c_str()).GetVersionString());
  48. #else
  49. //mLog::Force("------------------------ Version: {$} (32-bit) ------------------------", FileVersion(szMouldPath.c_str()).GetVersionString());
  50. #endif
  51. //mLog::Info("IRay Driver Prepare");
  52. dev = new FPDDeviceIRay(EventCenter, m_ConfigFileName);
  53. //mLog::Info("new FPDDeviceIRay over");
  54. }
  55. //驱动连接
  56. bool nsFPD::IRayDriver::Connect()
  57. {
  58. //mLog::Info("IRay Driver Connect");
  59. m_bConnect = true;
  60. return true;
  61. }
  62. //驱动断连
  63. void nsFPD::IRayDriver::Disconnect()
  64. {
  65. m_bConnect = false;
  66. }
  67. //判断驱动是否连接
  68. bool nsFPD::IRayDriver::isConnected() const
  69. {
  70. return m_bConnect;
  71. }
  72. //驱动创建设备对象
  73. auto nsFPD::IRayDriver::CreateDevice(int index) -> std::unique_ptr <IODevice>
  74. {
  75. //mLog::Info("CreateDevice({$})", index);
  76. auto Driver = std::unique_ptr <IODevice>(new IODevice(dev));
  77. dev->CreateDevice();
  78. dev->Register();
  79. return Driver;
  80. }
  81. //驱动探针
  82. std::string nsFPD::IRayDriver::DriverProbe()
  83. {
  84. //mLog::Info("Driver Probe");
  85. ResDataObject r_config, HardwareInfo;
  86. if (r_config.loadFile(m_ConfigFileName.c_str()))
  87. {
  88. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  89. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  90. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  91. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  92. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  93. }
  94. else
  95. {
  96. HardwareInfo.add("MajorID", "Generator");
  97. HardwareInfo.add("MinorID", "Dr");
  98. HardwareInfo.add("VendorID", "iRay");
  99. HardwareInfo.add("ProductID", "Mars");
  100. HardwareInfo.add("SerialID", "Driver");
  101. }
  102. string ret = HardwareInfo.encode();
  103. //mLog::Info("Diver_Probe over");
  104. return ret;
  105. }
  106. //获取驱动配置
  107. bool nsFPD::IRayDriver::GetDeviceConfig(std::string& Cfg)
  108. {
  109. Cfg = m_DeviceConfig.encode();
  110. //mLog::Info("GetDeviceConfig over");
  111. return true;
  112. }
  113. //驱动设置设备配置
  114. bool nsFPD::IRayDriver::SetDeviceConfig(std::string Cfg)
  115. {
  116. //mLog::Info("SetDeviceConfig {$} ", Cfg.c_str());
  117. //mLog::Info("SetDeviceConfig over");
  118. return true;
  119. ResDataObject DeviceConfig;
  120. DeviceConfig.decode(Cfg.c_str());
  121. ResDataObject DescriptionTempEx;
  122. DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"];
  123. //mLog::Info("Attribute:{$}", DescriptionTempEx.encode());
  124. bool bSaveFile = false; //true:重新保存配置文件
  125. string strAccess = "";
  126. for (int i = 0; i < DescriptionTempEx.size(); i++)
  127. {
  128. string strKey = DescriptionTempEx.GetKey(i);
  129. //mLog::Info("{$}", strKey.c_str());
  130. try
  131. {
  132. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  133. {
  134. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  135. if ("rw" == strAccess)
  136. {
  137. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  138. //1. 修改内存中的值,用于给上层发消息
  139. (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i];
  140. //2. 拿到Innerkey
  141. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  142. //mLog::Info("ConfigInfo Count: {$}", nConfigInfoCount);
  143. string strTemp = ""; //存储AttributeKey
  144. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  145. {
  146. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  147. if (strTemp == strKey)
  148. {
  149. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  150. break;
  151. }
  152. }
  153. //3. 修改配置文件中的值
  154. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i]))
  155. {
  156. bSaveFile = true;
  157. }
  158. }
  159. else
  160. {
  161. //mLog::Info("{$} is not a RW configuration item", strKey.c_str());
  162. }
  163. }
  164. else
  165. {
  166. //mLog::Warn("without this attribute {$}", strKey.c_str());
  167. }
  168. }
  169. catch (...)
  170. {
  171. //mLog::Error("SetDriverConfig crashed");
  172. return false;
  173. }
  174. }
  175. if (bSaveFile)
  176. {
  177. //3. 重新保存配置文件
  178. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  179. m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  180. //mLog::Info("SaveConfigFile over");
  181. }
  182. //mLog::Info("SetDriverConfig over");
  183. return true;
  184. }
  185. //驱动获取设备配置内容
  186. bool nsFPD::IRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
  187. {
  188. strValue = "";
  189. string strTemp = pInnerKey;
  190. ////mLog::Trace("Inner key: {$}", strTemp);
  191. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  192. {
  193. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  194. {
  195. strValue = (string)config["connections"][pInnerKey];
  196. }
  197. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  198. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  199. {
  200. strValue = (string)config[pInnerKey];
  201. }
  202. else if (SyncType == strTemp || FPDWorkStation == strTemp ||
  203. ImageWidth == strTemp || ImageHeight == strTemp)
  204. {
  205. strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
  206. }
  207. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  208. TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp ||
  209. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  210. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  211. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  212. ShowTemperature == strTemp || ShowWifi == strTemp ||
  213. ShowBattery == strTemp || ShowBluetooth == strTemp ||
  214. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
  215. {
  216. strValue = (string)config[pInnerKey];
  217. }
  218. else
  219. {
  220. strValue = "";
  221. //mLog::Warn("Error Configuration item: {$}", pInnerKey);
  222. }
  223. }
  224. return true;
  225. }
  226. //驱动设置设备配置文件内容
  227. bool nsFPD::IRayDriver::SetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, const char* szValue)
  228. {
  229. string strTemp = pInnerKey;
  230. //mLog::Trace("Begin to change {$} item value to {$}", pInnerKey, szValue);
  231. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  232. {
  233. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  234. {
  235. config["connections"][pInnerKey] = szValue;
  236. }
  237. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  238. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  239. {
  240. config[pInnerKey] = szValue;
  241. }
  242. else if (SyncType == strTemp || FPDWorkStation == strTemp ||
  243. ImageWidth == strTemp || ImageHeight == strTemp)
  244. {
  245. config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
  246. }
  247. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  248. TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
  249. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  250. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  251. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  252. ShowTemperature == strTemp || ShowWifi == strTemp ||
  253. ShowBattery == strTemp || ShowBluetooth == strTemp ||
  254. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp)
  255. {
  256. config[pInnerKey] = szValue;
  257. }
  258. else
  259. {
  260. //mLog::Warn("Error Configuration item: {$}", pInnerKey);
  261. return false;
  262. }
  263. }
  264. return true;
  265. }
  266. //获取设备资源
  267. std::string nsFPD::IRayDriver::GetResource()
  268. {
  269. ResDataObject r_config, temp;
  270. if (!temp.loadFile(m_ConfigFileName.c_str()))
  271. {
  272. return "";
  273. }
  274. m_ConfigAll = temp;
  275. r_config = temp["CONFIGURATION"];
  276. m_Configurations = r_config;
  277. ResDataObject DescriptionTemp;
  278. ResDataObject ListTemp;
  279. string strTemp = ""; //用于读取字符串配置信息
  280. string strIndex = ""; //用于读取配置信息中的List项
  281. int nTemp = -1; //用于读取整型配置信息
  282. char sstream[10] = { 0 }; //用于转换值
  283. string strValue = ""; //用于存储配置的值
  284. string strType = ""; //用于存储配置的类型 int/float/string...
  285. /***
  286. * 1. 通过循环,将所有配置项写到pDeviceConfig
  287. * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
  288. ***/
  289. try
  290. {
  291. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  292. ////mLog::Trace(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
  293. m_pAttribute->clear();
  294. m_pDescription->clear();
  295. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  296. {
  297. DescriptionTemp.clear();
  298. ListTemp.clear();
  299. //AttributeType
  300. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  301. DescriptionTemp.add(AttributeType, strTemp.c_str());
  302. ////mLog::Trace(g_pFPDCtrlLog, "--> {$}: {$}", AttributeType, strTemp.c_str());
  303. strType = strTemp; //记录配置项的类型
  304. //AttributeKey
  305. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  306. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  307. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  308. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
  309. //2. 赋值
  310. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  311. if ("int" == strType)
  312. {
  313. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  314. ////mLog::Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str()));
  315. }
  316. else if ("float" == strType)
  317. {
  318. (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
  319. ////mLog::Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str()));
  320. }
  321. else //其它先按string类型处理
  322. {
  323. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  324. ////mLog::Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str());
  325. }
  326. //AttributeAccess
  327. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  328. DescriptionTemp.add(AttributeAccess, strTemp.c_str());
  329. ////mLog::Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str());
  330. //AttributeRangeMin
  331. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  332. if (strTemp != "") //不需要的配置项为空
  333. {
  334. DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
  335. ////mLog::Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str());
  336. }
  337. //AttributeRangeMax
  338. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  339. if (strTemp != "") //不需要的配置项为空
  340. {
  341. DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
  342. ////mLog::Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMax, strTemp.c_str());
  343. }
  344. //AttributeList
  345. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  346. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  347. {
  348. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  349. {
  350. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  351. sprintf_s(sstream, "%d", nListIndex);
  352. ListTemp.add(sstream, strTemp.c_str());
  353. ////mLog::Trace(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str());
  354. }
  355. DescriptionTemp.add(AttributeList, ListTemp);
  356. }
  357. //AttributeRequired
  358. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  359. DescriptionTemp.add(AttributeRequired, strTemp.c_str());
  360. ////mLog::Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str());
  361. //AttributeDefaultValue
  362. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  363. if (strTemp != "") //不需要的配置项为空
  364. {
  365. DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
  366. ////mLog::Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str());
  367. }
  368. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  369. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  370. }
  371. }
  372. catch (exception e)
  373. {
  374. //mLog::Error("Get config error: {$}", e.what());
  375. return "";
  376. }
  377. ResDataObject resDeviceResource;
  378. resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
  379. resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
  380. ResDataObject DescriptionTempEx;
  381. DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
  382. m_DeviceConfig = DescriptionTempEx;
  383. string res = DescriptionTempEx.encode();
  384. ////mLog::Debug("resDeviceResource :{$} ", DescriptionTempEx.encode());
  385. //if (dev)
  386. //{
  387. // dev->SyncErrorList();
  388. //}
  389. return res;
  390. }
  391. //设备探针
  392. std::string nsFPD::IRayDriver::DeviceProbe()
  393. {
  394. ResDataObject r_config, HardwareInfo;
  395. if (r_config.loadFile(m_ConfigFileName.c_str()))
  396. {
  397. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  398. HardwareInfo.add("MinorID", "Device");
  399. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  400. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  401. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  402. }
  403. else
  404. {
  405. HardwareInfo.add("MajorID", "Detector");
  406. HardwareInfo.add("MinorID", "Device");
  407. HardwareInfo.add("VendorID", "iRay");
  408. HardwareInfo.add("ProductID", "Mars");
  409. HardwareInfo.add("SerialID", "1234");
  410. }
  411. string ret = HardwareInfo.encode();
  412. return ret;
  413. }
  414. //=================================================================================================================================================================================
  415. // 设备对象
  416. //=================================================================================================================================================================================
  417. extern IRayCtrl* g_pIRayCtrl;
  418. #define MAX_STRING 1024
  419. nsFPD::FPDDeviceIRay::FPDDeviceIRay(std::shared_ptr <IOEventCenter> center, string ConfigPath)
  420. :m_strWorkPath(""),
  421. m_nDeviceIndex(0),
  422. m_eAppStatus(APP_STATUS_WORK_END),
  423. m_bHasGrid(false),
  424. m_nGridLicense(0),
  425. m_strVoltage(""),
  426. m_strLastError(""),
  427. m_strCalibTime(""),
  428. m_strLogFilePath(""),
  429. m_bOpened(false),
  430. m_bBatteryCharging(false),
  431. m_bRecoveringImage(false),
  432. m_bAbortRecover(false),
  433. m_bSNListExisted(false),
  434. m_bUIReady(false),
  435. m_bImagePendingOrNot(false),
  436. m_bResetDetector(false),
  437. m_nTemperCheckResult(0),
  438. m_nXCUStatus(0),
  439. m_nBatteryCapacity(0),
  440. m_nBatteryCharges(0),
  441. m_nShockCounts(0),
  442. m_nWorkStation(0),
  443. m_fDoseParam(0),
  444. m_nFullImgWidth(0),
  445. m_nFullImgHeight(0),
  446. m_nTopOffset(0),
  447. m_nLeftOffset(0),
  448. m_nImageBits(0),
  449. m_fFactorEXI2UGY(0.0f),
  450. m_bPreviewEnable(false),
  451. m_bTestSensitivity(false),
  452. m_fBatteryTemperature(0.0f),
  453. m_nXrayCalibNum(0),
  454. m_bCalibReportFailed(false),
  455. m_pwFullImageData(nullptr),
  456. m_pwRawImageData(nullptr),
  457. m_pwPreviewImg(nullptr),
  458. m_pPreviewImageHead(nullptr),
  459. m_pFullImageHead(nullptr),
  460. m_pDetectors(nullptr),
  461. m_bConnect2XCU(false),
  462. m_bXCUresult(false),
  463. m_nActiveState(FPD_NOT_ACTIVE),
  464. m_bDueDateWarnSend(false),
  465. m_bCallFDConnectOver(false),
  466. m_bDisConnected(false),
  467. m_ExitEvt(nullptr),
  468. m_bAttached(false),
  469. m_hNotifyThread(nullptr),
  470. m_bRecoverImageStatusInit(false),
  471. m_bSaveRaw(false),
  472. m_bUIConfirmRecover(false),
  473. m_nCalibrationType(CCOS_CALIBRATION_TYPE_MAX),
  474. m_fLTEthreshold(450.0f),
  475. m_CalTemperlowWarn(0.0f),
  476. m_CalTemperupWarn(0.0f),
  477. m_LETCalTemperlowWarn(0.0f),
  478. m_LETCalTemperupWarn(0.0f),
  479. m_CalTemperWarnInitialed(false),
  480. m_lowBatteryBuda(0),
  481. m_pmsLoginStatus(false),
  482. m_nClinicalApplicationMode(0),
  483. m_nFilterMode(0),
  484. m_bStatusInAEC(false)
  485. {
  486. g_strAppPath = GetProcessDirectory() + "\\";
  487. m_AcqUnit.reset(new OemAcq(center, this));
  488. m_SyncUnit.reset(new OemSync(center, this));
  489. m_CalibUnit.reset(new OemCalib(center, this));
  490. m_DetectorCtrlUnit.reset(new OemDetectorCtrl(center, this));
  491. m_Battery.reset(new DeviceBatteryMould("DetectorIRayBattery", 0, 10, 20, 30, 40, 100, 100, 0, center));
  492. //m_Temperature.reset(new DeviceTemperatureMould("DetectorIRayTemperature", ABS_ZERO_TEMPERATURE, 0.0f, 10.0f, 60.0f, 20.0f, 40.0f, 70.0f, 0.0f, center));
  493. m_Wifi.reset(new DeviceWifiMould("DetectorIRayWifi", 0, 20, 30, 40, 50, 100, 100, 0, center));
  494. m_DetectorConfiguration.reset(new DetectorConfiguration(ConfigPath));
  495. m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, g_strAppPath));
  496. m_CalibProcess.reset(new CalibrationProcess());
  497. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  498. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  499. m_WaitCalibDoseEvt = CreateEvent(0, 1, 0, 0);
  500. m_OffsetCalibrationEvt = CreateEvent(0, 0, 0, 0);
  501. m_PauseCalibrationEvt = CreateEvent(0, 1, 0, 0);
  502. m_CompleteCalibrationEvt = CreateEvent(0, 1, 0, 0);
  503. m_CrateCalibReportEvt = CreateEvent(0, 0, 0, 0);
  504. m_UploadCalibMapOver = CreateEvent(0, 1, 0, 0);
  505. m_hXCUresult = CreateEvent(0, 1, 0, 0);
  506. m_ExitEvt = CreateEvent(0, 1, 0, 0);
  507. m_CalibGapEvt = CreateEvent(0, 1, 0, 0);
  508. m_WriteCumstomFileEvt = CreateEvent(0, 1, 0, 0);
  509. EventCenter = center;
  510. }
  511. nsFPD::FPDDeviceIRay::~FPDDeviceIRay()
  512. {
  513. SetEvent(m_ExitEvt);
  514. CloseHandle(m_WaitCalibDoseEvt);
  515. CloseHandle(m_OffsetCalibrationEvt);
  516. CloseHandle(m_PauseCalibrationEvt);
  517. CloseHandle(m_CompleteCalibrationEvt);
  518. CloseHandle(m_CrateCalibReportEvt);
  519. CloseHandle(m_WriteCumstomFileEvt);
  520. CloseHandle(m_UploadCalibMapOver);
  521. CloseHandle(m_hXCUresult);
  522. CloseHandle(m_CalibGapEvt);
  523. if (m_hNotifyThread != NULL)
  524. {
  525. CloseHandle(m_hNotifyThread);
  526. }
  527. }
  528. std::string nsFPD::FPDDeviceIRay::GetGUID() const
  529. {
  530. return DetectorUnitType;
  531. }
  532. bool nsFPD::FPDDeviceIRay::Prepare()
  533. {
  534. //mLog::Info("Device Prepare");
  535. //EventCenter->OnMaxBlockSize("DrQue", 3000 * 3000 * 2, 3, 1500 * 1500 * 2, 1);
  536. //SetMaxBlockSize(const char *pQueName, DWORD FullBlockSize, DWORD FullBlockCount, DWORD PrevBlockSize, DWORD PrevBlockCount)
  537. EventCenter->OnMaxBlockSize("RfQue", 6000 * 6000 * 2, 8, 3000 * 3000 * 2, 8); //开辟共享内存
  538. Connect();
  539. return true;
  540. }
  541. void nsFPD::FPDDeviceIRay::RegisterCtrl(nDetail::Dispatch* Dispatch)
  542. {
  543. Dispatch->Action.Push(ActionKey::GetDetectorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
  544. Dispatch->Action.Push("ActiveDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
  545. Dispatch->Action.Push("RESET", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
  546. Dispatch->Action.Push("EnterExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
  547. Dispatch->Action.Push("ExitExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
  548. Dispatch->Action.Push("RecoverImage", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
  549. Dispatch->Action.Push("ResetConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
  550. Dispatch->Action.Push("DisConnectFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
  551. Dispatch->Action.Push("DisConnectFPDForce", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPDForce);
  552. Dispatch->Action.Push("UpdateFirmware", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
  553. Dispatch->Action.Push("SaveSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
  554. Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
  555. Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);//event
  556. Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);//event
  557. Dispatch->Get.Push(CcosDetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
  558. Dispatch->Get.Push(CcosDetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
  559. Dispatch->Get.Push(CcosDetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);
  560. Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
  561. Dispatch->Get.Push(CcosDetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus);
  562. Dispatch->Get.Push(CcosDetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
  563. Dispatch->Get.Push("FPDShockSensorInfo", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
  564. Dispatch->Get.Push("FieldofViewShape", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
  565. Dispatch->Get.Push("FieldofViewDimension", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
  566. Dispatch->Get.Push("DetectorType", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
  567. Dispatch->Get.Push("Description", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
  568. Dispatch->Get.Push("DetectorID", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
  569. Dispatch->Get.Push("DateofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
  570. Dispatch->Get.Push("TimeofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
  571. Dispatch->Get.Push("DetectorConditionsNominalFlag", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
  572. Dispatch->Get.Push("FPDSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
  573. Dispatch->Get.Push("FPDSensitivityResult", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivityResult);
  574. Dispatch->Get.Push("PixelData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
  575. Dispatch->Get.Push("TargetEXI", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
  576. Dispatch->Get.Push("FPDLastError", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetLastError);
  577. //Dispatch->Get.Push("FirmwareStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFirmwareStatus);
  578. }
  579. void nsFPD::FPDDeviceIRay::RegisterAcq(nDetail::Dispatch* Dispatch)
  580. {
  581. Dispatch->Action.Push("SetAcqMode", m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
  582. Dispatch->Get.Push(CcosZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
  583. Dispatch->Get.Push("NoNeedWaitImage", m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
  584. Dispatch->Get.Push("ImgDataInfo", m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
  585. }
  586. void nsFPD::FPDDeviceIRay::RegisterSync(nDetail::Dispatch* Dispatch)
  587. {
  588. Dispatch->Action.Push("SetSyncMode", m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
  589. Dispatch->Action.Push("SetXwindowSize", m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
  590. Dispatch->Action.Push("PrepareAcquisition", m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
  591. Dispatch->Action.Push("StartAcquisition", m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
  592. Dispatch->Action.Push("StopAcquisition", m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
  593. Dispatch->Get.Push(CcosFPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
  594. Dispatch->Get.Push(CcosXwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
  595. Dispatch->Get.Push(CcosImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
  596. }
  597. void nsFPD::FPDDeviceIRay::RegisterCalib(nDetail::Dispatch* Dispatch)
  598. {
  599. Dispatch->Action.Push("UploadCalibrationFiles", m_CalibUnit.get(), &CalibUnit::JSUploadCalibrationFiles);
  600. Dispatch->Action.Push("SetSID", m_CalibUnit.get(), &CalibUnit::JSSetSID);
  601. Dispatch->Action.Push("ActiveCalibration", m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
  602. Dispatch->Action.Push("GetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
  603. Dispatch->Action.Push("PrepareCalibration", m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
  604. Dispatch->Action.Push("StartCalibration", m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
  605. Dispatch->Action.Push("StopCalibration", m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
  606. Dispatch->Action.Push("SetCorrectionType", m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
  607. Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
  608. Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
  609. Dispatch->Get.Push("UploadCalibrationFilesResult", m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
  610. }
  611. void nsFPD::FPDDeviceIRay::Register()
  612. {
  613. auto Disp = &Dispatch;
  614. RegisterCtrl(Disp);
  615. RegisterAcq(Disp);
  616. RegisterSync(Disp);
  617. RegisterCalib(Disp);
  618. }
  619. void nsFPD::FPDDeviceIRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  620. {
  621. m_nDeviceIndex = nDetectorID;
  622. switch (nEventLevel)
  623. {
  624. case EVT_LEVEL_CONFIGURATION:
  625. {
  626. OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  627. break;
  628. }
  629. case EVT_LEVEL_INFORMATOION:
  630. {
  631. OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  632. break;
  633. }
  634. case EVT_LEVEL_STATUS:
  635. {
  636. OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  637. break;
  638. }
  639. case EVT_LEVEL_DATA:
  640. {
  641. OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  642. break;
  643. }
  644. case EVT_LEVEL_WARNING:
  645. {
  646. OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  647. break;
  648. }
  649. case EVT_LEVEL_ERROR:
  650. {
  651. OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  652. break;
  653. }
  654. default:
  655. {
  656. break;
  657. }
  658. }
  659. }
  660. void nsFPD::FPDDeviceIRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  661. {
  662. switch (nEventID)
  663. {
  664. case EVT_CONF_PANEL_SERIAL:
  665. {
  666. m_stDeviceConfig.strPanelSerial = pszMsg;
  667. //mLog::Info("Receive Panel {$} SN {$}", nDetectorID, pszMsg);
  668. char cDetectorID[17] = { 0 };
  669. memcpy(cDetectorID, m_stDeviceConfig.strPanelSerial.c_str(), 16);
  670. string strDetectorID = cDetectorID;
  671. m_DetectorCtrlUnit->SetDetectorID(strDetectorID);
  672. //mLog::Info("SedDetectorID {$}", strDetectorID.c_str());
  673. if (!m_bRecoverImageStatusInit)
  674. {
  675. m_RecoverImageStatus.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
  676. m_RecoverImageStatus.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
  677. m_RecoverImageStatus.add("DetectorWifiSignal", "1");
  678. m_RecoverImageStatus.add("Result", "-1");
  679. m_bRecoverImageStatusInit = true;
  680. }
  681. break;
  682. }
  683. case EVT_CONF_RAW_WIDTH:
  684. {
  685. if (m_stDeviceConfig.nFullImageWidth != nParam1)
  686. {
  687. m_stDeviceConfig.nFullImageWidth = nParam1;
  688. }
  689. //mLog::Info("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth);
  690. break;
  691. }
  692. case EVT_CONF_RAW_HIGHT:
  693. {
  694. if (m_stDeviceConfig.nFullImageHeight != nParam1)
  695. {
  696. m_stDeviceConfig.nFullImageHeight = nParam1;
  697. }
  698. //mLog::Info("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight);
  699. break;
  700. }
  701. case EVT_CONF_RAW_BITS:
  702. {
  703. m_stDeviceConfig.nImageBits = nParam1;
  704. //mLog::Info("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits);
  705. break;
  706. }
  707. case EVT_CONF_PIXELSPACE:
  708. {
  709. m_stDeviceConfig.nPixelSpace = (int)fParam2;
  710. //mLog::Info("Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
  711. break;
  712. }
  713. case EVT_CONF_PREVIEW_WIDTH:
  714. {
  715. if (m_stDeviceConfig.nPreviewWidth != nParam1)
  716. {
  717. m_stDeviceConfig.nPreviewWidth = nParam1;
  718. }
  719. //mLog::Info("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
  720. break;
  721. }
  722. case EVT_CONF_PREVIEW_HIGHT:
  723. {
  724. if (m_stDeviceConfig.nPreviewHeight != nParam1)
  725. {
  726. m_stDeviceConfig.nPreviewHeight = nParam1;
  727. }
  728. //mLog::Info("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
  729. break;
  730. }
  731. case EVT_CONF_FIRWARE_UPDATE:
  732. {
  733. m_stDeviceConfig.nFirmwareStatus = nParam1;
  734. m_DetectorCtrlUnit->SetFirmwareStatus(to_string(nParam1));
  735. //mLog::Info("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
  736. break;
  737. }
  738. case EVT_CONF_PART_NUMBER:
  739. {
  740. m_stDeviceConfig.strPartNumber = pszMsg;
  741. //mLog::Info("Panel {$} PartNumber:{$}", nDetectorID, pszMsg);
  742. break;
  743. }
  744. case EVT_CONF_WIFI_SSID:
  745. {
  746. m_stDeviceConfig.strWifiSSID = pszMsg;
  747. //mLog::Info("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg);
  748. break;
  749. }
  750. case EVT_CONF_IFBOARD:
  751. {
  752. m_stDeviceConfig.strInterfaceBoard = pszMsg;
  753. //mLog::Info("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg);
  754. break;
  755. }
  756. case EVT_CONF_DATECODE:
  757. {
  758. m_stDeviceConfig.strDateCode = pszMsg;
  759. //mLog::Info("Panel {$} DateCode:{$}", nDetectorID, pszMsg);
  760. break;
  761. }
  762. default:
  763. {
  764. break;
  765. }
  766. }
  767. }
  768. void nsFPD::FPDDeviceIRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  769. {
  770. int nID = nDetectorID;
  771. switch (nEventID)
  772. {
  773. case EVT_INFO_POWER_ON:
  774. {
  775. int nPowerOn = nParam1;
  776. //mLog::Info("Detector {$} PowerOn:{$}", nID, nPowerOn);
  777. m_stDeviceConfig.nPowerOn = nPowerOn;
  778. break;
  779. }
  780. case EVT_INFO_WIFI_DATARATE:
  781. {
  782. m_stDeviceConfig.nWifiDataRate = nParam1;
  783. //mLog::Info("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate);
  784. break;
  785. }
  786. case EVT_INFO_WIFI_CHANNEL:
  787. {
  788. m_stDeviceConfig.nWifiChannel = nParam1;
  789. //mLog::Info("Panel {$} WifiChannel:{$}", nID, m_stDeviceConfig.nWifiChannel);
  790. break;
  791. }
  792. case EVT_INFO_WIFI_SIGNALPOWER:
  793. {
  794. m_stDeviceConfig.nWifiSignalPower = nParam1;
  795. break;
  796. }
  797. case EVT_INFO_WIFI_NOISEPOWER:
  798. {
  799. m_stDeviceConfig.nWifiNoisePower = nParam1;
  800. //mLog::Info("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower);
  801. break;
  802. }
  803. case EVT_INFO_CALIBRATIOIN_TIMEL:
  804. {
  805. m_stDeviceConfig.strCalibrationLTETime = pszMsg;
  806. //mLog::Info("Panel {$} LTE Calibration Time:{$}", nID, pszMsg);
  807. break;
  808. }
  809. case EVT_INFO_FPVOLTAGE:
  810. {
  811. m_strVoltage = pszMsg;
  812. break;
  813. }
  814. default:
  815. {
  816. break;
  817. }
  818. }
  819. }
  820. void nsFPD::FPDDeviceIRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  821. {
  822. string strWarnErrorCode = "";
  823. switch (nEventID)
  824. {
  825. case EVT_STATUS_INIT:
  826. {
  827. if (PANEL_EVENT_END_OK == nParam1)
  828. {
  829. //OnInitResult(true);
  830. m_stDeviceConfig.bConnectStatus = true;
  831. m_stDeviceConfig.bInitOK = true;
  832. }
  833. else if (PANEL_EVENT_END_ERROR == nParam1)
  834. {
  835. //OnInitResult(false);
  836. }
  837. else if (PANEL_EVENT_END == nParam1) //未连接探测器
  838. {
  839. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
  840. }
  841. else if (PANEL_EVENT_START == nParam1)
  842. {
  843. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START));
  844. }
  845. break;
  846. }
  847. case EVT_STATUS_SELECTPANEL:
  848. {
  849. break;
  850. }
  851. case EVT_STATUS_PANEL:
  852. {
  853. ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
  854. if (PANEL_STANDBY == nParam1)
  855. {
  856. //mLog::Info("Panel Status:PREPARE");
  857. }
  858. else if (PANEL_READY_EXP == nParam1)
  859. {
  860. //mLog::Info("Panel Status:READY");
  861. m_SyncUnit->FPDReadyNotify(true);
  862. }
  863. else if (PANEL_OFFSET_CAL == nParam1)
  864. {
  865. //mLog::Info("Panel Status:PANEL_OFFSET_CAL");
  866. }
  867. else if (PANEL_OFFSET_FINISH == nParam1)
  868. {
  869. //mLog::Info("Panel Status:PANEL_OFFSET_FINISH");
  870. //StopCalibrationInside();
  871. }
  872. else if (PANEL_OFFSET_FAILED == nParam1)
  873. {
  874. //mLog::Info("Panel Status:PANEL_OFFSET_FAILED");
  875. //AbortCalibration();
  876. }
  877. else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
  878. {
  879. //mLog::Info("Panel Status: XWINDOW_ON");
  880. XWindowOnNotify();
  881. }
  882. else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
  883. {
  884. //mLog::Info("Panel Status: XWINDOW_OFF");
  885. XWindowOffNotify();
  886. }
  887. else if (PANEL_GAIN_FINISH == nParam1)
  888. {
  889. //mLog::Info("Panel Status:CALIBRATION_FINISH");
  890. }
  891. else if (PANEL_GAIN_PREPARE == nParam1)
  892. {
  893. //mLog::Info("Detector Notify Xray Prepare");
  894. }
  895. else if (PANEL_GAIN_READY_EXP == nParam1)
  896. {
  897. m_SyncUnit->FPDReadyNotify(true);
  898. }
  899. else
  900. {
  901. //mLog::Info("Panel {$} Status Unknown: {$}", nDetectorID, (int)m_ePanelStatus);
  902. }
  903. break;
  904. }
  905. case EVT_STATUS_CALIBRATIOIN:
  906. {
  907. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  908. //string strSNote;
  909. switch (eStatus)
  910. {
  911. case PANEL_EVENT_START:
  912. break;
  913. case PANEL_EVENT_END_OK:
  914. //mLog::Info("Calibration process is success");
  915. //CompleteCalibration();
  916. SetEvent(m_CompleteCalibrationEvt);
  917. break;
  918. case PANEL_EVENT_END_ERROR:
  919. //mLog::Info("Calibration process is failed");
  920. break;
  921. case PANEL_EVENT_TIMEOUT:
  922. //mLog::Info("Calibration timeout");
  923. //mLog::Info("Calibration process is failed");
  924. break;
  925. default:
  926. break;
  927. }
  928. break;
  929. }
  930. case EVT_STATUS_SAVECALIB:
  931. {
  932. if (PANEL_EVENT_START == nParam1)
  933. {
  934. //mLog::Info("Begin to Save Calibration Files");
  935. }
  936. else if (PANEL_EVENT_END_ERROR == nParam1)
  937. {
  938. SetEvent(m_UploadCalibMapOver);
  939. //mLog::Info("Save Calibration Files failed");
  940. }
  941. else if (PANEL_EVENT_END == nParam1)
  942. {
  943. SetEvent(m_UploadCalibMapOver);
  944. //mLog::Info("Save Calibration Files Success");
  945. }
  946. break;
  947. }
  948. case EVT_STATUS_SAVEDEFECT:
  949. {
  950. if (PANEL_EVENT_START == nParam1)
  951. {
  952. //mLog::Info("Begin to Save Defect Files");
  953. }
  954. else if (PANEL_EVENT_END_ERROR == nParam1)
  955. {
  956. SetEvent(m_UploadCalibMapOver);
  957. //mLog::Info("Save Defect Files failed");
  958. }
  959. else if (PANEL_EVENT_END == nParam1)
  960. {
  961. m_stDeviceConfig.bTaskEnd = true;
  962. //mLog::Info("Save Defect Files Success");
  963. SetEvent(m_UploadCalibMapOver);
  964. }
  965. break;
  966. }
  967. case EVT_STATUS_ACQUISITION:
  968. {
  969. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  970. switch (eStatus)
  971. {
  972. case PANEL_EVENT_START:
  973. break;
  974. case PANEL_EVENT_END_OK:
  975. break;
  976. case PANEL_EVENT_END_ERROR: //由于断线造成指令执行失败
  977. {
  978. string strWarnErrorCode = ERR_FPD_ACQ_FAILED;
  979. break;
  980. }
  981. default:
  982. break;
  983. }
  984. break;
  985. }
  986. case EVT_STATUS_PREPARE_EDNCALIBRATION:
  987. break;
  988. case EVT_STATUS_IMAGEPENDING:
  989. {
  990. string strTemp = pszMsg;
  991. if (strTemp.find("true") != std::string::npos)
  992. {
  993. m_bImagePendingOrNot = true;
  994. }
  995. else
  996. {
  997. m_bImagePendingOrNot = false;
  998. }
  999. break;
  1000. }
  1001. case EVT_STATUS_IMAGERECOVERAUTO:
  1002. {
  1003. m_RecoverImageStatus["Result"] = "0";
  1004. //mLog::Info("m_RecoverImageStatus[Result] = 0 by auto");
  1005. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  1006. m_bAbortRecover = false; //终止恢复图像的变量也要重置
  1007. m_bRecoveringImage = false; //不再恢复图像过程中
  1008. m_nRecoverImageTimes = 0; //下次恢复图像,重置
  1009. m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
  1010. break;
  1011. }
  1012. case EVT_STATUS_TEMPERATURE:
  1013. {
  1014. float fTemperature = fParam2;
  1015. //OnProcessTemperature(nID, fTemperature);
  1016. m_stDeviceConfig.fCurrentTemperValue = fTemperature;
  1017. //mLog::Info("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature);
  1018. //SendTemperatureValue(fTemperature);
  1019. break;
  1020. }
  1021. case EVT_STATUS_WIFI:
  1022. {
  1023. int nWifiLevel = nParam1;
  1024. //mLog::Info("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel);
  1025. m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
  1026. //SendWifiValue(nWifiLevel);
  1027. break;
  1028. }
  1029. case EVT_STATUS_BATTERY_VALUE:
  1030. {
  1031. int nBatteryValue = nParam1;
  1032. m_lowBatteryBuda = m_lowBatteryBuda + 1;
  1033. if (m_lowBatteryBuda >= 10000)
  1034. {
  1035. m_lowBatteryBuda = 10000;
  1036. }
  1037. //mLog::Info("Detector {$} Battery:{$}", nDetectorID, nParam1);
  1038. //SendInfoLog("DEV_LOG_FPD_BATTERY", nBatteryValue);
  1039. if (nBatteryValue < m_stDeviceConfig.nBatteryLimit)
  1040. {
  1041. //battery error
  1042. if (!m_bBatteryCharging) //如果没有充电;
  1043. {
  1044. strWarnErrorCode = ERR_FPD_BATTERY_LOW;
  1045. //OnError(strWarnErrorCode);
  1046. strWarnErrorCode = WAR_FPD_BATTERY_LOW;
  1047. //OnWarnX(strWarnErrorCode);
  1048. }
  1049. }
  1050. else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
  1051. {
  1052. strWarnErrorCode = ERR_FPD_BATTERY_LOW;
  1053. //OnErrorX(strWarnErrorCode);
  1054. strWarnErrorCode = WAR_FPD_BATTERY_LOW;
  1055. }
  1056. else
  1057. {
  1058. strWarnErrorCode = ERR_FPD_BATTERY_LOW;
  1059. //OnErrorX(strWarnErrorCode);
  1060. strWarnErrorCode = WAR_FPD_BATTERY_LOW;
  1061. //OnWarnX(strWarnErrorCode);
  1062. }
  1063. m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
  1064. //mLog::Info("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue);
  1065. if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
  1066. {
  1067. //防止探测器电池电量状态异常跳变
  1068. if (m_lowBatteryBuda >= 2)
  1069. {
  1070. //SendBatteryValue(nBatteryValue);
  1071. }
  1072. }
  1073. else
  1074. {
  1075. //SendBatteryValue(nBatteryValue);
  1076. }
  1077. break;
  1078. }
  1079. case EVT_STATUS_BATTERY_CHARGING:
  1080. {
  1081. string strTemp = pszMsg;
  1082. if (strTemp.find("true") != std::string::npos)
  1083. {
  1084. m_bBatteryCharging = true;
  1085. }
  1086. else
  1087. {
  1088. m_bBatteryCharging = false;
  1089. }
  1090. break;
  1091. }
  1092. case EVT_STATUS_SHOCK_SENSOR:
  1093. {
  1094. m_nShockCounts = nParam1;
  1095. string strWarn = WAR_FPD_MAX_SHOCK_NUM;
  1096. //mLog::Info("Panel {$} Shock Sensor Number:{$}", nDetectorID, m_nShockCounts);
  1097. m_stDeviceConfig.nShockTimes = m_nShockCounts;
  1098. break;
  1099. }
  1100. case EVT_STATUS_HALL_SENSOR:
  1101. {
  1102. int nWorkstaion = nParam1;
  1103. //mLog::Info("Update Hall Status : {$} ", nWorkstaion);
  1104. //mLog::Info("Panel {$} WS:{$},Current OGP WS:{$} ", nDetectorID, nWorkstaion, m_nWorkStation);
  1105. m_stDeviceConfig.nWorkstation = nWorkstaion;
  1106. break;
  1107. }
  1108. case EVT_STATUS_PING:
  1109. {
  1110. break;
  1111. }
  1112. case EVT_STATUS_RESET:
  1113. {
  1114. int nStatus = nParam1;
  1115. if (PANEL_RESET_BEGIN == nStatus)
  1116. {
  1117. }
  1118. else if (PANEL_RESET_OK == nStatus)
  1119. {
  1120. m_bResetDetector = false;
  1121. }
  1122. else if (PANEL_RESET_ERROR == nStatus)
  1123. {
  1124. }
  1125. break;
  1126. }
  1127. default:
  1128. {
  1129. break;
  1130. }
  1131. }
  1132. }
  1133. void nsFPD::FPDDeviceIRay::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1134. {
  1135. switch (nEventID)
  1136. {
  1137. case EVT_DATA_RAW_IMAGE:
  1138. {
  1139. //mLog::Info("Image Arrive");
  1140. if (APP_STATUS_IDLE == m_eAppStatus)
  1141. {
  1142. //mLog::Error("Omit Image in Idle Status");
  1143. return;
  1144. }
  1145. //mLog::Info("Currenct FPD FullImage Width:{$}, FullImage Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight);
  1146. float fImageReferUGY = 2.5f;
  1147. if (APP_STATUS_WORK_BEGIN == m_eAppStatus)
  1148. {
  1149. fImageReferUGY = 2.5f;
  1150. }
  1151. if (NULL == m_pwRawImageData)
  1152. {
  1153. m_pwRawImageData = new WORD[m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight];
  1154. }
  1155. memcpy(m_pwRawImageData, pParam, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * sizeof(WORD));
  1156. if (m_bSaveRaw)
  1157. {
  1158. //SaveRaw("iRaySDK");
  1159. string strFullImageName = "FullImage.raw";
  1160. SaveRawImage(strFullImageName, m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight);
  1161. }
  1162. OnProcessImage(m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight, fImageReferUGY);
  1163. m_bStatusInAEC = false;
  1164. break;
  1165. }
  1166. case EVT_DATA_PREVIEW_IMAGE:
  1167. {
  1168. //mLog::Info("Preview Image Arrive");
  1169. m_SyncUnit->ImageReadingNotify();
  1170. if (NULL == m_pwPreviewImg)
  1171. {
  1172. m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight];
  1173. }
  1174. memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD));
  1175. OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  1176. break;
  1177. }
  1178. case EVT_DATA_AEC_PREEXP_IMAGE:
  1179. {
  1180. //mLog::Info("AEC PreExp Image Arrive");
  1181. if (NULL == m_pwPreviewImg)
  1182. {
  1183. m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight];
  1184. }
  1185. memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD));
  1186. if (m_bSaveRaw)
  1187. {
  1188. //SaveImage(L"PreviewImage.raw", pwRawImage, nHeight, nWidth);
  1189. string strImageName = "PreExpImage.raw";
  1190. SaveRawImage(strImageName, m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  1191. }
  1192. OnProcessPreExpImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  1193. m_bStatusInAEC = true;
  1194. break;
  1195. }
  1196. case EVT_DATA_DOSEPARAM:
  1197. {
  1198. m_fDoseParam = nParam1;// static_cast<int>(fParam2 * 1000);
  1199. //mLog::Info("calibration dose {$}, Param1 {$}", m_fDoseParam, nParam1);
  1200. SetEvent(m_WaitCalibDoseEvt);
  1201. break;
  1202. }
  1203. default:
  1204. {
  1205. break;
  1206. }
  1207. }
  1208. }
  1209. void nsFPD::FPDDeviceIRay::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1210. {
  1211. string strErrorName = "";
  1212. switch (nEventID)
  1213. {
  1214. case EVT_ERR_COMMUNICATE:
  1215. {
  1216. strErrorName = ERR_FPD_DISCONNECT;
  1217. string strTemp = pszMsg;
  1218. if (strTemp.find("true") != std::string::npos)
  1219. {
  1220. m_stDeviceConfig.nWorkstation = -1;
  1221. m_stDeviceConfig.bConnectStatus = false;
  1222. m_nBatteryCapacity = 0;
  1223. //SendDetectorInfo();
  1224. m_lowBatteryBuda = 0;
  1225. m_stDeviceConfig.nCurrentWifiValue = 0;
  1226. m_stDeviceConfig.nCurrentBatteryValue = 0;
  1227. }
  1228. else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo
  1229. {
  1230. m_stDeviceConfig.bConnectStatus = true;
  1231. }
  1232. break;
  1233. }
  1234. case EVT_ERR_EXP_REQUEST:
  1235. {
  1236. string strTemp = pszMsg;
  1237. strErrorName = ERR_FPD_ACQ_FAILED;
  1238. break;
  1239. }
  1240. case EVT_ERR_GET_IMAGE:
  1241. {
  1242. string strTemp = pszMsg;
  1243. if (strTemp.find("true") != std::string::npos)
  1244. {
  1245. if (APP_STATUS_WORK_BEGIN != m_eAppStatus) //如果不在检查界面;
  1246. {
  1247. //mLog::Fatal("there are image exist in current detector,do you want to continue");
  1248. }
  1249. else //if (m_bSiemensCmd)
  1250. {
  1251. //mLog::Fatal("FPD has exposed Image!");
  1252. }
  1253. //endif
  1254. }
  1255. else if (strTemp.find("false") != std::string::npos)
  1256. {
  1257. m_bAbortRecover = false; //终止恢复图像的变量也要重置
  1258. m_bRecoveringImage = false; //不再恢复图像过程中
  1259. m_nRecoverImageTimes = 0; //下次恢复图像,重置
  1260. m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
  1261. }
  1262. break;
  1263. }
  1264. case EVT_ERR_INIT_FAILED:
  1265. {
  1266. strErrorName = ERR_FPD_FATAL_ERROR;
  1267. string strTemp = pszMsg;
  1268. break;
  1269. }
  1270. default:
  1271. {
  1272. break;
  1273. }
  1274. }
  1275. }
  1276. void nsFPD::FPDDeviceIRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1277. {
  1278. }
  1279. DWORD nsFPD::FPDDeviceIRay::OnNotify(LPVOID pParam)
  1280. {
  1281. return 0;
  1282. }
  1283. bool nsFPD::FPDDeviceIRay::CreateDevice()
  1284. {
  1285. if (!LoadConfig())
  1286. {
  1287. //mLog::Info("Load configuration file failed!!!");
  1288. return false;
  1289. }
  1290. bool bDemo = false;
  1291. bool bRet = false;
  1292. int nDemo = (int)m_DetectorConfiguration->m_Configurations["DemoEnable"];
  1293. if (nDemo != 0)
  1294. {
  1295. bDemo = true;
  1296. }
  1297. if (bDemo)
  1298. {
  1299. return bRet;
  1300. }
  1301. if ((g_pIRayCtrl != nullptr) || (m_pDetectors != nullptr))
  1302. {
  1303. //mLog::Info("CreateDevice failed!");
  1304. return false;
  1305. }
  1306. m_pDetectors = new IRayCtrl();
  1307. g_pIRayCtrl = reinterpret_cast<IRayCtrl*>(m_pDetectors);
  1308. bRet = m_pDetectors->Init(g_strAppPath);
  1309. m_pDetectors->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig);
  1310. //mLog::Info("Create Device over");
  1311. return bRet;
  1312. }
  1313. RET_STATUS nsFPD::FPDDeviceIRay::Connect()
  1314. {
  1315. //mLog::Info("------------------------ FPD type {$}, Device {$} Start running. ------------------------ ", m_stDeviceConfig.strDeviceName.c_str(), this);
  1316. bool bRet = m_pDetectors->Connect(g_strAppPath, this);
  1317. if (!bRet)
  1318. {
  1319. //SendConnectStatusToUI(false);
  1320. return RET_STATUS::RET_FAILED;
  1321. }
  1322. //mLog::Info("Device Connect detector over ");
  1323. return RET_STATUS::RET_SUCCEED;
  1324. }
  1325. RET_STATUS nsFPD::FPDDeviceIRay::GetDeviceDictionary(std::string& out)
  1326. {
  1327. return RET_STATUS::RET_SUCCEED;
  1328. }
  1329. RET_STATUS nsFPD::FPDDeviceIRay::EnterExam(int nExamStatus)
  1330. {
  1331. //mLog::Info("EnterExam");
  1332. switch (nExamStatus)
  1333. {
  1334. case APP_STATUS_WORK_BEGIN:
  1335. //mLog::Info("Enter into Exam Windows");
  1336. m_eAppStatus = APP_STATUS_WORK_BEGIN;
  1337. break;
  1338. case APP_STATUS_WORK_END:
  1339. //mLog::Info("Quit Exam Windows");
  1340. m_bTestSensitivity = false;
  1341. m_eAppStatus = APP_STATUS_WORK_END;
  1342. break;
  1343. case APP_STATUS_CAL_BEGIN:
  1344. //mLog::Info("Enter into Calibration Windows");
  1345. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  1346. break;
  1347. case APP_STATUS_CAL_END:
  1348. //mLog::Info("Quit Calibration Windows");
  1349. m_eAppStatus = APP_STATUS_CAL_END;
  1350. break;
  1351. default:
  1352. break;
  1353. }
  1354. m_pDetectors->EnterExam(m_eAppStatus);
  1355. return RET_STATUS::RET_SUCCEED;
  1356. }
  1357. RET_STATUS nsFPD::FPDDeviceIRay::ActiveDetector(bool bActive)
  1358. {
  1359. if (bActive)
  1360. {
  1361. //mLog::Info("ActiveDetector");
  1362. m_nActiveState = FPD_ACTIVE;
  1363. bool bRet = (m_pDetectors)->ActivePanel(this, bActive);
  1364. if (!bRet)
  1365. {
  1366. return RET_STATUS::RET_FAILED;
  1367. }
  1368. }
  1369. else
  1370. {
  1371. //mLog::Info("UnActiveDetector");
  1372. bool bRet = (m_pDetectors)->ActivePanel(this, bActive);
  1373. if (!bRet)
  1374. {
  1375. return RET_STATUS::RET_FAILED;
  1376. }
  1377. m_nActiveState = FPD_NOT_ACTIVE;
  1378. }
  1379. return RET_STATUS::RET_SUCCEED;
  1380. }
  1381. RET_STATUS nsFPD::FPDDeviceIRay::SetAcqMode(int mode)
  1382. {
  1383. /*if (!m_stDeviceConfig.bConnectStatus)
  1384. {
  1385. //mLog::Error("m_stDeviceConfig.bConnectStatus = false ");
  1386. return RET_STATUS::RET_THREAD_INVALID;
  1387. }*/
  1388. //mLog::Info("Device SetAcqMode: {$}", mode);
  1389. int nOmMode = 1;
  1390. int nFilterMode = m_stDeviceConfig.nFilterMode;
  1391. int nPanelID = m_nDeviceIndex + 1;
  1392. if (m_bStatusInAEC == true)
  1393. {
  1394. //mLog::Info("In AEC MainExposure...");
  1395. //激活应用配置模式:Manual曝光
  1396. //m_pDetectors->ActiveConfigurationMode(nPanelID, 1);
  1397. return RET_STATUS::RET_SUCCEED;
  1398. }
  1399. if (mode == 3) //AEC模式
  1400. {
  1401. nOmMode = 2;
  1402. //mLog::Info("In AEC PreExposure...");
  1403. //激活应用配置模式:AEC PreExp曝光
  1404. m_pDetectors->ActiveConfigurationMode(nPanelID, nOmMode);
  1405. }
  1406. else
  1407. {
  1408. nOmMode = 1;
  1409. //激活应用配置模式:Manual曝光
  1410. m_pDetectors->ActiveConfigurationMode(nPanelID, nOmMode);
  1411. }
  1412. m_pDetectors->SelectMode(0, nOmMode, nFilterMode);
  1413. try
  1414. {
  1415. //nOmMode = m_ACQMODElist[CcosAcqModeIdx];
  1416. /*if (nOmMode != mode)
  1417. {
  1418. //mLog::Info("input param invalid, can not support ");
  1419. return RET_STATUS::RET_INVALID;
  1420. }*/
  1421. //int nWidth = (int)m_ACQMODElist[CcosImageWidth];
  1422. //int nheight = (int)m_ACQMODElist[CcosImageHeight];
  1423. //int nbit = (int)m_ACQMODElist[CcosImageBits];
  1424. m_AcqUnit->SetFulImageInfo(m_stDeviceConfig.nFullImageHeight, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nImageBits, false);
  1425. m_AcqUnit->SetPrevImageInfo(m_stDeviceConfig.bPreviewEnable, m_stDeviceConfig.nPreviewHeight, m_stDeviceConfig.nPreviewWidth, false);
  1426. }
  1427. catch (...)
  1428. {
  1429. //mLog::Info("Illegal mode index!!! ");
  1430. return RET_STATUS::RET_NOSUPPORT;
  1431. }
  1432. if (m_pDetectors->SelectExamMode(nOmMode, this))
  1433. {
  1434. return RET_STATUS::RET_SUCCEED;
  1435. }
  1436. return RET_STATUS::RET_SUCCEED;
  1437. }
  1438. RET_STATUS nsFPD::FPDDeviceIRay::SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode)
  1439. {
  1440. if (!(m_pDetectors->SetSyncMode(nSyncMode, TriggerMode)))
  1441. {
  1442. return RET_STATUS::RET_FAILED;
  1443. }
  1444. return RET_STATUS::RET_SUCCEED;
  1445. }
  1446. RET_STATUS nsFPD::FPDDeviceIRay::SetXwindow(float XwindowSize)
  1447. {
  1448. return RET_STATUS::RET_SUCCEED;
  1449. }
  1450. RET_STATUS nsFPD::FPDDeviceIRay::SetSID(int nSID)
  1451. {
  1452. return RET_STATUS::RET_SUCCEED;
  1453. }
  1454. RET_STATUS nsFPD::FPDDeviceIRay::ActiveCalibration(CCOS_CALIBRATION_TYPE in)
  1455. {
  1456. return RET_STATUS::RET_SUCCEED;
  1457. }
  1458. RET_STATUS nsFPD::FPDDeviceIRay::PrepareCalibration()
  1459. {
  1460. return RET_STATUS::RET_SUCCEED;
  1461. }
  1462. RET_STATUS nsFPD::FPDDeviceIRay::GetRequestedDose(string& strDose)
  1463. {
  1464. return RET_STATUS::RET_SUCCEED;
  1465. }
  1466. RET_STATUS nsFPD::FPDDeviceIRay::StartCalibration()
  1467. {
  1468. return RET_STATUS::RET_SUCCEED;
  1469. }
  1470. RET_STATUS nsFPD::FPDDeviceIRay::StopCalibration()
  1471. {
  1472. return RET_STATUS::RET_SUCCEED;
  1473. }
  1474. RET_STATUS nsFPD::FPDDeviceIRay::SetCorrectionType(CCOS_CORRECTION_TYPE in)
  1475. {
  1476. return RET_STATUS::RET_SUCCEED;
  1477. }
  1478. RET_STATUS nsFPD::FPDDeviceIRay::ResetConnect()
  1479. {
  1480. return RET_STATUS::RET_SUCCEED;
  1481. }
  1482. RET_STATUS nsFPD::FPDDeviceIRay::DisConnectFPD()
  1483. {
  1484. return RET_STATUS::RET_SUCCEED;
  1485. }
  1486. RET_STATUS nsFPD::FPDDeviceIRay::RecoverImage(bool bRecoverIt)
  1487. {
  1488. return RET_STATUS::RET_SUCCEED;
  1489. }
  1490. RET_STATUS nsFPD::FPDDeviceIRay::GetRecoverImageState(string& strREI)
  1491. {
  1492. return RET_STATUS::RET_SUCCEED;
  1493. }
  1494. RET_STATUS nsFPD::FPDDeviceIRay::GetDetectorInfo(string& strFDI)
  1495. {
  1496. string strTempTemp = " ";
  1497. //mLog::Info("Get Detector Info");
  1498. strFDI = "jishinull";
  1499. return RET_STATUS::RET_SUCCEED;
  1500. }
  1501. RET_STATUS nsFPD::FPDDeviceIRay::UploadCalibrationFiles(string strFileName)
  1502. {
  1503. return RET_STATUS::RET_SUCCEED;
  1504. }
  1505. RET_STATUS nsFPD::FPDDeviceIRay::ResetError()
  1506. {
  1507. return RET_STATUS::RET_SUCCEED;
  1508. }
  1509. bool nsFPD::FPDDeviceIRay::LoadConfig()
  1510. {
  1511. if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
  1512. {
  1513. //mLog::Fatal("Load configuration file failed!!! ");
  1514. return false;
  1515. }
  1516. //mLog::Info("m_ACQMODElist: {$} ", m_ACQMODElist.encode());
  1517. m_nFullImgWidth = m_stDeviceConfig.nFullImageWidth;
  1518. m_nFullImgHeight = m_stDeviceConfig.nFullImageHeight;
  1519. m_nTopOffset = m_stDeviceConfig.nImageTopffset;
  1520. m_nBottomOffset = m_stDeviceConfig.nImageBottomOffset;
  1521. m_nLeftOffset = m_stDeviceConfig.nImageLeftOffset;
  1522. m_nRightOffset = m_stDeviceConfig.nImageRightOffset;
  1523. m_bPreviewEnable = m_stDeviceConfig.bPreviewEnable;
  1524. //mLog::Info("set previewEnable {$} ", m_bPreviewEnable ? "true" : "false");
  1525. if (m_stDeviceConfig.nForceGridSuppress > 0)
  1526. {
  1527. m_bForceGridSuppress = true;
  1528. }
  1529. else
  1530. {
  1531. m_bForceGridSuppress = false;
  1532. }
  1533. int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag];
  1534. m_stDeviceConfig.bConnectStatus = false;
  1535. m_bSaveRaw = (bool)m_DetectorConfiguration->m_Configurations["SaveRaw"];
  1536. //mLog::Info("set SaveRaw {$} ", m_bSaveRaw ? "true" : "false");
  1537. m_nClinicalApplicationMode = (int)m_DetectorConfiguration->m_Configurations["ClinicalApplicationMode"];
  1538. //mLog::Info("Clinical Application Mode: {$} ", m_nClinicalApplicationMode);
  1539. m_nFilterMode = (int)m_DetectorConfiguration->m_Configurations["FilterMode"];
  1540. //mLog::Info("Clinical Filter Mode: {$} ", m_nFilterMode);
  1541. string strFPDinfo;
  1542. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewShape"];
  1543. m_DetectorCtrlUnit->SetFieldofViewShape(strFPDinfo);
  1544. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewDimension"];
  1545. //m_DetectorCtrlUnit->SetFieldofViewDimension(strFPDinfo);
  1546. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["VendorID"];
  1547. //m_DetectorCtrlUnit->SetDetectorType("IRAY1012F2");
  1548. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"];
  1549. //m_DetectorCtrlUnit->SetDescription(strFPDinfo);
  1550. auto szFDinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI);
  1551. m_fFactorEXI2UGY = 100.0f / (float)atof(szFDinfo.c_str()) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  1552. //mLog::Info("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY);
  1553. auto strFPDcoef = std::to_string(m_fFactorEXI2UGY);
  1554. m_DetectorCtrlUnit->SetFPDSensitivity(strFPDcoef);//image process 重算ROIl的EXI需要此值
  1555. //m_DetectorCtrlUnit->SetPixelData("");
  1556. //m_DetectorCtrlUnit->SetTargetEXI("5000");
  1557. return true;
  1558. }
  1559. RET_STATUS nsFPD::FPDDeviceIRay::PrepareAcquisition()
  1560. {
  1561. //mLog::Info("==============================PrepareAcquisition");
  1562. /*if (!m_stDeviceConfig.bConnectStatus)
  1563. {
  1564. return RET_STATUS::RET_THREAD_INVALID;
  1565. }
  1566. if (!m_stDeviceConfig.bInitOK)
  1567. {
  1568. return RET_STATUS::RET_FAILED;
  1569. }*/
  1570. m_SyncUnit->FPDReadyNotify(false);
  1571. if (m_pDetectors->PrepareAcquisition(this) == RET_STATUS::RET_SUCCEED)
  1572. {
  1573. m_SyncUnit->FPDReadyNotify(true);
  1574. //mLog::Info("Send FPD Ready to Subsystem");
  1575. }
  1576. //mLog::Info("PrepareAcquisition over");
  1577. return RET_STATUS::RET_SUCCEED;
  1578. }
  1579. RET_STATUS nsFPD::FPDDeviceIRay::StartAcquisition(string in)
  1580. {
  1581. //mLog::Info("StartAcquisition");
  1582. m_bAbortRecover = false; //能执行StartAcq,说明没有错误可以ready曝光。不再影响abort后再次recoverimage功能
  1583. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1584. if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartAcquisition(this))
  1585. {
  1586. Ret = RET_STATUS::RET_SUCCEED;
  1587. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  1588. //mLog::Info("Send DETECTOR_STATUS_ACQ to Subsystem");
  1589. }
  1590. else
  1591. {
  1592. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1593. //mLog::Info("Send DETECTOR_STATUS_STANDBY to Subsystem");
  1594. //mLog::Error("StartAcquisition failed");
  1595. }
  1596. //mLog::Info("StartAcquisition over");
  1597. return Ret;
  1598. }
  1599. RET_STATUS nsFPD::FPDDeviceIRay::StopAcquisition()
  1600. {
  1601. //mLog::Info("StopAcquisition ");
  1602. /*if (!m_stDeviceConfig.bConnectStatus)
  1603. {
  1604. return RET_STATUS::RET_THREAD_INVALID;
  1605. }*/
  1606. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1607. if (RET_STATUS::RET_SUCCEED == m_pDetectors->StopAcquisition(this))
  1608. {
  1609. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1610. //mLog::Info("Send DETECTOR_STATUS_STANDBY to Subsystem");
  1611. Ret = RET_STATUS::RET_SUCCEED;
  1612. }
  1613. //mLog::Info("StopAcquisition over ");
  1614. return Ret;
  1615. }
  1616. RET_STATUS nsFPD::FPDDeviceIRay::XWindowOnNotify()
  1617. {
  1618. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1619. m_SyncUnit->XWindowOnNotify();
  1620. //mLog::Info("--- WindowOn ---");
  1621. m_stImgCreateTime = { 0 };
  1622. GetLocalTime(&m_stImgCreateTime);
  1623. //mLog::Info("Full image create time-{$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1624. return RET_STATUS::RET_SUCCEED;
  1625. }
  1626. RET_STATUS nsFPD::FPDDeviceIRay::XWindowOffNotify()
  1627. {
  1628. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1629. m_SyncUnit->XWindowOffNotify();
  1630. //mLog::Info("--- WindowOff ---");
  1631. return RET_STATUS::RET_SUCCEED;
  1632. }
  1633. string nsFPD::FPDDeviceIRay::MakeImageHead(IMAGE_VIEW_TYPE Type)
  1634. {
  1635. if (Type == IMAGE_FULL)
  1636. {
  1637. if (m_pFullImageHead == NULL)
  1638. {
  1639. m_pFullImageHead = new ResDataObject;
  1640. ResDataObject json;
  1641. json.add(SM_IMAGE_TYPE, (int)Type);
  1642. json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nFullImageWidth);
  1643. json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nFullImageHeight);
  1644. json.add(SM_IMAGE_BIT, 16);
  1645. json.add(SM_IMAGE_TAG, 1);
  1646. json.add(SM_IMAGE_INDEX, 1);
  1647. json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  1648. json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  1649. json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  1650. json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  1651. json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  1652. json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  1653. json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  1654. json.add(SM_IMAGE_LSB, "5000");
  1655. json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
  1656. json.add(SM_IMAGE_PIXELREPRESENTATION, "0");
  1657. json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
  1658. json.add(SM_IMAGE_ROTATION, "No");
  1659. json.add(SM_IMAGE_FLIP, "No");
  1660. json.add(SM_IMAGE_ORIGINX, "0");
  1661. json.add(SM_IMAGE_ORIGINY, "0");
  1662. json.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  1663. json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
  1664. m_pFullImageHead->add(SM_IMAGE_HEAD, json);
  1665. }
  1666. else
  1667. {
  1668. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
  1669. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
  1670. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
  1671. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
  1672. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
  1673. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
  1674. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
  1675. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
  1676. }
  1677. //mLog::Info((*m_pFullImageHead).encode());
  1678. return (*m_pFullImageHead).encode();
  1679. }
  1680. else
  1681. {
  1682. if (m_pPreviewImageHead == NULL)
  1683. {
  1684. m_pPreviewImageHead = new ResDataObject;
  1685. ResDataObject json;
  1686. json.add(SM_IMAGE_TYPE, (int)Type);
  1687. json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth);
  1688. json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight);
  1689. json.add(SM_IMAGE_BIT, 16);
  1690. json.add(SM_IMAGE_TAG, 1);
  1691. json.add(SM_IMAGE_INDEX, 1);
  1692. json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  1693. json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  1694. json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  1695. json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  1696. json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  1697. json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  1698. json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  1699. json.add(SM_IMAGE_LSB, "5000");
  1700. json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
  1701. json.add(SM_IMAGE_ROTATION, "No");
  1702. json.add(SM_IMAGE_FLIP, "No");
  1703. json.add(SM_IMAGE_ORIGINX, "0");
  1704. json.add(SM_IMAGE_ORIGINY, "0");
  1705. json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
  1706. json.add(SM_IMAGE_PIXELREPRESENTATION, "0");
  1707. json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
  1708. m_pPreviewImageHead->add(SM_IMAGE_HEAD, json);
  1709. }
  1710. else
  1711. {
  1712. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
  1713. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
  1714. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
  1715. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
  1716. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
  1717. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
  1718. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
  1719. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
  1720. }
  1721. return (*m_pPreviewImageHead).encode();
  1722. }
  1723. return "";
  1724. }
  1725. RET_STATUS nsFPD::FPDDeviceIRay::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
  1726. {
  1727. string strImageHead = MakeImageHead(Type);
  1728. return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
  1729. }
  1730. //======================================================================预览图==================================================================//
  1731. bool nsFPD::FPDDeviceIRay::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
  1732. {
  1733. //m_stFPDHeader.fFPDHeaderVersion = 0.0;
  1734. //m_stFPDHeader.nImageType = m_nCurrentAcqMode;
  1735. //m_stFPDHeader.nImageHeight = nHeight;
  1736. //m_stFPDHeader.nImageWidth = nWidth;
  1737. //m_stFPDHeader.nImageBits = m_nImageBits;
  1738. //m_stFPDHeader.fFactorEXI2UGY = m_fFactorEXI2UGY;
  1739. //m_stFPDHeader.fImageReferUGY = 2.5f;
  1740. //m_stFPDHeader.fTemperature = m_stDeviceConfig.fCurrentTemperValue;
  1741. //m_stFPDHeader.fPixelSpace = m_stDeviceConfig.fPixelSpace;
  1742. //mLog::Info("Currenct PreviewImage Width:{$}, Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  1743. if (m_stDeviceConfig.nSaveRaw > 1)
  1744. {
  1745. //SaveImage(L"PreviewImage.raw", pwRawImage, nHeight, nWidth);
  1746. }
  1747. return true;
  1748. }
  1749. void nsFPD::FPDDeviceIRay::PrevImageDateArrived(WORD* pImg)
  1750. {
  1751. AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight);
  1752. }
  1753. //======================================================================AEC预曝光图============================================================//
  1754. bool nsFPD::FPDDeviceIRay::OnProcessPreExpImage(WORD* pwRawImage, int nWidth, int nHeight)
  1755. {
  1756. //m_stFPDHeader.fFPDHeaderVersion = 0.0;
  1757. //m_stFPDHeader.nImageType = m_nCurrentAcqMode;
  1758. //m_stFPDHeader.nImageHeight = nHeight;
  1759. //m_stFPDHeader.nImageWidth = nWidth;
  1760. //m_stFPDHeader.nImageBits = m_nImageBits;
  1761. //m_stFPDHeader.fFactorEXI2UGY = m_fFactorEXI2UGY;
  1762. //m_stFPDHeader.fImageReferUGY = 2.5f;
  1763. //m_stFPDHeader.fTemperature = m_stDeviceConfig.fCurrentTemperValue;
  1764. //m_stFPDHeader.fPixelSpace = m_stDeviceConfig.fPixelSpace;
  1765. //mLog::Info("Currenct AEC PreExp Image Width:{$}, Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  1766. PreExpImageDateArrived(pwRawImage);
  1767. return true;
  1768. }
  1769. void nsFPD::FPDDeviceIRay::PreExpImageDateArrived(WORD* pImg)
  1770. {
  1771. AddFrameWithRawHead(IMAGE_AEC_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight);
  1772. }
  1773. //======================================================================大图==================================================================//
  1774. bool nsFPD::FPDDeviceIRay::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY)
  1775. {
  1776. //mLog::Info("Process Full Image");
  1777. //mLog::Info("Currenct Full Image Width:{$}, Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight);
  1778. //mLog::Info("Image EXI2UGY factor: {$}, Image Refer UGY: {$}", m_fFactorEXI2UGY, fImageReferUGY);
  1779. //图像预处理完成
  1780. FullImageDateArrived(pwRawImage);
  1781. //mLog::Info("Write Frame Over");
  1782. return true;
  1783. }
  1784. void nsFPD::FPDDeviceIRay::FullImageDateArrived(WORD* pImg)
  1785. {
  1786. AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight);
  1787. }
  1788. void nsFPD::FPDDeviceIRay::SaveRaw(string RawName)
  1789. {
  1790. //mLog::Info("Begin save image");
  1791. char szTemp[30] = { 0 };
  1792. FILE* fp;
  1793. string strFileName = g_strAppPath + "Image\\" + RawName + ".raw";
  1794. if ((fp = fopen(strFileName.c_str(), "wb")) == NULL)
  1795. {
  1796. DWORD dw = GetLastError();
  1797. //mLog::Error("fopen %s failed, %d", strFileName.c_str(), dw);
  1798. return;
  1799. }
  1800. fwrite(m_pwRawImageData, sizeof(WORD), m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight, fp);
  1801. fclose(fp);
  1802. //mLog::Info("Save image over");
  1803. }
  1804. bool nsFPD::FPDDeviceIRay::SaveRawImage(string strImageName, WORD* pwRawImage, int nWidth, int nHeight)
  1805. {
  1806. //mLog::Info("Save raw image: {$}", strImageName);
  1807. char szTemp[30] = { 0 };
  1808. FILE* fp;
  1809. string strFileName = g_strAppPath + "Image\\" + strImageName;
  1810. if ((fp = fopen(strFileName.c_str(), "wb")) == NULL)
  1811. {
  1812. DWORD dw = GetLastError();
  1813. //mLog::Error("fopen %s failed, %d", strFileName.c_str(), dw);
  1814. return false;
  1815. }
  1816. fwrite(pwRawImage, sizeof(WORD), nWidth * nHeight, fp);
  1817. fclose(fp);
  1818. //mLog::Info("Save raw image over");
  1819. return true;
  1820. }