DIOS.Dev.FPD.KonicaDR.cpp 67 KB

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