CCOS.Dev.FPD.TiRayDR.cpp 66 KB

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