CCOS.Dev.FPD.TiRayDR.cpp 65 KB

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