CCOS.Dev.FPD.TiRayDR.cpp 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936
  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. : FPDDeviceMould("DevTiRay"), 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. bool bRet = GetLogicMode(strMode, nMode);
  655. if (!bRet)
  656. {
  657. return RET_STATUS::RET_FAILED;
  658. }
  659. try
  660. {
  661. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  662. m_nFullImageWidth = (int)objModeConfig["ModeTable"][0]["ImageWidth"];
  663. m_nFullImageHeight = (int)objModeConfig["ModeTable"][0]["ImageHeight"];
  664. m_nImgBits = (int)objModeConfig["ModeTable"][0]["PhySizeInfoBit"];
  665. m_nPixelSpacing = (int)objModeConfig["ModeTable"][0]["PixelPitch"];
  666. m_nSensitivity = (int)objModeConfig["ModeTable"][0]["Sensitivity"];
  667. m_nFPDExpReadyTime = (int)objModeConfig["ModeTable"][0]["XWindow"];
  668. if (nullptr != m_pFullImgBuffer)
  669. {
  670. delete[]m_pFullImgBuffer;
  671. m_pFullImgBuffer = nullptr;
  672. }
  673. m_pFullImgBuffer = new unsigned short[(size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight];
  674. m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false);
  675. m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
  676. string strDoseOfExi = std::to_string(m_nSensitivity);
  677. m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  678. FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY);
  679. m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
  680. //读取校正时的目标EXI
  681. int nTargetCalibExi = (int)objModeConfig["ModeTable"][0]["TargetGainEXI"];
  682. m_nTargetCalibExi = nTargetCalibExi;
  683. FINFO("m_nTargetCalibExi:{$}", m_nTargetCalibExi);
  684. if (g_pDetector->SetAcqMode(nMode))
  685. {
  686. ret = RET_STATUS::RET_SUCCEED;
  687. m_AcqUnit->AcqModeNotify(strMode);
  688. }
  689. else
  690. {
  691. ret = RET_STATUS::RET_FAILED;
  692. }
  693. }
  694. catch (ResDataObjectExption& e)
  695. {
  696. FERROR("Read configuration failed, Error code: {$}", e.what());
  697. }
  698. FINFO("Device SetAcqMode Over");
  699. return ret;
  700. }
  701. bool nsFPD::FPDDeviceTiRay::GetLogicMode(string& strAcqMode, int& nLogicMode)
  702. {
  703. if (strAcqMode == "RAD")
  704. {
  705. nLogicMode = RAD;
  706. }
  707. else if (strAcqMode == "DualEnergy")
  708. {
  709. nLogicMode = DUAL_ENERGY;
  710. }
  711. else if (strAcqMode == "DDR"||strAcqMode == "TOMO")
  712. {
  713. nLogicMode = DDR;
  714. }
  715. else if (strAcqMode == "PF")
  716. {
  717. nLogicMode = PF;
  718. }
  719. else if (strAcqMode == "1")
  720. {
  721. nLogicMode = RAD;
  722. }
  723. else if (strAcqMode == "2")
  724. {
  725. nLogicMode = DUAL_ENERGY;
  726. }
  727. else if (strAcqMode == "3")
  728. {
  729. nLogicMode = DDR;
  730. }
  731. else if (strAcqMode == "4")
  732. {
  733. nLogicMode = PF;
  734. }
  735. else
  736. {
  737. FERROR("Not support mode!");
  738. return false;
  739. }
  740. return true;
  741. }
  742. RET_STATUS nsFPD::FPDDeviceTiRay::GetSyncMode(SYNC_MODE& eSyncMode)
  743. {
  744. FINFO("--Func Device-- GetSyncMode Start");
  745. eSyncMode = m_eSyncMode;
  746. FINFO("Device GetSyncMode Over");
  747. return RET_STATUS::RET_SUCCEED;
  748. }
  749. RET_STATUS nsFPD::FPDDeviceTiRay::PrepareAcquisition()
  750. {
  751. FINFO("--Func Device-- PrepareAcquisition Start");
  752. RET_STATUS ret = RET_STATUS::RET_FAILED;
  753. if (!m_bDeviceConnect)
  754. {
  755. FERROR("Detector not connected, return");
  756. return ret;
  757. }
  758. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  759. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  760. {
  761. FERROR("PrepareAcquisition failed. Detector at Calibration status");
  762. }
  763. m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
  764. if (g_pDetector->PrepareAcquisition(this))
  765. {
  766. ret = RET_STATUS::RET_SUCCEED;
  767. }
  768. FINFO("Device PrepareAcquisition Over");
  769. return ret;
  770. }
  771. RET_STATUS nsFPD::FPDDeviceTiRay::StartAcquisition(string in)
  772. {
  773. FINFO("--Func Device-- StartAcquisition Start");
  774. RET_STATUS ret = RET_STATUS::RET_FAILED;
  775. if (!m_bDeviceConnect)
  776. {
  777. FERROR("Detector not connected, return");
  778. return ret;
  779. }
  780. if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
  781. {
  782. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  783. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  784. {
  785. FERROR("PrepareAcquisition failed. Detector at Calibration status.");
  786. }
  787. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  788. {
  789. FERROR("Detector already at Acq status.");
  790. }
  791. }
  792. else
  793. {
  794. if (g_pDetector->StartAcquisition(this))
  795. {
  796. ret = RET_STATUS::RET_SUCCEED;
  797. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  798. }
  799. else
  800. {
  801. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  802. }
  803. }
  804. FINFO("Device StartAcquisition Over");
  805. return ret;
  806. }
  807. RET_STATUS nsFPD::FPDDeviceTiRay::StopAcquisition()
  808. {
  809. FINFO("--Func Device-- StopAcquisition Start");
  810. RET_STATUS ret = RET_STATUS::RET_FAILED;
  811. if (!m_bDeviceConnect)
  812. {
  813. FERROR("Detector not connected, return");
  814. return ret;
  815. }
  816. if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
  817. {
  818. FINFO("Detector already at Acq status.");
  819. ret = RET_STATUS::RET_SUCCEED;
  820. }
  821. else
  822. {
  823. if (g_pDetector->StopAcquisition(this))
  824. {
  825. ret = RET_STATUS::RET_SUCCEED;
  826. //m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  827. }
  828. }
  829. FINFO("Device StopAcquisition Over");
  830. return ret;
  831. }
  832. RET_STATUS nsFPD::FPDDeviceTiRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
  833. {
  834. FINFO("--Func Device-- ActiveCalibration Start");
  835. FINFO("ActiveCalibration {$}", (int)eType);
  836. RET_STATUS ret = RET_STATUS::RET_FAILED;
  837. if (!m_bDeviceConnect)
  838. {
  839. FERROR("m_bDeviceConnect is false, detector not connect, return");
  840. return ret;
  841. }
  842. if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
  843. {
  844. FERROR("calibration type is invalid!");
  845. return RET_STATUS::RET_INVALID;
  846. }
  847. else
  848. {
  849. m_CalibType = eType;
  850. }
  851. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  852. if (eType == CCOS_CALIBRATION_TYPE_XRAY)
  853. {
  854. FINFO("calibration type: XRAY");
  855. int nCalibrationRounds = (int)m_CalibDoseList.size();
  856. g_pDetector->SetCalibRounds(nCalibrationRounds);
  857. }
  858. if (g_pDetector->ActiveCalibration(this, eType))
  859. {
  860. ret = RET_STATUS::RET_SUCCEED;
  861. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  862. m_CalibUnit->SetCalibrationProgress("0");
  863. }
  864. else
  865. {
  866. FERROR("Active calibration failed");
  867. ret = RET_STATUS::RET_FAILED;
  868. }
  869. //重置校正流程参数
  870. m_nCalibCurrentCalibrationRound = 1;
  871. m_nCalibCurrentExposureIndex = 1;
  872. m_nCalibCurrentExposureNum = 0;
  873. FINFO("Device ActiveCalibration Over");
  874. return ret;
  875. }
  876. RET_STATUS nsFPD::FPDDeviceTiRay::PrepareCalibration()
  877. {
  878. FINFO("--Func Device-- PrepareCalibration Start");
  879. RET_STATUS ret = RET_STATUS::RET_FAILED;
  880. if (!m_bDeviceConnect)
  881. {
  882. FERROR("m_bDeviceConnect is false, detector not connect, return");
  883. return ret;
  884. }
  885. if (g_pDetector->PrepareCalibration(this))
  886. {
  887. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_PREPARE));
  888. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  889. if (nCalibrationType == CCOS_CALIBRATION_TYPE_XRAY && m_eSyncMode == SYNC_AED)
  890. {
  891. FINFO("set m_bEnterAcqStatus true");
  892. }
  893. ret = RET_STATUS::RET_SUCCEED;
  894. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  895. }
  896. else
  897. {
  898. FERROR("PrepareCalibration failed!");
  899. return ret;
  900. }
  901. FINFO("Device PrepareCalibration Over");
  902. return ret;
  903. }
  904. RET_STATUS nsFPD::FPDDeviceTiRay::GetRequestedDose(std::string& strDose)
  905. {
  906. FINFO("--Func Device-- GetRequestedDose Start");
  907. RET_STATUS ret = RET_STATUS::RET_FAILED;
  908. ResDataObject out;
  909. if (!m_bDeviceConnect)
  910. {
  911. FERROR("m_bDeviceConnect is false, detector not connect, return");
  912. return ret;
  913. }
  914. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  915. FINFO("GetRequestedDose calib type is {$}", (int)nCalibrationType);
  916. if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
  917. {
  918. out.add("Dose", 0.0f);
  919. out.add("kV", 0.0f);
  920. out.add("mA", 0.0f);
  921. out.add("ms", 0.0f);
  922. out.add("mAs", 0.0f);
  923. }
  924. else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
  925. {
  926. FINFO("calib dose list size is {$}", m_CalibDoseList.size());
  927. ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
  928. int nTargetExi = (int)temp["TargetGainEXI"];
  929. m_DetectorCtrlUnit->SetTargetEXI(std::to_string(nTargetExi));
  930. FINFO("nTargetExi:{$}", nTargetExi);
  931. out.add("Dose", nTargetExi);
  932. out.add("kV", temp["KV"]);
  933. out.add("mA", temp["MA"]);
  934. out.add("ms", temp["MS"]);
  935. out.add("mAs", temp["MAS"]);
  936. }
  937. else
  938. {
  939. FERROR("Don't support CalibrationType($)", (int)nCalibrationType);
  940. return ret;
  941. }
  942. strDose = out.encode();
  943. FINFO("GetRequestedDose:{$}", strDose);
  944. ret = RET_STATUS::RET_SUCCEED;
  945. FINFO("Device GetRequestedDose Over");
  946. return ret;
  947. }
  948. RET_STATUS nsFPD::FPDDeviceTiRay::SetRequestedDose(std::string strDose)
  949. {
  950. FINFO("--Func Device-- SetRequestedDose Start");
  951. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  952. FINFO("SetRequestedDose Over");
  953. return Ret;
  954. }
  955. RET_STATUS nsFPD::FPDDeviceTiRay::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
  956. {
  957. FINFO("--Func Device-- GetCalibrationStep Start");
  958. cout << "--Func Device-- GetCalibrationStep Start. DetectorID: " << nDetectorID << endl;
  959. RET_STATUS ret = RET_STATUS::RET_SUCCEED;
  960. ResDataObject out;
  961. int nCalibrationRounds = (int)m_CalibDoseList.size();
  962. int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
  963. if (g_pDetector->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound))
  964. {
  965. cout << "g_pDetector->GetCalibrationStep success" << endl;
  966. FINFO("GetCalibrationStep success");
  967. }
  968. else
  969. {
  970. cout << "g_pDetector->GetCalibrationStep failed" << endl;
  971. FERROR("GetCalibrationStep error");
  972. ret = RET_STATUS::RET_FAILED;
  973. return ret;
  974. }
  975. out.add("CalibrationRounds", (int)m_CalibDoseList.size());
  976. out.add("TotalExposureNum", m_nCalibTotalExposureNum);
  977. out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
  978. out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]);
  979. out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
  980. out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
  981. cout << "Calibration info - Rounds: " << nCalibrationRounds
  982. << ", TotalExposures: " << m_nCalibTotalExposureNum
  983. << ", CurrentRound: " << m_nCalibCurrentCalibrationRound
  984. << ", CurrentIndex: " << m_nCalibCurrentExposureIndex << endl;
  985. strCalibrationStepInfo = out.encode();
  986. cout << "strCalibrationStepInfo: " << strCalibrationStepInfo << endl;
  987. cout << "Device GetCalibrationStep Over. Return: " << ret << endl;
  988. FINFO("strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
  989. FINFO("Device GetCalibrationStep Over");
  990. return ret;
  991. }
  992. RET_STATUS nsFPD::FPDDeviceTiRay::StartCalibration()
  993. {
  994. FINFO("--Func Device-- StartCalibration Start");
  995. RET_STATUS ret = RET_STATUS::RET_FAILED;
  996. if (!m_bDeviceConnect)
  997. {
  998. FERROR("m_bDeviceConnect is false, detector not connect, return");
  999. return ret;
  1000. }
  1001. if (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PREPARE)
  1002. {
  1003. FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus());
  1004. return ret;
  1005. }
  1006. if (g_pDetector->StartCalibration(this))
  1007. {
  1008. FINFO("start calibration success set detector status");
  1009. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  1010. ret = RET_STATUS::RET_SUCCEED;
  1011. if (m_eSyncMode == SYNC_AED)
  1012. {
  1013. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartCalibration
  1014. }
  1015. }
  1016. else
  1017. {
  1018. FERROR("StartCalibration failed");
  1019. ret = RET_STATUS::RET_FAILED;
  1020. return ret;
  1021. }
  1022. FINFO("Device StartCalibration Over");
  1023. return ret;
  1024. }
  1025. RET_STATUS nsFPD::FPDDeviceTiRay::StopCalibration()
  1026. {
  1027. FINFO("--Func Device-- StopCalibration Start");
  1028. RET_STATUS ret = RET_STATUS::RET_FAILED;
  1029. if (!m_bDeviceConnect)
  1030. {
  1031. FERROR("m_bDeviceConnect is false, detector not connect, return");
  1032. return ret;
  1033. }
  1034. m_eAppStatus = APP_STATUS_CAL_END;
  1035. if (g_pDetector->StopCalibration(this))
  1036. {
  1037. ret = RET_STATUS::RET_SUCCEED;
  1038. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
  1039. }
  1040. else
  1041. {
  1042. FERROR("StopCalibration failed");
  1043. }
  1044. FINFO("Device StopCalibration Over");
  1045. return ret;
  1046. }
  1047. RET_STATUS nsFPD::FPDDeviceTiRay::AbortCalibration()
  1048. {
  1049. FINFO("--Func Device-- AbortCalibration Start");
  1050. m_eAppStatus = APP_STATUS_CAL_END;
  1051. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  1052. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1053. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  1054. m_CalibUnit->SetCalibrationProgress("100");
  1055. if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
  1056. {
  1057. g_pDetector->AbortCalibration(this);
  1058. m_AcqUnit->SendNoNeedWaitImage(true);
  1059. }
  1060. //如果中止的时候探测器在采集状态需要停止采集
  1061. return RET_STATUS::RET_SUCCEED;
  1062. FINFO("Device AbortCalibration Over");
  1063. }
  1064. RET_STATUS nsFPD::FPDDeviceTiRay::AcceptCalibration()
  1065. {
  1066. FINFO("--Func Device-- AcceptCalibration Start");
  1067. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1068. if (g_pDetector->AcceptCalibration())
  1069. {
  1070. FINFO("AcceptCalibration success");
  1071. Ret = RET_STATUS::RET_SUCCEED;
  1072. }
  1073. else
  1074. {
  1075. FERROR("AcceptCalibration error");
  1076. Ret = RET_STATUS::RET_FAILED;
  1077. }
  1078. int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
  1079. //完成校正条件:轮数够了,曝光次数够了
  1080. if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
  1081. {
  1082. FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
  1083. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1084. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1085. m_CalibUnit->SetCalibrationProgress("100");
  1086. return Ret;
  1087. }
  1088. if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
  1089. {
  1090. m_nCalibCurrentCalibrationRound++;
  1091. m_nCalibCurrentExposureIndex = 1;
  1092. }
  1093. else
  1094. {
  1095. m_nCalibCurrentExposureIndex++;
  1096. }
  1097. m_nCalibCurrentExposureNum++;
  1098. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1099. FINFO("Device AcceptCalibration Over");
  1100. return Ret;
  1101. }
  1102. RET_STATUS nsFPD::FPDDeviceTiRay::RejectCalibration()
  1103. {
  1104. FINFO("--Func Device-- RejectCalibration Start");
  1105. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1106. if (g_pDetector->RejectCalibration())
  1107. {
  1108. Ret = RET_STATUS::RET_SUCCEED;
  1109. }
  1110. else
  1111. {
  1112. FERROR("RejectCalibration error");
  1113. Ret = RET_STATUS::RET_FAILED;
  1114. }
  1115. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1116. FINFO("Device RejectCalibration Over");
  1117. return Ret;
  1118. }
  1119. RET_STATUS nsFPD::FPDDeviceTiRay::ActiveDetector(bool bActive)
  1120. {
  1121. FINFO("--Func Device-- ActiveDetector Start");
  1122. if (!m_stDeviceConfig.bConnectStatus)
  1123. {
  1124. return RET_STATUS::RET_THREAD_INVALID;
  1125. }
  1126. FINFO("Device ActiveDetector Over");
  1127. return RET_STATUS::RET_SUCCEED;
  1128. }
  1129. RET_STATUS nsFPD::FPDDeviceTiRay::CompleteCalibration()
  1130. {
  1131. FINFO("--Func Device-- CompleteCalibration Start");
  1132. if (!g_pDetector->CompleteCalibration(this))
  1133. {
  1134. FERROR("CompleteCalibration fail!");
  1135. return RET_STATUS::RET_FAILED;
  1136. }
  1137. if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_DARK)
  1138. {
  1139. FINFO("CompleteCalibration Calibration Type DARK");
  1140. }
  1141. else if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_XRAY)
  1142. {
  1143. FINFO("CompleteCalibration Calibration Type XRAY");
  1144. m_eAppStatus = APP_STATUS_CAL_END;
  1145. }
  1146. FINFO("CompleteCalibration set detector status standby");
  1147. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1148. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1149. m_CalibUnit->SetCalibrationProgress("100");
  1150. FINFO("Device CompleteCalibration Over");
  1151. return RET_STATUS::RET_SUCCEED;
  1152. }
  1153. RET_STATUS nsFPD::FPDDeviceTiRay::SaveCalibrationFile(bool bSaveFlag)
  1154. {
  1155. FINFO("--Func Device-- SaveCalibrationFile Start");
  1156. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1157. FINFO("SaveCalibrationFile bSaveFlag: {$}", bSaveFlag);
  1158. if (!bSaveFlag)
  1159. {
  1160. FERROR("Not save calibration file");
  1161. return Ret;
  1162. }
  1163. //点击save按钮时先调用compelte再调用save
  1164. CompleteCalibration();
  1165. if (g_pDetector->SaveCalibrationFile())
  1166. {
  1167. m_CalibUnit->SetSaveCalibrationFileFinish(true);
  1168. Ret = RET_STATUS::RET_SUCCEED;
  1169. //更新配置文件中校正日期和时间
  1170. time_t localtime = time(NULL);
  1171. string strLocalTime = DatetimeToString(localtime);
  1172. FINFO("strLocalTime:{$}", strLocalTime);
  1173. m_CalibUnit->SetLastCalibrationDate(strLocalTime);
  1174. FINFO("m_CalibUnit->SetLastCalibrationDate Over");
  1175. //清除校正文件相关警告
  1176. //m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
  1177. //m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
  1178. }
  1179. else
  1180. {
  1181. FERROR("SaveCalibrationFile error");
  1182. m_CalibUnit->SetSaveCalibrationFileFinish(false);
  1183. Ret = RET_STATUS::RET_FAILED;
  1184. }
  1185. FINFO("Device SaveCalibrationFile Over");
  1186. return Ret;
  1187. }
  1188. bool nsFPD::FPDDeviceTiRay::Support_DarkCalib()
  1189. {
  1190. return true;
  1191. }
  1192. bool nsFPD::FPDDeviceTiRay::Support_XrayCalib()
  1193. {
  1194. return true;
  1195. }
  1196. void nsFPD::FPDDeviceTiRay::SendTemperatureValue(float fValue)
  1197. {
  1198. int nStatus = 0;
  1199. m_Temperature->SetTemperature(fValue, nStatus);
  1200. FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
  1201. return;
  1202. }
  1203. void nsFPD::FPDDeviceTiRay::SendWifiValue(int nValue)
  1204. {
  1205. int nStatus = 0;
  1206. m_Wifi->SetSignalValue(nValue, nStatus);
  1207. FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
  1208. return;
  1209. }
  1210. void nsFPD::FPDDeviceTiRay::SendBatteryValue(int nValue)
  1211. {
  1212. int nStatus = 0;
  1213. m_Battery->SetRemainPowerValue(nValue, nStatus);
  1214. FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
  1215. return;
  1216. }
  1217. bool nsFPD::FPDDeviceTiRay::LoadConfig()
  1218. {
  1219. FINFO("--Func Device-- LoadConfig Start");
  1220. if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_CalibDoseList, m_nCalibTotalExposureNum))
  1221. {
  1222. FERROR("Load configuration file failed!!!");
  1223. return false;
  1224. }
  1225. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  1226. m_nFullImageWidth = (int)objModeConfig["ModeTable"][0]["ImageWidth"];
  1227. m_nFullImageHeight = (int)objModeConfig["ModeTable"][0]["ImageHeight"];
  1228. m_nImgBits = (int)objModeConfig["ModeTable"][0]["PhySizeInfoBit"];
  1229. m_nPixelSpacing = (int)objModeConfig["ModeTable"][0]["PixelPitch"];
  1230. m_nSensitivity = (int)objModeConfig["ModeTable"][0]["Sensitivity"];
  1231. m_nFPDExpReadyTime = (int)objModeConfig["ModeTable"][0]["XWindow"];
  1232. if (nullptr != m_pFullImgBuffer)
  1233. {
  1234. delete[]m_pFullImgBuffer;
  1235. m_pFullImgBuffer = nullptr;
  1236. }
  1237. m_pFullImgBuffer = new unsigned short[(size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight];
  1238. m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false);
  1239. m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
  1240. string strDoseOfExi = std::to_string(m_nSensitivity);
  1241. m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  1242. m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
  1243. //读取校正时的目标EXI
  1244. int nTargetCalibExi = (int)objModeConfig["ModeTable"][0]["TargetGainEXI"];
  1245. m_nTargetCalibExi = nTargetCalibExi;
  1246. //FINFO("m_CalibDoseList:{$}", m_CalibDoseList.encode());
  1247. //FINFO("m_nCalibTotalExposureNum:{$}", m_nCalibTotalExposureNum);
  1248. //m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode);
  1249. //m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate);
  1250. //m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime);
  1251. m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0,
  1252. m_stDeviceConfig.nBatteryLimit,
  1253. m_stDeviceConfig.nBatteryWarning,
  1254. 100,
  1255. m_stDeviceConfig.nBatteryLimit,
  1256. 100, 100, 0, EventCenter));
  1257. m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f, m_stDeviceConfig.fTemperatureErrorMin,
  1258. m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax,
  1259. m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax,
  1260. m_stDeviceConfig.fTemperatureErrorMax, 0.0f, EventCenter));
  1261. m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning,
  1262. 100, m_stDeviceConfig.nWifiLimit, 100, 100, 0, EventCenter));
  1263. FINFO("Device LoadConfig Over");
  1264. return true;
  1265. }
  1266. void nsFPD::FPDDeviceTiRay::RegisterCtrl(nsDetail::Dispatch* Dispatch)
  1267. {
  1268. Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
  1269. Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
  1270. Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
  1271. Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum);
  1272. Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
  1273. Dispatch->Action.Push(ActionKey::ScanDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSScanDetector);
  1274. Dispatch->Action.Push(ActionKey::ConnectDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSConnectDetector);
  1275. Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
  1276. Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
  1277. Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
  1278. Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
  1279. Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
  1280. Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
  1281. Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
  1282. Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
  1283. Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);//CcosDetectorAttachedFlag
  1284. Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR);
  1285. Dispatch->Get.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSerialNumber);
  1286. Dispatch->Set.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetConnectStatus);
  1287. Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus);
  1288. Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType);
  1289. Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription);
  1290. Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID);
  1291. Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData);
  1292. Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI);
  1293. Dispatch->Set.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus);
  1294. Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR);
  1295. Dispatch->Set.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSerialNumber);
  1296. Dispatch->Update.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateSerialNumber);
  1297. }
  1298. void nsFPD::FPDDeviceTiRay::RegisterAcq(nsDetail::Dispatch* Dispatch)
  1299. {
  1300. Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
  1301. Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode);
  1302. Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
  1303. Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
  1304. Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
  1305. Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState);
  1306. Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage);
  1307. }
  1308. void nsFPD::FPDDeviceTiRay::RegisterSync(nsDetail::Dispatch* Dispatch)
  1309. {
  1310. Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
  1311. Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
  1312. Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
  1313. Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
  1314. Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
  1315. Dispatch->Action.Push(ActionKey::ActiveSyncMode, m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode);
  1316. Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
  1317. Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
  1318. Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
  1319. Dispatch->Get.Push(AttrKey::FPDExpReady, m_SyncUnit.get(), &SyncUnit::JSGetExpReadyStatus);
  1320. Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
  1321. Dispatch->Get.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode);
  1322. Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
  1323. Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus);
  1324. Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
  1325. Dispatch->Set.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::SetSupportSyncMode);
  1326. }
  1327. void nsFPD::FPDDeviceTiRay::RegisterCalib(nsDetail::Dispatch* Dispatch)
  1328. {
  1329. Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
  1330. Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
  1331. Dispatch->Action.Push(ActionKey::SetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose);
  1332. Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
  1333. Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
  1334. Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
  1335. Dispatch->Action.Push(ActionKey::AbortCalibration, m_CalibUnit.get(), &CalibUnit::JSAbortCalibration);
  1336. Dispatch->Action.Push(ActionKey::CompleteCalibration, m_CalibUnit.get(), &CalibUnit::JSCompleteCalibration);
  1337. Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
  1338. Dispatch->Action.Push(ActionKey::AcceptCalibration, m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration);
  1339. Dispatch->Action.Push(ActionKey::RejectCalibration, m_CalibUnit.get(), &CalibUnit::JSRejectCalibration);
  1340. Dispatch->Action.Push(ActionKey::SaveCalibrationFile, m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile);
  1341. Dispatch->Action.Push(ActionKey::GetCalibrationStep, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep);
  1342. Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
  1343. Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
  1344. Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
  1345. Dispatch->Get.Push(AttrKey::SupportCalibrationType, m_CalibUnit.get(), &CalibUnit::JSGetSupportCalibrationType);
  1346. Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
  1347. Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
  1348. Dispatch->Get.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSGetCalibMode);
  1349. Dispatch->Get.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSGetLastCalibrationDate);
  1350. Dispatch->Get.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpireTime);
  1351. Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus);
  1352. Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress);
  1353. Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult);
  1354. Dispatch->Set.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::SetLastCalibrationDate);
  1355. Dispatch->Set.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpireTime);
  1356. Dispatch->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode);
  1357. Dispatch->Update.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSUpdateLastCalibrationDate);
  1358. Dispatch->Update.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpireTime);
  1359. }
  1360. void nsFPD::FPDDeviceTiRay::RegisterOthers(nsDetail::Dispatch* Dispatch)
  1361. {
  1362. Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
  1363. Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
  1364. Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
  1365. Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
  1366. Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
  1367. Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
  1368. Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
  1369. Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax);
  1370. Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin);
  1371. Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
  1372. Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
  1373. Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
  1374. Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
  1375. //Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
  1376. Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
  1377. Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
  1378. Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
  1379. Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
  1380. Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax);
  1381. Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin);
  1382. Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
  1383. Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
  1384. Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
  1385. Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
  1386. Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
  1387. Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
  1388. Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
  1389. Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
  1390. Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax);
  1391. Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin);
  1392. Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
  1393. Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
  1394. Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
  1395. Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
  1396. }
  1397. void nsFPD::FPDDeviceTiRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel,
  1398. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1399. {
  1400. switch (nEventLevel)
  1401. {
  1402. case EVT_LEVEL_CONFIGURATION:
  1403. {
  1404. OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1405. break;
  1406. }
  1407. case EVT_LEVEL_INFORMATOION:
  1408. {
  1409. OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1410. break;
  1411. }
  1412. case EVT_LEVEL_STATUS:
  1413. {
  1414. OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1415. break;
  1416. }
  1417. case EVT_LEVEL_DATA:
  1418. {
  1419. OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1420. break;
  1421. }
  1422. case EVT_LEVEL_WARNING:
  1423. {
  1424. OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1425. break;
  1426. }
  1427. case EVT_LEVEL_ERROR:
  1428. {
  1429. OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1430. break;
  1431. }
  1432. default:
  1433. break;
  1434. }
  1435. }
  1436. void nsFPD::FPDDeviceTiRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
  1437. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1438. {
  1439. FERROR("Not support this conf({$})", nEventID);
  1440. }
  1441. void nsFPD::FPDDeviceTiRay::OnEventProcessInfo(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_DATA_RAW_IMAGE:
  1447. {
  1448. FINFO("EVT_DATA_RAW_IMAGE");
  1449. m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
  1450. //某些值暂时先用假值,有需要再改
  1451. ResDataObject objImageHead, objTemp;
  1452. objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
  1453. objTemp.add(SM_IMAGE_BIT, m_nImgBits);
  1454. objTemp.add(SM_IMAGE_TAG, 1);
  1455. objTemp.add(SM_IMAGE_INDEX, 1);
  1456. objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  1457. objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  1458. objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  1459. objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  1460. objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  1461. objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  1462. objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  1463. objTemp.add(SM_IMAGE_LSB, "5000");
  1464. objTemp.add(SM_IMAGE_DOSE, m_nSensitivity);
  1465. objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
  1466. objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  1467. objTemp.add(SM_IMAGE_FLIP, "No");
  1468. objTemp.add(SM_IMAGE_ORIGINX, "0");
  1469. objTemp.add(SM_IMAGE_ORIGINY, "0");
  1470. objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  1471. objTemp.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
  1472. objTemp.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
  1473. objTemp.add(SM_IMAGE_ROTATION, "No");
  1474. objTemp.add("ImagePath", pszMsg);
  1475. objImageHead.add(SM_IMAGE_HEAD, objTemp);
  1476. FINFO("Full image head: {$}", objImageHead.encode());
  1477. FINFO("Add image Size: FullImageWidth: {$}, FullImageHeight: {$}", m_nFullImageWidth, m_nFullImageHeight);
  1478. m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_nFullImageWidth * m_nFullImageHeight);
  1479. FINFO("Add image over");
  1480. break;
  1481. }
  1482. default:
  1483. FERROR("Not support this data({$})", nEventID);
  1484. break;
  1485. }
  1486. }
  1487. void nsFPD::FPDDeviceTiRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
  1488. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1489. {
  1490. switch (nEventID)
  1491. {
  1492. case EVT_STATUS_INIT:
  1493. FINFO("EVT_STATUS_INIT nParam1:{$}", nParam1);
  1494. break;
  1495. case EVT_STATUS_PANEL:
  1496. {
  1497. ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
  1498. if (PANEL_CLOSE == nParam1)
  1499. {
  1500. FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
  1501. m_bDeviceConnect = false;
  1502. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
  1503. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
  1504. //m_WarnAndError->SendError(ERR_FPD_DISCONNECT, "");
  1505. }
  1506. else if (PANEL_CONNECT == nParam1)
  1507. {
  1508. FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
  1509. m_bDeviceConnect = true;
  1510. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  1511. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
  1512. //m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
  1513. }
  1514. else if (PANEL_STANDBY == nParam1)
  1515. {
  1516. FINFO("EVT_STATUS_PANEL PANEL_STANDBY");
  1517. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1518. }
  1519. else if (PANEL_SLEEP == nParam1)
  1520. {
  1521. FINFO("EVT_STATUS_PANEL PANEL_NOT_READY");
  1522. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  1523. }
  1524. else if (PANEL_READY_EXP == nParam1)
  1525. {
  1526. FINFO("EVT_STATUS_PANEL PANEL_READY_EXP");
  1527. m_SyncUnit->FPDReadyNotify(true);
  1528. m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
  1529. }
  1530. else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
  1531. {
  1532. m_stImgCreateTime = { 0 };
  1533. GetLocalTime(&m_stImgCreateTime);
  1534. FINFO("XWindowOn at {$}-{$}-{$} {$}:{$}:{$}:{$}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
  1535. m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1536. m_SyncUnit->XWindowOnNotify();
  1537. FINFO("m_SyncUnit XWindowOnNotify Finished!");
  1538. }
  1539. else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
  1540. {
  1541. m_stImgCreateTime = { 0 };
  1542. GetLocalTime(&m_stImgCreateTime);
  1543. FINFO("XWindowOff at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
  1544. m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1545. m_SyncUnit->XWindowOffNotify();
  1546. }
  1547. else if (PANEL_START_ACQ == nParam1)
  1548. {
  1549. FINFO("EVT_STATUS_PANEL PANEL_START_ACQ");
  1550. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  1551. }
  1552. else if (PANEL_XRAY_ON == nParam1)
  1553. {
  1554. FINFO("EVT_STATUS_PANEL PANEL_XRAY_ON");
  1555. m_SyncUnit->XrayOnNotify();
  1556. }
  1557. else if (PANEL_XRAY_OFF == nParam1)
  1558. {
  1559. FINFO("EVT_STATUS_PANEL PANEL_XRAY_OFF");
  1560. m_SyncUnit->XrayOffNotify();
  1561. }
  1562. break;
  1563. }
  1564. case EVT_STATUS_CALIBRATIOIN:
  1565. {
  1566. FINFO("EVT_STATUS_PANEL EVT_STATUS_CALIBRATIOIN");
  1567. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1568. switch (eStatus)
  1569. {
  1570. case PANEL_EVENT_START:
  1571. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  1572. break;
  1573. case PANEL_EVENT_BEGIN:
  1574. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  1575. break;
  1576. case PANEL_EVENT_END_OK:
  1577. case PANEL_EVENT_END_ERROR:
  1578. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1579. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1580. m_CalibUnit->SetCalibrationProgress(to_string(100));//make progress
  1581. break;
  1582. case PANEL_EVENT_TIMEOUT:
  1583. break;
  1584. default:
  1585. break;
  1586. }
  1587. break;
  1588. }
  1589. case EVT_STATUS_SINGLEEXP:
  1590. {
  1591. FINFO("EVT_STATUS_PANEL EVT_STATUS_SINGLEEXP");
  1592. if (DOSE_ACCEPT == nParam1)
  1593. {
  1594. FINFO("Calibration Result is acceptable");
  1595. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1596. m_CalibUnit->PauseCalibration();
  1597. }
  1598. else
  1599. {
  1600. FERROR("Not support this param({$})", nParam1);
  1601. }
  1602. break;
  1603. }
  1604. case EVT_STATUS_TEMPERATURE:
  1605. {
  1606. FINFO("EVT_STATUS_PANEL EVT_STATUS_TEMPERATURE");
  1607. float fTemperature = fParam2;
  1608. SendTemperatureValue(fTemperature);
  1609. break;
  1610. }
  1611. case EVT_STATUS_WIFI:
  1612. {
  1613. FINFO("EVT_STATUS_PANEL EVT_STATUS_WIFI");
  1614. int nWifiLevel = nParam1;
  1615. SendWifiValue(nWifiLevel);
  1616. break;
  1617. }
  1618. case EVT_STATUS_BATTERY_VALUE:
  1619. {
  1620. FINFO("EVT_STATUS_PANEL EVT_STATUS_BATTERY_VALUE");
  1621. int nBatteryValue = nParam1;
  1622. SendBatteryValue(nBatteryValue);
  1623. break;
  1624. }
  1625. default:
  1626. FERROR("Not support this event({$})", nEventID);
  1627. break;
  1628. }
  1629. }
  1630. void nsFPD::FPDDeviceTiRay::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
  1631. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1632. {
  1633. switch (nEventID)
  1634. {
  1635. case EVT_DATA_RAW_IMAGE:
  1636. {
  1637. FINFO("EVT_DATA_RAW_IMAGE");
  1638. m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
  1639. memcpy(m_pFullImgBuffer, pParam, (size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight * sizeof(unsigned short));
  1640. //某些值暂时先用假值,有需要再改
  1641. ResDataObject objImageHead, objTemp;
  1642. objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
  1643. objTemp.add(SM_IMAGE_BIT, m_nImgBits);
  1644. objTemp.add(SM_IMAGE_TAG, 1);
  1645. objTemp.add(SM_IMAGE_INDEX, 1);
  1646. objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  1647. objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  1648. objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  1649. objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  1650. objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  1651. objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  1652. objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  1653. objTemp.add(SM_IMAGE_LSB, "5000");
  1654. objTemp.add(SM_IMAGE_DOSE, m_nSensitivity);
  1655. objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
  1656. objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  1657. objTemp.add(SM_IMAGE_FLIP, "No");
  1658. objTemp.add(SM_IMAGE_ORIGINX, "0");
  1659. objTemp.add(SM_IMAGE_ORIGINY, "0");
  1660. objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  1661. objTemp.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
  1662. objTemp.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
  1663. objTemp.add(SM_IMAGE_ROTATION, "No");
  1664. objImageHead.add(SM_IMAGE_HEAD, objTemp);
  1665. FINFO("Full image head: {$}", objImageHead.encode());
  1666. FINFO("Add image Size: FullImageWidth: {$}, FullImageHeight: {$}", m_nFullImageWidth, m_nFullImageHeight);
  1667. m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pFullImgBuffer, m_nFullImageWidth * m_nFullImageHeight);
  1668. FINFO("Add image over");
  1669. break;
  1670. }
  1671. case EVT_DATA_DOSEPARAM:
  1672. {
  1673. m_fDoseParam = fParam2;
  1674. m_WaitCalibDoseEvt->SetEvent();
  1675. break;
  1676. }
  1677. default:
  1678. FERROR("Not support this data({$})", nEventID);
  1679. break;
  1680. }
  1681. }
  1682. void nsFPD::FPDDeviceTiRay::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
  1683. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1684. {
  1685. switch (nEventID)
  1686. {
  1687. case EVT_ERR_COMMUNICATE:
  1688. break;
  1689. case EVT_ERR_INIT_FAILED:
  1690. break;
  1691. default:
  1692. FERROR("Not support this FERROR({$})", nEventID);
  1693. break;
  1694. }
  1695. }
  1696. void nsFPD::FPDDeviceTiRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
  1697. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1698. {
  1699. FERROR("Not support this warn({$})", nEventID);
  1700. }
  1701. RET_STATUS nsFPD::FPDDeviceTiRay::ActiveSyncMode(int nSyncMode)
  1702. {
  1703. FINFO("--Func-- ActiveSyncMode nSyncMode:{$}", nSyncMode);
  1704. m_eSyncMode = (SYNC_MODE)nSyncMode;
  1705. if (g_pDetector->SetSyncMode(nSyncMode))
  1706. {
  1707. return RET_SUCCEED;
  1708. }
  1709. else
  1710. {
  1711. FERROR("ActiveSyncMode fail!");
  1712. return RET_FAILED;
  1713. }
  1714. }
  1715. RET_STATUS nsFPD::FPDDeviceTiRay::UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode)
  1716. {
  1717. FINFO("--Func-- UpdateCalibMode eCalibMode:{$}", (int)eCalibMode);
  1718. m_stDeviceConfig.nCalibMode = (int)eCalibMode;
  1719. if (g_pDetector->UpdateCalibMode(eCalibMode))
  1720. {
  1721. FINFO("UpdateCalibMode success!");
  1722. return RET_SUCCEED;
  1723. }
  1724. else
  1725. {
  1726. FERROR("UpdateCalibMode fail!");
  1727. return RET_FAILED;
  1728. }
  1729. }
  1730. RET_STATUS nsFPD::FPDDeviceTiRay::UpdateLastCalibrationDate(std::string in)
  1731. {
  1732. FINFO("--Func-- UpdateLastCalibrationDate in:{$}", in);
  1733. m_stDeviceConfig.strLastCalibrationDate = in;
  1734. return RET_SUCCEED;
  1735. }
  1736. RET_STATUS nsFPD::FPDDeviceTiRay::UpdateCalibrationFileExpireTime(std::string in)
  1737. {
  1738. FINFO("--Func-- UpdateCalibrationFileExpireTime in:{$}", in);
  1739. m_stDeviceConfig.strCalibrationFileExpireTime = in;
  1740. return RET_SUCCEED;
  1741. }