CCOS.Dev.FPD.TiRayDR.cpp 63 KB

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