DIOS.Dev.FPD.Yuying.cpp 104 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610
  1. // CCOS.Dev.FPD.Yuying.cpp : 定义 DLL 的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include <stdio.h>
  5. #include <OleAuto.h>
  6. #include <sys/stat.h>
  7. #include "FileVersion.hpp"
  8. #include "common_api.h"
  9. #include "GridSuppression.h"
  10. #include "TemperatureCheck.h"
  11. #include "DICOMImageHeadKey.h"
  12. #include "CCOS.Dev.FPD.Yuying.h"
  13. #include "YuyingCtrl.h"
  14. #pragma comment(lib, "Version.lib")
  15. namespace nsFPD = CCOS::Dev::Detail::Detector;
  16. Log4CPP::Logger* gLogger = nullptr;
  17. static nsFPD::YuyingDriver gIODriver;
  18. //-----------------------------------------------------------------------------
  19. // GetIODriver & CreateIODriver
  20. //-----------------------------------------------------------------------------
  21. extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  22. {
  23. return &gIODriver;
  24. }
  25. extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  26. {
  27. return new nsFPD::YuyingDriver();
  28. }
  29. //-----------------------------------------------------------------------------
  30. // YuyingDriver
  31. //-----------------------------------------------------------------------------
  32. nsFPD::YuyingDriver::YuyingDriver()
  33. {
  34. dev = NULL;
  35. m_bConnect = false;
  36. m_pAttribute.reset(new ResDataObject());
  37. m_pDescription.reset(new ResDataObject());
  38. }
  39. nsFPD::YuyingDriver::~YuyingDriver()
  40. {
  41. }
  42. extern const char* g_szMouldPath;
  43. void nsFPD::YuyingDriver::Prepare()
  44. {
  45. string strWorkPath = GetProcessDirectory();
  46. string strLogPath = strWorkPath + DetectorLogPath; //GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)";
  47. Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.YuyingDM");
  48. auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  49. gLogger = Log4CPP::LogManager::GetLogger("FPD.YuyingDM");
  50. #ifdef WIN64
  51. Force("------------------------ Version: {$} (64-bit) ------------------------", FileVersion(g_szMouldPath).GetVersionString());
  52. #else
  53. Force("------------------------ Version: {$} (32-bit)------------------------", FileVersion(g_szMouldPath).GetVersionString());
  54. #endif
  55. dev = new FPDDeviceYuying(EventCenter, m_ConfigFileName);
  56. Info("new FPDDeviceYuying over");
  57. }
  58. bool nsFPD::YuyingDriver::Connect()
  59. {
  60. Info("YuyingDriver Connect");
  61. m_bConnect = true;
  62. return true;
  63. }
  64. void nsFPD::YuyingDriver::Disconnect()
  65. {
  66. Info("YuyingDriver Disconnect");
  67. m_bConnect = false;
  68. }
  69. bool nsFPD::YuyingDriver::isConnected() const
  70. {
  71. return m_bConnect;
  72. }
  73. auto nsFPD::YuyingDriver::CreateDevice(int index) -> std::unique_ptr <IODevice>
  74. {
  75. Info("CreateDevice({$})", index);
  76. auto Driver = std::unique_ptr <IODevice>(new IODevice(dev));
  77. dev->CreateDevice();
  78. dev->Register();
  79. return Driver;
  80. }
  81. std::string nsFPD::YuyingDriver::DriverProbe()
  82. {
  83. Info("nsFPD::YuyingDriver::Driver_Probe");
  84. ResDataObject r_config, HardwareInfo;
  85. if (r_config.loadFile(m_ConfigFileName.c_str()))
  86. {
  87. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  88. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  89. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  90. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  91. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  92. }
  93. else
  94. {
  95. HardwareInfo.add("MajorID", "Generator");
  96. HardwareInfo.add("MinorID", "Dr");
  97. HardwareInfo.add("VendorID", "Yuying");
  98. HardwareInfo.add("ProductID", "Mars");
  99. HardwareInfo.add("SerialID", "Driver");
  100. }
  101. string ret = HardwareInfo.encode();
  102. return ret;
  103. }
  104. bool nsFPD::YuyingDriver::GetDeviceConfig(std::string& Cfg)
  105. {
  106. Cfg = m_DeviceConfig.encode();
  107. Info("GetDeviceConfig over");
  108. return true;
  109. }
  110. bool nsFPD::YuyingDriver::SetDeviceConfig(std::string Cfg)
  111. {
  112. Info("--Func-- SetDeviceConfig {$} ", Cfg.c_str());
  113. ResDataObject DeviceConfig;
  114. DeviceConfig.decode(Cfg.c_str());
  115. ResDataObject DescriptionTempEx;
  116. DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"];
  117. Info("Attribute:{$}", DescriptionTempEx.encode());
  118. bool bSaveFile = false; //true:重新保存配置文件
  119. string strAccess = "";
  120. for (int i = 0; i < DescriptionTempEx.size(); i++)
  121. {
  122. string strKey = DescriptionTempEx.GetKey(i);
  123. Info("{$}", strKey.c_str());
  124. try
  125. {
  126. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  127. {
  128. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  129. if ("rw" == strAccess)
  130. {
  131. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  132. //1. 修改内存中的值,用于给上层发消息
  133. (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i];
  134. //2. 拿到Innerkey
  135. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  136. Info("ConfigInfo Count: {$}", nConfigInfoCount);
  137. string strTemp = ""; //存储AttributeKey
  138. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  139. {
  140. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  141. if (strTemp == strKey)
  142. {
  143. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  144. break;
  145. }
  146. }
  147. //3. 修改配置文件中的值
  148. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i]))
  149. {
  150. bSaveFile = true;
  151. }
  152. }
  153. else
  154. {
  155. Info("{$} is not a RW configuration item", strKey.c_str());
  156. }
  157. }
  158. else
  159. {
  160. Warn("without this attribute {$}", strKey.c_str());
  161. }
  162. }
  163. catch (...)
  164. {
  165. Error("SetDriverConfig crashed");
  166. return false;
  167. }
  168. }
  169. if (bSaveFile)
  170. {
  171. //3. 重新保存配置文件
  172. SaveConfigFile(true);
  173. }
  174. Info("SetDriverConfig over");
  175. return true;
  176. }
  177. bool nsFPD::YuyingDriver::SaveConfigFile(bool bSendNotify)
  178. {
  179. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  180. m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  181. Info("SaveConfigFile over");
  182. return true;
  183. }
  184. bool nsFPD::YuyingDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
  185. {
  186. strValue = "";
  187. string strTemp = pInnerKey;
  188. //Trace("Inner key: {$}", strTemp);
  189. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  190. {
  191. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  192. {
  193. strValue = (string)config["connections"][pInnerKey];
  194. }
  195. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  196. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  197. {
  198. strValue = (string)config[pInnerKey];
  199. }
  200. else if (SyncType == strTemp || FPDWorkStation == strTemp ||
  201. ImageWidth == strTemp || ImageHeight == strTemp)
  202. {
  203. strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
  204. }
  205. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  206. TempUpperLimit == strTemp || TempLowerLimit == strTemp || "TempMinLimit" == strTemp ||
  207. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  208. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  209. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  210. ShowTemperature == strTemp || ShowWifi == strTemp ||
  211. ShowBattery == strTemp || ShowBluetooth == strTemp ||
  212. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || "Attached" == strTemp)
  213. {
  214. strValue = (string)config[pInnerKey];
  215. }
  216. else
  217. {
  218. strValue = "";
  219. Warn("Error Configuration item: {$}", pInnerKey);
  220. }
  221. }
  222. return true;
  223. }
  224. /***
  225. ** 说明: 设置配置文件内容
  226. ***/
  227. bool nsFPD::YuyingDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue)
  228. {
  229. string strTemp = pInnerKey;
  230. Trace("Begin to change {$} item value to {$}", pInnerKey, szValue);
  231. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  232. {
  233. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  234. {
  235. config["connections"][pInnerKey] = szValue;
  236. }
  237. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  238. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  239. {
  240. config[pInnerKey] = szValue;
  241. }
  242. else if (SyncType == strTemp || FPDWorkStation == strTemp ||
  243. ImageWidth == strTemp || ImageHeight == strTemp)
  244. {
  245. config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
  246. }
  247. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  248. TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
  249. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  250. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  251. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  252. ShowTemperature == strTemp || ShowWifi == strTemp ||
  253. ShowBattery == strTemp || ShowBluetooth == strTemp ||
  254. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp)
  255. {
  256. config[pInnerKey] = szValue;
  257. }
  258. else
  259. {
  260. Warn("Error Configuration item: {$}", pInnerKey);
  261. return false;
  262. }
  263. }
  264. return true;
  265. }
  266. std::string nsFPD::YuyingDriver::GetResource()
  267. {
  268. ResDataObject r_config, temp;
  269. if (!temp.loadFile(m_ConfigFileName.c_str()))
  270. {
  271. return "";
  272. }
  273. m_ConfigAll = temp;
  274. r_config = temp["CONFIGURATION"];
  275. m_Configurations = r_config;
  276. ResDataObject DescriptionTemp;
  277. ResDataObject ListTemp;
  278. string strTemp = ""; //用于读取字符串配置信息
  279. string strIndex = ""; //用于读取配置信息中的List项
  280. int nTemp = -1; //用于读取整型配置信息
  281. char sstream[10] = { 0 }; //用于转换值
  282. string strValue = ""; //用于存储配置的值
  283. string strType = ""; //用于存储配置的类型 int/float/string...
  284. /***
  285. * 1. 通过循环,将所有配置项写到pDeviceConfig
  286. * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
  287. ***/
  288. try
  289. {
  290. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  291. //Trace(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
  292. m_pAttribute->clear();
  293. m_pDescription->clear();
  294. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  295. {
  296. DescriptionTemp.clear();
  297. ListTemp.clear();
  298. //AttributeType
  299. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  300. DescriptionTemp.add(AttributeType, strTemp.c_str());
  301. //Trace(g_pFPDCtrlLog, "--> {$}: {$}", AttributeType, strTemp.c_str());
  302. strType = strTemp; //记录配置项的类型
  303. //AttributeKey
  304. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  305. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  306. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  307. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
  308. //2. 赋值
  309. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  310. if ("int" == strType)
  311. {
  312. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  313. //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str()));
  314. }
  315. else if ("float" == strType)
  316. {
  317. (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
  318. //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str()));
  319. }
  320. else //其它先按string类型处理
  321. {
  322. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  323. //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str());
  324. }
  325. //AttributeAccess
  326. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  327. DescriptionTemp.add(AttributeAccess, strTemp.c_str());
  328. //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str());
  329. //AttributeRangeMin
  330. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  331. if (strTemp != "") //不需要的配置项为空
  332. {
  333. DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
  334. //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str());
  335. }
  336. //AttributeRangeMax
  337. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  338. if (strTemp != "") //不需要的配置项为空
  339. {
  340. DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
  341. //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMax, strTemp.c_str());
  342. }
  343. //AttributeList
  344. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  345. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  346. {
  347. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  348. {
  349. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  350. sprintf_s(sstream, "%d", nListIndex);
  351. ListTemp.add(sstream, strTemp.c_str());
  352. //Trace(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str());
  353. }
  354. DescriptionTemp.add(AttributeList, ListTemp);
  355. }
  356. //AttributeRequired
  357. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  358. DescriptionTemp.add(AttributeRequired, strTemp.c_str());
  359. //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str());
  360. //AttributeDefaultValue
  361. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  362. if (strTemp != "") //不需要的配置项为空
  363. {
  364. DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
  365. //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str());
  366. }
  367. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  368. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  369. }
  370. }
  371. catch (exception e)
  372. {
  373. Error("Get config error: {$}", e.what());
  374. return "";
  375. }
  376. ResDataObject resDeviceResource;
  377. resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
  378. resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
  379. ResDataObject DescriptionTempEx;
  380. DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
  381. m_DeviceConfig = DescriptionTempEx;
  382. string res = DescriptionTempEx.encode();
  383. return res;
  384. }
  385. std::string nsFPD::YuyingDriver::DeviceProbe()
  386. {
  387. ResDataObject r_config, HardwareInfo;
  388. if (r_config.loadFile(m_ConfigFileName.c_str()))
  389. {
  390. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  391. HardwareInfo.add("MinorID", "Device");
  392. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  393. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  394. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  395. }
  396. else
  397. {
  398. HardwareInfo.add("MajorID", "Detector");
  399. HardwareInfo.add("MinorID", "Device");
  400. HardwareInfo.add("VendorID", "Yuying");
  401. HardwareInfo.add("ProductID", "Mars");
  402. HardwareInfo.add("SerialID", "1234");
  403. }
  404. string ret = HardwareInfo.encode();
  405. return ret;
  406. }
  407. extern YuyingCtrl* g_pYuyingCtrl;
  408. const float ABS_ZERO_TEMPERATURE = -273.15f; //绝对零度
  409. nsFPD::FPDDeviceYuying::FPDDeviceYuying(std::shared_ptr <IOEventCenter> center, string ConfigPath)
  410. :m_strSDKPath(""),
  411. m_nDeviceIndex(0),
  412. m_eAppStatus(APP_STATUS_WORK_END),
  413. m_nGridLicense(0),
  414. m_strModuleIP(""),
  415. m_strModuleSN(""),
  416. m_strShockSensor(""),
  417. m_strBatterySN(""),
  418. m_strMotionStatus(""),
  419. m_strSelfTest(""),
  420. m_strLastError(""),
  421. m_strCalibTime(""),
  422. m_bOpened(false),
  423. m_bBatteryCharging(false),
  424. m_bRecoveringImage(false),
  425. m_bAbortRecover(false),
  426. m_bUIReady(false),
  427. m_bImagePendingOrNot(false),
  428. m_bResetDetector(false),
  429. m_nBatteryCapacity(0),
  430. m_nBatteryCharges(0),
  431. m_nShockCounts(0),
  432. m_nWorkStation(0),
  433. m_fDoseParam(0),
  434. m_nRawImgWidth(0),
  435. m_nRawImgHeight(0),
  436. m_nFullImgWidth(0),
  437. m_nFullImgHeight(0),
  438. m_nTopOffset(0),
  439. m_nLeftOffset(0),
  440. m_nImageBits(0),
  441. m_fFactorEXI2UGY(0.0f),
  442. m_bPreviewEnable(false),
  443. m_bTestSensitivity(false),
  444. m_fBatteryTemperature(0.0f),
  445. m_nXrayCalibNum(0),
  446. m_pwFullImageData(nullptr),
  447. m_pwRawImageData(nullptr),
  448. m_pwPreviewImg(nullptr),
  449. m_pPreviewImageHead(NULL),
  450. m_pFullImageHead(NULL),
  451. m_pDetectors(NULL),
  452. m_bDisConnected(false),
  453. m_ExitEvt(NULL),
  454. m_bAttached(false),
  455. m_hNotifyThread(NULL),
  456. m_bRecoverImageStatusInit(false),
  457. m_bSaveRaw(false),
  458. m_bOffsetCalibRunning(false),
  459. m_bUIConfirmRecover(false),
  460. m_nCalibrationType(CCOS_CALIBRATION_TYPE_MAX),
  461. m_CalTemperlowWarn(0.0f),
  462. m_CalTemperupWarn(0.0f),
  463. m_CalTemperWarnInitialed(false)
  464. {
  465. super::EventCenter = center;
  466. g_strAppPath = GetProcessDirectory() + "\\";
  467. m_AcqUnit.reset(new OemAcq(center, this));
  468. m_SyncUnit.reset(new OemSync(center, this));
  469. m_CalibUnit.reset(new OemCalib(center, this));
  470. m_DetectorCtrlUnit.reset(new OemDetectorCtrl(center, this));
  471. m_Battery.reset(new DeviceBatteryMould("DetectorYuyingBattery", 0, 10, 20, 30, 40, 100, 100, 0, center));
  472. m_Temperature.reset(new DeviceTemperatureMould("DetectorYuyingTemperature", ABS_ZERO_TEMPERATURE, 0.0f, 10.0f, 60.0f, 20.0f, 40.0f, 70.0f, 0.0f, center));
  473. m_Wifi.reset(new DeviceWifiMould("DetectorYuyingWifi", 0, 20, 30, 40, 50, 100, 100, 0, center));
  474. m_DetectorConfiguration.reset(new DetectorConfiguration(ConfigPath));
  475. m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, g_strAppPath));
  476. m_CalibProcess.reset(new CalibrationProcess());
  477. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  478. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  479. m_WaitCalibDoseEvt = CreateEvent(0, 1, 0, 0);
  480. m_OffsetCalibrationEvt = CreateEvent(0, 0, 0, 0);
  481. m_PauseCalibrationEvt = CreateEvent(0, 1, 0, 0);
  482. m_CompleteCalibrationEvt = CreateEvent(0, 1, 0, 0);
  483. m_CrateCalibReportEvt = CreateEvent(0, 0, 0, 0);
  484. m_UploadCalibMapOver = CreateEvent(0, 1, 0, 0);
  485. m_ExitEvt = CreateEvent(0, 1, 0, 0);
  486. m_CalibGapEvt = CreateEvent(0, 1, 0, 0);
  487. m_WriteCumstomFileEvt = CreateEvent(0, 1, 0, 0);
  488. }
  489. nsFPD::FPDDeviceYuying::~FPDDeviceYuying()
  490. {
  491. SetEvent(m_ExitEvt);
  492. CloseHandle(m_WaitCalibDoseEvt);
  493. CloseHandle(m_OffsetCalibrationEvt);
  494. CloseHandle(m_PauseCalibrationEvt);
  495. CloseHandle(m_CompleteCalibrationEvt);
  496. CloseHandle(m_CrateCalibReportEvt);
  497. CloseHandle(m_WriteCumstomFileEvt);
  498. CloseHandle(m_UploadCalibMapOver);
  499. CloseHandle(m_CalibGapEvt);
  500. if (m_hNotifyThread != NULL)
  501. {
  502. CloseHandle(m_hNotifyThread);
  503. }
  504. if (m_pwFullImageData)
  505. {
  506. delete[] m_pwFullImageData;
  507. m_pwFullImageData = nullptr;
  508. }
  509. }
  510. std::string nsFPD::FPDDeviceYuying::GetGUID() const
  511. {
  512. return DetectorUnitType;
  513. }
  514. bool nsFPD::FPDDeviceYuying::Prepare()
  515. {
  516. //SetMaxBlockSize(const char *pQueName, DWORD FullBlockSize, DWORD FullBlockCount, DWORD PrevBlockSize, DWORD PrevBlockCount)
  517. EventCenter->OnMaxBlockSize("DrQue", m_nRawImgWidth * m_nRawImgHeight * 2, 3, 1500 * 1500 * 2, 1);
  518. Connect();
  519. return true;
  520. }
  521. void nsFPD::FPDDeviceYuying::RegisterCtrl(nDetail::Dispatch* Dispatch)
  522. {
  523. Dispatch->Action.Push("GetFPDinformation", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
  524. Dispatch->Action.Push("ActiveDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
  525. Dispatch->Action.Push("RESET", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
  526. Dispatch->Action.Push("EnterExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
  527. Dispatch->Action.Push("ExitExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
  528. Dispatch->Action.Push("AttachConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect);
  529. Dispatch->Action.Push("CancelAttach", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach);
  530. Dispatch->Action.Push("RecoverImage", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
  531. Dispatch->Action.Push("ResetConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
  532. Dispatch->Action.Push("DisConnectFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
  533. Dispatch->Action.Push("DisConnectFPDForce", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPDForce);
  534. Dispatch->Action.Push("UpdateFirmware", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
  535. Dispatch->Action.Push("SaveSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
  536. Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
  537. Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
  538. Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);
  539. Dispatch->Get.Push("DetectorStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
  540. Dispatch->Get.Push("DetectorConnectStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
  541. Dispatch->Get.Push("DetectorAttach", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);
  542. Dispatch->Get.Push("FPDAttached", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
  543. //煜影乳腺探测器固定板,只有温度没有电池和Wifi
  544. Dispatch->Get.Push("ShowTemperature", [this](std::string& out) { out = "1"; return RET_STATUS::RET_SUCCEED; });
  545. Dispatch->Get.Push("ShowWifi", [this](std::string& out) { out = "0"; return RET_STATUS::RET_SUCCEED; });
  546. Dispatch->Get.Push("ShowBattery", [this](std::string& out) { out = "0"; return RET_STATUS::RET_SUCCEED; });
  547. Dispatch->Get.Push("DetectorInitialStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus);
  548. Dispatch->Get.Push("DetectorUpdateFWStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
  549. Dispatch->Get.Push("FPDShockSensorInfo", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
  550. Dispatch->Get.Push("FieldofViewShape", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
  551. Dispatch->Get.Push("FieldofViewDimension", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
  552. Dispatch->Get.Push("DetectorType", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
  553. Dispatch->Get.Push("Description", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
  554. Dispatch->Get.Push("DetectorID", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
  555. Dispatch->Get.Push("DateofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
  556. Dispatch->Get.Push("TimeofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
  557. Dispatch->Get.Push("DetectorConditionsNominalFlag", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
  558. Dispatch->Get.Push("FPDSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
  559. Dispatch->Get.Push("FPDSensitivityResult", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivityResult);
  560. Dispatch->Get.Push("PixelData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
  561. Dispatch->Get.Push("TargetEXI", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
  562. Dispatch->Get.Push("FPDLastError", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetLastError);
  563. Dispatch->Get.Push("FirmwareStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFirmwareStatus);
  564. }
  565. void nsFPD::FPDDeviceYuying::RegisterAcq(nDetail::Dispatch* Dispatch)
  566. {
  567. Dispatch->Action.Push("SetAcqMode", m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
  568. Dispatch->Get.Push("ZskkFPDState", m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
  569. Dispatch->Get.Push("NoNeedWaitImage", m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
  570. Dispatch->Get.Push("ImgDataInfo", m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
  571. }
  572. void nsFPD::FPDDeviceYuying::RegisterSync(nDetail::Dispatch* Dispatch)
  573. {
  574. Dispatch->Action.Push("SetSyncMode", m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
  575. Dispatch->Action.Push("SetXwindowSize", m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
  576. Dispatch->Action.Push("PrepareAcquisition", m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
  577. Dispatch->Action.Push("StartAcquisition", m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
  578. Dispatch->Action.Push("StopAcquisition", m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
  579. Dispatch->Action.Push("ActiveSyncMode", m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode);
  580. Dispatch->Get.Push("FPDReadyStatus", m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
  581. Dispatch->Get.Push("XwindowStatus", m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
  582. Dispatch->Get.Push("ImageReadingStatus", m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
  583. Dispatch->Get.Push("SupportSyncMode", m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode);
  584. }
  585. void nsFPD::FPDDeviceYuying::RegisterCalib(nDetail::Dispatch* Dispatch)
  586. {
  587. Dispatch->Action.Push("UploadCalibrationFiles", m_CalibUnit.get(), &CalibUnit::JSUploadCalibrationFiles);
  588. Dispatch->Action.Push("SetSID", m_CalibUnit.get(), &CalibUnit::JSSetSID);
  589. Dispatch->Action.Push("ActiveCalibration", m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
  590. Dispatch->Action.Push("GetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
  591. Dispatch->Action.Push("PrepareCalibration", m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
  592. Dispatch->Action.Push("StartCalibration", m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
  593. Dispatch->Action.Push("StopCalibration", m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
  594. Dispatch->Action.Push("SetCorrectionType", m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
  595. Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
  596. Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
  597. Dispatch->Get.Push("UploadCalibrationFilesResult", m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
  598. }
  599. void nsFPD::FPDDeviceYuying::RegisterOthers(nDetail::Dispatch* Dispatch)
  600. {
  601. Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
  602. Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
  603. Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
  604. Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
  605. Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
  606. Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
  607. Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
  608. Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
  609. Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
  610. Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
  611. Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
  612. Dispatch->Get.Push(m_WarnAndError->m_MSGUnit->GetKey().c_str(), [this](std::string& out) { out = m_WarnAndError->m_MSGUnit->JSGet(); return RET_STATUS::RET_SUCCEED; });
  613. }
  614. void nsFPD::FPDDeviceYuying::Register()
  615. {
  616. auto Disp = &Dispatch;
  617. RegisterCtrl(Disp);
  618. RegisterAcq(Disp);
  619. RegisterSync(Disp);
  620. RegisterCalib(Disp);
  621. RegisterOthers(Disp);
  622. }
  623. bool nsFPD::FPDDeviceYuying::LoadConfig()
  624. {
  625. if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig))
  626. {
  627. Fatal("Load configuration file failed!!! ");
  628. return false;
  629. }
  630. try
  631. {
  632. m_nRawImgWidth = m_stDeviceConfig.nRawWidth;
  633. m_nRawImgHeight = m_stDeviceConfig.nRawHeight;
  634. m_nFullImgWidth = m_stDeviceConfig.nFullImageWidth;
  635. m_nFullImgHeight = m_stDeviceConfig.nFullImageHeight;
  636. m_nImageBits = m_stDeviceConfig.nImageBits;
  637. m_nTopOffset = m_stDeviceConfig.nImageTopOffset;
  638. m_nBottomOffset = m_stDeviceConfig.nImageBottomOffset;
  639. m_nLeftOffset = m_stDeviceConfig.nImageLeftOffset;
  640. m_nRightOffset = m_stDeviceConfig.nImageRightOffset;
  641. m_bPreviewEnable = m_stDeviceConfig.bPreviewEnable;
  642. Debug("PreviewEnable: {$} ", m_bPreviewEnable ? "true" : "false");
  643. SetAttachStatus(1);
  644. m_bSaveRaw = m_stDeviceConfig.nSaveRaw ? true : false;
  645. Debug("Set SaveRaw: {$} ", m_bSaveRaw ? "true" : "false");
  646. m_bForceGridSuppress = m_stDeviceConfig.nForceGridSuppress ? true : false;
  647. Debug("Set ForceGridSuppress: {$}", m_bForceGridSuppress ? "true" : "false");
  648. //SDK目录
  649. m_strSDKPath = (string)m_DetectorConfiguration->m_Configurations["SDKPath"];
  650. Info("SDKPath: {$}", m_strSDKPath);
  651. string strFPDinfo;
  652. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewShape"];
  653. m_DetectorCtrlUnit->SetFieldofViewShape(strFPDinfo);
  654. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewDimension"];
  655. m_DetectorCtrlUnit->SetFieldofViewDimension(strFPDinfo);
  656. m_DetectorCtrlUnit->SetDetectorType("SCINTILLATOR");
  657. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"];
  658. m_DetectorCtrlUnit->SetDescription(strFPDinfo);
  659. m_DetectorCtrlUnit->SetDetectorConditionsNominalFlag("YES");
  660. auto szFDinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI);
  661. m_fFactorEXI2UGY = 100.0f / (float)atof(szFDinfo.c_str()) * 1.0f; //统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  662. Info("FactorEXI2UGY: {$} ", m_fFactorEXI2UGY);
  663. auto strFPDcoef = std::to_string(m_fFactorEXI2UGY);
  664. m_DetectorCtrlUnit->SetFPDSensitivity(strFPDcoef);
  665. string strPixelData = std::to_string(m_stDeviceConfig.nImageBits);
  666. m_DetectorCtrlUnit->SetPixelData(strPixelData);
  667. m_DetectorCtrlUnit->SetTargetEXI("5000");
  668. m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
  669. m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(m_stDeviceConfig.strCalibrationTime);
  670. //------------------------------------可支持的同步模式
  671. ResDataObject jsonSupportSyncType;
  672. jsonSupportSyncType = m_DetectorConfiguration->m_Configurations["SupportSyncMode"];
  673. Debug("SupportSyncMode: {$}", jsonSupportSyncType.encode());
  674. m_SyncUnit->JSSetSupportSyncMode(jsonSupportSyncType.encode());
  675. //--------------------------------------------------------------------------------校正
  676. m_CalibDoseList = m_DetectorConfiguration->m_Configurations["CalibConfig"];
  677. Debug("CalibDoseList: {$} ", m_CalibDoseList.encode());
  678. for (int i = 0; i < m_CalibDoseList.size(); i++)
  679. {
  680. ResDataObject temp = m_CalibDoseList[i];
  681. }
  682. int nConfXrayOnGap = (int)m_DetectorConfiguration->m_Configurations["XrayOnGap"];
  683. m_nConfXrayOnGap = 1000 * nConfXrayOnGap;
  684. Info("XrayOnGap: {$}", m_nConfXrayOnGap);
  685. float fConfGenWaitGap = (float)m_DetectorConfiguration->m_Configurations["GenWaitGap"];
  686. m_nGenWaitGap = (int)(1000.0 * fConfGenWaitGap);
  687. Info("GenWaitGap: {$}", m_nGenWaitGap);
  688. }
  689. catch (exception e)
  690. {
  691. Error("Get has exception error: {$}", e.what());
  692. }
  693. return true;
  694. }
  695. void nsFPD::FPDDeviceYuying::InitializeTemperatureConfigs()
  696. {
  697. auto temperuperror = m_stDeviceConfig.fTemperMaxLimit;
  698. auto temperupwarn = m_stDeviceConfig.fTemperUpLimit;
  699. auto temperlowwarn = m_stDeviceConfig.fTemperLowLimit;
  700. auto temperlowerror = m_stDeviceConfig.fTemperMinLimit;
  701. //Caliberation Temperature ranger
  702. m_CalTemperupWarn = m_stDeviceConfig.fCalibTemperUp;
  703. m_CalTemperlowWarn = m_stDeviceConfig.fCalibTemperLow;
  704. if (m_Temperature)
  705. {
  706. m_Temperature->SetTemperatureErrorMax(to_string(temperuperror));
  707. m_Temperature->SetTemperatureWarningMax(to_string(temperupwarn));
  708. m_Temperature->SetTemperatureCalibWarningMax(to_string(m_CalTemperupWarn));
  709. m_Temperature->SetTemperatureCalibWarningMin(to_string(m_CalTemperlowWarn));
  710. m_Temperature->SetTemperatureWarningMin(to_string(temperlowwarn));
  711. m_Temperature->SetTemperatureErrorMin(to_string(temperlowerror));
  712. }
  713. Info("Temperature config initialize result {$}<{$}<{$}<{$}<{$}<{$}",
  714. temperlowerror, temperlowwarn, m_CalTemperlowWarn, m_CalTemperupWarn, temperupwarn, temperuperror);
  715. }
  716. bool nsFPD::FPDDeviceYuying::CreateDevice()
  717. {
  718. if (!LoadConfig())
  719. {
  720. Info("Load configuration file failed!!! ");
  721. return false;
  722. }
  723. InitializeTemperatureConfigs();
  724. bool bRet = false;
  725. if (g_pYuyingCtrl == NULL)
  726. {
  727. m_pDetectors = new YuyingCtrl();
  728. g_pYuyingCtrl = m_pDetectors;
  729. m_pDetectors->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig);
  730. bRet = m_pDetectors->Init(g_strAppPath);
  731. Info("Create SDK ctrl ok ");
  732. }
  733. else
  734. {
  735. m_pDetectors = g_pYuyingCtrl;
  736. Info("SDK ctrl Already exit ");
  737. m_pDetectors->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig);
  738. }
  739. return bRet;
  740. }
  741. RET_STATUS nsFPD::FPDDeviceYuying::Connect()
  742. {
  743. Info("------------------------ FPD type {$}, Device {$} Start running. ------------------------ ", m_stDeviceConfig.strDeviceName.c_str(), this);
  744. string strPath = g_strAppPath + m_strSDKPath + "\\FpdSys.dll";
  745. m_stDeviceConfig.strSoftware = GetFileVersion(strPath);
  746. Info("Yuying SDK version: {$}", m_stDeviceConfig.strSoftware.c_str());
  747. if (m_stDeviceConfig.bConnectStatus)
  748. {
  749. Info("Already Connected, return");
  750. return RET_STATUS::RET_SUCCEED;
  751. }
  752. if (m_bDisConnected)
  753. {
  754. Info("Already DisConnected, just return");
  755. return RET_STATUS::RET_FAILED;
  756. }
  757. if (m_bOpened) //已经初始化连接设备
  758. {
  759. Info("Already init, return");
  760. return RET_STATUS::RET_SUCCEED;
  761. }
  762. if (m_hNotifyThread == NULL)
  763. {
  764. m_hNotifyThread = CreateThread(0, 0, OnNotify, this, 0, &m_NotifyThreadID);
  765. if (m_hNotifyThread == NULL)
  766. {
  767. Info("Start Exposure Thread Failed!");
  768. }
  769. else
  770. {
  771. Info("Start Exposure Thread End");
  772. }
  773. }
  774. //g_strAppPath = "C:\\SVN\\Ccos\\CcosDriver_V2\\Deliver\\Bin\\ReleaseX64";
  775. bool bRet = m_pDetectors->Connect(g_strAppPath, this);
  776. if (!bRet)
  777. {
  778. Error("Device connect failed!");
  779. return RET_STATUS::RET_FAILED;
  780. }
  781. m_bOpened = true;
  782. Info("call connect detector over ");
  783. return RET_STATUS::RET_SUCCEED;
  784. }
  785. DWORD nsFPD::FPDDeviceYuying::OnNotify(LPVOID pParam)
  786. {
  787. Info("OnNotify Loop Entry-----------");
  788. FPDDeviceYuying* pNotifyOpr = (FPDDeviceYuying*)pParam;
  789. HANDLE* pHandles = new HANDLE[6];
  790. pHandles[0] = pNotifyOpr->m_PauseCalibrationEvt;
  791. pHandles[1] = pNotifyOpr->m_CompleteCalibrationEvt;
  792. pHandles[2] = pNotifyOpr->m_OffsetCalibrationEvt;
  793. pHandles[3] = pNotifyOpr->m_CrateCalibReportEvt;
  794. pHandles[4] = pNotifyOpr->m_WriteCumstomFileEvt;
  795. pHandles[5] = pNotifyOpr->m_ExitEvt;
  796. int nHandlesNum = 6;
  797. DWORD nTimeOut = 5000;
  798. while (1)
  799. {
  800. DWORD dwResult = WaitForMultipleObjects(nHandlesNum, pHandles, FALSE, nTimeOut);
  801. if (dwResult == WAIT_TIMEOUT)
  802. {
  803. if (!pNotifyOpr->m_stDeviceConfig.bConnectStatus)
  804. {
  805. Info("connect to FPD not finished");
  806. continue;
  807. }
  808. }
  809. if (dwResult == WAIT_OBJECT_0)//m_PauseCalibrationEvt
  810. {
  811. Info("OnNotify get PauseCalibration evt");
  812. pNotifyOpr->PauseCalibration();
  813. }
  814. if (dwResult == WAIT_OBJECT_0 + 1)//m_CompleteCalibrationEvt
  815. {
  816. ResetEvent(pNotifyOpr->m_CompleteCalibrationEvt);
  817. Info("OnNotify get CompleteCalibration evt");
  818. pNotifyOpr->CompleteCalibration();
  819. }
  820. else if (dwResult == WAIT_OBJECT_0 + 2)//m_OffsetCalibrationEvt
  821. {
  822. Info("OnNotify get m_OffsetCalibrationEvt evt");
  823. while (pNotifyOpr->m_bOffsetCalibRunning)
  824. {
  825. Info("Send XWindow Notify ");
  826. pNotifyOpr->m_SyncUnit->XWindowOnNotify();
  827. Sleep(10000);
  828. pNotifyOpr->m_SyncUnit->XWindowOffNotify();
  829. }
  830. Info("end m_OffsetCalibrationEvt evt");
  831. }
  832. else if (dwResult == WAIT_OBJECT_0 + 3)//m_CrateCalibReportEvt
  833. {
  834. Info("OnNotify get m_CrateCalibReportEvt evt");
  835. pNotifyOpr->SaveFailedCalibFile();
  836. break;
  837. }
  838. else if (dwResult == WAIT_OBJECT_0 + 4)//m_WriteCumstomFileEvt
  839. {
  840. Info("OnNotify get m_WriteCumstomFileEvt evt");
  841. pNotifyOpr->m_pDetectors->WriteCumstomFile(pNotifyOpr->m_nDeviceIndex);
  842. break;
  843. }
  844. else if (dwResult == WAIT_OBJECT_0 + 5)//m_ExitEvt
  845. {
  846. Info("Exit OnNotify Thread");
  847. break;
  848. }
  849. }
  850. delete[] pHandles;
  851. CloseHandle(pNotifyOpr->m_ExitEvt);
  852. return 0;
  853. }
  854. RET_STATUS nsFPD::FPDDeviceYuying::ActiveDetector(bool bActive)
  855. {
  856. if (bActive)
  857. {
  858. Info("ActiveDetector");
  859. bool bRet = (m_pDetectors)->ActivePanel(this, bActive);
  860. if (!bRet)
  861. {
  862. return RET_STATUS::RET_FAILED;
  863. }
  864. //SendAllError();
  865. }
  866. else
  867. {
  868. Info("UnActiveDetector");
  869. bool bRet = (m_pDetectors)->ActivePanel(this, bActive);
  870. if (!bRet)
  871. {
  872. return RET_STATUS::RET_FAILED;
  873. }
  874. //ClearAllError();
  875. }
  876. return RET_STATUS::RET_SUCCEED;
  877. }
  878. void nsFPD::FPDDeviceYuying::UnactiveBySDK(void* pActviedDPC)
  879. {
  880. if (pActviedDPC != this)
  881. {
  882. //goto Unactive status, clear errorlist
  883. }
  884. }
  885. RET_STATUS nsFPD::FPDDeviceYuying::PrepareAcquisition()
  886. {
  887. Info("==============================PrepareAcquisition");
  888. if (!m_stDeviceConfig.bConnectStatus)
  889. {
  890. return RET_STATUS::RET_THREAD_INVALID;
  891. }
  892. m_pDetectors->PrepareAcquisition(this);
  893. m_SyncUnit->FPDReadyNotify(true);
  894. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  895. Info("PrepareAcquisition over");
  896. return RET_STATUS::RET_SUCCEED;
  897. }
  898. RET_STATUS nsFPD::FPDDeviceYuying::StartAcquisition(string in)
  899. {
  900. Info("StartAcquisition ");
  901. if (!m_stDeviceConfig.bConnectStatus)
  902. {
  903. return RET_STATUS::RET_THREAD_INVALID;
  904. }
  905. m_AcqUnit->ImagerPixelSpacingNotify(m_stDeviceConfig.nPixelSpace);
  906. m_bAbortRecover = false;//能执行StartAcq,说明没有错误可以ready曝光。不再影响abort后再次recoverimage功能
  907. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  908. if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartAcquisition(this))
  909. {
  910. Ret = RET_STATUS::RET_SUCCEED;
  911. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  912. }
  913. else
  914. {
  915. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  916. Error("StartAcquisition failed");
  917. }
  918. Info("StartAcquisition over");
  919. return Ret;
  920. }
  921. RET_STATUS nsFPD::FPDDeviceYuying::StopAcquisition()
  922. {
  923. Info("StopAcquisition ");
  924. if (!m_stDeviceConfig.bConnectStatus)
  925. {
  926. return RET_STATUS::RET_THREAD_INVALID;
  927. }
  928. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  929. if (RET_STATUS::RET_SUCCEED == m_pDetectors->StopAcquisition(this))
  930. {
  931. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  932. Ret = RET_STATUS::RET_SUCCEED;
  933. }
  934. Info("StopAcquisition over ");
  935. return Ret;
  936. }
  937. //设置同步模式
  938. RET_STATUS nsFPD::FPDDeviceYuying::ActiveSyncMode(int nSyncMode)
  939. {
  940. Info("=====ActiveSyncMode: {$}", nSyncMode);
  941. if (!m_stDeviceConfig.bConnectStatus)
  942. {
  943. return RET_STATUS::RET_FAILED;
  944. }
  945. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  946. if (m_pDetectors->ActiveSyncMode(this, nSyncMode))
  947. {
  948. Ret = RET_STATUS::RET_SUCCEED;
  949. Info("ActiveSyncMode success");
  950. }
  951. return Ret;
  952. }
  953. string nsFPD::FPDDeviceYuying::GetFileVersion(string strFilePathName)
  954. {
  955. DWORD dwVerSize = GetFileVersionInfoSize(strFilePathName.c_str(), NULL);
  956. if (dwVerSize == 0)
  957. {
  958. return "";
  959. }
  960. LPVOID pVersionBuffer = malloc(dwVerSize);
  961. if (nullptr == pVersionBuffer)
  962. {
  963. return "";
  964. }
  965. GetFileVersionInfo(strFilePathName.c_str(), 0, dwVerSize, pVersionBuffer);
  966. VS_FIXEDFILEINFO* pInfo;
  967. UINT nInfoLen;
  968. char szValue[MAX_PATH] = { 0 };
  969. if (VerQueryValue(pVersionBuffer, ("\\"), (void**)&pInfo, &nInfoLen))
  970. {
  971. sprintf_s(szValue, ("%d.%d.%d.%d"),
  972. HIWORD(pInfo->dwFileVersionMS), LOWORD(pInfo->dwFileVersionMS),
  973. HIWORD(pInfo->dwFileVersionLS), LOWORD(pInfo->dwFileVersionLS));
  974. }
  975. string strVersion = szValue;
  976. return strVersion;
  977. }
  978. void nsFPD::FPDDeviceYuying::SendTemperatureValue(float fTemp)
  979. {
  980. int nStatus = 0;
  981. m_Temperature->SetTemperature(fTemp, nStatus);
  982. Info("SendTemperatureValue: {$}, status {$} ", fTemp, nStatus);
  983. return;
  984. }
  985. void nsFPD::FPDDeviceYuying::SendWifiValue(int nWifi)
  986. {
  987. int nStatus = 0;
  988. m_Wifi->SetSignalValue(nWifi, nStatus);
  989. Info("SendWifiValue: {$}, status {$} ", nWifi, nStatus);
  990. return;
  991. }
  992. void nsFPD::FPDDeviceYuying::SendBatteryValue(int nBattery)
  993. {
  994. int nStatus = 0;
  995. m_Battery->SetRemainPowerValue(nBattery, nStatus);
  996. Info("SendBatteryValue: {$}, status {$} ", nBattery, nStatus);
  997. return;
  998. }
  999. RET_STATUS nsFPD::FPDDeviceYuying::XWindowOnNotify()
  1000. {
  1001. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1002. m_SyncUnit->XWindowOnNotify();
  1003. Info("WindowOn ");
  1004. m_stImgCreateTime = { 0 };
  1005. GetLocalTime(&m_stImgCreateTime);
  1006. Info("Full image create time-{$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1007. return Ret;
  1008. }
  1009. RET_STATUS nsFPD::FPDDeviceYuying::XWindowOffNotify()
  1010. {
  1011. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1012. m_SyncUnit->XWindowOffNotify();
  1013. Info("WindowOff ");
  1014. return Ret;
  1015. }
  1016. RET_STATUS nsFPD::FPDDeviceYuying::ActiveCalibration(CCOS_CALIBRATION_TYPE Type)
  1017. {
  1018. Info("ActiveCalibration is {$}", (int)Type);
  1019. if (!m_stDeviceConfig.bConnectStatus)
  1020. {
  1021. Info(" unconnected ");
  1022. return RET_STATUS::RET_THREAD_INVALID;
  1023. }
  1024. if (Type == CCOS_CALIBRATION_TYPE_NONE || Type == CCOS_CALIBRATION_TYPE_MAX)
  1025. {
  1026. Info(" type error {$} ", (int)Type);
  1027. return RET_STATUS::RET_INVALID;
  1028. }
  1029. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  1030. m_nCalibrationType = Type;
  1031. OnErrorX(ERR_FPD_DOSE_LOW);
  1032. OnErrorX(ERR_FPD_DOSE_HIGH);
  1033. OnErrorX(ERR_FPD_DOSE_OBJ);//清除之前的错误,如果有的话
  1034. RET_STATUS Ret = m_pDetectors->ActiveCalibration(Type, this);
  1035. if (RET_STATUS::RET_SUCCEED == Ret)
  1036. {
  1037. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  1038. m_CalibUnit->SetCalibrationProgress("0");
  1039. if (Type == CCOS_CALIBRATION_TYPE_XRAY)
  1040. {
  1041. ResetEvent(m_WaitCalibDoseEvt);
  1042. }
  1043. m_nXrayCalibNum = 0;
  1044. }
  1045. ResetEvent(m_OffsetCalibrationEvt);
  1046. ResetEvent(m_CompleteCalibrationEvt);
  1047. Info("ActiveCalibration {$} over", (int)Type);
  1048. return Ret;
  1049. }
  1050. RET_STATUS nsFPD::FPDDeviceYuying::GetRequestedDose(string& strDose)
  1051. {
  1052. Info("GetRequestedDose");
  1053. if (!m_stDeviceConfig.bConnectStatus)
  1054. {
  1055. return RET_STATUS::RET_THREAD_INVALID;
  1056. }
  1057. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1058. bool bGetDoseInfo = false;
  1059. ResDataObject out;
  1060. if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
  1061. {
  1062. out.add("Dose", 0.0f);
  1063. out.add("kV", 0.0f);
  1064. out.add("mA", 0.0f);
  1065. out.add("ms", 0.0f);
  1066. out.add("mAs", 0.0f);
  1067. bGetDoseInfo = true;
  1068. Ret = RET_STATUS::RET_SUCCEED;
  1069. }
  1070. else if (CCOS_CALIBRATION_TYPE_XRAY == m_nCalibrationType)
  1071. {
  1072. float fDose = (m_fDoseParam * 1.0f) / 1000.0f;
  1073. Info("GetRequestedDose Xray {$} over {$}", fDose, m_fDoseParam);
  1074. Ret = RET_STATUS::RET_SUCCEED;
  1075. for (int i = 0; i < m_CalibDoseList.size(); i++)
  1076. {
  1077. ResDataObject temp = m_CalibDoseList[i];
  1078. int nDose = temp["Dose"];
  1079. if (m_fDoseParam == nDose)
  1080. {
  1081. out.add("Dose", nDose);
  1082. out.add("kV", temp["kV"]);
  1083. out.add("mA", temp["mA"]);
  1084. out.add("ms", temp["ms"]);
  1085. out.add("mAs", temp["mAs"]);
  1086. bGetDoseInfo = true;
  1087. break;
  1088. }
  1089. }
  1090. }
  1091. else
  1092. {
  1093. Ret = RET_STATUS::RET_FAILED;
  1094. }
  1095. if (bGetDoseInfo)
  1096. {
  1097. strDose = out.encode();
  1098. Info("GetRequestedDose {$} over", strDose.c_str());
  1099. }
  1100. else
  1101. {
  1102. Error("GetRequestedDose failed");
  1103. }
  1104. return Ret;
  1105. }
  1106. RET_STATUS nsFPD::FPDDeviceYuying::PrepareCalibration()
  1107. {
  1108. Info("PrepareCalibration");
  1109. if (!m_stDeviceConfig.bConnectStatus)
  1110. {
  1111. return RET_STATUS::RET_THREAD_INVALID;
  1112. }
  1113. m_SyncUnit->FPDReadyNotify(true);
  1114. if (CCOS_CALIBRATION_TYPE_XRAY == m_nCalibrationType)
  1115. {
  1116. int nWaitTime = m_nConfXrayOnGap - m_nGenWaitGap;
  1117. WaitForSingleObject(m_CalibGapEvt, nWaitTime);
  1118. }
  1119. Info("PrepareCalibration over");
  1120. return RET_STATUS::RET_SUCCEED;
  1121. }
  1122. RET_STATUS nsFPD::FPDDeviceYuying::StartCalibration()
  1123. {
  1124. Info("StartCalibration ");
  1125. if (!m_stDeviceConfig.bConnectStatus)
  1126. {
  1127. return RET_STATUS::RET_THREAD_INVALID;
  1128. }
  1129. if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
  1130. {
  1131. m_bOffsetCalibRunning = true;
  1132. SetEvent(m_OffsetCalibrationEvt);
  1133. }
  1134. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1135. ResetEvent(m_PauseCalibrationEvt);
  1136. if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartCalibration(this))
  1137. {
  1138. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  1139. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  1140. Ret = RET_STATUS::RET_SUCCEED;
  1141. }
  1142. else
  1143. {
  1144. Error("StartCalibration failed ");
  1145. Ret = RET_STATUS::RET_FAILED;
  1146. }
  1147. Info("StartCalibration over ");
  1148. return RET_STATUS::RET_SUCCEED;
  1149. }
  1150. RET_STATUS nsFPD::FPDDeviceYuying::PauseCalibration()
  1151. {
  1152. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1153. m_nXrayCalibNum++;
  1154. //int nDose = (int)m_fDoseParam;
  1155. //if (nDose == 25 && m_nXrayCalibNum == 10)
  1156. if (m_nXrayCalibNum != 20)
  1157. {
  1158. Info("start to waitting CalibDoseEvt");
  1159. DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
  1160. //m_nXrayCalibNum = 0;
  1161. }
  1162. //else if (nDose != 25)
  1163. //{
  1164. // if (m_nXrayCalibNum != 13)
  1165. // {
  1166. // Info("start to waitting CalibDoseEvt");
  1167. // DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
  1168. // }
  1169. //}
  1170. ResetEvent(m_PauseCalibrationEvt);
  1171. ResetEvent(m_WaitCalibDoseEvt);
  1172. m_AcqUnit->SendNoNeedWaitImage(true);
  1173. if (m_nXrayCalibNum != 20)
  1174. {
  1175. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1176. m_CalibUnit->PauseCalibration();
  1177. }
  1178. Info("Driver PauseCalibration over,m_nXrayCalibNum {$}", m_nXrayCalibNum);
  1179. return Ret;
  1180. }
  1181. RET_STATUS nsFPD::FPDDeviceYuying::StopCalibration()
  1182. {
  1183. Info("StopCalibration ");
  1184. if (!m_stDeviceConfig.bConnectStatus)
  1185. {
  1186. return RET_STATUS::RET_THREAD_INVALID;
  1187. }
  1188. if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
  1189. {
  1190. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
  1191. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1192. m_CalibUnit->SetCalibrationProgress("100");
  1193. Info("StopDarkCalibration over ");
  1194. return RET_STATUS::RET_SUCCEED;
  1195. }
  1196. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1197. m_eAppStatus = APP_STATUS_CAL_END;
  1198. if (RET_STATUS::RET_SUCCEED == m_pDetectors->AbortCalibration(this))
  1199. {
  1200. Ret = RET_STATUS::RET_SUCCEED;
  1201. }
  1202. else
  1203. {
  1204. Ret = RET_STATUS::RET_FAILED;
  1205. }
  1206. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
  1207. m_CalibUnit->SetCalibrationProgress("100");
  1208. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1209. m_AcqUnit->SendNoNeedWaitImage(true);
  1210. Info("StopCalibration over ");
  1211. return RET_STATUS::RET_SUCCEED;
  1212. }
  1213. void nsFPD::FPDDeviceYuying::AbortCalibration()
  1214. {
  1215. Info("AbortCalibration ");
  1216. if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
  1217. {
  1218. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  1219. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1220. m_CalibUnit->SetCalibrationProgress("100");
  1221. Info("AbortDarkCalibration over ");
  1222. return;
  1223. }
  1224. m_eAppStatus = APP_STATUS_CAL_END;
  1225. m_pDetectors->AbortCalibration(this);
  1226. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  1227. m_CalibUnit->SetCalibrationProgress("100");
  1228. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1229. m_AcqUnit->SendNoNeedWaitImage(true);
  1230. Info("AbortXrayCalibration over");
  1231. return;
  1232. }
  1233. void nsFPD::FPDDeviceYuying::StopCalibrationInside()
  1234. {
  1235. Info("StopCalibrationInside");
  1236. if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
  1237. {
  1238. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1239. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1240. m_CalibUnit->SetCalibrationProgress("100");
  1241. Info("StopCalibrationInside dark over");
  1242. return;
  1243. }
  1244. m_eAppStatus = APP_STATUS_CAL_END;
  1245. m_pDetectors->AbortCalibration(this);
  1246. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1247. m_CalibUnit->SetCalibrationProgress("100");
  1248. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1249. m_AcqUnit->SendNoNeedWaitImage(true);
  1250. Info("StopCalibrationInside xray over");
  1251. return;
  1252. }
  1253. bool nsFPD::FPDDeviceYuying::CompleteCalibration()
  1254. {
  1255. m_stDeviceConfig.fCalibTemperature = m_stDeviceConfig.fCurrentTemperValue;
  1256. ResetEvent(m_UploadCalibMapOver);
  1257. m_pDetectors->CompleteCalibration(this);
  1258. DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000);
  1259. if (WAIT_OBJECT_0 == nRet)
  1260. {
  1261. Info("got event m_UploadCalibMapOver");
  1262. }
  1263. else if (WAIT_TIMEOUT == nRet)
  1264. {
  1265. Info("wait event m_UploadCalibMapOver timeout");
  1266. }
  1267. else
  1268. {
  1269. Info("wait event m_UploadCalibMapOver error");
  1270. }
  1271. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1272. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1273. m_CalibUnit->SetCalibrationProgress("100");
  1274. CheckCalibartionDue();
  1275. return true;
  1276. }
  1277. void nsFPD::FPDDeviceYuying::SaveFailedCalibFile()
  1278. {
  1279. m_pDetectors->SaveFailedCalibFiles(m_nDeviceIndex, false);
  1280. }
  1281. RET_STATUS nsFPD::FPDDeviceYuying::ResetConnect()
  1282. {
  1283. Info("Reset Connect");
  1284. m_pDetectors->ResetFPD(this);
  1285. Info("FPDDeviceYuying::ResetConnect over ");
  1286. return RET_STATUS::RET_SUCCEED;
  1287. }
  1288. RET_STATUS nsFPD::FPDDeviceYuying::DisConnectFPD()
  1289. {
  1290. Info("DisConnectFPD");
  1291. if (!m_pDetectors->DisConnect(this))
  1292. {
  1293. Error("DisConnectFPD failed");
  1294. return RET_STATUS::RET_FAILED;
  1295. }
  1296. SendWifiValue(0);
  1297. SendBatteryValue(0);
  1298. SendTemperatureValue(ABS_ZERO_TEMPERATURE);
  1299. m_bDisConnected = true;
  1300. ResetAllError();
  1301. Info("DisConnectFPD over");
  1302. return RET_STATUS::RET_SUCCEED;
  1303. }
  1304. RET_STATUS nsFPD::FPDDeviceYuying::UpdateFirmware()
  1305. {
  1306. m_pDetectors->OnUpdateFirmware(this);
  1307. return RET_STATUS::RET_SUCCEED;
  1308. }
  1309. RET_STATUS nsFPD::FPDDeviceYuying::AttachConnect()
  1310. {
  1311. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START));
  1312. return RET_STATUS::RET_SUCCEED;
  1313. }
  1314. RET_STATUS nsFPD::FPDDeviceYuying::CancelAttach()
  1315. {
  1316. return RET_STATUS::RET_SUCCEED;
  1317. }
  1318. RET_STATUS nsFPD::FPDDeviceYuying::SetAttachStatus(int nStatus)
  1319. {
  1320. return m_DetectorCtrlUnit->SetAttachStatus(to_string(nStatus));
  1321. }
  1322. void nsFPD::FPDDeviceYuying::FullImageDateArrived(WORD* pImg)
  1323. {
  1324. AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight);
  1325. }
  1326. void nsFPD::FPDDeviceYuying::PrevImageDateArrived(WORD* pImg)
  1327. {
  1328. AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight);
  1329. }
  1330. RET_STATUS nsFPD::FPDDeviceYuying::SetXwindow(float XwindowSize)
  1331. {
  1332. Info("SetXwindowSize {$}", XwindowSize);
  1333. Info("SetXwindowSize over");
  1334. return RET_STATUS::RET_SUCCEED;
  1335. }
  1336. RET_STATUS nsFPD::FPDDeviceYuying::EnterExam(int nExamStatus)
  1337. {
  1338. Info("EnterExam");
  1339. switch (nExamStatus)
  1340. {
  1341. case APP_STATUS_WORK_BEGIN:
  1342. Info("Enter into Exam Windows");
  1343. OnErrorX(ERR_FPD_DOSE_LOW);
  1344. OnErrorX(ERR_FPD_DOSE_HIGH);
  1345. OnErrorX(ERR_FPD_DOSE_OBJ);//清除之前校正的错误,如果有的话
  1346. break;
  1347. case APP_STATUS_WORK_END:
  1348. Info("Quit Exam Windows");
  1349. m_bTestSensitivity = false;
  1350. break;
  1351. case APP_STATUS_DETSHARE_BEGIN:
  1352. Info("Enter into Detector Share Windows");
  1353. break;
  1354. case APP_STATUS_DETSHAR_END:
  1355. Info("Quit Detector Share Windows");
  1356. break;
  1357. case APP_STATUS_CAL_BEGIN:
  1358. Info("Enter into Calibration Windows");
  1359. break;
  1360. case APP_STATUS_CAL_END:
  1361. Info("Quit Calibration Windows");
  1362. break;
  1363. case APP_STATUS_WORK_IN_SENSITIVITY:
  1364. Info("Enter into sensitivity test interface");
  1365. m_bTestSensitivity = true;
  1366. break;
  1367. default:
  1368. Warn("Undefined app status");
  1369. break;
  1370. }
  1371. m_eAppStatus = (APP_STATUS)nExamStatus;
  1372. m_pDetectors->EnterExam(m_eAppStatus);
  1373. return RET_STATUS::RET_SUCCEED;
  1374. }
  1375. RET_STATUS nsFPD::FPDDeviceYuying::SetAcqMode(int mode)
  1376. {
  1377. if (!m_stDeviceConfig.bConnectStatus)
  1378. {
  1379. Error("m_stDeviceConfig.bConnectStatus = false ");
  1380. return RET_STATUS::RET_THREAD_INVALID;
  1381. }
  1382. if (nullptr == m_pwFullImageData)
  1383. {
  1384. m_pwFullImageData = new WORD[m_nFullImgWidth * m_nFullImgHeight];
  1385. }
  1386. m_AcqUnit->SetFulImageInfo(m_nFullImgWidth, m_nFullImgHeight, m_nImageBits, false);
  1387. m_AcqUnit->SetPrevImageInfo(m_stDeviceConfig.bPreviewEnable, m_stDeviceConfig.nPreviewHeight, m_stDeviceConfig.nPreviewWidth, false);
  1388. if (!m_pDetectors->SelectExamMode(1, this))
  1389. {
  1390. Error("Set acqmode failed");
  1391. return RET_STATUS::RET_FAILED;
  1392. }
  1393. return RET_STATUS::RET_SUCCEED;
  1394. }
  1395. RET_STATUS nsFPD::FPDDeviceYuying::SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode)
  1396. {
  1397. if (!m_stDeviceConfig.bConnectStatus)
  1398. {
  1399. return RET_STATUS::RET_THREAD_INVALID;
  1400. }
  1401. //return (m_pDetectors)->SetSyncMode(nSyncMode, TriggerMode);
  1402. return RET_STATUS::RET_SUCCEED;
  1403. }
  1404. void nsFPD::FPDDeviceYuying::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1405. {
  1406. m_nDeviceIndex = nDetectorID;
  1407. switch (nEventLevel)
  1408. {
  1409. case EVT_LEVEL_CONFIGURATION:
  1410. {
  1411. OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1412. break;
  1413. }
  1414. case EVT_LEVEL_INFORMATOION:
  1415. {
  1416. OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1417. break;
  1418. }
  1419. case EVT_LEVEL_STATUS:
  1420. {
  1421. OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1422. break;
  1423. }
  1424. case EVT_LEVEL_DATA:
  1425. {
  1426. OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1427. break;
  1428. }
  1429. case EVT_LEVEL_WARNING:
  1430. {
  1431. OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1432. break;
  1433. }
  1434. case EVT_LEVEL_ERROR:
  1435. {
  1436. OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1437. break;
  1438. }
  1439. default:
  1440. {
  1441. break;
  1442. }
  1443. }
  1444. }
  1445. void nsFPD::FPDDeviceYuying::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1446. {
  1447. switch (nEventID)
  1448. {
  1449. case EVT_CONF_PANEL_SERIAL:
  1450. {
  1451. m_stDeviceConfig.strPanelSerial = pszMsg;
  1452. Info("Receive Panel {$} SN {$}", nDetectorID, pszMsg);
  1453. char cDetectorID[17] = { 0 };
  1454. memcpy(cDetectorID, m_stDeviceConfig.strPanelSerial.c_str(), 16);
  1455. string strDetectorID = cDetectorID;
  1456. m_DetectorCtrlUnit->SetDetectorID(strDetectorID);
  1457. Info("SedDetectorID {$}", strDetectorID.c_str());
  1458. if (!m_bRecoverImageStatusInit)
  1459. {
  1460. m_RecoverImageStatus.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
  1461. m_RecoverImageStatus.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
  1462. m_RecoverImageStatus.add("DetectorWifiSignal", "1");
  1463. m_RecoverImageStatus.add("Result", "-1");
  1464. m_bRecoverImageStatusInit = true;
  1465. }
  1466. break;
  1467. }
  1468. case EVT_CONF_RAW_WIDTH:
  1469. {
  1470. if (m_stDeviceConfig.nFullImageWidth != nParam1)
  1471. {
  1472. m_stDeviceConfig.nFullImageWidth = nParam1;
  1473. }
  1474. Info("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth);
  1475. break;
  1476. }
  1477. case EVT_CONF_RAW_HIGHT:
  1478. {
  1479. if (m_stDeviceConfig.nFullImageHeight != nParam1)
  1480. {
  1481. m_stDeviceConfig.nFullImageHeight = nParam1;
  1482. }
  1483. Info("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight);
  1484. break;
  1485. }
  1486. case EVT_CONF_RAW_BITS:
  1487. {
  1488. if (m_stDeviceConfig.nImageBits != nParam1)
  1489. {
  1490. m_stDeviceConfig.nImageBits = nParam1;
  1491. }
  1492. m_stDeviceConfig.nImageBits = nParam1;
  1493. Info("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits);
  1494. break;
  1495. }
  1496. case EVT_CONF_PIXELSPACE:
  1497. {
  1498. m_stDeviceConfig.nPixelSpace = nParam1;
  1499. Info("Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
  1500. break;
  1501. }
  1502. case EVT_CONF_PREVIEW_WIDTH:
  1503. {
  1504. if (m_stDeviceConfig.nPreviewWidth != nParam1)
  1505. {
  1506. m_stDeviceConfig.nPreviewWidth = nParam1;
  1507. }
  1508. Info("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
  1509. break;
  1510. }
  1511. case EVT_CONF_PREVIEW_HIGHT:
  1512. {
  1513. if (m_stDeviceConfig.nPreviewHeight != nParam1)
  1514. {
  1515. m_stDeviceConfig.nPreviewHeight = nParam1;
  1516. }
  1517. Info("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
  1518. break;
  1519. }
  1520. case EVT_CONF_MODULE_TYPE:
  1521. {
  1522. Info("Receive Panel {$} ModuleType {$}", nDetectorID, pszMsg);
  1523. break;
  1524. }
  1525. case EVT_CONF_MODULE_IP:
  1526. {
  1527. m_strModuleIP = pszMsg;
  1528. Info("Receive Panel {$} ModuleIP {$}", nDetectorID, pszMsg);
  1529. break;
  1530. }
  1531. case EVT_CONF_MODULE_SN:
  1532. {
  1533. m_strModuleSN = pszMsg;
  1534. Info("Receive Panel {$} ModuleSN {$}", nDetectorID, pszMsg);
  1535. break;
  1536. }
  1537. case EVT_CONF_FIRWARE_UPDATE:
  1538. {
  1539. m_stDeviceConfig.nFirmwareStatus = nParam1;
  1540. m_DetectorCtrlUnit->SetFirmwareStatus(to_string(nParam1));
  1541. Info("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
  1542. break;
  1543. }
  1544. case EVT_CONF_PART_NUMBER:
  1545. {
  1546. break;
  1547. }
  1548. case EVT_CONF_BATTERY_SN:
  1549. {
  1550. m_strBatterySN = pszMsg;
  1551. Info("Panel {$} Battery SN:{$}", nDetectorID, pszMsg);
  1552. break;
  1553. }
  1554. case EVT_CONF_WIFI_SSID:
  1555. {
  1556. m_stDeviceConfig.strWifiSSID = pszMsg;
  1557. Info("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg);
  1558. break;
  1559. }
  1560. case EVT_CONF_IFBOARD:
  1561. {
  1562. Info("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg);
  1563. break;
  1564. }
  1565. default:
  1566. {
  1567. break;
  1568. }
  1569. }
  1570. }
  1571. void nsFPD::FPDDeviceYuying::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1572. {
  1573. int nID = nDetectorID;
  1574. switch (nEventID)
  1575. {
  1576. case EVT_INFO_BATTERY_CAPACITY:
  1577. {
  1578. int nBatteryCapacity = nParam1;
  1579. if ((nBatteryCapacity != m_nBatteryCapacity) && (m_strBatterySN != ""))
  1580. {
  1581. Info("{$},SN:{$}", nBatteryCapacity, m_strBatterySN);
  1582. m_nBatteryCapacity = nBatteryCapacity;
  1583. }
  1584. break;
  1585. }
  1586. case EVT_INFO_BATTERY_TEMPERATURE:
  1587. {
  1588. float fBatteryTemper = fParam2;
  1589. if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) && (m_strBatterySN != ""))
  1590. {
  1591. Info("SN:{$} ,temperature:{$}", m_strBatterySN, fBatteryTemper);
  1592. m_fBatteryTemperature = fBatteryTemper;
  1593. }
  1594. break;
  1595. }
  1596. case EVT_INFO_BATTERY_CHARGES:
  1597. {
  1598. int nBatteryCharges = nParam1;
  1599. if ((nBatteryCharges != m_nBatteryCharges) && (m_strBatterySN != ""))
  1600. {
  1601. Info("SN:{$},Charge number:{$}", m_strBatterySN, nBatteryCharges);
  1602. m_nBatteryCharges = nBatteryCharges;
  1603. }
  1604. break;
  1605. }
  1606. case EVT_INFO_WIFI_DATARATE:
  1607. {
  1608. if (nParam1 != m_stDeviceConfig.nWifiDataRate)
  1609. {
  1610. }
  1611. m_stDeviceConfig.nWifiDataRate = nParam1;
  1612. Info("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate);
  1613. break;
  1614. }
  1615. case EVT_INFO_WIFI_CHANNEL:
  1616. {
  1617. m_stDeviceConfig.nWifiChannel = nParam1;
  1618. Info("Panel {$} WifiChannel:{$}", nID, m_stDeviceConfig.nWifiChannel);
  1619. break;
  1620. }
  1621. case EVT_INFO_WIFI_SIGNALPOWER:
  1622. {
  1623. m_stDeviceConfig.nWifiSignalPower = nParam1;
  1624. break;
  1625. }
  1626. case EVT_INFO_WIFI_NOISEPOWER:
  1627. {
  1628. m_stDeviceConfig.nWifiNoisePower = nParam1;
  1629. Info("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower);
  1630. break;
  1631. }
  1632. case EVT_INFO_SHOCKSENSOR_INFO:
  1633. {
  1634. Info("Receive ShockSensor Info");
  1635. m_strShockSensor = pszMsg;
  1636. m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor);
  1637. break;
  1638. }
  1639. case EVT_INFO_CALIBRATIOIN_DATE:
  1640. {
  1641. //m_stDeviceConfig.strCalibrationDate = pszMsg;
  1642. Info("Panel {$} STE Calibration Date:{$}", nID, pszMsg);
  1643. //m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
  1644. //m_stDeviceConfig.strCalibrationDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationDate);
  1645. break;
  1646. }
  1647. case EVT_INFO_CALIBRATIOIN_TIME:
  1648. {
  1649. Info("Panel {$} STE Calibration Time:{$}", nID, pszMsg);
  1650. m_stDeviceConfig.strCalibrationTime = pszMsg;
  1651. m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(m_stDeviceConfig.strCalibrationTime);
  1652. break;
  1653. }
  1654. default:
  1655. {
  1656. break;
  1657. }
  1658. }
  1659. }
  1660. void nsFPD::FPDDeviceYuying::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1661. {
  1662. int nID = nDetectorID;
  1663. string strWarnErrorCode = "";
  1664. switch (nEventID)
  1665. {
  1666. case EVT_STATUS_INIT:
  1667. {
  1668. if (PANEL_EVENT_END_OK == nParam1)
  1669. {
  1670. OnInitResult(true);
  1671. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
  1672. Info("connect FPD ok. Start Status Polling");
  1673. }
  1674. else if (PANEL_EVENT_END_ERROR == nParam1)
  1675. {
  1676. OnInitResult(false);
  1677. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_FAILED));
  1678. }
  1679. else if (PANEL_EVENT_END == nParam1) //未连接探测器
  1680. {
  1681. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
  1682. }
  1683. else if (PANEL_EVENT_START == nParam1)
  1684. {
  1685. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START));
  1686. }
  1687. break;
  1688. }
  1689. case EVT_STATUS_MOTION:
  1690. {
  1691. m_strMotionStatus = pszMsg;
  1692. break;
  1693. }
  1694. case EVT_STATUS_UPDATE_FIRMWARE:
  1695. {
  1696. if (PANEL_EVENT_START == nParam1)
  1697. {
  1698. Info("Start update firmware");
  1699. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START));
  1700. }
  1701. else if (PANEL_EVENT_BEGIN == nParam1)
  1702. {
  1703. Info("Update firmware begin");
  1704. m_stDeviceConfig.bConnectStatus = false;
  1705. }
  1706. else if (PANEL_EVENT_END_ERROR == nParam1)
  1707. {
  1708. Info("Update firmware failed");
  1709. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR));
  1710. }
  1711. else if (PANEL_EVENT_SUCCESS == nParam1)
  1712. {
  1713. Info("update firmware success");
  1714. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS));
  1715. }
  1716. else if (PANEL_EVENT_FWU_ERROR_BATTERY == nParam1)
  1717. {
  1718. Info("update firmware failed, battery < 50");
  1719. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR_BATTERY));
  1720. }
  1721. else if (PANEL_EVENT_FWU_ERROR_OMIT == nParam1)
  1722. {
  1723. Info("update firmware failed, Omit");
  1724. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR_OMIT));
  1725. }
  1726. break;
  1727. }
  1728. case EVT_STATUS_DETECTORSHARE:
  1729. {
  1730. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1731. switch (eStatus)
  1732. {
  1733. case PANEL_CONNECT_OK:
  1734. {
  1735. string strError = ERR_FPD_NOFPD;
  1736. OnErrorX(strError); //之前可能会提示NO DETECTOR
  1737. Info("SetConnectStatus(PANEL_CONNECT_OK)");
  1738. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
  1739. m_stDeviceConfig.bConnectStatus = true;
  1740. SetAttachStatus(1);
  1741. m_bAttached = true;
  1742. break;
  1743. }
  1744. case PANEL_CONNECT_ERROR:
  1745. {
  1746. Info("SetConnectStatus(PANEL_CONNECT_ERROR)");
  1747. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
  1748. }
  1749. break;
  1750. case PANEL_DISCONNECT_SUCCESS:
  1751. {
  1752. m_nBatteryCapacity = 0;
  1753. m_strBatterySN = "";
  1754. m_stDeviceConfig.bExisted = false;
  1755. m_stDeviceConfig.bConnectStatus = false;
  1756. Info("SetConnectStatus(PANEL_DISCONNECT_SUCCESS)");
  1757. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
  1758. break;
  1759. }
  1760. case PANEL_DISCONNECT_ERROR:
  1761. Info("SetConnectStatus(PANEL_DISCONNECT_ERROR)");
  1762. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
  1763. break;
  1764. default:
  1765. break;
  1766. }
  1767. break;
  1768. }
  1769. case EVT_STATUS_SINGLEINIT:
  1770. {
  1771. break;
  1772. }
  1773. case EVT_STATUS_SELECTPANEL:
  1774. {
  1775. break;
  1776. }
  1777. case EVT_STATUS_PANEL:
  1778. {
  1779. ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
  1780. if (PANEL_STANDBY == nParam1)
  1781. {
  1782. Info("Panel Status:PREPARE");
  1783. }
  1784. else if (PANEL_READY_EXP == nParam1)
  1785. {
  1786. Info("Panel Status:READY");
  1787. Action_ExpReady();
  1788. }
  1789. else if (PANEL_OFFSET_CAL == nParam1)
  1790. {
  1791. Info("Panel Status:PANEL_OFFSET_CAL");
  1792. }
  1793. else if (PANEL_OFFSET_FINISH == nParam1)
  1794. {
  1795. Info("Panel Status:PANEL_OFFSET_FINISH");
  1796. m_bOffsetCalibRunning = false;
  1797. StopCalibrationInside();
  1798. }
  1799. else if (PANEL_OFFSET_FAILED == nParam1)
  1800. {
  1801. Info("Panel Status:PANEL_OFFSET_FAILED");
  1802. m_bOffsetCalibRunning = false;
  1803. AbortCalibration();
  1804. }
  1805. else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
  1806. {
  1807. Info("Panel Status:XWINDOW_ON");
  1808. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  1809. XWindowOnNotify();
  1810. }
  1811. else if (PANEL_XWINDOW_OFF == nParam1) //Xwindow Off
  1812. {
  1813. Info("Panel Status:XWINDOW_OFF");
  1814. XWindowOffNotify();
  1815. }
  1816. else if (PANEL_GAIN_FINISH == nParam1)
  1817. {
  1818. Info("Panel Status:CALIBRATION_FINISH");
  1819. }
  1820. else if (PANEL_GAIN_PREPARE == nParam1)
  1821. {
  1822. Info("Detector Notify Xray Prepare");
  1823. }
  1824. else if (PANEL_GAIN_READY_EXP == nParam1)
  1825. {
  1826. Action_ExpReady();
  1827. }
  1828. else
  1829. {
  1830. Info("Panel {$} Status is :{$}", nID, (int)m_ePanelStatus);
  1831. }
  1832. break;
  1833. }
  1834. case EVT_STATUS_CALIBRATIOIN:
  1835. {
  1836. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1837. switch (eStatus)
  1838. {
  1839. case PANEL_EVENT_START:
  1840. break;
  1841. case PANEL_EVENT_END_OK:
  1842. Info("Calibration process is success");
  1843. //CompleteCalibration();
  1844. SetEvent(m_CompleteCalibrationEvt);
  1845. break;
  1846. case PANEL_EVENT_END_ERROR:
  1847. Info("Calibration process is failed");
  1848. break;
  1849. case PANEL_EVENT_TIMEOUT:
  1850. Info("Calibration timeout");
  1851. Info("Calibration process is failed");
  1852. break;
  1853. case PANEL_EVENT_CALIB_REPORT:
  1854. Info("Create Calibration Report failed");
  1855. SetEvent(m_CrateCalibReportEvt);
  1856. break;
  1857. default:
  1858. break;
  1859. }
  1860. break;
  1861. }
  1862. case EVT_STATUS_SAVECALIB:
  1863. {
  1864. if (PANEL_EVENT_START == nParam1)
  1865. {
  1866. Info("Begin to Save Calibration Files");
  1867. }
  1868. else if (PANEL_EVENT_END_ERROR == nParam1)
  1869. {
  1870. SetEvent(m_UploadCalibMapOver);
  1871. Info("Save Calibration Files failed");
  1872. }
  1873. else if (PANEL_EVENT_END == nParam1)
  1874. {
  1875. SetEvent(m_UploadCalibMapOver);
  1876. Info("Save Calibration Files Success");
  1877. }
  1878. break;
  1879. }
  1880. case EVT_STATUS_SAVEDEFECT:
  1881. {
  1882. if (PANEL_EVENT_START == nParam1)
  1883. {
  1884. Info("Begin to Save Defect Files");
  1885. }
  1886. else if (PANEL_EVENT_END_ERROR == nParam1)
  1887. {
  1888. SetEvent(m_UploadCalibMapOver);
  1889. Info("Save Defect Files failed");
  1890. }
  1891. else if (PANEL_EVENT_END == nParam1)
  1892. {
  1893. Info("Save Defect Files Success");
  1894. SetEvent(m_UploadCalibMapOver);
  1895. }
  1896. break;
  1897. }
  1898. case EVT_STATUS_ACQUISITION:
  1899. {
  1900. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1901. switch (eStatus)
  1902. {
  1903. case PANEL_EVENT_START:
  1904. break;
  1905. case PANEL_EVENT_END_OK:
  1906. break;
  1907. case PANEL_EVENT_END_ERROR: //由于断线造成指令执行失败
  1908. {
  1909. string strWarnErrorCode = ERR_FPD_ACQ_FAILED;//fixbug 12473 开窗失败不用ERR_FPD_RESTART上报
  1910. OnError(strWarnErrorCode);
  1911. break;
  1912. }
  1913. default:
  1914. break;
  1915. }
  1916. break;
  1917. }
  1918. case EVT_STATUS_PREPARE_EDNCALIBRATION:
  1919. break;
  1920. case EVT_STATUS_SINGLEEXP:
  1921. {
  1922. if (DOSE_TOO_HIGH == nParam1)
  1923. {
  1924. Info("Dose too high");
  1925. m_strLastError = "Current dose level is too high and beyond the tolerance interval";
  1926. OnError(ERR_FPD_DOSE_HIGH, m_strLastError);
  1927. AbortCalibration();
  1928. }
  1929. else if (DOSE_TOO_LOW == nParam1)
  1930. {
  1931. Info("Dose too low");
  1932. m_strLastError = "Current dose level is too low and beyond the tolerance interval";
  1933. OnError(ERR_FPD_DOSE_LOW, m_strLastError);
  1934. AbortCalibration();
  1935. }
  1936. else if (DOSE_OBJECT == nParam1)
  1937. {
  1938. Info("Dose object");
  1939. m_strLastError = "Calibration has failed. Please check emergency stop button or calibration switch, otherwise call service.";
  1940. OnError(ERR_FPD_DOSE_OBJ, m_strLastError);
  1941. AbortCalibration();
  1942. }
  1943. else if (DOSE_ACCEPT == nParam1)
  1944. {
  1945. Info("Calibration Result is acceptable");
  1946. m_strLastError = "";
  1947. OnErrorX(ERR_FPD_DOSE_LOW);
  1948. OnErrorX(ERR_FPD_DOSE_HIGH);
  1949. OnErrorX(ERR_FPD_DOSE_OBJ);
  1950. SetEvent(m_PauseCalibrationEvt);
  1951. }
  1952. else if (PANEL_EVENT_END_OK == nParam1)
  1953. {
  1954. }
  1955. else if (PANEL_EVENT_END_ERROR == nParam1)
  1956. {
  1957. AbortCalibration();
  1958. }
  1959. break;
  1960. }
  1961. case EVT_STATUS_IMAGEPENDING:
  1962. {
  1963. string strTemp = pszMsg;
  1964. if (strTemp.find("true") != std::string::npos)
  1965. {
  1966. m_bImagePendingOrNot = true;
  1967. }
  1968. else
  1969. {
  1970. m_bImagePendingOrNot = false;
  1971. }
  1972. if (m_bImagePendingOrNot) // && !m_bResetDetector
  1973. {
  1974. OnError(ERR_FPD_IMAGE_PENDING);
  1975. }
  1976. else
  1977. {
  1978. m_bResetDetector = false;//可以再次reset
  1979. OnErrorX(ERR_FPD_IMAGE_PENDING);
  1980. }
  1981. break;
  1982. }
  1983. case EVT_STATUS_IMAGERECOVERAUTO:
  1984. {
  1985. OnErrorX(ERR_FPD_IMAGE_PENDING);
  1986. m_RecoverImageStatus["Result"] = "0";
  1987. Info("m_RecoverImageStatus[Result] = 0 by auto");
  1988. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  1989. m_bAbortRecover = false; //终止恢复图像的变量也要重置
  1990. m_bRecoveringImage = false; //不再恢复图像过程中
  1991. m_nRecoverImageTimes = 0; //下次恢复图像,重置
  1992. m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
  1993. break;
  1994. }
  1995. case EVT_STATUS_TEMPERATURE:
  1996. {
  1997. float fTemperature = fParam2;
  1998. OnProcessTemperature(nID, fTemperature);
  1999. m_stDeviceConfig.fCurrentTemperValue = fTemperature;
  2000. Info("Detector {$} Temperature Value:{$}", nID, fTemperature);
  2001. SendTemperatureValue(fTemperature);
  2002. break;
  2003. }
  2004. case EVT_STATUS_WIFI:
  2005. {
  2006. int nWifiLevel = nParam1;
  2007. Info("Detector {$} Wifi Value:{$}", nID, nWifiLevel);
  2008. strWarnErrorCode = ERR_FPD_WIFI_LOW;
  2009. if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错
  2010. {
  2011. OnErrorX(strWarnErrorCode);
  2012. }
  2013. else if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
  2014. {
  2015. //wifi error
  2016. OnWarnX(WAR_FPD_WIFI_LOW);
  2017. OnError(strWarnErrorCode);
  2018. }
  2019. else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning)
  2020. {
  2021. //wifi error
  2022. OnErrorX(strWarnErrorCode);
  2023. strWarnErrorCode = WAR_FPD_WIFI_LOW;
  2024. OnWarn(nID, strWarnErrorCode);
  2025. }
  2026. else
  2027. {
  2028. OnErrorX(strWarnErrorCode);
  2029. strWarnErrorCode = WAR_FPD_WIFI_LOW;
  2030. OnWarnX(strWarnErrorCode);
  2031. }
  2032. if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue)
  2033. {
  2034. Info("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}",
  2035. m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate);
  2036. }
  2037. m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
  2038. SendWifiValue(nWifiLevel);
  2039. break;
  2040. }
  2041. case EVT_STATUS_BATTERY_VALUE:
  2042. {
  2043. int nBatteryValue = nParam1;
  2044. Info("Detector {$} Battery:{$}", nID, nParam1);
  2045. if (nBatteryValue < m_stDeviceConfig.nBatteryLimit)
  2046. {
  2047. if (!m_bBatteryCharging) //如果没有充电;
  2048. {
  2049. strWarnErrorCode = ERR_FPD_BATTERY_LOW;
  2050. OnError(strWarnErrorCode);
  2051. strWarnErrorCode = WAR_FPD_BATTERY_LOW;
  2052. OnWarnX(strWarnErrorCode);
  2053. }
  2054. }
  2055. else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
  2056. {
  2057. //battery error
  2058. strWarnErrorCode = ERR_FPD_BATTERY_LOW;
  2059. OnErrorX(strWarnErrorCode);
  2060. strWarnErrorCode = WAR_FPD_BATTERY_LOW;
  2061. //这里需要滤波,如果2次以上都检测到低于告警值才上报该警告
  2062. OnWarn(nID, strWarnErrorCode);
  2063. }
  2064. else
  2065. {
  2066. strWarnErrorCode = ERR_FPD_BATTERY_LOW;
  2067. OnErrorX(strWarnErrorCode);
  2068. strWarnErrorCode = WAR_FPD_BATTERY_LOW;
  2069. OnWarnX(strWarnErrorCode);
  2070. }
  2071. m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
  2072. Info("Detector {$} Battery Value:{$}", nID, nBatteryValue);
  2073. if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
  2074. {
  2075. //防止探测器电池电量状态异常跳变
  2076. SendBatteryValue(nBatteryValue);
  2077. }
  2078. else
  2079. {
  2080. SendBatteryValue(nBatteryValue);
  2081. }
  2082. break;
  2083. }
  2084. case EVT_STATUS_BATTERY_CHARGING:
  2085. {
  2086. string strTemp = pszMsg;
  2087. if (strTemp.find("true") != std::string::npos)
  2088. {
  2089. m_bBatteryCharging = true;
  2090. }
  2091. else
  2092. {
  2093. m_bBatteryCharging = false;
  2094. }
  2095. break;
  2096. }
  2097. case EVT_STATUS_SHOCK_SENSOR:
  2098. {
  2099. m_nShockCounts = nParam1;
  2100. string strWarn = WAR_FPD_MAX_SHOCK_NUM;
  2101. Info("Panel {$} Shock Sensor Number:{$}", nID, m_nShockCounts);
  2102. if ((m_nShockCounts >= m_stDeviceConfig.nMaxShockNumber) && (m_stDeviceConfig.nShockTimes != m_nShockCounts))//避免频繁发送
  2103. {
  2104. Info("Reach Max Shock Sensor Number");
  2105. OnWarn(nID, strWarn);
  2106. }
  2107. else
  2108. {
  2109. OnWarnX(strWarn);
  2110. }
  2111. m_stDeviceConfig.nShockTimes = m_nShockCounts;
  2112. break;
  2113. }
  2114. case EVT_STATUS_HALL_SENSOR:
  2115. {
  2116. int nWorkstaion = nParam1;
  2117. Info("Update Hall Status : {$} ", nWorkstaion);
  2118. Info("Panel {$} WS:{$},Current OGP WS:{$} ", nID, nWorkstaion, m_nWorkStation);
  2119. m_stDeviceConfig.nWorkstation = nWorkstaion;
  2120. break;
  2121. }
  2122. case EVT_STATUS_PING:
  2123. {
  2124. break;
  2125. }
  2126. case EVT_STATUS_PMSNOTOPEN:
  2127. {
  2128. string strTemp = pszMsg;
  2129. if (strTemp.find("true") != std::string::npos)
  2130. {
  2131. Info("PMS isn't open");
  2132. //SendInfoPopup("PMSOpenNote");
  2133. }
  2134. break;
  2135. }
  2136. case EVT_STATUS_RESTOREFILES:
  2137. {
  2138. string strTemp = pszMsg;
  2139. Info("Restore calibration files");
  2140. break;
  2141. }
  2142. case EVT_STATUS_LASTERROR:
  2143. {
  2144. m_strLastError = pszMsg;
  2145. Info("Panel {$} LastError {$}", nID, pszMsg);
  2146. break;
  2147. }
  2148. case EVT_STATUS_RESET:
  2149. {
  2150. break;
  2151. }
  2152. default:
  2153. {
  2154. break;
  2155. }
  2156. }
  2157. }
  2158. //保存RAW图数据
  2159. void nsFPD::FPDDeviceYuying::SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight)
  2160. {
  2161. Info("Begin SaveRawImage: {$}, width: {$}, height: {$}", pImgName, nWidth, nHeight);
  2162. if (pRawImg == NULL || pImgName == NULL)
  2163. {
  2164. Error("Undefined parameter");
  2165. return;
  2166. }
  2167. string strImagePath = g_strAppPath + "Image\\" + pImgName;
  2168. FILE* fp;
  2169. if ((fp = fopen(strImagePath.c_str(), "wb")) == NULL)
  2170. {
  2171. DWORD dw = GetLastError();
  2172. Error("fopen {$} failed, {$}", strImagePath.c_str(), dw);
  2173. return;
  2174. }
  2175. fwrite(pRawImg, sizeof(WORD), nWidth * nHeight, fp);
  2176. fclose(fp);
  2177. Info("End SaveRawImage");
  2178. return;
  2179. }
  2180. void nsFPD::FPDDeviceYuying::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  2181. {
  2182. switch (nEventID)
  2183. {
  2184. case EVT_DATA_RAW_IMAGE:
  2185. {
  2186. Info("Image Arrved");
  2187. if (APP_STATUS_IDLE == m_eAppStatus)
  2188. {
  2189. Error("Omit Image in Idle Status");
  2190. return;
  2191. }
  2192. Info("RawImageWidth: {$}, RawImageHeight: {$}; FullImageWidth: {$}, FullImageHeight: {$}", m_nRawImgWidth, m_nRawImgHeight, m_nFullImgWidth, m_nFullImgHeight);
  2193. float fImageReferUGY = 2.5;
  2194. memcpy(m_pwFullImageData, pParam, m_nFullImgWidth * m_nFullImgHeight * sizeof(WORD));
  2195. if (m_bSaveRaw)
  2196. {
  2197. SaveRawImage("YuyingDMImage.raw", m_pwFullImageData, m_nFullImgWidth, m_nFullImgHeight);
  2198. }
  2199. OnProcessImage(m_pwFullImageData, m_nFullImgWidth, m_nFullImgHeight, fImageReferUGY);
  2200. break;
  2201. }
  2202. case EVT_DATA_PREVIEW_IMAGE:
  2203. {
  2204. Info("Preview Image Arrved");
  2205. m_SyncUnit->ImageReadingNotify();
  2206. if (NULL == m_pwPreviewImg)
  2207. {
  2208. m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight];
  2209. }
  2210. memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD));
  2211. OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  2212. break;
  2213. }
  2214. case EVT_DATA_DOSEPARAM:
  2215. {
  2216. m_fDoseParam = nParam1;// static_cast<int>(fParam2 * 1000);
  2217. Info("calibration dose {$}, Param1 {$}", m_fDoseParam, nParam1);
  2218. SetEvent(m_WaitCalibDoseEvt);
  2219. break;
  2220. }
  2221. default:
  2222. {
  2223. break;
  2224. }
  2225. }
  2226. }
  2227. void nsFPD::FPDDeviceYuying::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  2228. {
  2229. string strErrorName = "";
  2230. switch (nEventID)
  2231. {
  2232. case EVT_ERR_COMMUNICATE:
  2233. {
  2234. strErrorName = ERR_FPD_DISCONNECT;
  2235. string strTemp = pszMsg;
  2236. if (strTemp.find("true") != std::string::npos)
  2237. {
  2238. m_stDeviceConfig.nWorkstation = -1;
  2239. m_stDeviceConfig.bConnectStatus = false;
  2240. m_nBatteryCapacity = 0;
  2241. m_stDeviceConfig.nCurrentWifiValue = 0;
  2242. m_stDeviceConfig.nCurrentBatteryValue = 0;
  2243. SendWifiValue(0);
  2244. SendBatteryValue(0);
  2245. //fix 断开连接时温度保留当前值,清除温度相关告警信息
  2246. ProcessTempreatureOnLostCommunicate();
  2247. OnError(strErrorName);
  2248. }
  2249. else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo
  2250. {
  2251. //SendResultJson("Communication",true);
  2252. if (m_stDeviceConfig.nCurrentWifiValue != -1)
  2253. {
  2254. SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
  2255. SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
  2256. SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
  2257. }
  2258. m_stDeviceConfig.bConnectStatus = true;
  2259. //if (m_WarnAndError->IsErrorExist(ERR_FPD_DISCONNECT)) //如果已经恢复了通讯,不再重复发送LOG
  2260. {
  2261. OnErrorX(strErrorName);
  2262. }//endif
  2263. OnErrorX(ERR_FPD_ACQ_FAILED);//fixbug 12473 开窗失败不用ERR_FPD_RESTART上报
  2264. }
  2265. break;
  2266. }
  2267. case EVT_ERR_EXP_REQUEST:
  2268. {
  2269. string strTemp = pszMsg;
  2270. if (strTemp.find("true") != std::string::npos)
  2271. {
  2272. //SendCmd(nID, Sequence_C, L"FRM", String_C, _T("00040000")); //帧曝光失败
  2273. }
  2274. else
  2275. {
  2276. return;
  2277. }
  2278. strErrorName = ERR_FPD_ACQ_FAILED;
  2279. break;
  2280. }
  2281. case EVT_ERR_GET_IMAGE:
  2282. {
  2283. string strTemp = pszMsg;
  2284. if (strTemp.find("true") != std::string::npos)
  2285. {
  2286. if (APP_STATUS_WORK_BEGIN != m_eAppStatus) //如果不在检查界面;
  2287. {
  2288. Fatal("there are image exist in current detector,do you want to continue");
  2289. }
  2290. else //if (m_bSiemensCmd)
  2291. {
  2292. Fatal("FPD has exposed Image!");
  2293. CallSiemensRecoverAction(true);
  2294. }
  2295. //endif
  2296. }
  2297. else if (strTemp.find("false") != std::string::npos)
  2298. {
  2299. if (m_bRecoveringImage)
  2300. {
  2301. CallSiemensRecoverAction(false);
  2302. }
  2303. else
  2304. {
  2305. m_bAbortRecover = false; //终止恢复图像的变量也要重置
  2306. m_bRecoveringImage = false; //不再恢复图像过程中
  2307. m_nRecoverImageTimes = 0; //下次恢复图像,重置
  2308. m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
  2309. }
  2310. }
  2311. break;
  2312. }
  2313. case EVT_ERR_MAX_NUMBER:
  2314. {
  2315. strErrorName = ERR_FPD_MAX_NUMBER;
  2316. string strTemp = pszMsg;
  2317. if (strTemp.find("true") != std::string::npos)
  2318. {
  2319. Error("Exceed max number");
  2320. OnError(strErrorName);
  2321. }
  2322. break;
  2323. }
  2324. case EVT_ERR_SN_NOTINLIST:
  2325. {
  2326. strErrorName = ERR_FPD_SN_NOT_LIST;
  2327. Error("Not in List");
  2328. string strTemp = pszMsg;
  2329. if (strTemp.find("true") != std::string::npos)
  2330. {
  2331. OnError(strErrorName);
  2332. }
  2333. break;
  2334. }
  2335. case EVT_ERR_POWER_OFF:
  2336. {
  2337. strErrorName = ERR_FPD_POWEROFF;
  2338. string strTemp = pszMsg;
  2339. if (strTemp.find("true") != std::string::npos)
  2340. {
  2341. ProcessTempreatureOnLostCommunicate();
  2342. OnError(strErrorName);
  2343. m_stDeviceConfig.bConnectStatus = false;
  2344. }
  2345. else if (strTemp.find("false") != std::string::npos)
  2346. {
  2347. OnErrorX(strErrorName);
  2348. }
  2349. break;
  2350. }
  2351. case EVT_ERR_INIT_FAILED:
  2352. {
  2353. strErrorName = ERR_FPD_FATAL_ERROR;
  2354. string strTemp = pszMsg;
  2355. if (strTemp.find("true") != std::string::npos)
  2356. {
  2357. OnError(strErrorName);
  2358. m_stDeviceConfig.bConnectStatus = false;
  2359. }
  2360. else if (strTemp.find("false") != std::string::npos)
  2361. {
  2362. OnErrorX(strErrorName);
  2363. }
  2364. break;
  2365. }
  2366. default:
  2367. {
  2368. }
  2369. }
  2370. }
  2371. void nsFPD::FPDDeviceYuying::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  2372. {
  2373. string strWarnName = "";
  2374. }
  2375. bool nsFPD::FPDDeviceYuying::OnInitResult(bool bSuccess)
  2376. {
  2377. if (bSuccess)
  2378. {
  2379. m_stDeviceConfig.bConnectStatus = true;
  2380. //CheckCalibartionDue();
  2381. //LoadSensitivity();
  2382. m_stDeviceConfig.bInitOK = true;
  2383. }
  2384. else
  2385. {
  2386. m_stDeviceConfig.bConnectStatus = false;
  2387. }
  2388. m_stDeviceConfig.bExisted = true;
  2389. auto temperuperror = m_stDeviceConfig.fTemperMaxLimit;
  2390. auto temperlowerror = m_stDeviceConfig.fTemperMinLimit;
  2391. auto temperupwarn = m_stDeviceConfig.fTemperUpLimit;
  2392. auto temperlowwarn = m_stDeviceConfig.fTemperLowLimit;
  2393. if (m_Temperature)
  2394. {
  2395. m_Temperature->SetTemperatureErrorMax(to_string(temperuperror));
  2396. m_Temperature->SetTemperatureWarningMax(to_string(temperupwarn));
  2397. m_Temperature->SetTemperatureCalibWarningMax(to_string(m_CalTemperupWarn));
  2398. m_Temperature->SetTemperatureCalibWarningMin(to_string(m_CalTemperlowWarn));
  2399. m_Temperature->SetTemperatureWarningMin(to_string(temperlowwarn));
  2400. m_Temperature->SetTemperatureErrorMin(to_string(temperlowerror));
  2401. }
  2402. auto wifiWarning = m_stDeviceConfig.nWifiWarning;
  2403. auto wifiError = m_stDeviceConfig.nWifiLimit;
  2404. if (m_Wifi)
  2405. {
  2406. m_Wifi->SetSignalWarningMin(to_string(wifiWarning));
  2407. m_Wifi->SetSignalErrorMin(to_string(wifiError));
  2408. }
  2409. return true;
  2410. }
  2411. //-----------------------------------------------------------------------------
  2412. //
  2413. // 函数名称 : CheckCalibartionDue
  2414. // 函数描述 : 检查校正文件是否过期
  2415. // 返回类型 : 过期true or false
  2416. // 接口参数 :
  2417. //
  2418. //-----------------------------------------------------------------------------
  2419. bool nsFPD::FPDDeviceYuying::CheckCalibartionDue()
  2420. {
  2421. Info("[Checking Calibration Date]");
  2422. string strWarn = WAR_FPD_LOAD_CORRECT_FILE;
  2423. if (!m_CalibProcess->CheckCalibartionDue(m_stDeviceConfig))
  2424. {
  2425. OnWarn(m_nDeviceIndex, strWarn);
  2426. return false;
  2427. }
  2428. OnWarnX(strWarn);
  2429. Info("[Calibration File is Normal]");
  2430. return true;
  2431. }
  2432. bool nsFPD::FPDDeviceYuying::LoadSensitivity()
  2433. {
  2434. Info("Load Sensitivity.txt");
  2435. string strTemp = m_stDeviceConfig.strPanelSerial + "_Sensitivity.txt";
  2436. string strPath = g_strAppPath + "references\\" + strTemp;
  2437. char* pszSensitivity = NULL;
  2438. FILE* pFile;
  2439. if ((pFile = fopen(strPath.c_str(), "rb")) == NULL)
  2440. {
  2441. Info("Read {$} File Error", strPath.c_str());
  2442. return false;
  2443. }
  2444. Info("Open {$} over", strPath.c_str());
  2445. fseek(pFile, 0, SEEK_END); ///将文件指针移动文件结尾
  2446. long nLen = ftell(pFile); ///求出当前文件指针距离文件开始的字节数
  2447. Info("Length is :{$}", nLen);
  2448. pszSensitivity = new char[nLen + 1];
  2449. memset(pszSensitivity, 0, nLen + 1);
  2450. fseek(pFile, 0, SEEK_SET); ///将文件指针移动文件头
  2451. size_t rLen = fread(pszSensitivity, (size_t)1, nLen, pFile);
  2452. Info("read Length is :{$} {$}", rLen, pszSensitivity);
  2453. if (rLen != nLen)
  2454. {
  2455. delete[] pszSensitivity;
  2456. fclose(pFile);
  2457. Info("Read Sensitivity info Error");
  2458. return false;
  2459. }
  2460. fclose(pFile);
  2461. m_fFactorEXI2UGY = (float)atof(pszSensitivity);
  2462. auto strSensitivity = std::to_string(m_fFactorEXI2UGY);
  2463. m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity);
  2464. Info("Sensitivity is :{$}", m_fFactorEXI2UGY);
  2465. if (pszSensitivity)
  2466. {
  2467. delete[] pszSensitivity;
  2468. pszSensitivity = NULL;
  2469. }
  2470. Info("Read Sensitivity Over");
  2471. return true;
  2472. }
  2473. RET_STATUS nsFPD::FPDDeviceYuying::SaveSensitivity()
  2474. {
  2475. Info("Save Sensitivity");
  2476. return RET_STATUS::RET_SUCCEED;
  2477. }
  2478. //预览图
  2479. bool nsFPD::FPDDeviceYuying::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
  2480. {
  2481. Info("Currenct PreviewImage Width: {$}, Height: {$}", nWidth, nHeight);
  2482. if (m_stDeviceConfig.nSaveRaw > 1)
  2483. {
  2484. SaveRawImage("PreviewImage.raw", pwRawImage, nWidth, nHeight);
  2485. }
  2486. PrevImageDateArrived(pwRawImage);
  2487. Info("Write PreviewImage Over");
  2488. return true;
  2489. }
  2490. //大图
  2491. bool nsFPD::FPDDeviceYuying::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY)
  2492. {
  2493. Info("Process Full Image");
  2494. Info("Image EXI2UGY factor:{$},Image Refer UGY: {$}", m_fFactorEXI2UGY, fImageReferUGY);
  2495. //if (nImageWidth < m_nFullImgWidth + m_nLeftOffset)
  2496. //{
  2497. // Info("nImageWidth:{$},m_nFullImgWidth: {$},m_nLeftOffset:{$}", nImageWidth, m_nFullImgWidth, m_nLeftOffset);
  2498. // m_nFullImgWidth = nImageWidth;
  2499. // m_nLeftOffset = 0;
  2500. //}
  2501. //if (nImageHeight < m_nFullImgHeight + m_nTopOffset)
  2502. //{
  2503. // Info("nImageHeight:{$},m_nFullImgHeight: {$},m_nLeftOffset:{$}", nImageHeight, m_nFullImgHeight, m_nTopOffset);
  2504. // m_nFullImgHeight = nImageHeight;
  2505. // m_nTopOffset = 0;
  2506. //}
  2507. Info("Grid {$} Setting:{$}", m_bForceGridSuppress, m_stDeviceConfig.nGridSuppressed);
  2508. Sleep(500);
  2509. pwRawImage[0] = 65535;
  2510. //图像预处理完成
  2511. FullImageDateArrived(pwRawImage);
  2512. Info("Write Frame Over");
  2513. return true;
  2514. }
  2515. void nsFPD::FPDDeviceYuying::OnProcessTemperature(int nID, float fTemperature)
  2516. {
  2517. string strWarnErrorCode = "";
  2518. auto lowerror = m_stDeviceConfig.fTemperMinLimit;
  2519. auto uperror = m_stDeviceConfig.fTemperMaxLimit;
  2520. auto lowwarn = m_stDeviceConfig.fTemperLowLimit;
  2521. auto upwarn = m_stDeviceConfig.fTemperUpLimit;
  2522. auto calupwarn = m_CalTemperupWarn;
  2523. auto callowwarn = m_CalTemperlowWarn;
  2524. //should be lowerror < lowwarn < callowwarn < calupwarn < upwarn < uperror
  2525. m_stDeviceConfig.nTemperatureStatus = TEMP_NORMAL;
  2526. if (fTemperature > callowwarn && fTemperature < calupwarn)
  2527. {
  2528. //normal,clear all warns&errors
  2529. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  2530. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  2531. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  2532. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  2533. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  2534. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  2535. }
  2536. else if ((fTemperature <= callowwarn && fTemperature > lowwarn)
  2537. || (fTemperature >= calupwarn && fTemperature < upwarn)
  2538. )
  2539. {//out of cal range
  2540. Info("Exceed Calibration Temperature");
  2541. m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
  2542. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  2543. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  2544. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  2545. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  2546. strWarnErrorCode = WAR_FPD_EXCEED_CALB_TEMPER_HIGH;
  2547. if (fTemperature <= callowwarn && fTemperature > lowwarn)
  2548. {
  2549. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  2550. strWarnErrorCode = WAR_FPD_EXCEED_CALB_TEMPER_LOW;
  2551. }
  2552. else
  2553. {
  2554. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  2555. }
  2556. OnWarn(nID, strWarnErrorCode);
  2557. }
  2558. else if (fTemperature > lowerror && fTemperature <= lowwarn)
  2559. {//low warn
  2560. Info("Exceed Temperature Low Warning");
  2561. m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
  2562. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  2563. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  2564. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  2565. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  2566. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  2567. strWarnErrorCode = WAR_FPD_TEMPERTURE_LOW;
  2568. OnWarn(nID, strWarnErrorCode);
  2569. }
  2570. else if (fTemperature <= lowerror)
  2571. {//low error
  2572. Info("Exceed Min Temperature");
  2573. m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW;
  2574. if (m_stDeviceConfig.bActived)
  2575. {
  2576. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  2577. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  2578. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  2579. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  2580. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  2581. strWarnErrorCode = ERR_FPD_TEMPLOW_NOT_ACQ;
  2582. OnError(strWarnErrorCode);
  2583. }
  2584. }
  2585. else if (fTemperature >= upwarn && fTemperature < uperror)
  2586. {//up warn
  2587. Info("Exceed Temperature High Warning");
  2588. m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
  2589. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  2590. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  2591. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  2592. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  2593. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  2594. strWarnErrorCode = WAR_FPD_TEMPERATURE_HIGH;
  2595. OnWarn(nID, strWarnErrorCode);
  2596. }
  2597. else if (fTemperature >= uperror)
  2598. {//up error
  2599. Info("Exceed Max Temperature");
  2600. m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH;
  2601. if (m_stDeviceConfig.bActived)
  2602. {
  2603. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  2604. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  2605. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  2606. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  2607. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  2608. strWarnErrorCode = ERR_FPD_TEMPHIGH_NOT_ACQ;
  2609. OnError(strWarnErrorCode);
  2610. }
  2611. }
  2612. }
  2613. void nsFPD::FPDDeviceYuying::Action_ExpReady()
  2614. {
  2615. m_SyncUnit->FPDReadyNotify(true);
  2616. }
  2617. bool nsFPD::FPDDeviceYuying::GetCalibrationTime(bool ExpMode)
  2618. {
  2619. string strValue = "";
  2620. m_strCalibTime = strValue;
  2621. Info("CalibrationTime {$}", m_strCalibTime.c_str());
  2622. return true;
  2623. }
  2624. bool nsFPD::FPDDeviceYuying::SaveConfigFile(bool bSendNotify)
  2625. {
  2626. m_DetectorConfiguration->SaveConfig();
  2627. Info("SaveConfigFile over");
  2628. return true;
  2629. }
  2630. RET_STATUS nsFPD::FPDDeviceYuying::SetSID(int nSID)
  2631. {
  2632. if (nSID < 0 || nSID>200)
  2633. {
  2634. return RET_STATUS::RET_INVALID;
  2635. }
  2636. m_stDeviceConfig.nSID = nSID;
  2637. return RET_STATUS::RET_SUCCEED;
  2638. }
  2639. RET_STATUS nsFPD::FPDDeviceYuying::UploadCalibrationFiles(string strFileName)
  2640. {
  2641. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2642. Info("Update Calibration Defect map:{$}", strFileName.c_str());
  2643. bool bLTEenable = false;
  2644. if ((strFileName.find("defect_") == string::npos) || (strFileName.find(".dft") == string::npos))
  2645. {
  2646. Info("the defect map is invalid");
  2647. m_CalibUnit->SetUploadCalibrationFilesResult("false");
  2648. return RET_STATUS::RET_FAILED;
  2649. }
  2650. if (strFileName.find("LTE") != string::npos)
  2651. {
  2652. bLTEenable = true;
  2653. }
  2654. ResetEvent(m_UploadCalibMapOver);
  2655. bool bRet = m_pDetectors->UploadCalibrationFiles(this, strFileName);
  2656. if (!bRet)
  2657. {
  2658. Info("UploadCalibrationFiles failed");
  2659. m_CalibUnit->SetUploadCalibrationFilesResult("false");
  2660. return RET_STATUS::RET_FAILED;
  2661. }
  2662. DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000);
  2663. if (WAIT_OBJECT_0 == nRet)
  2664. {
  2665. m_CalibUnit->SetUploadCalibrationFilesResult("true");
  2666. Info("got event m_UploadCalibMapOver");
  2667. }
  2668. else if (WAIT_TIMEOUT == nRet)
  2669. {
  2670. m_CalibUnit->SetUploadCalibrationFilesResult("false");
  2671. Info("wait event m_UploadCalibMapOver timeout");
  2672. return RET_STATUS::RET_FAILED;
  2673. }
  2674. else
  2675. {
  2676. m_CalibUnit->SetUploadCalibrationFilesResult("false");
  2677. Info("wait event m_UploadCalibMapOver error");
  2678. return RET_STATUS::RET_FAILED;
  2679. }
  2680. return Ret;
  2681. }
  2682. RET_STATUS nsFPD::FPDDeviceYuying::GetRecoverImageState(string& RCI)
  2683. {
  2684. Info("GetRecoverImageState");
  2685. m_bSendRecoverMessage = true;
  2686. RCI = m_RecoverImageStatus.encode();
  2687. return RET_STATUS::RET_SUCCEED;
  2688. }
  2689. RET_STATUS nsFPD::FPDDeviceYuying::RecoverImage(bool bRecoverIt)
  2690. {
  2691. Info("Recover Image {$}", bRecoverIt);
  2692. m_bUIConfirmRecover = true;
  2693. int nRecoverOrNot = 0;
  2694. if (bRecoverIt)
  2695. {
  2696. nRecoverOrNot = 1;
  2697. }
  2698. if (nRecoverOrNot != 0)
  2699. {
  2700. string strResult = (string)m_RecoverImageStatus["Result"];
  2701. if (strResult == "0")
  2702. {
  2703. Info("already recover success,just return");
  2704. return RET_STATUS::RET_SUCCEED;
  2705. }
  2706. m_RecoverImageStatus["Result"] = "1";
  2707. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  2708. if (!(m_pDetectors)->RecoverLastImage())
  2709. {
  2710. m_RecoverImageStatus["Result"] = "2";
  2711. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  2712. m_bUIConfirmRecover = false;
  2713. }
  2714. m_nRecoverImageTimes++;
  2715. }
  2716. else
  2717. {
  2718. Info("Abort Recovering Image");
  2719. m_bAbortRecover = true; //终止恢复图像的变量也要重置
  2720. m_bRecoveringImage = false; //不再恢复图像过程中
  2721. m_nRecoverImageTimes = 0; //下次恢复图像,重置
  2722. m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
  2723. m_pDetectors->CancelImageRecover();
  2724. if (m_stDeviceConfig.bConnectStatus)
  2725. {
  2726. if (m_bImagePendingOrNot)
  2727. {
  2728. OnError(ERR_FPD_IMAGE_PENDING);
  2729. }
  2730. else
  2731. {
  2732. OnErrorX(ERR_FPD_IMAGE_PENDING);
  2733. }
  2734. }
  2735. else
  2736. {
  2737. OnError(ERR_FPD_IMAGE_PENDING);
  2738. OnError(ERR_FPD_DISCONNECT);
  2739. }
  2740. }
  2741. return RET_STATUS::RET_SUCCEED;
  2742. }
  2743. bool nsFPD::FPDDeviceYuying::CallSiemensRecoverAction(bool bErrorResult)
  2744. {
  2745. string strRecoverInfo = "";
  2746. if (bErrorResult)
  2747. {
  2748. if (m_bAbortRecover)
  2749. {
  2750. Info("Recover Image is Cancelled");
  2751. return true;
  2752. }
  2753. SendWifiValue(0);
  2754. SendBatteryValue(0);
  2755. SendTemperatureValue(ABS_ZERO_TEMPERATURE);
  2756. if (!m_bRecoveringImage)
  2757. {
  2758. m_RecoverImageStatus["Result"] = "-1";//新的imagerecover流程开始,防止之前成功recover过,上层查询状态引发误解
  2759. m_DetectorCtrlUnit->SetRecoverImageEvent("0");
  2760. OnError(ERR_FPD_IMAGE_PENDING);
  2761. m_bRecoveringImage = true;
  2762. m_bUIConfirmRecover = false;
  2763. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  2764. Info("SetRecoverImageEvent");
  2765. return true;
  2766. }
  2767. m_RecoverImageStatus["Result"] = "2";
  2768. }
  2769. else
  2770. {
  2771. m_bAbortRecover = false; //终止恢复图像的变量也要重置
  2772. m_bRecoveringImage = false; //不再恢复图像过程中
  2773. m_nRecoverImageTimes = 0; //下次恢复图像,重置
  2774. m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
  2775. if (m_bUIConfirmRecover)
  2776. {
  2777. Info("Recover Image Success");
  2778. m_RecoverImageStatus["Result"] = "0";
  2779. Info("m_RecoverImageStatus[Result] = 0");
  2780. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  2781. m_bUIConfirmRecover = false;
  2782. Info("send RecoverImageState over");
  2783. }
  2784. else
  2785. {
  2786. m_RecoverImageStatus["Result"] = "3";
  2787. Info("m_RecoverImageStatus[Result] = 3");
  2788. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  2789. Warn("UI do not confirm, image have been abandoned");
  2790. m_RecoverImageStatus["Result"] = "0";
  2791. m_AcqUnit->SendNoNeedWaitImage(true);
  2792. }
  2793. return true;
  2794. }
  2795. Info("CallSiemensRecoverAction {$}", m_RecoverImageStatus.encode());
  2796. if (m_bSendRecoverMessage)
  2797. {
  2798. if (m_bUIConfirmRecover)
  2799. {
  2800. m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
  2801. m_bUIConfirmRecover = false;
  2802. Info("send RecoverImageState over");
  2803. }
  2804. else
  2805. {
  2806. Warn("UI do not confirm omit send result");
  2807. }
  2808. }
  2809. return true;
  2810. }
  2811. RET_STATUS nsFPD::FPDDeviceYuying::GetDetectorInfo(string& strFDI)
  2812. {
  2813. ResDataObject strDetectorInfo;
  2814. string strTempTemp = " ";
  2815. Info("Get Detector Info");
  2816. if (m_stDeviceConfig.strPanelSerial == "")
  2817. {
  2818. Info("Get Detector Info Failed");
  2819. strDetectorInfo.add("DetectorName", "Simulator");
  2820. strDetectorInfo.add("DetectorSN", "Simulator");
  2821. strDetectorInfo.add("Firmware", " ");
  2822. strDetectorInfo.add("APFirmware", " ");
  2823. strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
  2824. strDetectorInfo.add("SSID", " ");
  2825. strDetectorInfo.add("LifeTime", "0");
  2826. strDetectorInfo.add("PowerOn", "0");
  2827. strDetectorInfo.add("DateCode", " ");
  2828. strDetectorInfo.add("PartNumber", " ");
  2829. strDetectorInfo.add("WifiDataRate", " ");
  2830. strDetectorInfo.add("WifiChannel", "0");
  2831. strDetectorInfo.add("DetectorExist", "0");
  2832. strDetectorInfo.add("SystemAS", "0");
  2833. strDetectorInfo.add("CalibrationDate", "0");
  2834. strDetectorInfo.add("CalibrationDue", "0");
  2835. strDetectorInfo.add("CalibrationExist", "0");
  2836. strDetectorInfo.add("CommunicationStatus", "0");
  2837. strDetectorInfo.add("DetectorTemperature", "0");
  2838. strDetectorInfo.add("FDCalibrationTemperature", "0");
  2839. strDetectorInfo.add("TemperatureStatus", "0");
  2840. strDetectorInfo.add("WaitTime", "0");
  2841. strDetectorInfo.add("DetectorWifiSignal", "0");
  2842. strDetectorInfo.add("DetectorBattery", "0");
  2843. strDetectorInfo.add("ShockSensor", "NULL");
  2844. strDetectorInfo.add("FirmwareUpdate", "0");
  2845. //encode
  2846. strFDI = strDetectorInfo.encode();
  2847. return RET_STATUS::RET_SUCCEED;
  2848. }
  2849. strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
  2850. strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
  2851. strDetectorInfo.add("APFirmware", "NULL");
  2852. strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
  2853. strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
  2854. if (m_strSelfTest != "")
  2855. {
  2856. ResDataObject strDetectorSelfTest;
  2857. strDetectorSelfTest.decode(m_strSelfTest.c_str());
  2858. strDetectorInfo += strDetectorSelfTest;
  2859. }
  2860. strDetectorInfo.add("FD_Voltage_List1", "NULL");
  2861. strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate);
  2862. strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel);
  2863. strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted);
  2864. //System Workstation
  2865. strDetectorInfo.add("SystemAS", m_stDeviceConfig.nWorkstation);
  2866. //DetectorCalibrationDate
  2867. Info("DetectorCalibrationDate {$}", m_stDeviceConfig.strCalibrationDate.c_str());
  2868. if (m_stDeviceConfig.strCalibrationDate != " ")
  2869. {
  2870. if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos)
  2871. {
  2872. Info("find 19700101");
  2873. strDetectorInfo.add("CalibrationDate", "0");
  2874. strDetectorInfo.add("CalibrationDue", "0");
  2875. strDetectorInfo.add("CalibrationExist", 0);
  2876. }
  2877. else
  2878. {
  2879. strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/);
  2880. strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/);
  2881. strDetectorInfo.add("CalibrationExist", 1);
  2882. }
  2883. }
  2884. else
  2885. {
  2886. strDetectorInfo.add("CalibrationDate", "0");
  2887. strDetectorInfo.add("CalibrationDue", "0");
  2888. strDetectorInfo.add("CalibrationExist", 0);
  2889. }
  2890. if (m_stDeviceConfig.bConnectStatus)
  2891. {
  2892. strDetectorInfo.add("CommunicationStatus", 1);
  2893. }
  2894. else
  2895. {
  2896. strDetectorInfo.add("CommunicationStatus", 0);
  2897. }
  2898. strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature);
  2899. strDetectorInfo.add("ShockSensor", m_nShockCounts);
  2900. if (FW_MANDATORY_UPDATE == m_stDeviceConfig.nFirmwareStatus && m_stDeviceConfig.bConnectStatus) //需要升级
  2901. {
  2902. strDetectorInfo.add("FirmwareUpdate", 1);
  2903. }
  2904. else
  2905. {
  2906. strDetectorInfo.add("FirmwareUpdate", 0);
  2907. }
  2908. Trace("{$}", strDetectorInfo.encode());
  2909. strFDI = strDetectorInfo.encode();
  2910. return RET_STATUS::RET_SUCCEED;
  2911. }
  2912. string nsFPD::FPDDeviceYuying::MakeImageHead(IMAGE_VIEW_TYPE Type)
  2913. {
  2914. if (Type == IMAGE_FULL)
  2915. {
  2916. if (m_pFullImageHead == NULL)
  2917. {
  2918. m_pFullImageHead = new ResDataObject;
  2919. ResDataObject json;
  2920. json.add(SM_IMAGE_TYPE, (int)Type);
  2921. json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nFullImageWidth);
  2922. json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nFullImageHeight);
  2923. json.add(SM_IMAGE_BIT, 16);
  2924. json.add(SM_IMAGE_TAG, 1);
  2925. json.add(SM_IMAGE_INDEX, 1);
  2926. json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  2927. json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  2928. json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  2929. json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  2930. json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  2931. json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  2932. json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  2933. json.add(SM_IMAGE_LSB, "5000");
  2934. json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
  2935. json.add(SM_IMAGE_PIXELREPRESENTATION, "0");
  2936. json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
  2937. json.add(SM_IMAGE_ROTATION, "No");
  2938. json.add(SM_IMAGE_FLIP, "No");
  2939. json.add(SM_IMAGE_ORIGINX, "0");
  2940. json.add(SM_IMAGE_ORIGINY, "0");
  2941. json.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  2942. json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
  2943. m_pFullImageHead->add(SM_IMAGE_HEAD, json);
  2944. }
  2945. else
  2946. {
  2947. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
  2948. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
  2949. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
  2950. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
  2951. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
  2952. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
  2953. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
  2954. (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
  2955. }
  2956. return (*m_pFullImageHead).encode();
  2957. }
  2958. else
  2959. {
  2960. if (m_pPreviewImageHead == NULL)
  2961. {
  2962. m_pPreviewImageHead = new ResDataObject;
  2963. ResDataObject json;
  2964. json.add(SM_IMAGE_TYPE, (int)Type);
  2965. json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth);
  2966. json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight);
  2967. json.add(SM_IMAGE_BIT, 16);
  2968. json.add(SM_IMAGE_TAG, 1);
  2969. json.add(SM_IMAGE_INDEX, 1);
  2970. json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  2971. json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  2972. json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  2973. json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  2974. json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  2975. json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  2976. json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  2977. json.add(SM_IMAGE_LSB, "5000");
  2978. json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
  2979. json.add(SM_IMAGE_ROTATION, "No");
  2980. json.add(SM_IMAGE_FLIP, "No");
  2981. json.add(SM_IMAGE_ORIGINX, "0");
  2982. json.add(SM_IMAGE_ORIGINY, "0");
  2983. json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
  2984. json.add(SM_IMAGE_PIXELREPRESENTATION, "0");
  2985. json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
  2986. m_pPreviewImageHead->add(SM_IMAGE_HEAD, json);
  2987. }
  2988. else
  2989. {
  2990. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
  2991. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
  2992. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
  2993. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
  2994. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
  2995. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
  2996. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
  2997. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
  2998. }
  2999. return (*m_pPreviewImageHead).encode();
  3000. }
  3001. return "";
  3002. }
  3003. RET_STATUS nsFPD::FPDDeviceYuying::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
  3004. {
  3005. string strImageHead = MakeImageHead(Type);
  3006. return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
  3007. }
  3008. void nsFPD::FPDDeviceYuying::ClearAllError()
  3009. {
  3010. m_WarnAndError->ClearAllError();
  3011. }
  3012. void nsFPD::FPDDeviceYuying::SyncErrorList()
  3013. {
  3014. if (m_WarnAndError)
  3015. {
  3016. m_WarnAndError->SyncErrorList();
  3017. }
  3018. }
  3019. void nsFPD::FPDDeviceYuying::OnErrorX(string strErrCode)
  3020. {
  3021. bool bExit = false;
  3022. if (m_WarnAndError->IsErrorExist(strErrCode))
  3023. {
  3024. bExit = true;
  3025. }
  3026. m_WarnAndError->OnErrorX(strErrCode);
  3027. int nErrNum = m_WarnAndError->GetExistErrorNum();
  3028. }
  3029. void nsFPD::FPDDeviceYuying::OnError(string strErrCode, string strErr)
  3030. {
  3031. string strBackCom = "";
  3032. m_WarnAndError->OnError(strErrCode, strErr);
  3033. }
  3034. void nsFPD::FPDDeviceYuying::OnWarn(int nIndex, string strWarnCode, string strWarn)
  3035. {
  3036. m_WarnAndError->OnWarn(strWarnCode, strWarn);
  3037. }
  3038. void nsFPD::FPDDeviceYuying::OnWarnX(string strWarnCode)
  3039. {
  3040. m_WarnAndError->OnWarnX(strWarnCode);
  3041. }
  3042. RET_STATUS nsFPD::FPDDeviceYuying::ResetError()
  3043. {
  3044. Info("ResetError");
  3045. OnErrorX(ERR_FPD_DOSE_LOW);
  3046. OnErrorX(ERR_FPD_DOSE_HIGH);
  3047. OnErrorX(ERR_FPD_DOSE_OBJ); //清除之前的错误,如果有的话
  3048. return RET_STATUS::RET_SUCCEED;
  3049. }
  3050. void nsFPD::FPDDeviceYuying::SendAllError()
  3051. {
  3052. m_WarnAndError->SendAllError();
  3053. }
  3054. void nsFPD::FPDDeviceYuying::ProcessTempreatureOnLostCommunicate()
  3055. {
  3056. SendTemperatureValue(ABS_ZERO_TEMPERATURE);
  3057. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  3058. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  3059. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  3060. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  3061. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  3062. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  3063. OnWarnX(WAR_FPD_WIFI_LOW);
  3064. OnWarnX(WAR_FPD_BATTERY_LOW);
  3065. OnErrorX(ERR_FPD_WIFI_LOW);
  3066. OnErrorX(ERR_FPD_BATTERY_LOW);
  3067. }
  3068. void nsFPD::FPDDeviceYuying::ResetAllError()
  3069. {
  3070. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_HIGH);
  3071. OnWarnX(WAR_FPD_EXCEED_CALB_TEMPER_LOW);
  3072. OnWarnX(WAR_FPD_TEMPERTURE_LOW);
  3073. OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
  3074. OnErrorX(ERR_FPD_TEMPHIGH_NOT_ACQ);
  3075. OnErrorX(ERR_FPD_TEMPLOW_NOT_ACQ);
  3076. OnWarnX(WAR_FPD_LOAD_CORRECT_FILE);
  3077. OnWarnX(WAR_FPD_WIFI_LOW);
  3078. OnWarnX(WAR_FPD_MAX_SHOCK_NUM);
  3079. OnWarnX(WAR_FPD_IN_INITIAL);
  3080. OnWarnX(WAR_FPD_ATTACH_PMS_LOGOUT);
  3081. OnWarnX(WAR_FPD_BATTERY_LOW);
  3082. OnErrorX(ERR_FPD_WIFI_LOW);
  3083. OnErrorX(ERR_FPD_BATTERY_LOW);
  3084. OnErrorX(ERR_FPD_DISCONNECT);
  3085. OnErrorX(ERR_FPD_POWEROFF);
  3086. OnErrorX(ERR_FPD_ACQ_FAILED);
  3087. OnErrorX(ERR_FPD_DOSE_LOW);
  3088. OnErrorX(ERR_FPD_DOSE_HIGH);
  3089. OnErrorX(ERR_FPD_DOSE_OBJ);
  3090. OnErrorX(ERR_FPD_IMAGE_PENDING);
  3091. OnErrorX(ERR_FPD_FATAL_ERROR);
  3092. OnErrorX(LASTERR_ATTACH_FAIL_WITHIMG);
  3093. OnErrorX(LASTERR_ATTACH_FAIL_BATTERYLOW);
  3094. }
  3095. RET_STATUS nsFPD::FPDDeviceYuying::SetCorrectionType(CCOS_CORRECTION_TYPE in)
  3096. {
  3097. return RET_STATUS::RET_SUCCEED;
  3098. }