CCOS.Dev.FPD.TiRayDR.cpp 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892
  1. #include "CCOS.Dev.FPD.TiRayDR.h"
  2. #include "common_api.h"
  3. #include "DICOMImageHeadKey.h"
  4. #include "Detector_TiRayDR.h"
  5. namespace nsFPD = CCOS::Dev::Detail::Detector;
  6. //-----------------------------------------------------------------------------
  7. // FPDDeviceTiRay
  8. //-----------------------------------------------------------------------------
  9. extern Detector_TiRayDR* g_pDetector;
  10. static nsFPD::TiRayDriver gIODriver;
  11. //Log4CPP::Logger* mLog::gLogger = nullptr;
  12. extern "C" CCOS::Dev::IODriver * GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  13. {
  14. return &gIODriver;
  15. }
  16. extern "C" CCOS::Dev::IODriver * CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  17. {
  18. return new nsFPD::TiRayDriver();
  19. }
  20. nsFPD::TiRayDriver::TiRayDriver()
  21. {
  22. pObjDev = nullptr;
  23. m_bDriverConnect = false; //缺省为false
  24. m_pAttribute.reset(new ResDataObject());
  25. m_pDescription.reset(new ResDataObject());
  26. }
  27. nsFPD::TiRayDriver::~TiRayDriver()
  28. {
  29. if (pObjDev != nullptr)
  30. {
  31. delete pObjDev;
  32. pObjDev = nullptr;
  33. }
  34. }
  35. void nsFPD::TiRayDriver::Prepare()
  36. {
  37. //string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
  38. //auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  39. //mLog::gLogger = Log4CPP::LogManager::GetLogger("Module");
  40. //mLog::FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
  41. #ifdef TiRay4343
  42. //mLog::FINFO("TiRayDriver::Prepare get logger FPD.TiRay4343");
  43. #endif // TiRay4343
  44. #ifdef TiRay2530W
  45. //mLog::FINFO("TiRayDriver::Prepare get logger FPD.TiRay2530W");
  46. #endif // TiRay2530W
  47. #ifdef TiRay4343W
  48. //mLog::FINFO("TiRayDriver::Prepare get logger FPD.TiRay4343W");
  49. #endif // TiRay4343W
  50. }
  51. bool nsFPD::TiRayDriver::Connect()
  52. {
  53. //mLog::FINFO("--Func-- Driver Connect Start");
  54. bool bWired = false;
  55. bool bWireless = false;
  56. if (pObjDev == nullptr)
  57. {
  58. pObjDev = new FPDDeviceTiRay(EventCenter, m_ConfigFileName);
  59. }
  60. /*m_DetectorConfiguration.reset(new DetectorConfiguration(m_ConfigFileName));
  61. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  62. std::string strWiredIP = (std::string)objModeConfig["DetectorWiredIP"];
  63. std::string strWiressIP = (std::string)objModeConfig["DetectorWirelessIP"];
  64. bWired = CheckConnect(strWiredIP);
  65. if (strWiressIP != "0.0.0.0")
  66. bWireless = CheckConnect(strWiressIP);
  67. //mLog::FINFO("Driver Connect Over");
  68. if (bWired || bWireless)
  69. {
  70. m_bDriverConnect = true;
  71. return true;
  72. }
  73. else
  74. {
  75. m_bDriverConnect = false;
  76. return false;
  77. }*/
  78. m_bDriverConnect = true;
  79. return true;
  80. }
  81. void nsFPD::TiRayDriver::Disconnect()
  82. {
  83. //mLog::FINFO("--Func-- Driver Disconnect Start");
  84. m_bDriverConnect = false; //disconnect置为false
  85. //mLog::FINFO("Driver Disconnect Over");
  86. }
  87. bool nsFPD::TiRayDriver::isConnected() const
  88. {
  89. return m_bDriverConnect;
  90. }
  91. bool nsFPD::TiRayDriver::CheckConnect(std::string strIP)
  92. {
  93. CMyPingip obPingIp;
  94. if (!obPingIp.PingFunction(strIP.c_str()))
  95. {
  96. //mLog::FINFO("ping {$} Failed", strIP);
  97. return false;
  98. }
  99. return true;
  100. }
  101. auto nsFPD::TiRayDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
  102. {
  103. //mLog::FINFO("--Func-- Driver CreateDevice Start");
  104. auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
  105. pObjDev->CreateDevice();
  106. pObjDev->Register();
  107. //mLog::FINFO("Driver CreateDevice Over");
  108. return Device;
  109. }
  110. std::string nsFPD::TiRayDriver::DriverProbe()
  111. {
  112. //mLog::FINFO("--Func-- Driver DriverProbe Start");
  113. //mLog::FINFO("DriverProbe Config Name: {$}", m_ConfigFileName);
  114. ResDataObject r_config, HardwareInfo;
  115. if (r_config.loadFile(m_ConfigFileName.c_str()))
  116. {
  117. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  118. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  119. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  120. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  121. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  122. }
  123. else
  124. {
  125. HardwareInfo.add("MajorID", "Detector");
  126. HardwareInfo.add("MinorID", "DR");
  127. HardwareInfo.add("VendorID", "TiRay");
  128. #ifdef TiRay4343
  129. HardwareInfo.add("ProductID", "DY4343");
  130. #endif // TiRay4343
  131. #ifdef TiRay2530W
  132. HardwareInfo.add("ProductID", "DY2530W");
  133. #endif // TiRay2530W
  134. #ifdef TiRay4343W
  135. HardwareInfo.add("ProductID", "DY4343W");
  136. #endif // TiRay4343W
  137. HardwareInfo.add("SerialID", "Driver");
  138. }
  139. string str = HardwareInfo.encode();
  140. return str;
  141. }
  142. /***
  143. ** 获取ID和配置
  144. ***/
  145. std::string nsFPD::TiRayDriver::GetResource()
  146. {
  147. //mLog::FINFO("--Func-- Driver GetResource Start");
  148. ResDataObject r_config, temp;
  149. //mLog::FINFO("m_ConfigFileName:{$}", m_ConfigFileName);
  150. if (!temp.loadFile(m_ConfigFileName.c_str()))
  151. {
  152. return "";
  153. }
  154. m_ConfigAll = temp;
  155. r_config = temp["CONFIGURATION"];
  156. m_Configurations = r_config;
  157. ResDataObject DescriptionTemp;
  158. ResDataObject ListTemp;
  159. string strTemp = ""; //用于读取字符串配置信息
  160. int nTemp = -1; //用于读取整型配置信息
  161. string strValue = ""; //用于存储配置的值
  162. string strType = ""; //用于存储配置的类型 int/float/string...
  163. string strAccess = ""; //用于存储权限的类型 R/W/RW
  164. try
  165. {
  166. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  167. m_pAttribute->clear();
  168. m_pDescription->clear();
  169. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  170. {
  171. DescriptionTemp.clear();
  172. ListTemp.clear();
  173. //AttributeType
  174. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  175. DescriptionTemp.add(AttributeType, strTemp.c_str());
  176. strType = strTemp; //记录配置项的类型
  177. //AttributeKey
  178. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  179. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  180. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  181. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
  182. //2. 赋值
  183. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  184. if ("int" == strType)
  185. {
  186. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  187. }
  188. else if ("float" == strType)
  189. {
  190. (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
  191. }
  192. else //其它先按string类型处理
  193. {
  194. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  195. }
  196. //AttributeAccess
  197. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  198. DescriptionTemp.add(AttributeAccess, strTemp.c_str());
  199. //AttributeRangeMin
  200. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  201. if (strTemp != "") //不需要的配置项为空
  202. {
  203. DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
  204. }
  205. //AttributeRangeMax
  206. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  207. if (strTemp != "") //不需要的配置项为空
  208. {
  209. DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
  210. }
  211. //AttributeList
  212. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  213. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  214. {
  215. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  216. {
  217. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  218. auto temKey = std::to_string(nListIndex);
  219. ListTemp.add(temKey.c_str(), strTemp.c_str());
  220. }
  221. DescriptionTemp.add(AttributeList, ListTemp);
  222. }
  223. //AttributeRequired
  224. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  225. DescriptionTemp.add(AttributeRequired, strTemp.c_str());
  226. //AttributeDefaultValue
  227. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  228. if (strTemp != "") //不需要的配置项为空
  229. {
  230. DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
  231. }
  232. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  233. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  234. }
  235. }
  236. catch (ResDataObjectExption& e)
  237. {
  238. //mLog::FERROR("Get config FERROR: {$}", e.what());
  239. return "";
  240. }
  241. ResDataObject resDeviceResource;
  242. resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
  243. resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
  244. ResDataObject DescriptionTempEx;
  245. DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
  246. m_DeviceConfig = DescriptionTempEx;
  247. string res = DescriptionTempEx.encode();
  248. //mLog::FINFO("Driver GetResource Over");
  249. return res;
  250. }
  251. std::string nsFPD::TiRayDriver::DeviceProbe()
  252. {
  253. //mLog::FINFO("--Func-- Driver DeviceProbe Start");
  254. ResDataObject r_config, HardwareInfo;
  255. if (r_config.loadFile(m_ConfigFileName.c_str()))
  256. {
  257. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  258. HardwareInfo.add("MinorID", "Device");
  259. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  260. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  261. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  262. }
  263. else
  264. {
  265. HardwareInfo.add("MajorID", "Detector");
  266. HardwareInfo.add("MinorID", "Device");
  267. HardwareInfo.add("VendorID", "TiRay");
  268. #ifdef TiRay4343
  269. HardwareInfo.add("ProductID", "DY4343");
  270. #endif // TiRay4343
  271. #ifdef TiRay2530W
  272. HardwareInfo.add("ProductID", "DY2530W");
  273. #endif // TiRay2530W
  274. #ifdef TiRay4343W
  275. HardwareInfo.add("ProductID", "DY4343W");
  276. #endif // TiRay4343W
  277. HardwareInfo.add("SerialID", "1234");
  278. }
  279. string str = HardwareInfo.encode();
  280. //mLog::FINFO("Driver DeviceProbe Over");
  281. return str;
  282. }
  283. bool nsFPD::TiRayDriver::GetDeviceConfig(std::string& Cfg)
  284. {
  285. //mLog::FINFO("--Func-- Driver GetDeviceConfig Start");
  286. Cfg = m_DeviceConfig.encode();
  287. //mLog::FINFO("Cfg:{$}", Cfg);
  288. //mLog::FINFO("Driver GetDeviceConfig Over");
  289. return true;
  290. }
  291. bool nsFPD::TiRayDriver::SetDeviceConfig(std::string Cfg)
  292. {
  293. //mLog::FINFO("--Func-- Driver SetDeviceConfig Start");
  294. //mLog::FINFO("SetDeviceConfig {$}", Cfg.c_str());
  295. ResDataObject DeviceConfig;
  296. DeviceConfig.decode(Cfg.c_str());
  297. ResDataObject DescriptionTempEx;
  298. DescriptionTempEx = DeviceConfig["DeviceConfig"];
  299. bool bSaveFile = false; //true:重新保存配置文件
  300. string strAccess = "";
  301. for (int i = 0; i < DescriptionTempEx.size(); i++)
  302. {
  303. ResDataObject temp = DescriptionTempEx[i];
  304. //mLog::FINFO("{$}", temp.encode());
  305. for (int j = 0; j < temp.size(); j++)
  306. {
  307. string strKey = temp.GetKey(j);
  308. //mLog::FINFO("{$}", strKey.c_str());
  309. try
  310. {
  311. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  312. {
  313. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  314. if ("RW" == strAccess || "rw" == strAccess)
  315. {
  316. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  317. //1. 修改内存中的值,用于给上层发消息
  318. (*m_pAttribute)[strKey.c_str()] = temp[j];
  319. //2. 拿到Innerkey
  320. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  321. //mLog::FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
  322. string strTemp = ""; //存储AttributeKey
  323. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  324. {
  325. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  326. if (strTemp == strKey)
  327. {
  328. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  329. break;
  330. }
  331. }
  332. //3. 修改配置文件中的值
  333. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
  334. {
  335. bSaveFile = true;
  336. }
  337. }
  338. else
  339. {
  340. //mLog::FINFO("{$} is not a RW configuration item", strKey.c_str());
  341. }
  342. }
  343. }
  344. catch (ResDataObjectExption& e)
  345. {
  346. //mLog::FERROR("SetDeviceConfig crashed: {$}", e.what());
  347. return false;
  348. }
  349. }
  350. }
  351. if (bSaveFile)
  352. {
  353. //3. 重新保存配置文件
  354. SaveConfigFile(true);
  355. }
  356. //mLog::FINFO("Driver SetDeviceConfig Over");
  357. return true;
  358. }
  359. bool nsFPD::TiRayDriver::SaveConfigFile(bool bSendNotify)
  360. {
  361. //mLog::FINFO("--Func-- Driver SaveConfigFile Start");
  362. //mLog::FINFO("ConfigFileName:{$}", m_ConfigFileName);
  363. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  364. bool ret = m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  365. //mLog::FINFO("Driver SaveConfigFile Over");
  366. if (ret)
  367. {
  368. //mLog::FINFO("SaveConfigFile Success!");
  369. return true;
  370. }
  371. else
  372. {
  373. //mLog::FERROR("SaveConfigFile Fail!");
  374. return false;
  375. }
  376. }
  377. bool nsFPD::TiRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey,
  378. int nPathID, string& strValue)
  379. {
  380. //mLog::FINFO("--Func-- Driver GetDeviceConfigValue Start");
  381. strValue = "";
  382. string strTemp = pInnerKey;
  383. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  384. {
  385. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  386. {
  387. strValue = (string)config["connections"][pInnerKey];
  388. }
  389. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  390. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  391. {
  392. strValue = (string)config[pInnerKey];
  393. }
  394. else if (SyncType == strTemp || FPDWorkStation == strTemp ||
  395. ImageWidth == strTemp || ImageHeight == strTemp)
  396. {
  397. strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
  398. }
  399. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  400. TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp ||
  401. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  402. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  403. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  404. ShowTemperature == strTemp || ShowWifi == strTemp ||
  405. ShowBattery == strTemp || ShowBluetooth == strTemp ||
  406. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp ||
  407. CcosDetectorAttachedFlag == strTemp)
  408. {
  409. strValue = (string)config[pInnerKey];
  410. }
  411. else
  412. {
  413. strValue = "";
  414. //mLog::FERROR("FERROR Configuration item: {$}", pInnerKey);
  415. }
  416. }
  417. //mLog::FINFO("Driver GetDeviceConfigValue Over");
  418. return true;
  419. }
  420. bool nsFPD::TiRayDriver::SetDeviceConfigValue(ResDataObject &config, const char* pInnerKey,
  421. int nPathID, const char* szValue)
  422. {
  423. //mLog::FINFO("--Func-- Driver SetDeviceConfigValue Start");
  424. //mLog::FINFO("SetDeviceConfigValue change {$} item value to {$}", pInnerKey, szValue);
  425. string strTemp = pInnerKey;
  426. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  427. {
  428. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  429. {
  430. config["connections"][pInnerKey] = szValue;
  431. }
  432. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  433. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  434. {
  435. config[pInnerKey] = szValue;
  436. }
  437. else if (SyncType == strTemp || FPDWorkStation == strTemp ||
  438. ImageWidth == strTemp || ImageHeight == strTemp)
  439. {
  440. config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
  441. }
  442. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  443. TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
  444. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  445. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  446. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  447. ShowTemperature == strTemp || ShowWifi == strTemp ||
  448. ShowBattery == strTemp || ShowBluetooth == strTemp ||
  449. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp ||
  450. CcosDetectorAttachedFlag == strTemp)
  451. {
  452. config[pInnerKey] = szValue;
  453. }
  454. else
  455. {
  456. //mLog::FERROR("FERROR Configuration item: {$}", pInnerKey);
  457. return false;
  458. }
  459. }
  460. //mLog::FINFO("Driver SetDeviceConfigValue Over");
  461. return true;
  462. }
  463. nsFPD::FPDDeviceTiRay::FPDDeviceTiRay(std::shared_ptr<IOEventCenter> center, std::string strConfigPath)
  464. : m_nFPDExpReadyTime(1000),
  465. m_nCalibTotalExposureNum{},
  466. m_nCalibCurrentCalibrationRound{1},
  467. m_nCalibCurrentExposureIndex{},
  468. m_nCalibCurrentExposureNum{},
  469. m_nFullImageHeight{},
  470. m_nFullImageWidth{},
  471. m_nImgBits{},
  472. m_nPixelSpacing{},
  473. m_nSensitivity{},
  474. m_fDose{},
  475. m_fFactorEXI2UGY{},
  476. m_eSyncMode(SYNC_SOFTWARE),
  477. m_eAppStatus(APP_STATUS_IDLE),
  478. m_bDeviceConnect(false),
  479. m_pFullImgBuffer(nullptr)
  480. {
  481. m_strWorkPath = GetProcessDirectory();
  482. m_DetectorCtrlUnit.reset(new OemCtrl(center, this));
  483. m_AcqUnit.reset(new OemAcq(center, this));
  484. m_SyncUnit.reset(new OemSync(center, this));
  485. m_CalibUnit.reset(new OemCalib(center, this));
  486. m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
  487. std::string strErrorInfoPath = m_strWorkPath + "\\OEMDrivers\\Detector\\Conf\\";
  488. //m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, strErrorInfoPath));
  489. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
  490. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  491. EventCenter = center;
  492. }
  493. nsFPD::FPDDeviceTiRay::~FPDDeviceTiRay()
  494. {
  495. if (nullptr != m_pFullImgBuffer)
  496. {
  497. delete[] m_pFullImgBuffer;
  498. m_pFullImgBuffer = nullptr;
  499. }
  500. }
  501. std::string nsFPD::FPDDeviceTiRay::GetGUID() const
  502. {
  503. return DetectorUnitType;
  504. }
  505. bool nsFPD::FPDDeviceTiRay::Prepare()
  506. {
  507. //mLog::FINFO("--Func Device-- Prepare Start");
  508. //EventCenter->OnMaxBlockSize("DrTiRay", 4000 * 4000 * 2, 6, 1500 * 1500 * 2, 2);
  509. Connect();
  510. //mLog::FINFO("Device Prepare Over");
  511. return true;
  512. }
  513. bool nsFPD::FPDDeviceTiRay::CreateDevice()
  514. {
  515. //mLog::FINFO("--Func Device-- CreateDevice Start");
  516. if (!LoadConfig())
  517. {
  518. return false;
  519. }
  520. if (nullptr == g_pDetector)
  521. {
  522. g_pDetector = new Detector_TiRayDR();
  523. }
  524. g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
  525. //mLog::FINFO("Device CreateDevice Over");
  526. return true;
  527. }
  528. void nsFPD::FPDDeviceTiRay::Register()
  529. {
  530. //mLog::FINFO("--Func Device-- Register Start");
  531. auto Disp = m_Dispatch.Lock().As();
  532. RegisterCtrl(Disp);
  533. RegisterAcq(Disp);
  534. RegisterSync(Disp);
  535. RegisterCalib(Disp);
  536. RegisterOthers(Disp);
  537. //mLog::FINFO("Device Register Over");
  538. }
  539. RET_STATUS nsFPD::FPDDeviceTiRay::ScanDetector(string& strDetectorInfo)
  540. {
  541. if (nullptr == g_pDetector)
  542. {
  543. std::cerr << "[FPDDeviceTiRay::ScanDetector] g_pDetector is not initialized!" << std::endl;
  544. return RET_STATUS::RET_FAILED;
  545. }
  546. return g_pDetector->ScanDetector(strDetectorInfo) ?
  547. RET_STATUS::RET_SUCCEED : RET_STATUS::RET_FAILED;
  548. }
  549. RET_STATUS nsFPD::FPDDeviceTiRay::Connect()
  550. {
  551. //mLog::FINFO("--Func Device-- Connect Start");
  552. m_DetectorCtrlUnit->SetAttachStatus(to_string(1)); //没有attach功能,直接上发1,使客户端显示探测器状态
  553. RET_STATUS ret = RET_STATUS::RET_FAILED;
  554. if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
  555. {
  556. m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode);
  557. string strTemp = (string)m_DetectorConfiguration->m_Configurations["SerialNumber"];
  558. m_DetectorCtrlUnit->SetSerialNumber(strTemp);
  559. //m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate);
  560. //m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime);
  561. if (m_stDeviceConfig.bSupportDDR) //是否支持DDR采集功能
  562. {
  563. m_DetectorCtrlUnit->SetSupportDDR("YES");
  564. }
  565. else
  566. {
  567. m_DetectorCtrlUnit->SetSupportDDR("NO");
  568. }
  569. ret = RET_STATUS::RET_SUCCEED;
  570. }
  571. //mLog::FINFO("Device Connect Over");
  572. return ret;
  573. }
  574. RET_STATUS nsFPD::FPDDeviceTiRay::EnterExam(int nExamMode)
  575. {
  576. //mLog::FINFO("--Func Device-- EnterExam Start");
  577. switch (nExamMode)
  578. {
  579. case APP_STATUS_WORK_BEGIN:
  580. //mLog::FINFO("Enter into Exam Windows");
  581. m_eAppStatus = APP_STATUS_WORK_BEGIN;
  582. //mLog::FINFO("m_stDeviceConfig.strLastCalibrationDate:{$}", m_stDeviceConfig.strLastCalibrationDate);
  583. //进检查时判断当前校正文件是否过期,如果即将过期或者已过期都向上通知
  584. //if (m_stDeviceConfig.strLastCalibrationDate == "0000-00-00 00:00:00")
  585. //{
  586. // //没有做过校正
  587. // //mLog::FWARN("No calibration file, please make a calibration!");
  588. // //m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_NOT_EXIST, "");
  589. //}
  590. //else
  591. //{
  592. // time_t lastCalibDate = StringToDatetime(m_stDeviceConfig.strLastCalibrationDate);
  593. // int nExpireTime = std::stoi(m_stDeviceConfig.strCalibrationFileExpireTime);//单位:天
  594. // //mLog::FINFO("nExpireTime:{$}", nExpireTime);
  595. // time_t localtime = time(NULL);
  596. // //判断是否过期
  597. // if (localtime > lastCalibDate + nExpireTime * 24 * 3600)
  598. // {
  599. // //过期了报错
  600. // //mLog::FWARN("Calibration file is expired! please make a calibration!");
  601. // //m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_OUTDATE, "");
  602. // }
  603. //}
  604. break;
  605. case APP_STATUS_WORK_END:
  606. //mLog::FINFO("Quit Exam Windows");
  607. m_eAppStatus = APP_STATUS_WORK_END;
  608. break;
  609. case APP_STATUS_DETSHARE_BEGIN:
  610. //mLog::FINFO("Enter into Detector Share Windows");
  611. m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
  612. break;
  613. case APP_STATUS_DETSHAR_END:
  614. //mLog::FINFO("Quit Detector Share Windows");
  615. m_eAppStatus = APP_STATUS_DETSHAR_END;
  616. break;
  617. case APP_STATUS_CAL_BEGIN:
  618. //mLog::FINFO("Enter into Calibration Windows");
  619. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  620. break;
  621. case APP_STATUS_CAL_END:
  622. //mLog::FINFO("Quit Calibration Windows");
  623. m_eAppStatus = APP_STATUS_CAL_END;
  624. break;
  625. case APP_STATUS_WORK_IN_SENSITIVITY:
  626. //mLog::FINFO("Enter into sensitivity test interface");
  627. m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
  628. break;
  629. default:
  630. break;
  631. }
  632. g_pDetector->EnterExamMode(nExamMode);
  633. //mLog::FINFO("Device EnterExam Over");
  634. return RET_STATUS::RET_SUCCEED;
  635. }
  636. RET_STATUS nsFPD::FPDDeviceTiRay::SetAcqMode(string strMode)
  637. {
  638. //mLog::FINFO("--Func Device-- SetAcqMode Start");
  639. RET_STATUS ret = RET_STATUS::RET_FAILED;
  640. //如果没连接,不执行
  641. if (!m_bDeviceConnect)
  642. {
  643. //mLog::FERROR("Detector not connected, return");
  644. return ret;
  645. }
  646. //设置采集模式时发一次非Standby状态,配合子系统走流程,使界面ready状态和探测器同步
  647. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  648. int nMode = AcqMode::RAD;
  649. try
  650. {
  651. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  652. m_nFullImageWidth = (int)objModeConfig["ModeTable"][0]["ImageWidth"];
  653. m_nFullImageHeight = (int)objModeConfig["ModeTable"][0]["ImageHeight"];
  654. m_nImgBits = (int)objModeConfig["ModeTable"][0]["PhySizeInfoBit"];
  655. m_nPixelSpacing = (int)objModeConfig["ModeTable"][0]["PixelPitch"];
  656. m_nSensitivity = (int)objModeConfig["ModeTable"][0]["Sensitivity"];
  657. m_nFPDExpReadyTime = (int)objModeConfig["ModeTable"][0]["XWindow"];
  658. if (nullptr != m_pFullImgBuffer)
  659. {
  660. delete[]m_pFullImgBuffer;
  661. m_pFullImgBuffer = nullptr;
  662. }
  663. m_pFullImgBuffer = new unsigned short[(size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight];
  664. m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false);
  665. m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
  666. string strDoseOfExi = std::to_string(m_nSensitivity);
  667. m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  668. //mLog::FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY);
  669. m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
  670. //读取校正时的目标EXI
  671. int nTargetCalibExi = (int)objModeConfig["ModeTable"][0]["TargetGainEXI"];
  672. m_nTargetCalibExi = nTargetCalibExi;
  673. //mLog::FINFO("m_nTargetCalibExi:{$}", m_nTargetCalibExi);
  674. if (g_pDetector->SetAcqMode(nMode))
  675. {
  676. ret = RET_STATUS::RET_SUCCEED;
  677. m_AcqUnit->AcqModeNotify(strMode);
  678. }
  679. else
  680. {
  681. ret = RET_STATUS::RET_FAILED;
  682. }
  683. }
  684. catch (ResDataObjectExption& e)
  685. {
  686. //mLog::FERROR("Read configuration failed, Error code: {$}", e.what());
  687. }
  688. //mLog::FINFO("Device SetAcqMode Over");
  689. return ret;
  690. }
  691. RET_STATUS nsFPD::FPDDeviceTiRay::GetSyncMode(SYNC_MODE& eSyncMode)
  692. {
  693. //mLog::FINFO("--Func Device-- GetSyncMode Start");
  694. eSyncMode = m_eSyncMode;
  695. //mLog::FINFO("Device GetSyncMode Over");
  696. return RET_STATUS::RET_SUCCEED;
  697. }
  698. RET_STATUS nsFPD::FPDDeviceTiRay::PrepareAcquisition()
  699. {
  700. //mLog::FINFO("--Func Device-- PrepareAcquisition Start");
  701. RET_STATUS ret = RET_STATUS::RET_FAILED;
  702. if (!m_bDeviceConnect)
  703. {
  704. //mLog::FERROR("Detector not connected, return");
  705. return ret;
  706. }
  707. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  708. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  709. {
  710. //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status");
  711. }
  712. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  713. {
  714. //mLog::FERROR("Detector already at Acq status");
  715. ret = RET_STATUS::RET_SUCCEED;
  716. }
  717. else
  718. {
  719. m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
  720. if (g_pDetector->PrepareAcquisition(this))
  721. {
  722. ret = RET_STATUS::RET_SUCCEED;
  723. }
  724. }
  725. //mLog::FINFO("Device PrepareAcquisition Over");
  726. return ret;
  727. }
  728. RET_STATUS nsFPD::FPDDeviceTiRay::StartAcquisition(string in)
  729. {
  730. //mLog::FINFO("--Func Device-- StartAcquisition Start");
  731. RET_STATUS ret = RET_STATUS::RET_FAILED;
  732. if (!m_bDeviceConnect)
  733. {
  734. //mLog::FERROR("Detector not connected, return");
  735. return ret;
  736. }
  737. if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
  738. {
  739. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  740. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  741. {
  742. //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status.");
  743. }
  744. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  745. {
  746. //mLog::FERROR("Detector already at Acq status.");
  747. }
  748. }
  749. else
  750. {
  751. if (g_pDetector->StartAcquisition(this))
  752. {
  753. ret = RET_STATUS::RET_SUCCEED;
  754. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  755. }
  756. else
  757. {
  758. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  759. }
  760. }
  761. //mLog::FINFO("Device StartAcquisition Over");
  762. return ret;
  763. }
  764. RET_STATUS nsFPD::FPDDeviceTiRay::StopAcquisition()
  765. {
  766. //mLog::FINFO("--Func Device-- StopAcquisition Start");
  767. RET_STATUS ret = RET_STATUS::RET_FAILED;
  768. if (!m_bDeviceConnect)
  769. {
  770. //mLog::FERROR("Detector not connected, return");
  771. return ret;
  772. }
  773. if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
  774. {
  775. //mLog::FINFO("Detector already at Acq status.");
  776. ret = RET_STATUS::RET_SUCCEED;
  777. }
  778. else
  779. {
  780. if (g_pDetector->StopAcquisition(this))
  781. {
  782. ret = RET_STATUS::RET_SUCCEED;
  783. //m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  784. }
  785. }
  786. //mLog::FINFO("Device StopAcquisition Over");
  787. return ret;
  788. }
  789. RET_STATUS nsFPD::FPDDeviceTiRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
  790. {
  791. //mLog::FINFO("--Func Device-- ActiveCalibration Start");
  792. //mLog::FINFO("ActiveCalibration {$}", (int)eType);
  793. RET_STATUS ret = RET_STATUS::RET_FAILED;
  794. if (!m_bDeviceConnect)
  795. {
  796. //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
  797. return ret;
  798. }
  799. if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
  800. {
  801. //mLog::FERROR("calibration type is invalid!");
  802. return RET_STATUS::RET_INVALID;
  803. }
  804. else
  805. {
  806. m_CalibType = eType;
  807. }
  808. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  809. if (eType == CCOS_CALIBRATION_TYPE_XRAY)
  810. {
  811. //mLog::FINFO("calibration type: XRAY");
  812. int nCalibrationRounds = (int)m_CalibDoseList.size();
  813. g_pDetector->SetCalibRounds(nCalibrationRounds);
  814. }
  815. if (g_pDetector->ActiveCalibration(this, eType))
  816. {
  817. ret = RET_STATUS::RET_SUCCEED;
  818. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  819. m_CalibUnit->SetCalibrationProgress("0");
  820. }
  821. else
  822. {
  823. //mLog::FERROR("Active calibration failed");
  824. ret = RET_STATUS::RET_FAILED;
  825. }
  826. //重置校正流程参数
  827. m_nCalibCurrentCalibrationRound = 1;
  828. m_nCalibCurrentExposureIndex = 1;
  829. m_nCalibCurrentExposureNum = 0;
  830. //mLog::FINFO("Device ActiveCalibration Over");
  831. return ret;
  832. }
  833. RET_STATUS nsFPD::FPDDeviceTiRay::PrepareCalibration()
  834. {
  835. //mLog::FINFO("--Func Device-- PrepareCalibration Start");
  836. RET_STATUS ret = RET_STATUS::RET_FAILED;
  837. if (!m_bDeviceConnect)
  838. {
  839. //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
  840. return ret;
  841. }
  842. if (g_pDetector->PrepareCalibration(this))
  843. {
  844. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_PREPARE));
  845. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  846. if (nCalibrationType == CCOS_CALIBRATION_TYPE_XRAY && m_eSyncMode == SYNC_AED)
  847. {
  848. //mLog::FINFO("set m_bEnterAcqStatus true");
  849. }
  850. ret = RET_STATUS::RET_SUCCEED;
  851. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  852. }
  853. else
  854. {
  855. //mLog::FERROR("PrepareCalibration failed!");
  856. return ret;
  857. }
  858. //mLog::FINFO("Device PrepareCalibration Over");
  859. return ret;
  860. }
  861. RET_STATUS nsFPD::FPDDeviceTiRay::GetRequestedDose(std::string& strDose)
  862. {
  863. //mLog::FINFO("--Func Device-- GetRequestedDose Start");
  864. RET_STATUS ret = RET_STATUS::RET_FAILED;
  865. ResDataObject out;
  866. if (!m_bDeviceConnect)
  867. {
  868. //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
  869. return ret;
  870. }
  871. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  872. //mLog::FINFO("GetRequestedDose calib type is {$}", (int)nCalibrationType);
  873. if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
  874. {
  875. out.add("Dose", 0.0f);
  876. out.add("kV", 0.0f);
  877. out.add("mA", 0.0f);
  878. out.add("ms", 0.0f);
  879. out.add("mAs", 0.0f);
  880. }
  881. else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
  882. {
  883. //mLog::FINFO("calib dose list size is {$}", m_CalibDoseList.size());
  884. ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
  885. int nTargetExi = (int)temp["TargetGainEXI"];
  886. m_DetectorCtrlUnit->SetTargetEXI(std::to_string(nTargetExi));
  887. //mLog::FINFO("nTargetExi:{$}", nTargetExi);
  888. out.add("Dose", nTargetExi);
  889. out.add("kV", temp["KV"]);
  890. out.add("mA", temp["MA"]);
  891. out.add("ms", temp["MS"]);
  892. out.add("mAs", temp["MAS"]);
  893. }
  894. else
  895. {
  896. //mLog::FERROR("Don't support CalibrationType($)", (int)nCalibrationType);
  897. return ret;
  898. }
  899. strDose = out.encode();
  900. //mLog::FINFO("GetRequestedDose:{$}", strDose);
  901. ret = RET_STATUS::RET_SUCCEED;
  902. //mLog::FINFO("Device GetRequestedDose Over");
  903. return ret;
  904. }
  905. RET_STATUS nsFPD::FPDDeviceTiRay::SetRequestedDose(std::string strDose)
  906. {
  907. //mLog::FINFO("--Func Device-- SetRequestedDose Start");
  908. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  909. //mLog::FINFO("SetRequestedDose Over");
  910. return Ret;
  911. }
  912. RET_STATUS nsFPD::FPDDeviceTiRay::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
  913. {
  914. //mLog::FINFO("--Func Device-- GetCalibrationStep Start");
  915. cout << "--Func Device-- GetCalibrationStep Start. DetectorID: " << nDetectorID << endl;
  916. RET_STATUS ret = RET_STATUS::RET_SUCCEED;
  917. ResDataObject out;
  918. int nCalibrationRounds = (int)m_CalibDoseList.size();
  919. int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
  920. if (g_pDetector->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound))
  921. {
  922. cout << "g_pDetector->GetCalibrationStep success" << endl;
  923. //mLog::FINFO("GetCalibrationStep success");
  924. }
  925. else
  926. {
  927. cout << "g_pDetector->GetCalibrationStep failed" << endl;
  928. //mLog::FERROR("GetCalibrationStep error");
  929. ret = RET_STATUS::RET_FAILED;
  930. return ret;
  931. }
  932. out.add("CalibrationRounds", (int)m_CalibDoseList.size());
  933. out.add("TotalExposureNum", m_nCalibTotalExposureNum);
  934. out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
  935. out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]);
  936. out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
  937. out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
  938. cout << "Calibration info - Rounds: " << nCalibrationRounds
  939. << ", TotalExposures: " << m_nCalibTotalExposureNum
  940. << ", CurrentRound: " << m_nCalibCurrentCalibrationRound
  941. << ", CurrentIndex: " << m_nCalibCurrentExposureIndex << endl;
  942. strCalibrationStepInfo = out.encode();
  943. cout << "strCalibrationStepInfo: " << strCalibrationStepInfo << endl;
  944. cout << "Device GetCalibrationStep Over. Return: " << ret << endl;
  945. //mLog::FINFO("strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
  946. //mLog::FINFO("Device GetCalibrationStep Over");
  947. return ret;
  948. }
  949. RET_STATUS nsFPD::FPDDeviceTiRay::StartCalibration()
  950. {
  951. //mLog::FINFO("--Func Device-- StartCalibration Start");
  952. RET_STATUS ret = RET_STATUS::RET_FAILED;
  953. if (!m_bDeviceConnect)
  954. {
  955. //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
  956. return ret;
  957. }
  958. if (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PREPARE)
  959. {
  960. //mLog::FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus());
  961. return ret;
  962. }
  963. if (g_pDetector->StartCalibration(this))
  964. {
  965. //mLog::FINFO("start calibration success set detector status");
  966. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  967. ret = RET_STATUS::RET_SUCCEED;
  968. if (m_eSyncMode == SYNC_AED)
  969. {
  970. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartCalibration
  971. }
  972. }
  973. else
  974. {
  975. //mLog::FERROR("StartCalibration failed");
  976. ret = RET_STATUS::RET_FAILED;
  977. return ret;
  978. }
  979. //mLog::FINFO("Device StartCalibration Over");
  980. return ret;
  981. }
  982. RET_STATUS nsFPD::FPDDeviceTiRay::StopCalibration()
  983. {
  984. //mLog::FINFO("--Func Device-- StopCalibration Start");
  985. RET_STATUS ret = RET_STATUS::RET_FAILED;
  986. if (!m_bDeviceConnect)
  987. {
  988. //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
  989. return ret;
  990. }
  991. m_eAppStatus = APP_STATUS_CAL_END;
  992. if (g_pDetector->StopCalibration(this))
  993. {
  994. ret = RET_STATUS::RET_SUCCEED;
  995. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
  996. }
  997. else
  998. {
  999. //mLog::FERROR("StopCalibration failed");
  1000. }
  1001. //mLog::FINFO("Device StopCalibration Over");
  1002. return ret;
  1003. }
  1004. RET_STATUS nsFPD::FPDDeviceTiRay::AbortCalibration()
  1005. {
  1006. //mLog::FINFO("--Func Device-- AbortCalibration Start");
  1007. m_eAppStatus = APP_STATUS_CAL_END;
  1008. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  1009. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1010. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  1011. m_CalibUnit->SetCalibrationProgress("100");
  1012. if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
  1013. {
  1014. g_pDetector->AbortCalibration(this);
  1015. m_AcqUnit->SendNoNeedWaitImage(true);
  1016. }
  1017. //如果中止的时候探测器在采集状态需要停止采集
  1018. return RET_STATUS::RET_SUCCEED;
  1019. //mLog::FINFO("Device AbortCalibration Over");
  1020. }
  1021. RET_STATUS nsFPD::FPDDeviceTiRay::AcceptCalibration()
  1022. {
  1023. //mLog::FINFO("--Func Device-- AcceptCalibration Start");
  1024. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1025. if (g_pDetector->AcceptCalibration())
  1026. {
  1027. //mLog::FINFO("AcceptCalibration success");
  1028. Ret = RET_STATUS::RET_SUCCEED;
  1029. }
  1030. else
  1031. {
  1032. //mLog::FERROR("AcceptCalibration error");
  1033. Ret = RET_STATUS::RET_FAILED;
  1034. }
  1035. int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
  1036. //完成校正条件:轮数够了,曝光次数够了
  1037. if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
  1038. {
  1039. //mLog::FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
  1040. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1041. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1042. m_CalibUnit->SetCalibrationProgress("100");
  1043. return Ret;
  1044. }
  1045. if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
  1046. {
  1047. m_nCalibCurrentCalibrationRound++;
  1048. m_nCalibCurrentExposureIndex = 1;
  1049. }
  1050. else
  1051. {
  1052. m_nCalibCurrentExposureIndex++;
  1053. }
  1054. m_nCalibCurrentExposureNum++;
  1055. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1056. //mLog::FINFO("Device AcceptCalibration Over");
  1057. return Ret;
  1058. }
  1059. RET_STATUS nsFPD::FPDDeviceTiRay::RejectCalibration()
  1060. {
  1061. //mLog::FINFO("--Func Device-- RejectCalibration Start");
  1062. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1063. if (g_pDetector->RejectCalibration())
  1064. {
  1065. Ret = RET_STATUS::RET_SUCCEED;
  1066. }
  1067. else
  1068. {
  1069. //mLog::FERROR("RejectCalibration error");
  1070. Ret = RET_STATUS::RET_FAILED;
  1071. }
  1072. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1073. //mLog::FINFO("Device RejectCalibration Over");
  1074. return Ret;
  1075. }
  1076. RET_STATUS nsFPD::FPDDeviceTiRay::ActiveDetector(bool bActive)
  1077. {
  1078. //mLog::FINFO("--Func Device-- ActiveDetector Start");
  1079. if (!m_stDeviceConfig.bConnectStatus)
  1080. {
  1081. return RET_STATUS::RET_THREAD_INVALID;
  1082. }
  1083. //mLog::FINFO("Device ActiveDetector Over");
  1084. return RET_STATUS::RET_SUCCEED;
  1085. }
  1086. RET_STATUS nsFPD::FPDDeviceTiRay::CompleteCalibration()
  1087. {
  1088. //mLog::FINFO("--Func Device-- CompleteCalibration Start");
  1089. if (!g_pDetector->CompleteCalibration(this))
  1090. {
  1091. //mLog::FERROR("CompleteCalibration fail!");
  1092. return RET_STATUS::RET_FAILED;
  1093. }
  1094. if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_DARK)
  1095. {
  1096. //mLog::FINFO("CompleteCalibration Calibration Type DARK");
  1097. }
  1098. else if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_XRAY)
  1099. {
  1100. //mLog::FINFO("CompleteCalibration Calibration Type XRAY");
  1101. m_eAppStatus = APP_STATUS_CAL_END;
  1102. }
  1103. //mLog::FINFO("CompleteCalibration set detector status standby");
  1104. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1105. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1106. m_CalibUnit->SetCalibrationProgress("100");
  1107. //mLog::FINFO("Device CompleteCalibration Over");
  1108. return RET_STATUS::RET_SUCCEED;
  1109. }
  1110. RET_STATUS nsFPD::FPDDeviceTiRay::SaveCalibrationFile(bool bSaveFlag)
  1111. {
  1112. //mLog::FINFO("--Func Device-- SaveCalibrationFile Start");
  1113. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1114. //mLog::FINFO("SaveCalibrationFile bSaveFlag: {$}", bSaveFlag);
  1115. if (!bSaveFlag)
  1116. {
  1117. //mLog::FERROR("Not save calibration file");
  1118. return Ret;
  1119. }
  1120. //点击save按钮时先调用compelte再调用save
  1121. CompleteCalibration();
  1122. if (g_pDetector->SaveCalibrationFile())
  1123. {
  1124. m_CalibUnit->SetSaveCalibrationFileFinish(true);
  1125. Ret = RET_STATUS::RET_SUCCEED;
  1126. //更新配置文件中校正日期和时间
  1127. time_t localtime = time(NULL);
  1128. string strLocalTime = DatetimeToString(localtime);
  1129. //mLog::FINFO("strLocalTime:{$}", strLocalTime);
  1130. m_CalibUnit->SetLastCalibrationDate(strLocalTime);
  1131. //mLog::FINFO("m_CalibUnit->SetLastCalibrationDate Over");
  1132. //清除校正文件相关警告
  1133. //m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
  1134. //m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
  1135. }
  1136. else
  1137. {
  1138. //mLog::FERROR("SaveCalibrationFile error");
  1139. m_CalibUnit->SetSaveCalibrationFileFinish(false);
  1140. Ret = RET_STATUS::RET_FAILED;
  1141. }
  1142. //mLog::FINFO("Device SaveCalibrationFile Over");
  1143. return Ret;
  1144. }
  1145. bool nsFPD::FPDDeviceTiRay::Support_DarkCalib()
  1146. {
  1147. return true;
  1148. }
  1149. bool nsFPD::FPDDeviceTiRay::Support_XrayCalib()
  1150. {
  1151. return true;
  1152. }
  1153. void nsFPD::FPDDeviceTiRay::SendTemperatureValue(float fValue)
  1154. {
  1155. int nStatus = 0;
  1156. m_Temperature->SetTemperature(fValue, nStatus);
  1157. //mLog::FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
  1158. return;
  1159. }
  1160. void nsFPD::FPDDeviceTiRay::SendWifiValue(int nValue)
  1161. {
  1162. int nStatus = 0;
  1163. m_Wifi->SetSignalValue(nValue, nStatus);
  1164. //mLog::FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
  1165. return;
  1166. }
  1167. void nsFPD::FPDDeviceTiRay::SendBatteryValue(int nValue)
  1168. {
  1169. int nStatus = 0;
  1170. m_Battery->SetRemainPowerValue(nValue, nStatus);
  1171. //mLog::FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
  1172. return;
  1173. }
  1174. bool nsFPD::FPDDeviceTiRay::LoadConfig()
  1175. {
  1176. //mLog::FINFO("--Func Device-- LoadConfig Start");
  1177. if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_CalibDoseList, m_nCalibTotalExposureNum))
  1178. {
  1179. //mLog::FERROR("Load configuration file failed!!!");
  1180. return false;
  1181. }
  1182. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  1183. m_nFullImageWidth = (int)objModeConfig["ModeTable"][0]["ImageWidth"];
  1184. m_nFullImageHeight = (int)objModeConfig["ModeTable"][0]["ImageHeight"];
  1185. m_nImgBits = (int)objModeConfig["ModeTable"][0]["PhySizeInfoBit"];
  1186. m_nPixelSpacing = (int)objModeConfig["ModeTable"][0]["PixelPitch"];
  1187. m_nSensitivity = (int)objModeConfig["ModeTable"][0]["Sensitivity"];
  1188. m_nFPDExpReadyTime = (int)objModeConfig["ModeTable"][0]["XWindow"];
  1189. if (nullptr != m_pFullImgBuffer)
  1190. {
  1191. delete[]m_pFullImgBuffer;
  1192. m_pFullImgBuffer = nullptr;
  1193. }
  1194. m_pFullImgBuffer = new unsigned short[(size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight];
  1195. m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false);
  1196. m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
  1197. string strDoseOfExi = std::to_string(m_nSensitivity);
  1198. m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  1199. m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
  1200. //读取校正时的目标EXI
  1201. int nTargetCalibExi = (int)objModeConfig["ModeTable"][0]["TargetGainEXI"];
  1202. m_nTargetCalibExi = nTargetCalibExi;
  1203. ////mLog::FINFO("m_CalibDoseList:{$}", m_CalibDoseList.encode());
  1204. ////mLog::FINFO("m_nCalibTotalExposureNum:{$}", m_nCalibTotalExposureNum);
  1205. //m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode);
  1206. //m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate);
  1207. //m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime);
  1208. m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0,
  1209. m_stDeviceConfig.nBatteryLimit,
  1210. m_stDeviceConfig.nBatteryWarning,
  1211. 100,
  1212. m_stDeviceConfig.nBatteryLimit,
  1213. 100, 100, 0, EventCenter));
  1214. m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f, m_stDeviceConfig.fTemperatureErrorMin,
  1215. m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax,
  1216. m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax,
  1217. m_stDeviceConfig.fTemperatureErrorMax, 0.0f, EventCenter));
  1218. m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning,
  1219. 100, m_stDeviceConfig.nWifiLimit, 100, 100, 0, EventCenter));
  1220. //mLog::FINFO("Device LoadConfig Over");
  1221. return true;
  1222. }
  1223. void nsFPD::FPDDeviceTiRay::RegisterCtrl(nsDetail::Dispatch* Dispatch)
  1224. {
  1225. Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
  1226. Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
  1227. Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
  1228. Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum);
  1229. Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
  1230. Dispatch->Action.Push(ActionKey::ScanDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSScanDetector);
  1231. Dispatch->Action.Push(ActionKey::ConnectDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSConnectDetector);
  1232. Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
  1233. Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
  1234. Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
  1235. Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
  1236. Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
  1237. Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
  1238. Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
  1239. Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
  1240. Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);//CcosDetectorAttachedFlag
  1241. Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR);
  1242. Dispatch->Get.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSerialNumber);
  1243. Dispatch->Set.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetConnectStatus);
  1244. Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus);
  1245. Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType);
  1246. Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription);
  1247. Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID);
  1248. Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData);
  1249. Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI);
  1250. Dispatch->Set.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus);
  1251. Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR);
  1252. Dispatch->Set.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSerialNumber);
  1253. Dispatch->Update.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateSerialNumber);
  1254. }
  1255. void nsFPD::FPDDeviceTiRay::RegisterAcq(nsDetail::Dispatch* Dispatch)
  1256. {
  1257. Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
  1258. Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode);
  1259. Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
  1260. Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
  1261. Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
  1262. Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState);
  1263. Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage);
  1264. }
  1265. void nsFPD::FPDDeviceTiRay::RegisterSync(nsDetail::Dispatch* Dispatch)
  1266. {
  1267. Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
  1268. Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
  1269. Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
  1270. Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
  1271. Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
  1272. Dispatch->Action.Push(ActionKey::ActiveSyncMode, m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode);
  1273. Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
  1274. Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
  1275. Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
  1276. Dispatch->Get.Push(AttrKey::FPDExpReady, m_SyncUnit.get(), &SyncUnit::JSGetExpReadyStatus);
  1277. Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
  1278. Dispatch->Get.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode);
  1279. Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
  1280. Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus);
  1281. Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
  1282. Dispatch->Set.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::SetSupportSyncMode);
  1283. }
  1284. void nsFPD::FPDDeviceTiRay::RegisterCalib(nsDetail::Dispatch* Dispatch)
  1285. {
  1286. Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
  1287. Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
  1288. Dispatch->Action.Push(ActionKey::SetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose);
  1289. Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
  1290. Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
  1291. Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
  1292. Dispatch->Action.Push(ActionKey::AbortCalibration, m_CalibUnit.get(), &CalibUnit::JSAbortCalibration);
  1293. Dispatch->Action.Push(ActionKey::CompleteCalibration, m_CalibUnit.get(), &CalibUnit::JSCompleteCalibration);
  1294. Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
  1295. Dispatch->Action.Push(ActionKey::AcceptCalibration, m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration);
  1296. Dispatch->Action.Push(ActionKey::RejectCalibration, m_CalibUnit.get(), &CalibUnit::JSRejectCalibration);
  1297. Dispatch->Action.Push(ActionKey::SaveCalibrationFile, m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile);
  1298. Dispatch->Action.Push(ActionKey::GetCalibrationStep, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep);
  1299. Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
  1300. Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
  1301. Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
  1302. Dispatch->Get.Push(AttrKey::SupportCalibrationType, m_CalibUnit.get(), &CalibUnit::JSGetSupportCalibrationType);
  1303. Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
  1304. Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
  1305. Dispatch->Get.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSGetCalibMode);
  1306. Dispatch->Get.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSGetLastCalibrationDate);
  1307. Dispatch->Get.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpireTime);
  1308. Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus);
  1309. Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress);
  1310. Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult);
  1311. Dispatch->Set.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::SetLastCalibrationDate);
  1312. Dispatch->Set.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpireTime);
  1313. Dispatch->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode);
  1314. Dispatch->Update.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSUpdateLastCalibrationDate);
  1315. Dispatch->Update.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpireTime);
  1316. }
  1317. void nsFPD::FPDDeviceTiRay::RegisterOthers(nsDetail::Dispatch* Dispatch)
  1318. {
  1319. Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
  1320. Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
  1321. Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
  1322. Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
  1323. Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
  1324. Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
  1325. Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
  1326. Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax);
  1327. Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin);
  1328. Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
  1329. Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
  1330. Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
  1331. Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
  1332. //Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
  1333. Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
  1334. Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
  1335. Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
  1336. Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
  1337. Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax);
  1338. Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin);
  1339. Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
  1340. Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
  1341. Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
  1342. Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
  1343. Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
  1344. Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
  1345. Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
  1346. Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
  1347. Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax);
  1348. Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin);
  1349. Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
  1350. Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
  1351. Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
  1352. Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
  1353. }
  1354. void nsFPD::FPDDeviceTiRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel,
  1355. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1356. {
  1357. switch (nEventLevel)
  1358. {
  1359. case EVT_LEVEL_CONFIGURATION:
  1360. {
  1361. OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1362. break;
  1363. }
  1364. case EVT_LEVEL_INFORMATOION:
  1365. {
  1366. OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1367. break;
  1368. }
  1369. case EVT_LEVEL_STATUS:
  1370. {
  1371. OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1372. break;
  1373. }
  1374. case EVT_LEVEL_DATA:
  1375. {
  1376. OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1377. break;
  1378. }
  1379. case EVT_LEVEL_WARNING:
  1380. {
  1381. OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1382. break;
  1383. }
  1384. case EVT_LEVEL_ERROR:
  1385. {
  1386. OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1387. break;
  1388. }
  1389. default:
  1390. break;
  1391. }
  1392. }
  1393. void nsFPD::FPDDeviceTiRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
  1394. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1395. {
  1396. //mLog::FERROR("Not support this conf({$})", nEventID);
  1397. }
  1398. void nsFPD::FPDDeviceTiRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
  1399. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1400. {
  1401. switch (nEventID)
  1402. {
  1403. case EVT_DATA_RAW_IMAGE:
  1404. {
  1405. //mLog::FINFO("EVT_DATA_RAW_IMAGE");
  1406. m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
  1407. //某些值暂时先用假值,有需要再改
  1408. ResDataObject objImageHead, objTemp;
  1409. objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
  1410. objTemp.add(SM_IMAGE_BIT, m_nImgBits);
  1411. objTemp.add(SM_IMAGE_TAG, 1);
  1412. objTemp.add(SM_IMAGE_INDEX, 1);
  1413. objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  1414. objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  1415. objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  1416. objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  1417. objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  1418. objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  1419. objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  1420. objTemp.add(SM_IMAGE_LSB, "5000");
  1421. objTemp.add(SM_IMAGE_DOSE, m_nSensitivity);
  1422. objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
  1423. objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  1424. objTemp.add(SM_IMAGE_FLIP, "No");
  1425. objTemp.add(SM_IMAGE_ORIGINX, "0");
  1426. objTemp.add(SM_IMAGE_ORIGINY, "0");
  1427. objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  1428. objTemp.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
  1429. objTemp.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
  1430. objTemp.add(SM_IMAGE_ROTATION, "No");
  1431. objTemp.add("ImagePath", pszMsg);
  1432. objImageHead.add(SM_IMAGE_HEAD, objTemp);
  1433. //mLog::FINFO("Full image head: {$}", objImageHead.encode());
  1434. //mLog::FINFO("Add image Size: FullImageWidth: {$}, FullImageHeight: {$}", m_nFullImageWidth, m_nFullImageHeight);
  1435. m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_nFullImageWidth * m_nFullImageHeight);
  1436. //mLog::FINFO("Add image over");
  1437. break;
  1438. }
  1439. default:
  1440. //mLog::FERROR("Not support this data({$})", nEventID);
  1441. break;
  1442. }
  1443. }
  1444. void nsFPD::FPDDeviceTiRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
  1445. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1446. {
  1447. switch (nEventID)
  1448. {
  1449. case EVT_STATUS_INIT:
  1450. //mLog::FINFO("EVT_STATUS_INIT nParam1:{$}", nParam1);
  1451. break;
  1452. case EVT_STATUS_PANEL:
  1453. {
  1454. ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
  1455. if (PANEL_CLOSE == nParam1)
  1456. {
  1457. //mLog::FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
  1458. m_bDeviceConnect = false;
  1459. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
  1460. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
  1461. //m_WarnAndError->SendError(ERR_FPD_DISCONNECT, "");
  1462. }
  1463. else if (PANEL_CONNECT == nParam1)
  1464. {
  1465. //mLog::FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
  1466. m_bDeviceConnect = true;
  1467. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  1468. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
  1469. //m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
  1470. }
  1471. else if (PANEL_STANDBY == nParam1)
  1472. {
  1473. //mLog::FINFO("EVT_STATUS_PANEL PANEL_STANDBY");
  1474. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1475. }
  1476. else if (PANEL_SLEEP == nParam1)
  1477. {
  1478. //mLog::FINFO("EVT_STATUS_PANEL PANEL_NOT_READY");
  1479. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  1480. }
  1481. else if (PANEL_READY_EXP == nParam1)
  1482. {
  1483. //mLog::FINFO("EVT_STATUS_PANEL PANEL_READY_EXP");
  1484. m_SyncUnit->FPDReadyNotify(true);
  1485. m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
  1486. }
  1487. else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
  1488. {
  1489. m_stImgCreateTime = { 0 };
  1490. GetLocalTime(&m_stImgCreateTime);
  1491. //mLog::FINFO("XWindowOn at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
  1492. //m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1493. m_SyncUnit->XWindowOnNotify();
  1494. //mLog::FINFO("m_SyncUnit XWindowOnNotify Finished!");
  1495. }
  1496. else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
  1497. {
  1498. m_stImgCreateTime = { 0 };
  1499. GetLocalTime(&m_stImgCreateTime);
  1500. //mLog::FINFO("XWindowOff at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
  1501. //m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1502. m_SyncUnit->XWindowOffNotify();
  1503. }
  1504. else if (PANEL_START_ACQ == nParam1)
  1505. {
  1506. //mLog::FINFO("EVT_STATUS_PANEL PANEL_START_ACQ");
  1507. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  1508. }
  1509. else if (PANEL_XRAY_ON == nParam1)
  1510. {
  1511. //mLog::FINFO("EVT_STATUS_PANEL PANEL_XRAY_ON");
  1512. m_SyncUnit->XrayOnNotify();
  1513. }
  1514. else if (PANEL_XRAY_OFF == nParam1)
  1515. {
  1516. //mLog::FINFO("EVT_STATUS_PANEL PANEL_XRAY_OFF");
  1517. m_SyncUnit->XrayOffNotify();
  1518. }
  1519. break;
  1520. }
  1521. case EVT_STATUS_CALIBRATIOIN:
  1522. {
  1523. //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_CALIBRATIOIN");
  1524. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1525. switch (eStatus)
  1526. {
  1527. case PANEL_EVENT_START:
  1528. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  1529. break;
  1530. case PANEL_EVENT_BEGIN:
  1531. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  1532. break;
  1533. case PANEL_EVENT_END_OK:
  1534. case PANEL_EVENT_END_ERROR:
  1535. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1536. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1537. m_CalibUnit->SetCalibrationProgress(to_string(100));//make progress
  1538. break;
  1539. case PANEL_EVENT_TIMEOUT:
  1540. break;
  1541. default:
  1542. break;
  1543. }
  1544. break;
  1545. }
  1546. case EVT_STATUS_SINGLEEXP:
  1547. {
  1548. //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_SINGLEEXP");
  1549. if (DOSE_ACCEPT == nParam1)
  1550. {
  1551. //mLog::FINFO("Calibration Result is acceptable");
  1552. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1553. m_CalibUnit->PauseCalibration();
  1554. }
  1555. else
  1556. {
  1557. //mLog::FERROR("Not support this param({$})", nParam1);
  1558. }
  1559. break;
  1560. }
  1561. case EVT_STATUS_TEMPERATURE:
  1562. {
  1563. //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_TEMPERATURE");
  1564. float fTemperature = fParam2;
  1565. SendTemperatureValue(fTemperature);
  1566. break;
  1567. }
  1568. case EVT_STATUS_WIFI:
  1569. {
  1570. //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_WIFI");
  1571. int nWifiLevel = nParam1;
  1572. SendWifiValue(nWifiLevel);
  1573. break;
  1574. }
  1575. case EVT_STATUS_BATTERY_VALUE:
  1576. {
  1577. //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_BATTERY_VALUE");
  1578. int nBatteryValue = nParam1;
  1579. SendBatteryValue(nBatteryValue);
  1580. break;
  1581. }
  1582. default:
  1583. //mLog::FERROR("Not support this event({$})", nEventID);
  1584. break;
  1585. }
  1586. }
  1587. void nsFPD::FPDDeviceTiRay::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
  1588. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1589. {
  1590. switch (nEventID)
  1591. {
  1592. case EVT_DATA_RAW_IMAGE:
  1593. {
  1594. //mLog::FINFO("EVT_DATA_RAW_IMAGE");
  1595. m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
  1596. memcpy(m_pFullImgBuffer, pParam, (size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight * sizeof(unsigned short));
  1597. //某些值暂时先用假值,有需要再改
  1598. ResDataObject objImageHead, objTemp;
  1599. objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
  1600. objTemp.add(SM_IMAGE_BIT, m_nImgBits);
  1601. objTemp.add(SM_IMAGE_TAG, 1);
  1602. objTemp.add(SM_IMAGE_INDEX, 1);
  1603. objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  1604. objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  1605. objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  1606. objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  1607. objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  1608. objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  1609. objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  1610. objTemp.add(SM_IMAGE_LSB, "5000");
  1611. objTemp.add(SM_IMAGE_DOSE, m_nSensitivity);
  1612. objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
  1613. objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  1614. objTemp.add(SM_IMAGE_FLIP, "No");
  1615. objTemp.add(SM_IMAGE_ORIGINX, "0");
  1616. objTemp.add(SM_IMAGE_ORIGINY, "0");
  1617. objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  1618. objTemp.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
  1619. objTemp.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
  1620. objTemp.add(SM_IMAGE_ROTATION, "No");
  1621. objImageHead.add(SM_IMAGE_HEAD, objTemp);
  1622. //mLog::FINFO("Full image head: {$}", objImageHead.encode());
  1623. //mLog::FINFO("Add image Size: FullImageWidth: {$}, FullImageHeight: {$}", m_nFullImageWidth, m_nFullImageHeight);
  1624. m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pFullImgBuffer, m_nFullImageWidth * m_nFullImageHeight);
  1625. //mLog::FINFO("Add image over");
  1626. break;
  1627. }
  1628. case EVT_DATA_DOSEPARAM:
  1629. {
  1630. m_fDoseParam = fParam2;
  1631. m_WaitCalibDoseEvt->SetEvent();
  1632. break;
  1633. }
  1634. default:
  1635. //mLog::FERROR("Not support this data({$})", nEventID);
  1636. break;
  1637. }
  1638. }
  1639. void nsFPD::FPDDeviceTiRay::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
  1640. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1641. {
  1642. switch (nEventID)
  1643. {
  1644. case EVT_ERR_COMMUNICATE:
  1645. break;
  1646. case EVT_ERR_INIT_FAILED:
  1647. break;
  1648. default:
  1649. //mLog::FERROR("Not support this FERROR({$})", nEventID);
  1650. break;
  1651. }
  1652. }
  1653. void nsFPD::FPDDeviceTiRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
  1654. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1655. {
  1656. //mLog::FERROR("Not support this warn({$})", nEventID);
  1657. }
  1658. RET_STATUS nsFPD::FPDDeviceTiRay::ActiveSyncMode(int nSyncMode)
  1659. {
  1660. //mLog::FINFO("--Func-- ActiveSyncMode nSyncMode:{$}", nSyncMode);
  1661. m_eSyncMode = (SYNC_MODE)nSyncMode;
  1662. if (g_pDetector->SetSyncMode(nSyncMode))
  1663. {
  1664. return RET_SUCCEED;
  1665. }
  1666. else
  1667. {
  1668. //mLog::FERROR("ActiveSyncMode fail!");
  1669. return RET_FAILED;
  1670. }
  1671. }
  1672. RET_STATUS nsFPD::FPDDeviceTiRay::UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode)
  1673. {
  1674. //mLog::FINFO("--Func-- UpdateCalibMode eCalibMode:{$}", (int)eCalibMode);
  1675. m_stDeviceConfig.nCalibMode = (int)eCalibMode;
  1676. if (g_pDetector->UpdateCalibMode(eCalibMode))
  1677. {
  1678. //mLog::FINFO("UpdateCalibMode success!");
  1679. return RET_SUCCEED;
  1680. }
  1681. else
  1682. {
  1683. //mLog::FERROR("UpdateCalibMode fail!");
  1684. return RET_FAILED;
  1685. }
  1686. }
  1687. RET_STATUS nsFPD::FPDDeviceTiRay::UpdateLastCalibrationDate(std::string in)
  1688. {
  1689. //mLog::FINFO("--Func-- UpdateLastCalibrationDate in:{$}", in);
  1690. m_stDeviceConfig.strLastCalibrationDate = in;
  1691. return RET_SUCCEED;
  1692. }
  1693. RET_STATUS nsFPD::FPDDeviceTiRay::UpdateCalibrationFileExpireTime(std::string in)
  1694. {
  1695. //mLog::FINFO("--Func-- UpdateCalibrationFileExpireTime in:{$}", in);
  1696. m_stDeviceConfig.strCalibrationFileExpireTime = in;
  1697. return RET_SUCCEED;
  1698. }