DIOS.Dev.FPD.AxsDM.cpp 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167
  1. #include "stdafx.h"
  2. #include "FileVersion.hpp"
  3. #include "CCOS.Dev.FPD.AxsDM.h"
  4. #include "common_api.h"
  5. #include "DICOMImageHeadKey.h"
  6. #include "AxsCtrl.h"
  7. #include <sys/stat.h>
  8. namespace nsFPD = CCOS::Dev::Detail::Detector;
  9. //-----------------------------------------------------------------------------
  10. // CFPDDeviceAXS
  11. //-----------------------------------------------------------------------------
  12. extern CAXSCtrl* g_pDetector;
  13. //-----------------------------------------------------------------------------
  14. // GetIODriver & CreateIODriver
  15. //-----------------------------------------------------------------------------
  16. static nsFPD::CAXSDriver gIODriver;
  17. Log4CPP::Logger* gLogger = nullptr;
  18. extern const char* g_szMouldPath;
  19. /// <summary>
  20. /// [DONE.CHECKED.]
  21. /// </summary>
  22. /// <returns></returns>
  23. extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  24. {
  25. return &gIODriver;
  26. }
  27. /// <summary>
  28. /// [DONE.TO BE TESTED.]
  29. /// </summary>
  30. /// <returns></returns>
  31. extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  32. {
  33. return new nsFPD::CAXSDriver();
  34. }
  35. /// <summary>
  36. /// 驱动构造函数
  37. /// [DONE.CHECKED.]
  38. /// </summary>
  39. nsFPD::CAXSDriver::CAXSDriver()
  40. {
  41. m_pObjDev = nullptr;
  42. m_bConnect = false; //缺省为false
  43. m_pAttribute.reset(new ResDataObject());
  44. m_pDescription.reset(new ResDataObject());
  45. }
  46. /// <summary>
  47. /// [DONE.TO BE TESTED.]
  48. /// </summary>
  49. nsFPD::CAXSDriver::~CAXSDriver()
  50. {
  51. if (m_pObjDev != nullptr)
  52. {
  53. delete m_pObjDev;
  54. m_pObjDev = nullptr;
  55. }
  56. Close();
  57. Log4CPP::ThreadContext::Map::Clear();
  58. gLogger = nullptr;
  59. }
  60. /// <summary>
  61. /// 驱动的准备,可以做一些特殊的操作
  62. /// new完Driver后最先执行的函数
  63. /// </summary>
  64. void nsFPD::CAXSDriver::Prepare()
  65. {
  66. printf("--Driver-- prepare \r\n");
  67. string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
  68. auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  69. gLogger = Log4CPP::LogManager::GetLogger("Module");
  70. FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
  71. #ifdef _WIN64
  72. FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
  73. #else
  74. FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
  75. #endif
  76. FINFO("Driver Prepare get logger");
  77. }
  78. /// <summary>
  79. /// 获取配置文件的配置信息并返回给web端显示,配置文件可配置读写权限和是否显示(重要)
  80. /// </summary>
  81. /// <returns>string</returns>
  82. std::string nsFPD::CAXSDriver::GetResource()
  83. {
  84. printf("AXS driver: GetResource m_ConfigFileName:%s\r\n", m_ConfigFileName.c_str());
  85. FINFO("AXS driver: GetResource m_ConfigFileName:{$}", m_ConfigFileName.c_str());
  86. ResDataObject r_config, temp;
  87. if (!temp.loadFile(m_ConfigFileName.c_str()))
  88. {
  89. return "";
  90. }
  91. m_ConfigAll = temp;
  92. r_config = temp["CONFIGURATION"];
  93. m_Configurations = r_config;
  94. ResDataObject DescriptionTemp;
  95. ResDataObject ListTemp;
  96. string strTemp = ""; //用于读取字符串配置信息
  97. string strIndex = ""; //用于读取配置信息中的List项
  98. int nTemp = -1; //用于读取整型配置信息
  99. string strValue = ""; //用于存储配置的值
  100. string strType = ""; //用于存储配置的类型 int/float/string...
  101. string strAccess = ""; //用于存储权限的类型 R/W/RW
  102. string strRequired = ""; // TRUE/FALSE
  103. string strDefaultValue = "";
  104. string strRangeMin = "";
  105. string strRangeMax = "";
  106. try
  107. {
  108. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  109. m_pAttribute->clear();
  110. m_pDescription->clear();
  111. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  112. {
  113. DescriptionTemp.clear();
  114. ListTemp.clear();
  115. //AttributeType
  116. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  117. DescriptionTemp.add(AttributeType, strTemp.c_str());
  118. strType = strTemp; //记录配置项的类型
  119. //AttributeKey
  120. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  121. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  122. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  123. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
  124. //2. 赋值
  125. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  126. if ("int" == strType)
  127. {
  128. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  129. }
  130. else if ("float" == strType)
  131. {
  132. (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
  133. }
  134. else //其它先按string类型处理
  135. {
  136. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  137. }
  138. //AttributeAccess
  139. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  140. DescriptionTemp.add(AttributeAccess, strTemp.c_str());
  141. //AttributeRangeMin
  142. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  143. if (strTemp != "") //不需要的配置项为空
  144. {
  145. DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
  146. }
  147. //AttributeRangeMax
  148. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  149. if (strTemp != "") //不需要的配置项为空
  150. {
  151. DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
  152. }
  153. //AttributeList
  154. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  155. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  156. {
  157. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  158. {
  159. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  160. auto temKey = std::to_string(nListIndex);
  161. ListTemp.add(temKey.c_str(), strTemp.c_str());
  162. }
  163. DescriptionTemp.add(AttributeList, ListTemp);
  164. }
  165. //AttributeRequired
  166. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  167. DescriptionTemp.add(AttributeRequired, strTemp.c_str());
  168. //AttributeDefaultValue
  169. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  170. if (strTemp != "") //不需要的配置项为空
  171. {
  172. DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
  173. }
  174. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  175. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  176. }
  177. }
  178. catch (ResDataObjectExption& e)
  179. {
  180. FERROR("Get config error: {$}", e.what());
  181. return "";
  182. }
  183. ResDataObject resDeviceResource;
  184. resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
  185. resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
  186. ResDataObject DescriptionTempEx;
  187. DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
  188. m_DeviceConfig = DescriptionTempEx;
  189. string res = DescriptionTempEx.encode();
  190. //FINFO("GetResource res:{$}", res.c_str());
  191. printf("AXS driver module: get resource over \r\n");
  192. FINFO("AXS driver module: get resource over \r\n");
  193. return res;
  194. }
  195. /// <summary>
  196. /// 驱动的连接,创建设备对象 new CFPDDeviceAXS
  197. /// </summary>
  198. /// <returns></returns>
  199. bool nsFPD::CAXSDriver::Connect()
  200. {
  201. printf("AXS driver module: Connect \r\n");
  202. FINFO("--Func-- driver connect\n");
  203. //从IODriver继承的EventCenter和m_ConfigFileName
  204. m_pObjDev = new CFPDDeviceAXS(EventCenter, m_ConfigFileName);
  205. m_bConnect = true; //connect执行完毕,置为true
  206. printf("AXS driver module: Connect over new CFPDDeviceAXS\r\n");
  207. FINFO("AXS driver module: Connect over new CFPDDeviceAXS");
  208. return true;
  209. }
  210. /// <summary>
  211. /// 驱动创建设备丢下,然后 给 上层返回 IODevice 对象指针
  212. /// [DONE.CHECKED.]
  213. /// </summary>
  214. /// <param name="index"></param>
  215. /// <returns></returns>
  216. auto nsFPD::CAXSDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
  217. {
  218. printf("AXS driver module: CreateDevice \r\n");
  219. FINFO("--Func-- driver createdevice \n");
  220. auto Device = std::unique_ptr<IODevice>(new IODevice(m_pObjDev));
  221. m_pObjDev->CreateDevice();
  222. m_pObjDev->Register();
  223. return Device;
  224. }
  225. /// <summary>
  226. /// 驱动断开连接,释放设备对象
  227. /// </summary>
  228. void nsFPD::CAXSDriver::Disconnect()
  229. {
  230. printf("AXS driver module: Disconnect \r\n");
  231. FINFO("--Func-- driver disconnect \n");
  232. if (m_pObjDev != nullptr)
  233. {
  234. delete m_pObjDev;
  235. m_pObjDev = nullptr;
  236. }
  237. m_bConnect = false; //disconnect置为false
  238. }
  239. bool nsFPD::CAXSDriver::isConnected() const
  240. {
  241. printf("AXS driver module: isConnected \r\n");
  242. return m_bConnect;
  243. }
  244. /// <summary>
  245. /// 驱动信息检索 TODO : 需要重新定义
  246. /// </summary>
  247. /// <returns></returns>
  248. std::string nsFPD::CAXSDriver::DriverProbe()
  249. {
  250. printf("AXS driver module: Driver Probe \r\n");
  251. ResDataObject r_config, HardwareInfo;
  252. if (r_config.loadFile(m_ConfigFileName.c_str()))
  253. {
  254. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  255. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  256. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  257. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  258. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  259. }
  260. else
  261. {
  262. HardwareInfo.add("MajorID", "Detector");
  263. HardwareInfo.add("MinorID", "DM");
  264. HardwareInfo.add("VendorID", "AXS");
  265. HardwareInfo.add("ProductID", "AXS");
  266. HardwareInfo.add("SerialID", "Driver");
  267. }
  268. string str = HardwareInfo.encode();
  269. return str;
  270. }
  271. /// <summary>
  272. /// 设备信息检索 TODO : 需要重新定义,TBD.
  273. /// </summary>
  274. /// <returns></returns>
  275. std::string nsFPD::CAXSDriver::DeviceProbe()
  276. {
  277. printf("AXS driver module: Device Probe \r\n");
  278. ResDataObject r_config, HardwareInfo;
  279. if (r_config.loadFile(m_ConfigFileName.c_str()))
  280. {
  281. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  282. HardwareInfo.add("MinorID", "Device");
  283. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  284. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  285. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  286. }
  287. else
  288. {
  289. HardwareInfo.add("MajorID", "Detector");
  290. HardwareInfo.add("MinorID", "Device");
  291. HardwareInfo.add("VendorID", "AXS");
  292. HardwareInfo.add("ProductID", "AXS");
  293. HardwareInfo.add("SerialID", "1234");
  294. }
  295. string str = HardwareInfo.encode();
  296. return str;
  297. }
  298. /// <summary>
  299. /// 设备配置读取接口
  300. /// [DONE.CHECKED.]
  301. /// </summary>
  302. /// <param name="Cfg"></param>
  303. /// <returns></returns>
  304. bool nsFPD::CAXSDriver::GetDeviceConfig(std::string& Cfg)
  305. {
  306. Cfg = m_DeviceConfig.encode();
  307. FINFO("GetDeviceConfig Cfg:{$}",Cfg.c_str());
  308. return true;
  309. }
  310. /// <summary>
  311. /// 提供给web配置中心的 配置写入接口
  312. /// [DONE.CHECKED.]
  313. /// </summary>
  314. /// <param name="Cfg"></param>
  315. /// <returns></returns>
  316. bool nsFPD::CAXSDriver::SetDeviceConfig(std::string Cfg)
  317. {
  318. FINFO("SetDeviceConfig Cfg:{$}", Cfg.c_str());
  319. ResDataObject DeviceConfig;
  320. DeviceConfig.decode(Cfg.c_str());
  321. ResDataObject DescriptionTempEx;
  322. DescriptionTempEx = DeviceConfig["DeviceConfig"];
  323. bool bSaveFile = false; //true:重新保存配置文件
  324. string strAccess = "";
  325. for (int i = 0; i < DescriptionTempEx.size(); i++)
  326. {
  327. ResDataObject temp = DescriptionTempEx[i];
  328. FINFO("{$}", temp.encode());
  329. for (int j = 0; j < temp.size(); j++)
  330. {
  331. string strKey = temp.GetKey(j);
  332. FINFO("{$}", strKey.c_str());
  333. try
  334. {
  335. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  336. {
  337. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  338. if ("RW" == strAccess || "rw" == strAccess)
  339. {
  340. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  341. //1. 修改内存中的值,用于给上层发消息
  342. (*m_pAttribute)[strKey.c_str()] = temp[j];
  343. //2. 拿到Innerkey
  344. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  345. FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
  346. string strTemp = ""; //存储AttributeKey
  347. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  348. {
  349. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  350. if (strTemp == strKey)
  351. {
  352. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  353. break;
  354. }
  355. }
  356. //3. 修改配置文件中的值
  357. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
  358. {
  359. bSaveFile = true;
  360. }
  361. }
  362. else
  363. {
  364. FINFO("{$} is not a RW configuration item", strKey.c_str());
  365. }
  366. }
  367. }
  368. catch (ResDataObjectExption& e)
  369. {
  370. FERROR("SetDriverConfig crashed: {$}", e.what());
  371. return false;
  372. }
  373. }
  374. }
  375. if (bSaveFile)
  376. {
  377. //4. 重新保存配置文件
  378. SaveConfigFile(true);
  379. }
  380. return true;
  381. }
  382. /// <summary>
  383. /// 保存配置到文件
  384. /// [DONE.TO BE TESTED.]
  385. /// </summary>
  386. /// <param name="bSendNotify"></param>
  387. /// <returns></returns>
  388. bool nsFPD::CAXSDriver::SaveConfigFile(bool bSendNotify)
  389. {
  390. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  391. m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  392. FINFO("SaveConfigFile m_ConfigAll:{$}", m_ConfigAll.encode());
  393. return true;
  394. }
  395. /// <summary>
  396. /// 读取当前配置项
  397. /// TBD. 审视参数列表
  398. /// </summary>
  399. /// <param name="config"></param>
  400. /// <param name="pInnerKey"></param>
  401. /// <param name="nPathID"></param>
  402. /// <param name="strValue"></param>
  403. /// <returns></returns>
  404. bool nsFPD::CAXSDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
  405. {
  406. strValue = "";
  407. string strTemp = pInnerKey;
  408. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  409. {
  410. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  411. {
  412. strValue = (string)config["connections"][pInnerKey];
  413. }
  414. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  415. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  416. {
  417. strValue = (string)config[pInnerKey];
  418. }
  419. else if (SyncType == strTemp || FPDWorkStation == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp ||
  420. ImageWidth == strTemp || ImageHeight == strTemp)
  421. {
  422. strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
  423. }
  424. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  425. TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp ||
  426. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  427. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  428. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  429. ShowTemperature == strTemp || ShowWifi == strTemp || "CalibMode" == strTemp ||
  430. ShowBattery == strTemp || ShowBluetooth == strTemp || OnlyHaveFpd == strTemp ||
  431. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
  432. {
  433. strValue = (string)config[pInnerKey];
  434. }
  435. else
  436. {
  437. strValue = "";
  438. FERROR("Error Configuration item: {$}", pInnerKey);
  439. }
  440. }
  441. printf("GetDeviceConfigValue pInnerKey:%s,strValue:%s\n", pInnerKey, strValue.c_str());
  442. //FINFO("GetDeviceConfigValue pInnerKey:{$},strValue:{$}", pInnerKey, strValue.c_str());
  443. return true;
  444. }
  445. /// <summary>
  446. /// 设置写入设备参数实现,这里过滤需要设置本探测器接受的参数
  447. /// 参数项和内容来源于 探测器配置文件 <ConfigToolInfo> <AttributeInfo>
  448. /// TBD. 具体内容
  449. /// comment by chenggw 2023.2.7
  450. /// </summary>
  451. /// <param name="config"></param>
  452. /// <param name="pInnerKey"></param>
  453. /// <param name="nPathID"></param>
  454. /// <param name="szValue"></param>
  455. /// <returns></returns>
  456. bool nsFPD::CAXSDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
  457. int nPathID, const char* szValue)
  458. {
  459. string strTemp = pInnerKey;
  460. printf("SetDeviceConfigValue pInnerKey:%s,szValue:%s", pInnerKey, szValue);
  461. FINFO("SetDeviceConfigValue pInnerKey:{$},szValue:{$}", pInnerKey, szValue);
  462. if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  463. {
  464. if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  465. {
  466. config["connections"][pInnerKey] = szValue;
  467. }
  468. else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  469. DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  470. {
  471. config[pInnerKey] = szValue;
  472. }
  473. else if (SyncType == strTemp || FPDWorkStation == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp ||
  474. ImageWidth == strTemp || ImageHeight == strTemp)
  475. {
  476. config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
  477. }
  478. else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  479. TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
  480. BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  481. BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  482. WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  483. ShowTemperature == strTemp || ShowWifi == strTemp || "CalibMode" == strTemp ||
  484. ShowBattery == strTemp || ShowBluetooth == strTemp || OnlyHaveFpd == strTemp ||
  485. FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
  486. {
  487. config[pInnerKey] = szValue;
  488. }
  489. else
  490. {
  491. FERROR("Error Configuration item: {$}", pInnerKey);
  492. return false;
  493. }
  494. }
  495. return true;
  496. }
  497. //CAXSDriver的Connect函数new CFPDDeviceAXS()时传入EventCenter 和 strConfigPath
  498. nsFPD::CFPDDeviceAXS::CFPDDeviceAXS(std::shared_ptr<IOEventCenter> center, std::string strConfigPath)
  499. : m_nCalibTotalExposureNum(0),
  500. m_nCalibCurrentCalibrationRound(0),
  501. m_nCalibCurrentExposureIndex(0),
  502. m_nCalibCurrentExposureNum(0),
  503. m_bImagePendingOrNot(false),
  504. m_bResetDetector(false)
  505. {
  506. m_pDetectors = nullptr;
  507. m_strWorkPath = GetProcessDirectory();
  508. m_bPreviewEnable = false;
  509. m_nImgBits = 16;
  510. m_nPreViewImgWidth = 0;
  511. m_nPreViewImgHeight = 0;
  512. m_nImgWidth = 0;
  513. m_nImgHeight = 0;
  514. m_pPreviewImageHead = nullptr;
  515. m_pImageHead = nullptr;
  516. m_pwPreviewImg = nullptr;
  517. m_pwRawImageData = nullptr;
  518. m_pwImageData = nullptr;
  519. m_nAngle = 0;
  520. m_nPixelSpacing = 0;
  521. m_fDose = 0.0f;
  522. m_fDoseParam = 0.0f;
  523. m_eAppStatus = APP_STATUS_IDLE;
  524. m_bConnect = false;
  525. m_eSyncMode = SYNC_AED;
  526. m_eCalibMode = CCOS_CALIBRATION_MODE_ZSKK;
  527. m_fFactorEXI2UGY = 0.0f;
  528. m_bForceGridSuppress = false;
  529. m_bAttached = false;
  530. m_nBatteryCapacity = 0;
  531. m_nBatteryCharges = 0;
  532. m_fBatteryTemperature = 0.0f;
  533. m_nShockCounts = 0;
  534. m_bOnlyHaveFpd = false;
  535. m_bFirstGetCalibImageLeft = true;
  536. m_nAcqMode = -1;
  537. m_DetectorCtrlUnit.reset(new CAxsCtrlUnit(center, this));
  538. m_AcqUnit.reset(new CAxsAcq(center, this));
  539. m_SyncUnit.reset(new CAxsSync(center, this));
  540. m_CalibUnit.reset(new CAxsCalib(center, this));
  541. m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
  542. //探测器告警及错误消息
  543. m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath));
  544. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
  545. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_MAX));
  546. EventCenter = center;
  547. }
  548. nsFPD::CFPDDeviceAXS::~CFPDDeviceAXS()
  549. {
  550. if (m_pPreviewImageHead)
  551. {
  552. delete m_pPreviewImageHead;
  553. m_pPreviewImageHead = nullptr;
  554. }
  555. if (m_pImageHead)
  556. {
  557. delete m_pImageHead;
  558. m_pImageHead = nullptr;
  559. }
  560. if (m_pwPreviewImg)
  561. {
  562. delete m_pwPreviewImg;
  563. m_pwPreviewImg = nullptr;
  564. }
  565. if (m_pwRawImageData)
  566. {
  567. delete m_pwRawImageData;
  568. m_pwRawImageData = nullptr;
  569. }
  570. if (m_pwImageData)
  571. {
  572. delete m_pwImageData;
  573. m_pwImageData = nullptr;
  574. }
  575. }
  576. std::string nsFPD::CFPDDeviceAXS::GetGUID() const
  577. {
  578. printf("AXS device module: GetGUID \r\n");
  579. return DetectorUnitType;
  580. }
  581. //在Driver Create Device时调用,读取配置信息,下发配置信息到ctrl
  582. bool nsFPD::CFPDDeviceAXS::CreateDevice()
  583. {
  584. printf("--Func-- CreateDevice \r\n");
  585. FINFO("================ CreateDevice");
  586. if (!LoadConfig())
  587. {
  588. return false;
  589. }
  590. if (nullptr == g_pDetector)
  591. {
  592. if (nullptr == m_pDetectors)
  593. {
  594. m_pDetectors = new CAXSCtrl();
  595. FINFO("Create SDK ctrl ok\n");
  596. g_pDetector = (CAXSCtrl*)m_pDetectors;
  597. }
  598. }
  599. else
  600. {
  601. m_pDetectors = g_pDetector;
  602. FERROR("SDK ctrl Already exit\n");
  603. }
  604. g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
  605. return true;
  606. }
  607. //在Driver Create Device时调用
  608. void nsFPD::CFPDDeviceAXS::Register()
  609. {
  610. FINFO("--Func-- device register");
  611. auto Disp = &Dispatch;
  612. RegisterCtrl(Disp);
  613. RegisterAcq(Disp);
  614. RegisterSync(Disp);
  615. RegisterCalib(Disp);
  616. RegisterOthers(Disp);
  617. //RegisterAutonumous(Disp);
  618. }
  619. //在Register之后调用
  620. bool nsFPD::CFPDDeviceAXS::Prepare()
  621. {
  622. printf("AXS device module: Prepare \r\n");
  623. FINFO("--Func-- device prepare \n");
  624. EventCenter->OnMaxBlockSize("AxsDmQue",m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgHeight * 2, 3, 1500 * 1500 * 2, 1);
  625. Connect();
  626. return true;
  627. }
  628. //在device prepare时调用
  629. RET_STATUS nsFPD::CFPDDeviceAXS::Connect()
  630. {
  631. printf("==========Fun Connect ========== \r\n");
  632. FINFO("==========Fun Connect ==========");
  633. RET_STATUS ret = RET_STATUS::RET_FAILED;
  634. if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
  635. {
  636. m_bConnect = true;
  637. ret = RET_STATUS::RET_SUCCEED;
  638. FINFO("FPD is connected!");
  639. }
  640. return ret;
  641. }
  642. RET_STATUS nsFPD::CFPDDeviceAXS::EnterExam(int nExamMode)
  643. {
  644. FINFO("==========Fun EnterExam ==========");
  645. FINFO("EnterExam nExamMode:{$}", nExamMode);
  646. switch (nExamMode)
  647. {
  648. case APP_STATUS_WORK_BEGIN:
  649. FINFO("Enter into Exam Windows");
  650. m_eAppStatus = APP_STATUS_WORK_BEGIN;
  651. break;
  652. case APP_STATUS_WORK_END:
  653. FINFO("Quit Exam Windows");
  654. m_eAppStatus = APP_STATUS_WORK_END;
  655. break;
  656. case APP_STATUS_DETSHARE_BEGIN:
  657. FINFO("Enter into Detector Share Windows");
  658. m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
  659. break;
  660. case APP_STATUS_DETSHAR_END:
  661. m_eAppStatus = APP_STATUS_IDLE;
  662. FINFO("Quit Detector Share Windows");
  663. m_eAppStatus = APP_STATUS_DETSHAR_END;
  664. break;
  665. case APP_STATUS_CAL_BEGIN:
  666. FINFO("Enter into Calibration Windows");
  667. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  668. break;
  669. case APP_STATUS_CAL_END:
  670. FINFO("Quit Calibration Windows");
  671. m_eAppStatus = APP_STATUS_CAL_END;
  672. break;
  673. case APP_STATUS_WORK_IN_SENSITIVITY:
  674. FINFO("Enter into sensitivity test interface");
  675. m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
  676. break;
  677. default:
  678. break;
  679. }
  680. g_pDetector->EnterExamMode(nExamMode);
  681. return RET_STATUS::RET_SUCCEED;
  682. }
  683. /***
  684. * 这是切换探测器的接口
  685. ***/
  686. RET_STATUS nsFPD::CFPDDeviceAXS::ActiveDetector(int nDetectorIndex, bool bActive)
  687. {
  688. FINFO("==========Fun ActiveDetector ==========");
  689. printf("ActiveDetector (%d) to (%d) \r\n", nDetectorIndex, bActive);
  690. FINFO("ActiveDetector {$} to {$}\n", nDetectorIndex, bActive);
  691. RET_STATUS ret = RET_STATUS::RET_SUCCEED;
  692. if (g_pDetector == nullptr)
  693. {
  694. printf("AXSCtrl object is not exist, return RET_FAILED\n");
  695. FERROR("AXSCtrl object is not exist, return RET_FAILED");
  696. return RET_STATUS::RET_FAILED;
  697. }
  698. return ret;
  699. }
  700. bool nsFPD::CFPDDeviceAXS::GetLogicMode(string& strAcqMode, int& nLogicMode)
  701. {
  702. if (strAcqMode == "RAD")
  703. {
  704. nLogicMode = RAD;
  705. }
  706. else if (strAcqMode == "AEC")
  707. {
  708. nLogicMode = AEC;
  709. }
  710. else if (strAcqMode == "1")
  711. {
  712. nLogicMode = RAD;
  713. }
  714. else if (strAcqMode == "2")
  715. {
  716. nLogicMode = AEC;
  717. }
  718. else
  719. {
  720. FERROR("Not support mode!");
  721. return false;
  722. }
  723. return true;
  724. }
  725. //设置采集模式 1-RAD 2-RAD-preview 3-动态
  726. RET_STATUS nsFPD::CFPDDeviceAXS::SetAcqMode(string strAcqMode)
  727. {
  728. FINFO("==========Fun SetAcqMode ==========");
  729. printf("SetAcqMode %s \n", strAcqMode.c_str());
  730. FINFO("SetAcqMode start, nMode:{$}", strAcqMode);
  731. RET_STATUS ret = RET_STATUS::RET_FAILED;
  732. if (!m_bConnect)
  733. {
  734. FERROR("Detector not connected, return");
  735. return ret;
  736. }
  737. int nMode = RAD;
  738. bool bRet = GetLogicMode(strAcqMode,nMode);
  739. if (!bRet)
  740. {
  741. return ret;
  742. }
  743. if (m_nAcqMode == nMode)
  744. {
  745. FINFO("Same acq mode! return");
  746. ret = RET_STATUS::RET_SUCCEED;
  747. return ret;
  748. }
  749. else
  750. {
  751. m_nAcqMode = nMode;
  752. }
  753. bool m_config_have = false;
  754. //如果没连接,不执行
  755. try
  756. {
  757. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  758. int nModeCount = (int)objModeConfig["ModeTable"].GetKeyCount("DetectorMode");
  759. for (int i = 0; i < nModeCount; i++)
  760. {
  761. int nLogicMode = (int)objModeConfig["ModeTable"][i]["LogicMode"];
  762. if (nLogicMode == nMode)
  763. {
  764. printf("find LogicMode == AcqMode\n");
  765. FINFO("find LogicMode == AcqMode");
  766. m_config_have = true;
  767. m_bPreviewEnable = (int)objModeConfig["ModeTable"][i]["HavePreview"];
  768. m_nImgWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"];
  769. m_nImgHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"];
  770. m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
  771. //m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
  772. m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
  773. m_eSyncMode = (SYNC_MODE)(int)objModeConfig["ModeTable"][i]["SyncType"];
  774. string strDose = (string)objModeConfig["ModeTable"][i]["CalibConfig"]["NodeInfo"]["Dose"]; //先写死成一个校正点
  775. m_fDose = stof(strDose);
  776. /*if (m_nAngle == 90 || m_nAngle == 270)
  777. {
  778. m_AcqUnit->SetFulImageInfo(m_nImgWidth, m_nImgHeight, m_nImgBits, false);
  779. }*/
  780. if (m_bPreviewEnable)
  781. {
  782. m_nPreViewImgWidth = (int)objModeConfig["ModeTable"][i]["PreviewImageWidth"];
  783. m_nPreViewImgHeight = (int)objModeConfig["ModeTable"][i]["PreviewImageHeight"];
  784. m_AcqUnit->SetPrevImageInfo(true, m_nPreViewImgHeight, m_nPreViewImgWidth, false);
  785. }
  786. else
  787. {
  788. m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
  789. }
  790. m_AcqUnit->SetFulImageInfo(m_nImgHeight, m_nImgWidth, m_nImgBits, false);
  791. if (((CAXSCtrl*)m_pDetectors)->SetAcqMode(nLogicMode, this))
  792. {
  793. ret = RET_STATUS::RET_SUCCEED;
  794. }
  795. FINFO("config file LogicMode:{$} SyncType:{$}", nLogicMode, (int)m_eSyncMode);
  796. //读取DetectorMode配置,并为imagebuffer申请内存空间
  797. if (((CAXSCtrl*)m_pDetectors)->SelectExamMode(nLogicMode, this))
  798. {
  799. ret = RET_STATUS::RET_SUCCEED;
  800. }
  801. printf("m_eSyncMode (%d) \r\n", m_eSyncMode);
  802. FINFO("m_eSyncMode ({$})", (int)m_eSyncMode);
  803. g_pDetector->SetSynMode(m_eSyncMode);
  804. break;
  805. }
  806. }
  807. if (!m_config_have)
  808. {
  809. FERROR("Illegal mode!");
  810. ret = RET_STATUS::RET_FAILED;
  811. }
  812. }
  813. catch (ResDataObjectExption& e)
  814. {
  815. FERROR("Read configuration failed, Error code: {$}", e.what());
  816. }
  817. FINFO("SetAcqMode end");
  818. return ret;
  819. }
  820. RET_STATUS nsFPD::CFPDDeviceAXS::PrepareAcquisition()
  821. {
  822. printf("--Func-- PrepareAcquisition \n");
  823. FINFO("==========Fun PrepareAcquisition ==========");
  824. RET_STATUS ret = RET_STATUS::RET_FAILED;
  825. if (!m_bConnect)
  826. {
  827. FERROR("Detector not connected, return");
  828. return ret;
  829. }
  830. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  831. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  832. {
  833. printf("PrepareAcquisition failed. Detector at Calibration status.\n");
  834. FERROR("PrepareAcquisition failed. Detector at Calibration status");
  835. return ret;
  836. }
  837. //如果已经调用StartAcquisition 那么直接返回成功
  838. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  839. {
  840. printf("Detector already at Acq status.\n");
  841. FERROR("Detector already at Acq status");
  842. ret = RET_STATUS::RET_SUCCEED;
  843. }
  844. m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
  845. if (g_pDetector->PrepareAcquisition(this))
  846. {
  847. ret = RET_STATUS::RET_SUCCEED;
  848. //因为PrepareAcquisition会等待探测器回调ready消息,回调后在通知app Ready状态
  849. FINFO("set detector status standby");
  850. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  851. }
  852. else
  853. {
  854. FERROR("fail to prepare acquisition!");
  855. }
  856. FINFO("==============================PrepareAcquisition over");
  857. return ret;
  858. }
  859. RET_STATUS nsFPD::CFPDDeviceAXS::StartAcquisition(string in)
  860. {
  861. printf("--Func-- StartAcquisition \n");
  862. FINFO("==========Fun StartAcquisition ==========");
  863. RET_STATUS ret = RET_STATUS::RET_FAILED;
  864. if (!m_bConnect)
  865. {
  866. FERROR("Detector not connected, return");
  867. return ret;
  868. }
  869. if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
  870. {
  871. FINFO("StartAcquisition detector status is not standby!");
  872. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  873. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  874. {
  875. printf("StartAcquisition failed. Detector at Calibration status.\n");
  876. FERROR("StartAcquisition failed. Detector at Calibration status.");
  877. }
  878. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  879. {
  880. printf("Detector already at Acq status.\n");
  881. FERROR("Detector already at Acq status.");
  882. }
  883. }
  884. else
  885. {
  886. if (g_pDetector->StartAcquisition(this))
  887. {
  888. ret = RET_STATUS::RET_SUCCEED;
  889. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  890. }
  891. else
  892. {
  893. printf("StartAcquisition fail!\n");
  894. FINFO("StartAcquisition fail!");
  895. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  896. }
  897. }
  898. FINFO("==============================StartAcquisition over");
  899. return ret;
  900. }
  901. //LMAM3-IZ85c一般情况下不会调用stop
  902. RET_STATUS nsFPD::CFPDDeviceAXS::StopAcquisition()
  903. {
  904. printf("--Func-- StopAcquisition \n");
  905. FINFO("==========Fun StopAcquisition ==========");
  906. RET_STATUS ret = RET_STATUS::RET_FAILED;
  907. if (!m_bConnect)
  908. {
  909. FERROR("Detector not connected, return");
  910. return ret;
  911. }
  912. if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
  913. {
  914. printf("Detector status already is standby\n");
  915. FINFO("Detector status already is standby");
  916. ret = RET_STATUS::RET_SUCCEED;
  917. }
  918. else
  919. {
  920. if (g_pDetector->StopAcquisition(this))
  921. {
  922. ret = RET_STATUS::RET_SUCCEED;
  923. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  924. }
  925. }
  926. FINFO("==============================StopAcquisition over");
  927. return ret;
  928. }
  929. RET_STATUS nsFPD::CFPDDeviceAXS::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
  930. {
  931. printf("--Func-- ActiveCalibration %d \n", eType);
  932. FINFO("==========Fun ActiveCalibration ==========");
  933. FINFO("ActiveCalibration type {$}", (int)eType);
  934. RET_STATUS ret = RET_SUCCEED;
  935. if (!m_bConnect)
  936. {
  937. printf("Detector not connected, return\n");
  938. FERROR("Detector not connected, return");
  939. ret = RET_STATUS::RET_FAILED;
  940. return ret;
  941. }
  942. if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
  943. {
  944. ret = RET_STATUS::RET_INVALID;
  945. return ret;
  946. }
  947. try
  948. {
  949. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  950. m_eCalibMode = (CCOS_CALIBRATION_MODE)(int)objModeConfig["CalibMode"];
  951. //告诉Ctrl 校正模式是ZSKK还是OTHER
  952. printf("m_eCalibMode (%d) \r\n", m_eCalibMode);
  953. FINFO("m_eCalibMode ({$})", (int)m_eCalibMode);
  954. g_pDetector->SetCalibMode(m_eCalibMode);
  955. }
  956. catch (ResDataObjectExption& e)
  957. {
  958. FERROR("Read configuration failed, Error code: {$}", e.what());
  959. }
  960. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  961. //设置ZSKK GAIN 校正的校正轮次,OTHER GAIN 校正需要曝光的次数在GetCalibrationStep中获取
  962. if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK && eType == CCOS_CALIBRATION_TYPE_XRAY)
  963. {
  964. printf("ZSKK calibration, type: XRAY\n");
  965. FINFO("ZSKK calibration, type: XRAY");
  966. int nCalibrationRounds = (int)m_CalibDoseList.size();
  967. g_pDetector->SetReferenceNum(nCalibrationRounds);
  968. //重置亮场校正流程参数
  969. m_nCalibCurrentCalibrationRound = 1;
  970. m_nCalibCurrentExposureIndex = 1;
  971. m_nCalibCurrentExposureNum = 0;
  972. }
  973. else if (m_eCalibMode == CCOS_CALIBRATION_MODE_OEM && eType == CCOS_CALIBRATION_TYPE_XRAY)
  974. {
  975. //开始激活校正的时候肯定是需要获取剩余需要曝光的图像张数的
  976. m_bFirstGetCalibImageLeft = true;
  977. }
  978. if (g_pDetector->ActiveCalibration(this, eType))
  979. {
  980. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  981. m_CalibUnit->SetCalibrationProgress("0");
  982. }
  983. else
  984. {
  985. printf("Active calibration failed!\n");
  986. FERROR("Active calibration failed!");
  987. ret = RET_STATUS::RET_FAILED;
  988. }
  989. printf("ActiveCalibration over\n");
  990. FINFO("==============================ActiveCalibration over");
  991. return ret;
  992. }
  993. RET_STATUS nsFPD::CFPDDeviceAXS::PrepareCalibration()
  994. {
  995. printf("--Func-- PrepareCalibration------ \n");
  996. FINFO("==========Fun PrepareCalibration ==========");
  997. RET_STATUS ret = RET_STATUS::RET_FAILED;
  998. if (!m_bConnect)
  999. {
  1000. printf("Detector not connected, return\n");
  1001. FERROR("Detector not connected, return");
  1002. return ret;
  1003. }
  1004. m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
  1005. if (g_pDetector->PrepareCalibration(this))
  1006. {
  1007. //此处不通知ready,等到探测器回调Ready事件后再通知
  1008. ret = RET_STATUS::RET_SUCCEED;
  1009. }
  1010. else
  1011. {
  1012. printf("Prepare calibration failed\n");
  1013. FERROR("Prepare calibration failed");
  1014. }
  1015. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1016. printf("PrepareCalibration over\n");
  1017. FINFO("==============================PrepareCalibration over");
  1018. return ret;
  1019. }
  1020. RET_STATUS nsFPD::CFPDDeviceAXS::GetRequestedDose(std::string& strDose)
  1021. {
  1022. FINFO("==========Fun GetRequestedDose ==========");
  1023. printf("--Func-- GetRequestedDose------ \n");
  1024. if (!m_stDeviceConfig.bConnectStatus)
  1025. {
  1026. return RET_STATUS::RET_THREAD_INVALID;
  1027. }
  1028. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  1029. bool bGetDoseInfo = false;
  1030. ResDataObject out;
  1031. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  1032. FINFO("GetRequestedDose calib type is {$}",(int)nCalibrationType);
  1033. printf("GetRequestedDose calib type is %d\n",nCalibrationType);
  1034. if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
  1035. {
  1036. out.add("Dose", 0.0f);
  1037. out.add("kV", 0.0f);
  1038. out.add("mA", 0.0f);
  1039. out.add("ms", 0.0f);
  1040. out.add("mAs", 0.0f);
  1041. bGetDoseInfo = true;
  1042. }
  1043. else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
  1044. {
  1045. FINFO("calib dose list size is {$}",m_CalibDoseList.size());
  1046. printf("calib dose list size is %d\n",(int)m_CalibDoseList.size());
  1047. for (int i = 0; i < m_CalibDoseList.size(); i++)
  1048. {
  1049. ResDataObject temp = m_CalibDoseList[i];
  1050. int nDose = temp["Dose"];
  1051. int nDoseParem = (int)(m_fDoseParam * 1000);
  1052. if (nDoseParem == nDose)
  1053. {
  1054. out.add("Dose", nDoseParem);
  1055. out.add("kV", temp["kV"]);
  1056. out.add("mA", temp["mA"]);
  1057. out.add("ms", temp["ms"]);
  1058. out.add("mAs", temp["mAs"]);
  1059. bGetDoseInfo = true;
  1060. FINFO("Find target dose parameter");
  1061. break;
  1062. }
  1063. }
  1064. }
  1065. else
  1066. {
  1067. FERROR("Can not support CalibrationType({$})", (int)nCalibrationType);
  1068. Ret = RET_STATUS::RET_FAILED;
  1069. }
  1070. if (bGetDoseInfo)
  1071. {
  1072. strDose = out.encode();
  1073. FINFO("GetRequestedDose:{$}", strDose.c_str());
  1074. }
  1075. else
  1076. {
  1077. FERROR("GetRequestedDose failed");
  1078. }
  1079. FINFO("==============================GetRequestedDose over");
  1080. return Ret;
  1081. }
  1082. RET_STATUS nsFPD::CFPDDeviceAXS::StartCalibration()
  1083. {
  1084. printf("--Func-- StartCalibration------ \n");
  1085. FINFO("==========Fun StartCalibration ==========");
  1086. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1087. if (!m_bConnect)
  1088. {
  1089. FERROR("detector is not connected");
  1090. return Ret;
  1091. }
  1092. if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
  1093. {
  1094. if (DETECTOR_STATUS_CALIB == m_DetectorCtrlUnit->GetDetectorStatus())
  1095. {
  1096. FERROR("StartCalibration Detector already at calibration status");
  1097. Ret = RET_STATUS::RET_SUCCEED;
  1098. return Ret;
  1099. }
  1100. }
  1101. if (((CAXSCtrl*)m_pDetectors)->StartCalibration(this))
  1102. {
  1103. printf("start calibration success set detector status\n");
  1104. FINFO("start calibration success set detector status");
  1105. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_CALIB));
  1106. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  1107. Ret = RET_STATUS::RET_SUCCEED;
  1108. }
  1109. else
  1110. {
  1111. Ret = RET_STATUS::RET_FAILED;
  1112. }
  1113. printf("StartCalibration over\n");
  1114. FINFO("==============================StartCalibration over");
  1115. return Ret;
  1116. }
  1117. RET_STATUS nsFPD::CFPDDeviceAXS::StopCalibration()
  1118. {
  1119. FINFO("==========Fun StopCalibration ==========");
  1120. printf("--Func-- StopCalibration------ \n");
  1121. RET_STATUS Ret = RET_STATUS::RET_FAILED;
  1122. if (!m_bConnect)
  1123. {
  1124. FERROR("Detector not connected, return");
  1125. return Ret;
  1126. }
  1127. m_eAppStatus = APP_STATUS_CAL_END;
  1128. if (((CAXSCtrl*)m_pDetectors)->StopCalibration(this))
  1129. {
  1130. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1131. Ret = RET_STATUS::RET_SUCCEED;
  1132. }
  1133. else
  1134. {
  1135. Ret = RET_STATUS::RET_FAILED;
  1136. }
  1137. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1138. FINFO("==============================StopCalibration over");
  1139. return Ret;
  1140. }
  1141. //create device 时调用
  1142. bool nsFPD::CFPDDeviceAXS::LoadConfig()
  1143. {
  1144. printf("--Func-- LoadConfig \r\n");
  1145. FINFO("================ LoadConfig\n");
  1146. if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
  1147. {
  1148. FERROR("Load configuration file failed!!!");
  1149. return false;
  1150. }
  1151. //获取校正模式 0-ZSKK 1-OTHER
  1152. m_eCalibMode = (CCOS_CALIBRATION_MODE)m_stDeviceConfig.nCalibMode;
  1153. //新增一个配置项代表当前系统中是否只有一个真是的平板探测器,其他设备没有或者是demo的
  1154. size_t keyCount = m_DetectorConfiguration->m_Configurations.GetKeyCount("OnlyHaveFpd");
  1155. FINFO("LoadConfig OnlyHaveFpd keyCount:{$}", keyCount);
  1156. if (keyCount)
  1157. {
  1158. m_bOnlyHaveFpd = (bool)m_DetectorConfiguration->m_Configurations["OnlyHaveFpd"];
  1159. if (m_bOnlyHaveFpd)
  1160. FINFO("current system only have FPD!");
  1161. }
  1162. if (m_stDeviceConfig.nForceGridSuppress > 0)
  1163. {
  1164. m_bForceGridSuppress = true;
  1165. }
  1166. else
  1167. {
  1168. m_bForceGridSuppress = false;
  1169. }
  1170. int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag];
  1171. if (nAttached == 1)
  1172. {
  1173. m_bAttached = true;
  1174. m_DetectorCtrlUnit->SetAttachStatus("1");
  1175. }
  1176. else
  1177. {
  1178. m_bAttached = false;
  1179. m_stDeviceConfig.bConnectStatus = false;
  1180. }
  1181. m_DetectorCtrlUnit->SetDetectorType("LMAM3-IZ85c");
  1182. string strFPDinfo;
  1183. strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"];
  1184. m_DetectorCtrlUnit->SetDescription(strFPDinfo);
  1185. m_DetectorCtrlUnit->SetDetectorConditionsNominalFlag("YES");
  1186. auto strFinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI);
  1187. m_DetectorCtrlUnit->SetFPDSensitivity(strFinfo);
  1188. //子系统将UI的TargetEXI 乘以 FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头。还原原始值,不再用100去除。
  1189. m_fFactorEXI2UGY = 100.0f / (float)atof(strFinfo.c_str()) * 1.0f;
  1190. FINFO("m_fFactorEXI2UGY = {$}", m_fFactorEXI2UGY);
  1191. m_DetectorCtrlUnit->SetPixelData("");
  1192. m_DetectorCtrlUnit->SetTargetEXI("5000");
  1193. m_Battery.reset(new DeviceBatteryMould("GetRemainPowerValue", 0,
  1194. m_stDeviceConfig.nBatteryLimit,
  1195. m_stDeviceConfig.nBatteryWarning,
  1196. 100, 0, 100, 100,
  1197. 0, EventCenter));
  1198. m_Temperature.reset(new DeviceTemperatureMould("GetTemperatureValue", 0.0f,
  1199. m_stDeviceConfig.fTemperatureMin,
  1200. m_stDeviceConfig.fTemperLowLimit,
  1201. m_stDeviceConfig.fTemperatureMax,
  1202. m_stDeviceConfig.fTemperMaxLimit,
  1203. 0.0f, 0.0f, 0.0f, EventCenter));
  1204. m_Wifi.reset(new DeviceWifiMould("GetWifiStrengthValue", 0,
  1205. m_stDeviceConfig.nWifiLimit,
  1206. m_stDeviceConfig.nWifiWarning,
  1207. 100, 0, 100, 100,
  1208. 0, EventCenter));
  1209. ResDataObject CalibDoseList;
  1210. string strCalibDose = m_strWorkPath + R"(\OEMDrivers\Detector\AXSDetector\CalibrationDose_AXS.xml)";
  1211. FINFO("start load calib dose file: {$}", strCalibDose.c_str());
  1212. struct stat buffer;
  1213. if (stat(strCalibDose.c_str(), &buffer) == 0)
  1214. {
  1215. try
  1216. {
  1217. CalibDoseList.loadFile(strCalibDose.c_str());
  1218. m_CalibDoseList = CalibDoseList["List"];
  1219. FINFO("m_CalibDoseList: {$} ", m_CalibDoseList.encode());
  1220. for (int i = 0; i < m_CalibDoseList.size(); i++)
  1221. {
  1222. ResDataObject temp = m_CalibDoseList[i];
  1223. int nExpNum = temp["ExpNum"];
  1224. m_nCalibTotalExposureNum += nExpNum;
  1225. //FINFO("temp: {$} ", temp.encode());
  1226. }
  1227. FINFO("CalibTotalExposureNum: {$}", m_nCalibTotalExposureNum);
  1228. }
  1229. catch (exception e)
  1230. {
  1231. FERROR("Get calibDose error: {$}", e.what());
  1232. }
  1233. }
  1234. else
  1235. {
  1236. FERROR("{$} file not exist!");
  1237. }
  1238. return true;
  1239. }
  1240. void nsFPD::CFPDDeviceAXS::RegisterCtrl(nsDetail::Dispatch* Dispatch)
  1241. {
  1242. Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
  1243. Dispatch->Action.Push(ActionKey::AttachConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect);
  1244. Dispatch->Action.Push(ActionKey::CancelAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach);
  1245. Dispatch->Action.Push(ActionKey::ResetConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
  1246. Dispatch->Action.Push(ActionKey::DisConnectFPD, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
  1247. Dispatch->Action.Push(ActionKey::UpdateFirmware, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
  1248. Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
  1249. Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
  1250. Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
  1251. Dispatch->Action.Push(ActionKey::RecoverImage, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
  1252. Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
  1253. Dispatch->Action.Push(ActionKey::SaveSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
  1254. Dispatch->Action.Push(ActionKey::RESET, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
  1255. Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
  1256. Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
  1257. Dispatch->Get.Push(AttrKey::DetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus);
  1258. Dispatch->Get.Push(AttrKey::DetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
  1259. Dispatch->Get.Push(AttrKey::DetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);//event
  1260. Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
  1261. Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
  1262. Dispatch->Get.Push(AttrKey::FPDShockSensorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
  1263. Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);//event
  1264. Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);//event
  1265. Dispatch->Get.Push(AttrKey::FieldofViewShape, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
  1266. Dispatch->Get.Push(AttrKey::FieldofViewDimension, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
  1267. Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
  1268. Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
  1269. Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
  1270. Dispatch->Get.Push(AttrKey::DateofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
  1271. Dispatch->Get.Push(AttrKey::TimeofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
  1272. Dispatch->Get.Push(AttrKey::DetectorConditionsNominalFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
  1273. Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
  1274. Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
  1275. Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
  1276. }
  1277. void nsFPD::CFPDDeviceAXS::RegisterAcq(nsDetail::Dispatch* Dispatch)
  1278. {
  1279. Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
  1280. Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
  1281. Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
  1282. Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
  1283. Dispatch->Get.Push(AttrKey::AutonumousMapFinish, m_AcqUnit.get(), &AcqUnit::JSAutonumousMapFinish);
  1284. }
  1285. void nsFPD::CFPDDeviceAXS::RegisterSync(nsDetail::Dispatch* Dispatch)
  1286. {
  1287. Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
  1288. Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
  1289. Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
  1290. Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
  1291. Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
  1292. Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
  1293. Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
  1294. Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
  1295. Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
  1296. Dispatch->Get.Push(AttrKey::XrayON, m_SyncUnit.get(), &SyncUnit::JSGetXrayON);
  1297. }
  1298. void nsFPD::CFPDDeviceAXS::RegisterCalib(nsDetail::Dispatch* Dispatch)
  1299. {
  1300. Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
  1301. Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
  1302. Dispatch->Action.Push(ActionKey::SetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose);
  1303. Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
  1304. Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
  1305. Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
  1306. Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
  1307. Dispatch->Action.Push(ActionKey::AcceptCalibration, m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration);
  1308. Dispatch->Action.Push(ActionKey::RejectCalibration, m_CalibUnit.get(), &CalibUnit::JSRejectCalibration);
  1309. Dispatch->Action.Push(ActionKey::SaveCalibrationFile, m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile);
  1310. Dispatch->Action.Push(ActionKey::GetCalibrationStep, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep);
  1311. Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
  1312. Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
  1313. Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
  1314. Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
  1315. Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
  1316. }
  1317. void nsFPD::CFPDDeviceAXS::RegisterOthers(nsDetail::Dispatch* Dispatch)
  1318. {
  1319. Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
  1320. Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
  1321. Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
  1322. }
  1323. void nsFPD::CFPDDeviceAXS::RegisterAutonumous(nsDetail::Dispatch* Dispatch)
  1324. {
  1325. Dispatch->Action.Push("OfflineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOfflineFPD);
  1326. Dispatch->Action.Push("OnlineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOnlineFPD);
  1327. Dispatch->Action.Push("GetAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAutonumousImageList);
  1328. Dispatch->Action.Push("RemoveAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousImageList);
  1329. Dispatch->Action.Push("RemoveAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousAll);
  1330. Dispatch->Action.Push("GetImageMetaData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetImageMetaData);
  1331. Dispatch->Action.Push("ExportAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExportAutonumousAll);
  1332. }
  1333. void nsFPD::CFPDDeviceAXS::SendTemperatureValue(float fValue)
  1334. {
  1335. int nStatus = 0;
  1336. m_Temperature->SetTemperature(fValue, nStatus);
  1337. FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
  1338. }
  1339. void nsFPD::CFPDDeviceAXS::SendWifiValue(int nValue)
  1340. {
  1341. int nStatus = 0;
  1342. m_Wifi->SetSignalValue(nValue, nStatus);
  1343. FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
  1344. }
  1345. void nsFPD::CFPDDeviceAXS::SendBatteryValue(int nValue)
  1346. {
  1347. int nStatus = 0;
  1348. m_Battery->SetRemainPowerValue(nValue, nStatus);
  1349. FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
  1350. }
  1351. /// <summary>
  1352. /// 探测器设备 所有 事件处理入口 @PZ_FPD
  1353. /// conf/info/status/data/warning/error
  1354. /// </summary>
  1355. /// <param name="nDetectorID"></param>
  1356. /// <param name="nEventID"></param>
  1357. /// <param name="nEventLevel"></param>
  1358. /// <param name="pszMsg"></param>
  1359. /// <param name="nParam1"></param>
  1360. /// <param name="fParam2"></param>
  1361. /// <param name="nPtrParamLen"></param>
  1362. /// <param name="pParam"></param>
  1363. void nsFPD::CFPDDeviceAXS::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1364. {
  1365. switch (nEventLevel)
  1366. {
  1367. case EVT_LEVEL_CONFIGURATION:
  1368. {
  1369. OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1370. break;
  1371. }
  1372. case EVT_LEVEL_INFORMATOION:
  1373. {
  1374. OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1375. break;
  1376. }
  1377. case EVT_LEVEL_STATUS:
  1378. {
  1379. OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1380. break;
  1381. }
  1382. case EVT_LEVEL_DATA:
  1383. {
  1384. OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1385. break;
  1386. }
  1387. case EVT_LEVEL_WARNING:
  1388. {
  1389. OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1390. break;
  1391. }
  1392. case EVT_LEVEL_ERROR:
  1393. {
  1394. OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1395. break;
  1396. }
  1397. default:
  1398. break;
  1399. }
  1400. }
  1401. // 通知子系统开窗
  1402. void nsFPD::CFPDDeviceAXS::NotifyXWindowOn() {
  1403. m_SyncUnit->XWindowOnNotify();
  1404. }
  1405. // 通知子系统关窗
  1406. void nsFPD::CFPDDeviceAXS::NotifyXWindowOff() {
  1407. m_SyncUnit->XWindowOffNotify();
  1408. }
  1409. bool nsFPD::CFPDDeviceAXS::GetOnlyHaveFpd()
  1410. {
  1411. return m_bOnlyHaveFpd;
  1412. }
  1413. int nsFPD::CFPDDeviceAXS::GetGainExposureNum()
  1414. {
  1415. return m_nCalibTotalExposureNum;
  1416. }
  1417. /// <summary>
  1418. /// 探测器设备 配置 事件处理 @PZ_FPD
  1419. /// 暂不支持 配置
  1420. /// </summary>
  1421. /// <param name="nDetectorID"></param>
  1422. /// <param name="nEventID"></param>
  1423. /// <param name="nEventLevel"></param>
  1424. /// <param name="pszMsg"></param>
  1425. /// <param name="nParam1"></param>
  1426. /// <param name="fParam2"></param>
  1427. /// <param name="nPtrParamLen"></param>
  1428. /// <param name="pParam"></param>
  1429. void nsFPD::CFPDDeviceAXS::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
  1430. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1431. {
  1432. switch (nEventID)
  1433. {
  1434. case EVT_CONF_PANEL_SERIAL:
  1435. {
  1436. m_stDeviceConfig.strPanelSerial = pszMsg;
  1437. FINFO("Receive Panel {$} SN {$}", nDetectorID, pszMsg);
  1438. m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
  1439. break;
  1440. }
  1441. case EVT_CONF_RAW_WIDTH:
  1442. {
  1443. if (m_stDeviceConfig.nFullImageWidth != nParam1)
  1444. {
  1445. m_stDeviceConfig.nFullImageWidth = nParam1;
  1446. }
  1447. FINFO("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth);
  1448. break;
  1449. }
  1450. case EVT_CONF_RAW_HIGHT:
  1451. {
  1452. if (m_stDeviceConfig.nFullImageHeight != nParam1)
  1453. {
  1454. m_stDeviceConfig.nFullImageHeight = nParam1;
  1455. }
  1456. FINFO("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight);
  1457. break;
  1458. }
  1459. case EVT_CONF_RAW_BITS:
  1460. {
  1461. m_stDeviceConfig.nImageBits = nParam1;
  1462. FINFO("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits);
  1463. break;
  1464. }
  1465. case EVT_CONF_PIXELSPACE:
  1466. {
  1467. m_stDeviceConfig.nPixelSpace = (int)fParam2;
  1468. FINFO("Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
  1469. break;
  1470. }
  1471. case EVT_CONF_PREVIEW_WIDTH:
  1472. {
  1473. if (m_stDeviceConfig.nPreviewWidth != nParam1)
  1474. {
  1475. m_stDeviceConfig.nPreviewWidth = nParam1;
  1476. }
  1477. FINFO("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
  1478. break;
  1479. }
  1480. case EVT_CONF_PREVIEW_HIGHT:
  1481. {
  1482. if (m_stDeviceConfig.nPreviewHeight != nParam1)
  1483. {
  1484. m_stDeviceConfig.nPreviewHeight = nParam1;
  1485. }
  1486. FINFO("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
  1487. break;
  1488. }
  1489. case EVT_CONF_MODULE_TYPE:
  1490. {
  1491. //m_strModuleType = pszMsg;
  1492. FINFO("Receive Panel {$} ModuleType {$}", nDetectorID, pszMsg);
  1493. break;
  1494. }
  1495. case EVT_CONF_MODULE_IP:
  1496. {
  1497. //m_strModuleIP = pszMsg;
  1498. FINFO("Receive Panel {$} ModuleIP {$}", nDetectorID, pszMsg);
  1499. break;
  1500. }
  1501. case EVT_CONF_MODULE_SN:
  1502. {
  1503. //m_strModuleSN = pszMsg;
  1504. FINFO("Receive Panel {$} ModuleSN {$}", nDetectorID, pszMsg);
  1505. break;
  1506. }
  1507. case EVT_CONF_FIRWARE_UPDATE:
  1508. {
  1509. m_stDeviceConfig.nFirmwareStatus = nParam1;
  1510. FINFO("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
  1511. break;
  1512. }
  1513. case EVT_CONF_PART_NUMBER:
  1514. {
  1515. m_stDeviceConfig.strPartNumber = pszMsg;
  1516. FINFO("Panel {$} PartNumber:{$}", nDetectorID, pszMsg);
  1517. break;
  1518. }
  1519. case EVT_CONF_BATTERY_SN:
  1520. {
  1521. //m_strBatterySN = pszMsg;
  1522. FINFO("Panel {$} Battery SN:{$}", nDetectorID, pszMsg);
  1523. break;
  1524. }
  1525. case EVT_CONF_WIFI_SSID:
  1526. {
  1527. m_stDeviceConfig.strWifiSSID = pszMsg;
  1528. FINFO("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg);
  1529. break;
  1530. }
  1531. case EVT_CONF_IFBOARD:
  1532. {
  1533. m_stDeviceConfig.strInterfaceBoard = pszMsg;
  1534. FINFO("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg);
  1535. break;
  1536. }
  1537. case EVT_CONF_DATECODE:
  1538. {
  1539. m_stDeviceConfig.strDateCode = pszMsg;
  1540. FINFO("Panel {$} DateCode:{$}", nDetectorID, pszMsg);
  1541. break;
  1542. }
  1543. case EVT_CONF_LIFETIME:
  1544. {
  1545. int nLifeTime = nParam1;
  1546. if ((nLifeTime != m_stDeviceConfig.nLifeTime) /*&& (m_strBatterySN != "")*/)
  1547. {
  1548. FINFO("LifeTime:{$}", nLifeTime);
  1549. m_stDeviceConfig.nLifeTime = nLifeTime;
  1550. }
  1551. break;
  1552. }
  1553. default:
  1554. break;
  1555. }
  1556. }
  1557. /// <summary>
  1558. /// 探测器设备 Info 事件处理 @PZ_FPD
  1559. /// 暂不支持 Info
  1560. /// </summary>
  1561. /// <param name="nDetectorID"></param>
  1562. /// <param name="nEventID"></param>
  1563. /// <param name="nEventLevel"></param>
  1564. /// <param name="pszMsg"></param>
  1565. /// <param name="nParam1"></param>
  1566. /// <param name="fParam2"></param>
  1567. /// <param name="nPtrParamLen"></param>
  1568. /// <param name="pParam"></param>
  1569. void nsFPD::CFPDDeviceAXS::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
  1570. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1571. {
  1572. int nID = nDetectorID;
  1573. switch (nEventID)
  1574. {
  1575. case EVT_INFO_POWER_ON:
  1576. {
  1577. int nPowerOn = nParam1;
  1578. FINFO("Detector {$} PowerOn:{$}", nID, nPowerOn);
  1579. if ((nPowerOn != m_stDeviceConfig.nPowerOn) /*&& (m_strBatterySN != "")*/)
  1580. {
  1581. m_stDeviceConfig.nPowerOn = nPowerOn;
  1582. }
  1583. break;
  1584. }
  1585. case EVT_INFO_BATTERY_CAPACITY:
  1586. {
  1587. int nBatteryCapacity = nParam1;
  1588. if ((nBatteryCapacity != m_nBatteryCapacity) /*&& (m_strBatterySN != "")*/)
  1589. {
  1590. FINFO("{$}", nBatteryCapacity);
  1591. m_nBatteryCapacity = nBatteryCapacity;
  1592. }
  1593. break;
  1594. }
  1595. case EVT_INFO_BATTERY_TEMPERATURE:
  1596. {
  1597. float fBatteryTemper = fParam2;
  1598. if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) /*&& (m_strBatterySN != "")*/)
  1599. {
  1600. FINFO("temperature:{$:f2}", fBatteryTemper);
  1601. m_fBatteryTemperature = fBatteryTemper;
  1602. }
  1603. break;
  1604. }
  1605. case EVT_INFO_BATTERY_CHARGES:
  1606. {
  1607. int nBatteryCharges = nParam1;
  1608. if ((nBatteryCharges != m_nBatteryCharges)/* && (m_strBatterySN != "")*/)
  1609. {
  1610. FINFO("Charge number:{$}", nBatteryCharges);
  1611. m_nBatteryCharges = nBatteryCharges;
  1612. }
  1613. break;
  1614. }
  1615. case EVT_INFO_WIFI_DATARATE:
  1616. {
  1617. m_stDeviceConfig.nWifiDataRate = nParam1;
  1618. FINFO("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate);
  1619. break;
  1620. }
  1621. case EVT_INFO_WIFI_CHANNEL:
  1622. {
  1623. m_stDeviceConfig.nWifiChannel = nParam1;
  1624. FINFO("Panel {$} WifiChannel:{$}", nID, m_stDeviceConfig.nWifiChannel);
  1625. break;
  1626. }
  1627. case EVT_INFO_WIFI_SIGNALPOWER:
  1628. {
  1629. m_stDeviceConfig.nWifiSignalPower = nParam1;
  1630. break;
  1631. }
  1632. case EVT_INFO_WIFI_NOISEPOWER:
  1633. {
  1634. m_stDeviceConfig.nWifiNoisePower = nParam1;
  1635. FINFO("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower);
  1636. break;
  1637. }
  1638. case EVT_INFO_FIRMWARE:
  1639. {
  1640. m_stDeviceConfig.strFirmware = pszMsg;
  1641. FINFO("Panel {$} Firmware:{$}", nID, pszMsg);
  1642. break;
  1643. }
  1644. case EVT_INFO_SHOCKSENSOR_INFO:
  1645. {
  1646. FINFO("Receive ShockSensor Info");
  1647. //m_strShockSensor = pszMsg;
  1648. //m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor);
  1649. break;
  1650. }
  1651. case EVT_INFO_CALIBRATIOIN_TIME:
  1652. {
  1653. m_stDeviceConfig.strCalibrationDate = pszMsg;
  1654. FINFO("Panel {$} Calibration Time:{$}", nID, pszMsg);
  1655. m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
  1656. m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration("");
  1657. //m_stDeviceConfig.strCalibrationDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationDate);
  1658. break;
  1659. }
  1660. case EVT_INFO_CALIBRATIOIN_TIMEL:
  1661. {
  1662. m_stDeviceConfig.strCalibrationLTEDate = pszMsg;
  1663. FINFO("Panel {$} Calibration LTE Time:{$}", nID, pszMsg);
  1664. //m_stDeviceConfig.strCalibrationLTEDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationLTEDate);
  1665. break;
  1666. }
  1667. case EVT_INFO_FPVOLTAGE:
  1668. {
  1669. //m_strVoltage = pszMsg;
  1670. break;
  1671. }
  1672. default:
  1673. break;
  1674. }
  1675. }
  1676. /// <summary>
  1677. /// 探测器设备状态事件 处理@PZ_FPD
  1678. /// </summary>
  1679. /// <param name="nDetectorID"></param>
  1680. /// <param name="nEventID"></param>
  1681. /// <param name="nEventLevel"></param>
  1682. /// <param name="pszMsg"></param>
  1683. /// <param name="nParam1"></param>
  1684. /// <param name="fParam2"></param>
  1685. /// <param name="nPtrParamLen"></param>
  1686. /// <param name="pParam"></param>
  1687. void nsFPD::CFPDDeviceAXS::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
  1688. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1689. {
  1690. switch (nEventID)
  1691. {
  1692. case EVT_STATUS_INIT:
  1693. {
  1694. if (PANEL_EVENT_END_OK == nParam1)
  1695. {
  1696. FINFO("Detector init success set connect status is true");
  1697. m_stDeviceConfig.bConnectStatus = true;
  1698. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
  1699. }
  1700. else if (PANEL_EVENT_END_ERROR == nParam1)
  1701. {
  1702. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_FAILED));
  1703. }
  1704. else if (PANEL_EVENT_END == nParam1) //未连接探测器
  1705. {
  1706. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
  1707. }
  1708. else if (PANEL_EVENT_START == nParam1)
  1709. {
  1710. m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START));
  1711. }
  1712. break;
  1713. }
  1714. case EVT_STATUS_MOTION:
  1715. {
  1716. //m_strMotionStatus = pszMsg;
  1717. break;
  1718. }
  1719. case EVT_STATUS_UPDATE_FIRMWARE:
  1720. {
  1721. if (PANEL_EVENT_START == nParam1)
  1722. {
  1723. FINFO("Start update firmware");
  1724. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START));
  1725. }
  1726. else if (PANEL_EVENT_BEGIN == nParam1)
  1727. {
  1728. FINFO("Update firmware begin");
  1729. m_stDeviceConfig.bConnectStatus = false;
  1730. }
  1731. else if (PANEL_EVENT_END_ERROR == nParam1)
  1732. {
  1733. FINFO("Update firmware failed");
  1734. //SendDetectorInfo(); //更新探测器状态图标
  1735. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR));
  1736. }
  1737. else if (PANEL_EVENT_SUCCESS == nParam1)
  1738. {
  1739. FINFO("update firmware success");
  1740. //SendDetectorInfo();
  1741. m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS));
  1742. }
  1743. break;
  1744. }
  1745. case EVT_STATUS_SELFTEST:
  1746. {
  1747. break;
  1748. }
  1749. case EVT_STATUS_DETECTORSHARE:
  1750. {
  1751. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1752. switch (eStatus)
  1753. {
  1754. case PANEL_ATTACH_START:
  1755. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START)); //重置status,避免服务判重,两次attach失败时,不将第二次的失败信息发送给客户端
  1756. FINFO("New Detector Attach start");
  1757. break;
  1758. case PANEL_ATTACH_OVER:
  1759. FINFO("New Detector Attach Over,Prepare to Connecting");
  1760. //m_DetectorCtrlUnit->SetAttachResult(true, m_stDeviceConfig.strDeviceName.c_str(), m_strModuleSN.c_str());
  1761. break;
  1762. case PANEL_ATTACH_FAILED: //UI显示Failed
  1763. FERROR("New Detector Attach failed");
  1764. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED));
  1765. break;
  1766. case PANEL_CONNECT_OK:
  1767. FINFO("OnEventProcessStatus panel connect ok set connect status is true");
  1768. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
  1769. m_stDeviceConfig.bConnectStatus = true;
  1770. break;
  1771. case PANEL_CONNECT_ERROR:
  1772. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
  1773. break;
  1774. case PANEL_DISCONNECT_SUCCESS:
  1775. m_nBatteryCapacity = 0;
  1776. //m_strBatterySN = "";
  1777. m_stDeviceConfig.bExisted = false;
  1778. m_stDeviceConfig.bConnectStatus = false;
  1779. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
  1780. break;
  1781. case PANEL_DISCONNECT_ERROR:
  1782. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
  1783. break;
  1784. default:
  1785. break;
  1786. }
  1787. break;
  1788. }
  1789. case EVT_STATUS_SINGLEINIT:
  1790. {
  1791. break;
  1792. }
  1793. case EVT_STATUS_SELECTPANEL:
  1794. {
  1795. break;
  1796. }
  1797. case EVT_STATUS_PANEL:
  1798. {
  1799. ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
  1800. if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
  1801. {
  1802. m_stImgCreateTime = { 0 };
  1803. GetLocalTime(&m_stImgCreateTime);
  1804. FINFO("XWindow on time {$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1805. m_SyncUnit->XWindowOnNotify();
  1806. }
  1807. else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
  1808. {
  1809. m_stImgCreateTime = { 0 };
  1810. GetLocalTime(&m_stImgCreateTime);
  1811. FINFO("XWindow off time {$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
  1812. m_SyncUnit->XWindowOffNotify();
  1813. }
  1814. else if (PANEL_READY_EXP == nParam1)
  1815. {
  1816. m_SyncUnit->FPDReadyNotify(true);
  1817. m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
  1818. }
  1819. else if (PANEL_GAIN_READY_EXP == nParam1)
  1820. {
  1821. m_SyncUnit->FPDReadyNotify(true);
  1822. m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
  1823. }
  1824. else if (PANEL_XRAY_ON == nParam1)
  1825. {
  1826. m_SyncUnit->XrayOnNotify();
  1827. }
  1828. else if (PANEL_XRAY_OFF == nParam1)
  1829. {
  1830. m_SyncUnit->XrayOffNotify();
  1831. }
  1832. else if (PANEL_CLOSE == nParam1)
  1833. {
  1834. FINFO("notify FPD not ready");
  1835. m_SyncUnit->FPDReadyNotify(false);
  1836. //右上角图标变灰色
  1837. m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN));
  1838. }
  1839. break;
  1840. }
  1841. case EVT_STATUS_CALIBRATIOIN:
  1842. {
  1843. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1844. switch (eStatus)
  1845. {
  1846. case PANEL_EVENT_END_OK:
  1847. FINFO("Calibration process end ok");
  1848. CompleteCalibration();
  1849. break;
  1850. case PANEL_EVENT_END_ERROR:
  1851. FINFO("Calibration process end error");
  1852. break;
  1853. case PANEL_EVENT_START:
  1854. FINFO("Calibration process start");
  1855. break;
  1856. case PANEL_EVENT_SUCCESS:
  1857. FINFO("Calibration process success");
  1858. break;
  1859. case PANEL_EVENT_END:
  1860. FINFO("Calibration process end");
  1861. break;
  1862. case PANEL_EVENT_BEGIN:
  1863. FINFO("Calibration process begin");
  1864. break;
  1865. case PANEL_EVENT_TIMEOUT:
  1866. FINFO("Calibration timeout");
  1867. break;
  1868. default:
  1869. break;
  1870. }
  1871. break;
  1872. }
  1873. case EVT_STATUS_SAVECALIB:
  1874. {
  1875. if (PANEL_EVENT_START == nParam1)
  1876. {
  1877. FINFO("Begin to Save Calibration Files");
  1878. }
  1879. else if (PANEL_EVENT_END_ERROR == nParam1)
  1880. {
  1881. FINFO("Save Calibration Files failed");
  1882. }
  1883. else if (PANEL_EVENT_END == nParam1)
  1884. {
  1885. FINFO("Save Calibration Files Success");
  1886. }
  1887. break;
  1888. }
  1889. case EVT_STATUS_SAVEDEFECT:
  1890. {
  1891. if (PANEL_EVENT_START == nParam1)
  1892. {
  1893. FINFO("Begin to Save Defect Files");
  1894. }
  1895. else if (PANEL_EVENT_END_ERROR == nParam1)
  1896. {
  1897. FINFO("Save Defect Files failed");
  1898. }
  1899. else if (PANEL_EVENT_END == nParam1)
  1900. {
  1901. FINFO("Save Defect Files Success");
  1902. m_stDeviceConfig.bTaskEnd = true;
  1903. }
  1904. break;
  1905. }
  1906. case EVT_STATUS_ACQUISITION:
  1907. {
  1908. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1909. switch (eStatus)
  1910. {
  1911. case PANEL_EVENT_START:
  1912. FINFO("Acquisition start");
  1913. break;
  1914. case PANEL_EVENT_END_OK:
  1915. FINFO("Acquisition end");
  1916. break;
  1917. case PANEL_EVENT_END_ERROR: //目前不会报错,不会走到这里
  1918. break;
  1919. default:
  1920. break;
  1921. }
  1922. break;
  1923. }
  1924. case EVT_STATUS_SINGLEEXP:
  1925. {
  1926. if (DOSE_TOO_HIGH == nParam1)
  1927. {
  1928. FINFO("Dose too high");
  1929. StopCalibration();
  1930. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1931. m_CalibUnit->SetCalibrationProgress("100");
  1932. m_AcqUnit->SendNoNeedWaitImage(true);
  1933. }
  1934. else if (DOSE_TOO_LOW == nParam1)
  1935. {
  1936. FINFO("Dose too low");
  1937. StopCalibration();
  1938. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1939. m_CalibUnit->SetCalibrationProgress("100");
  1940. m_AcqUnit->SendNoNeedWaitImage(true);
  1941. }
  1942. else if (DOSE_OBJECT == nParam1)
  1943. {
  1944. FINFO("Dose object");
  1945. StopCalibration();
  1946. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1947. m_AcqUnit->SendNoNeedWaitImage(true);
  1948. }
  1949. else if (DOSE_ACCEPT == nParam1)
  1950. {
  1951. FINFO("Calibration Result is acceptable");
  1952. //m_WarnAndError->OnErrorX("ERR_FPD_DOSE_INVALID");
  1953. }
  1954. else if (EVT_STATUS_LASTERROR == nParam1)
  1955. {
  1956. //m_strLastError = pszMsg;
  1957. //FINFO("Panel {$} LastError {$}", nID, pszMsg);
  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(nID, "ERR_FPD_IMAGE_PENDING");
  1975. }
  1976. else
  1977. {
  1978. m_bResetDetector = false;//可以再次reset
  1979. //m_WarnAndError->OnErrorX("ERR_FPD_IMAGE_PENDING");
  1980. }
  1981. break;
  1982. }
  1983. case EVT_STATUS_TEMPERATURE:
  1984. {
  1985. float fTemperature = fParam2;
  1986. OnProcessTemperature(nDetectorID, fTemperature);
  1987. m_stDeviceConfig.fCurrentTemperValue = fTemperature;
  1988. FINFO("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature);
  1989. SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
  1990. break;
  1991. }
  1992. case EVT_STATUS_WIFI:
  1993. {
  1994. int nWifiLevel = nParam1;
  1995. if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0)
  1996. {
  1997. nWifiLevel = int(nWifiLevel / 0.75);
  1998. if (nWifiLevel > 100)
  1999. {
  2000. nWifiLevel = 100;
  2001. }
  2002. }
  2003. FINFO("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel);
  2004. //strWarnErrorCode = "ERR_FPD_WIFI_LOW";
  2005. if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错
  2006. {
  2007. //m_WarnAndError->OnErrorX(strWarnErrorCode);
  2008. }
  2009. else if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
  2010. {
  2011. //wifi error
  2012. //OnError(nID, strWarnErrorCode);
  2013. }
  2014. else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning)
  2015. {
  2016. //wifi error
  2017. //m_WarnAndError->OnErrorX(strWarnErrorCode);
  2018. //strWarnErrorCode = "WAR_FPD_WIFI_LOW";
  2019. //OnWarn(nID, strWarnErrorCode);
  2020. }
  2021. else
  2022. {
  2023. //m_WarnAndError->OnErrorX(strWarnErrorCode);
  2024. }
  2025. FINFO("detector wifi level:{$}", nWifiLevel);
  2026. if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue)
  2027. {
  2028. FINFO("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate);
  2029. }
  2030. //endif
  2031. m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
  2032. SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
  2033. break;
  2034. }
  2035. case EVT_STATUS_BATTERY_VALUE:
  2036. {
  2037. int nBatteryValue = nParam1;
  2038. FINFO("Detector {$} Battery:{$}", nDetectorID, nParam1);
  2039. if (nBatteryValue < m_stDeviceConfig.nBatteryLimit)
  2040. {
  2041. //battery error
  2042. //if (!m_bBatteryCharging) //如果没有充电;
  2043. //{
  2044. // strWarnErrorCode = "ERR_FPD_BATTERY_LOW";
  2045. // OnError(nID, strWarnErrorCode);
  2046. //}
  2047. }
  2048. else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
  2049. {
  2050. //battery error
  2051. //strWarnErrorCode = "ERR_FPD_BATTERY_LOW";
  2052. //m_WarnAndError->OnErrorX(strWarnErrorCode);
  2053. //strWarnErrorCode = "WAR_FPD_BATTERY_LOW";
  2054. //OnWarn(nID, strWarnErrorCode);
  2055. }
  2056. else
  2057. {
  2058. //strWarnErrorCode = "ERR_FPD_BATTERY_LOW";
  2059. //m_WarnAndError->OnErrorX(strWarnErrorCode);
  2060. }
  2061. m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
  2062. FINFO("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue);
  2063. SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
  2064. break;
  2065. }
  2066. case EVT_STATUS_BATTERY_CHARGING:
  2067. {
  2068. /*string strTemp = pszMsg;
  2069. if (strTemp.find("true") != std::string::npos)
  2070. {
  2071. m_bBatteryCharging = true;
  2072. }
  2073. else
  2074. {
  2075. m_bBatteryCharging = false;
  2076. }*/
  2077. break;
  2078. }
  2079. case EVT_STATUS_SHOCK_SENSOR:
  2080. {
  2081. //m_nShockCounts = nParam1;
  2082. //string strLog;
  2083. //PRINTA_INFO("Panel %d Shock Sensor Number:%d", nID, m_nShockCounts);
  2084. //if ((m_nShockCounts >= m_stDeviceConfig.nMaxShockNumber) && (m_stDeviceConfig.nShockTimes != m_nShockCounts))//避免频繁发送
  2085. //{
  2086. // PRINTA_INFO("Reach Max Shock Sensor Number");
  2087. // OnWarn(nID, WAR_FPD_MAX_SHOCK_NUM);
  2088. // SendInfoLog("DEV_LOG_FPD_SHOCKSENSOR", m_strShockSensor);
  2089. //}
  2090. //m_stDeviceConfig.nShockTimes = m_nShockCounts;
  2091. break;
  2092. }
  2093. case EVT_STATUS_HALL_SENSOR:
  2094. {
  2095. //int nWorkstaion = nParam1;
  2096. //PRINTA_INFO("Update Hall Status : %d ", nWorkstaion);
  2097. //PRINTA_INFO("Panel %d WS:%d,Current OGP WS:%d ", nID, nWorkstaion, m_nWorkStation);
  2098. //m_stDeviceConfig.nWorkstation = nWorkstaion;
  2099. break;
  2100. }
  2101. case EVT_STATUS_PING:
  2102. {
  2103. break;
  2104. }
  2105. case EVT_STATUS_PMSNOTOPEN:
  2106. {
  2107. string strTemp = pszMsg;
  2108. if (strTemp.find("true") != std::string::npos)
  2109. {
  2110. FINFO("PMS isn't open");
  2111. }
  2112. break;
  2113. }
  2114. case EVT_STATUS_RESTOREFILES:
  2115. {
  2116. //string strTemp = pszMsg;
  2117. //if (strTemp.find("true") != std::string::npos)
  2118. //{
  2119. // PRINTA_INFO("Restore calibration files");
  2120. // string wcsPanelType = "3543dr";
  2121. // if (m_stDeviceConfig.strDeviceName.find("3543EZ") >= 0)
  2122. // {
  2123. // wcsPanelType = "3543ezh";
  2124. // }
  2125. // else if (m_stDeviceConfig.strDeviceName.find("2430EZ") != std::string::npos)
  2126. // {
  2127. // wcsPanelType = "2430ez";
  2128. // }
  2129. // m_CalibProcess->UpdateFDCalibList(m_nLTEenable, m_stDeviceConfig.strPanelSerial, wcsPanelType.c_str());
  2130. //}
  2131. break;
  2132. }
  2133. case EVT_STATUS_LASTERROR:
  2134. {
  2135. //m_strLastError = pszMsg;
  2136. //PRINTA_INFO("Panel {$} LastError {$}", nID, pszMsg);
  2137. break;
  2138. }
  2139. case EVT_STATUS_RESET:
  2140. {
  2141. int nStatus = nParam1;
  2142. if (PANEL_RESET_BEGIN == nStatus)
  2143. {
  2144. //弹出滚动条
  2145. }
  2146. else if (PANEL_RESET_OK == nStatus)
  2147. {
  2148. m_bResetDetector = false;
  2149. }
  2150. else if (PANEL_RESET_ERROR == nStatus)
  2151. {
  2152. // //OnError(nID,ERR_FPD_RESET,L"");
  2153. }
  2154. break;
  2155. }
  2156. case EVT_AUTONUMOUS_STATUS:
  2157. {
  2158. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  2159. switch (eStatus)
  2160. {
  2161. case PANEL_CONNECT_ERROR:
  2162. {
  2163. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
  2164. break;
  2165. }
  2166. case PANEL_CONNECT_OK:
  2167. {
  2168. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
  2169. m_stDeviceConfig.bConnectStatus = true;
  2170. break;
  2171. }
  2172. case PANEL_DISCONNECT_SUCCESS:
  2173. {
  2174. m_nBatteryCapacity = 0;
  2175. m_stDeviceConfig.bExisted = false;
  2176. m_stDeviceConfig.bConnectStatus = false;
  2177. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
  2178. break;
  2179. }
  2180. case PANEL_DISCONNECT_ERROR:
  2181. {
  2182. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
  2183. break;
  2184. }
  2185. case PANEL_START_STOREDIMAGE:
  2186. {
  2187. FINFO("Send start autonumous to server");
  2188. m_AcqUnit->SendAutonumousMapFinish(0);
  2189. break;
  2190. }
  2191. case PANEL_END_STOREDIMAGE:
  2192. {
  2193. FINFO("Send finish autonumous to server");
  2194. m_AcqUnit->SendAutonumousMapFinish(1);
  2195. break;
  2196. }
  2197. case PANEL_EXPORT_AUTONUMOUS_FINISH:
  2198. {
  2199. FINFO("Send finish export local autonumous to server");
  2200. m_AcqUnit->SendAutonumousMapFinish(2);
  2201. break;
  2202. }
  2203. default:
  2204. break;
  2205. }
  2206. break;
  2207. }
  2208. default:
  2209. break;
  2210. }
  2211. }
  2212. /// <summary>
  2213. /// 探测器设备图像数据事件 处理 @PZ_FPD
  2214. /// </summary>
  2215. /// <param name="nDetectorID"></param>
  2216. /// <param name="nEventID"></param>
  2217. /// <param name="nEventLevel"></param>
  2218. /// <param name="pszMsg"></param>
  2219. /// <param name="nParam1"></param>
  2220. /// <param name="fParam2"></param>
  2221. /// <param name="nPtrParamLen"></param>
  2222. /// <param name="pParam"></param>
  2223. void nsFPD::CFPDDeviceAXS::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
  2224. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  2225. {
  2226. switch (nEventID)
  2227. {
  2228. case EVT_DATA_RAW_IMAGE:
  2229. {
  2230. FINFO("Image Arrived");
  2231. if (APP_STATUS_IDLE == m_eAppStatus)
  2232. {
  2233. FERROR("Omit Image in Idle Status");
  2234. return;
  2235. }
  2236. FINFO("Currenct FPD FullImage Width:{$},FullImage Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight);
  2237. float fImageReferUGY = 2.5;
  2238. if (APP_STATUS_WORK_BEGIN == m_eAppStatus) //如果是在检查中
  2239. {
  2240. fImageReferUGY = 2.5;
  2241. }
  2242. if (NULL == m_pwRawImageData)
  2243. {
  2244. m_pwRawImageData = new WORD[m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight];
  2245. }
  2246. memcpy(m_pwRawImageData, pParam, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * sizeof(WORD));
  2247. OnProcessImage(m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight, fImageReferUGY);
  2248. break;
  2249. }
  2250. case EVT_DATA_PREVIEW_IMAGE:
  2251. {
  2252. FINFO("Preview Image Arrved");
  2253. FINFO("Current FPD preview image width: {$}, height: {$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  2254. m_SyncUnit->ImageReadingNotify();
  2255. //因为AEC图像的像素大小是4 不是 2 故这里要再乘以2
  2256. if (nullptr == m_pwPreviewImg)
  2257. {
  2258. m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2];
  2259. }
  2260. else
  2261. {
  2262. memset(m_pwPreviewImg, 0, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 4);
  2263. }
  2264. memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 4);
  2265. OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  2266. break;
  2267. }
  2268. case EVT_DATA_DOSEPARAM:
  2269. {
  2270. m_fDoseParam = fParam2;
  2271. break;
  2272. }
  2273. default:
  2274. FERROR("Not support this eventID ({$})", nEventID);
  2275. break;
  2276. }
  2277. }
  2278. /// <summary>
  2279. /// 探测器设备 ERROR 事件处理 @PZ_FPD
  2280. /// </summary>
  2281. /// <param name="nDetectorID"></param>
  2282. /// <param name="nEventID"></param>
  2283. /// <param name="nEventLevel"></param>
  2284. /// <param name="pszMsg"></param>
  2285. /// <param name="nParam1"></param>
  2286. /// <param name="fParam2"></param>
  2287. /// <param name="nPtrParamLen"></param>
  2288. /// <param name="pParam"></param>
  2289. void nsFPD::CFPDDeviceAXS::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
  2290. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  2291. {
  2292. switch (nEventID)
  2293. {
  2294. case EVT_ERR_COMMUNICATE:
  2295. {
  2296. //strErrorName = "ERR_FPD_DISCONNECT";
  2297. string strTemp = pszMsg;
  2298. if (strTemp.find("true") != std::string::npos)
  2299. {
  2300. m_stDeviceConfig.nWorkstation = -1;
  2301. m_stDeviceConfig.bConnectStatus = false;
  2302. m_nBatteryCapacity = 0;
  2303. m_stDeviceConfig.fCurrentTemperValue = 0.0f;
  2304. m_stDeviceConfig.nCurrentWifiValue = 0;
  2305. m_stDeviceConfig.nCurrentBatteryValue = 0;
  2306. SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
  2307. SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
  2308. SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
  2309. //OnError(nDetectorID, strErrorName);
  2310. }
  2311. else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo
  2312. {
  2313. m_stDeviceConfig.bConnectStatus = true;
  2314. //if (m_WarnAndError->IsErrorExist("ERR_FPD_DISCONNECT")) //如果已经恢复了通讯,不再重复发送LOG
  2315. //{
  2316. // m_WarnAndError->OnErrorX(strErrorName);
  2317. //}
  2318. }
  2319. break;
  2320. }
  2321. case EVT_ERR_EXP_REQUEST:
  2322. FERROR("OnEventProcessError EVT_ERR_EXP_REQUEST");
  2323. break;
  2324. case EVT_ERR_GET_IMAGE:
  2325. FERROR("OnEventProcessError EVT_ERR_GET_IMAGE");
  2326. break;
  2327. case EVT_ERR_MAX_NUMBER:
  2328. FERROR("OnEventProcessError EVT_ERR_MAX_NUMBER");
  2329. break;
  2330. case EVT_ERR_SN_NOTINLIST:
  2331. FERROR("OnEventProcessError EVT_ERR_SN_NOTINLIST");
  2332. break;
  2333. case EVT_ERR_POWER_OFF:
  2334. FERROR("OnEventProcessError EVT_ERR_POWER_OFF");
  2335. break;
  2336. case EVT_ERR_INIT_FAILED:
  2337. {
  2338. string strTemp = pszMsg;
  2339. if (strTemp.find("true") != std::string::npos)
  2340. {
  2341. //AddErrMsg("6", "initialize error");
  2342. }
  2343. else if (strTemp.find("false") != std::string::npos)
  2344. {
  2345. //一般不可恢复
  2346. }
  2347. break;
  2348. }
  2349. default:
  2350. FERROR("Not support this error({$})", nEventID);
  2351. break;
  2352. }
  2353. }
  2354. /// <summary>
  2355. /// 探测器设备 WARNING 事件 处理 @PZ_FPD
  2356. /// 当前版本不支持,TBD.
  2357. /// </summary>
  2358. /// <param name="nDetectorID"></param>
  2359. /// <param name="nEventID"></param>
  2360. /// <param name="nEventLevel"></param>
  2361. /// <param name="pszMsg"></param>
  2362. /// <param name="nParam1"></param>
  2363. /// <param name="fParam2"></param>
  2364. /// <param name="nPtrParamLen"></param>
  2365. /// <param name="pParam"></param>
  2366. void nsFPD::CFPDDeviceAXS::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
  2367. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  2368. {
  2369. FERROR("Not support this warn({$})", nEventID);
  2370. }
  2371. bool nsFPD::CFPDDeviceAXS::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
  2372. {
  2373. FINFO("Currenct PreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
  2374. PrevImageDateArrived(pwRawImage);
  2375. return true;
  2376. }
  2377. void nsFPD::CFPDDeviceAXS::PrevImageDateArrived(WORD* pImg)
  2378. {
  2379. //LMAM3-IZ85c的pre image 像素大小是4,单字节:宽*高*4 双字节:宽*高*2
  2380. AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2);
  2381. }
  2382. void nsFPD::CFPDDeviceAXS::FullImageDateArrived(WORD* pImg)
  2383. {
  2384. //LMAM3-IZ85c的有效图像像素大小是2,单字节:宽*高*2 双字节:宽*高
  2385. AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight);
  2386. }
  2387. RET_STATUS nsFPD::CFPDDeviceAXS::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
  2388. {
  2389. string strImageHead = MakeImageHead(Type);
  2390. FINFO("str image head:{$}",strImageHead.c_str());
  2391. printf("str image head:%s", strImageHead.c_str());
  2392. FINFO("FrameSize:{$}", FrameSize);
  2393. return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
  2394. }
  2395. string nsFPD::CFPDDeviceAXS::MakeImageHead(IMAGE_VIEW_TYPE Type)
  2396. {
  2397. if (m_pImageHead != NULL)
  2398. {
  2399. delete m_pImageHead;
  2400. m_pImageHead = nullptr;
  2401. }
  2402. if (Type == IMAGE_FULL)
  2403. {
  2404. if (m_pImageHead == NULL)
  2405. {
  2406. m_pImageHead = new ResDataObject;
  2407. ResDataObject json;
  2408. json.add(SM_IMAGE_TYPE, (int)Type);
  2409. json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nFullImageWidth);
  2410. json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nFullImageHeight);
  2411. json.add(SM_IMAGE_BIT, 16);
  2412. json.add(SM_IMAGE_TAG, 1);
  2413. json.add(SM_IMAGE_INDEX, 1);
  2414. json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  2415. json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  2416. json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  2417. json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  2418. json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  2419. json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  2420. json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  2421. json.add(SM_IMAGE_LSB, "5000");
  2422. json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
  2423. json.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  2424. json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
  2425. json.add(SM_IMAGE_ROTATION, "No");
  2426. json.add(SM_IMAGE_FLIP, "No");
  2427. json.add(SM_IMAGE_ORIGINX, "0");
  2428. json.add(SM_IMAGE_ORIGINY, "0");
  2429. json.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
  2430. json.add(SM_IMAGE_TEMP, 0.0f);
  2431. m_pImageHead->add(SM_IMAGE_HEAD, json);
  2432. }
  2433. else
  2434. {
  2435. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
  2436. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
  2437. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
  2438. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
  2439. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
  2440. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
  2441. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
  2442. (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
  2443. }
  2444. return (*m_pImageHead).encode();
  2445. }
  2446. else
  2447. {
  2448. if (m_pPreviewImageHead == NULL)
  2449. {
  2450. m_pPreviewImageHead = new ResDataObject;
  2451. ResDataObject json;
  2452. json.add(SM_IMAGE_TYPE, (int)Type);
  2453. json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth);
  2454. json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight);
  2455. json.add(SM_IMAGE_BIT, 16);
  2456. json.add(SM_IMAGE_TAG, 1);
  2457. json.add(SM_IMAGE_INDEX, 1);
  2458. json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
  2459. json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
  2460. json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
  2461. json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
  2462. json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
  2463. json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
  2464. json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
  2465. json.add(SM_IMAGE_LSB, "5000");
  2466. json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
  2467. json.add(SM_IMAGE_ROTATION, "No");
  2468. json.add(SM_IMAGE_FLIP, "No");
  2469. json.add(SM_IMAGE_ORIGINX, "0");
  2470. json.add(SM_IMAGE_ORIGINY, "0");
  2471. json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
  2472. json.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  2473. json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
  2474. m_pPreviewImageHead->add(SM_IMAGE_HEAD, json);
  2475. }
  2476. else
  2477. {
  2478. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
  2479. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
  2480. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
  2481. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
  2482. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
  2483. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
  2484. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
  2485. (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
  2486. }
  2487. return (*m_pPreviewImageHead).encode();
  2488. }
  2489. }
  2490. bool nsFPD::CFPDDeviceAXS::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY)
  2491. {
  2492. FINFO("CFPDDeviceAXS OnProcessImage");
  2493. if (pwRawImage == NULL)
  2494. {
  2495. FERROR("OnProcessImage src ImgData is null!");
  2496. return false;
  2497. }
  2498. if (!m_pwImageData)
  2499. {
  2500. m_pwImageData = new WORD[nImageWidth * nImageHeight];
  2501. }
  2502. if (!m_pwImageData)
  2503. {
  2504. FERROR("OnProcessImage new error!");
  2505. return false;
  2506. }
  2507. memcpy(m_pwImageData, pwRawImage, nImageWidth * nImageHeight * sizeof(WORD));
  2508. //图像预处理完成
  2509. m_pwImageData[0] = 65535;//坐标原点 bug 8164
  2510. //如果环境中只有探测器,那么这里增加一个推送状态
  2511. if (m_bOnlyHaveFpd)
  2512. {
  2513. FINFO("OnProcessImage OnlyHaveFpd Sleep 1s then set fpd standby(4)");
  2514. Sleep(1000);
  2515. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2516. }
  2517. FullImageDateArrived(m_pwImageData);
  2518. FINFO("OnProcessImage Write Frame Over");
  2519. return true;
  2520. }
  2521. RET_STATUS nsFPD::CFPDDeviceAXS::AcceptCalibration()
  2522. {
  2523. FINFO("==========Fun AcceptCalibration ==========");
  2524. printf("--func-- AcceptCalibration\n");
  2525. RET_STATUS ret = RET_STATUS::RET_SUCCEED;
  2526. if (((CAXSCtrl*)m_pDetectors)->AcceptCalibration())
  2527. {
  2528. FINFO("AcceptCalibration over");
  2529. ret = RET_STATUS::RET_SUCCEED;
  2530. }
  2531. else
  2532. {
  2533. FERROR("AcceptCalibration error");
  2534. ret = RET_STATUS::RET_FAILED;
  2535. }
  2536. if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK)
  2537. {
  2538. int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
  2539. //完成校正条件:轮数够了,曝光次数够了
  2540. if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
  2541. {
  2542. FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
  2543. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2544. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  2545. m_CalibUnit->SetCalibrationProgress("100");
  2546. return ret;
  2547. }
  2548. if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
  2549. {
  2550. m_nCalibCurrentCalibrationRound++;
  2551. m_nCalibCurrentExposureIndex = 1;
  2552. ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
  2553. int nDose = temp["Dose"];
  2554. m_fDoseParam = nDose / 1000.0f;
  2555. }
  2556. else
  2557. {
  2558. m_nCalibCurrentExposureIndex++;
  2559. }
  2560. }
  2561. else
  2562. {
  2563. if (m_nCalibCurrentExposureIndex == m_nCalibTotalExposureNum)
  2564. {
  2565. FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
  2566. m_nCalibCurrentExposureIndex = 1;
  2567. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2568. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  2569. m_CalibUnit->SetCalibrationProgress("100");
  2570. return ret;
  2571. }
  2572. else
  2573. {
  2574. m_fDoseParam = 2500 / 1000.0f;
  2575. m_nCalibCurrentExposureIndex++;
  2576. }
  2577. }
  2578. //在GetCalibrationStep中会把校正曝光的总次数和当前已接受的曝光次数传给app,app收到后会根据m_nCalibCurrentExposureNum和m_nCalibTotalExposureNum
  2579. //进行比较,如果相同则认为亮场校正完成,app会主动调用CompleteCalibration
  2580. m_nCalibCurrentExposureNum++;
  2581. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2582. FINFO("==============================AcceptCalibration over");
  2583. return ret;
  2584. }
  2585. RET_STATUS nsFPD::CFPDDeviceAXS::RejectCalibration()
  2586. {
  2587. printf("--Func-- RejectCalibration \n");
  2588. FINFO("==========Fun RejectCalibration ==========");
  2589. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2590. if (((CAXSCtrl*)m_pDetectors)->RejectCalibration())
  2591. {
  2592. Ret = RET_STATUS::RET_SUCCEED;
  2593. }
  2594. else
  2595. {
  2596. FERROR("RejectCalibration error");
  2597. Ret = RET_STATUS::RET_FAILED;
  2598. }
  2599. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2600. FINFO("==============================RejectCalibration over");
  2601. return Ret;
  2602. }
  2603. RET_STATUS nsFPD::CFPDDeviceAXS::SaveCalibrationFile(bool bSaveFlag)
  2604. {
  2605. printf("--Func-- SaveCalibrationFile \n");
  2606. FINFO("==========Fun SaveCalibrationFile ==========");
  2607. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2608. FINFO("SaveCalibrationFile by user: {$}", bSaveFlag);
  2609. if (!bSaveFlag)
  2610. {
  2611. FERROR("Not save calibration file");
  2612. return Ret;
  2613. }
  2614. if(m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK)
  2615. {
  2616. if (((CAXSCtrl*)m_pDetectors)->SaveCalibrationFile())
  2617. {
  2618. FINFO("SaveCalibrationFile over");
  2619. m_CalibUnit->SetSaveCalibrationFileFinish(true);
  2620. Ret = RET_STATUS::RET_SUCCEED;
  2621. }
  2622. else
  2623. {
  2624. FERROR("SaveCalibrationFile error");
  2625. m_CalibUnit->SetSaveCalibrationFileFinish(false);
  2626. Ret = RET_STATUS::RET_FAILED;
  2627. }
  2628. }
  2629. FINFO("==============================SaveCalibrationFile over");
  2630. return Ret;
  2631. }
  2632. RET_STATUS nsFPD::CFPDDeviceAXS::SetRequestedDose(std::string strDose)
  2633. {
  2634. FINFO("==========Fun SetRequestedDose ==========");
  2635. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2636. return Ret;
  2637. }
  2638. RET_STATUS nsFPD::CFPDDeviceAXS::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
  2639. {
  2640. printf("--func-- GetCalibrationStep\n");
  2641. FINFO("==========Fun GetCalibrationStep ==========");
  2642. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2643. FINFO("Calibration DetectorID: {$}", nDetectorID);
  2644. ResDataObject out;
  2645. if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK)
  2646. {
  2647. int nCalibrationRounds = (int)m_CalibDoseList.size();
  2648. int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];//当前轮需要曝光的次数(有效)
  2649. ((CAXSCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound);
  2650. //告诉app曝光情况,根据m_nCalibTotalExposureNum和m_nCalibCurrentExposureNum判断是否亮场校正完成
  2651. out.add("CalibrationRounds", (int)m_CalibDoseList.size());
  2652. out.add("TotalExposureNum", m_nCalibTotalExposureNum);
  2653. out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
  2654. out.add("ExposureNumCurrentRound", nExposureNumCurrentRound);
  2655. out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
  2656. out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
  2657. }
  2658. else
  2659. {
  2660. if (m_bFirstGetCalibImageLeft)
  2661. {
  2662. //获取需要曝光的次数
  2663. int nLeftCount = ((CAXSCtrl*)m_pDetectors)->GetCalImagesLeftCount();
  2664. FINFO("First Get Calib Images Left,count:{$}",nLeftCount);
  2665. m_nCalibTotalExposureNum = nLeftCount;
  2666. m_bFirstGetCalibImageLeft = false;
  2667. }
  2668. ((CAXSCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, 1, m_nCalibCurrentExposureIndex, m_nCalibTotalExposureNum);
  2669. out.add("CalibrationRounds", 1);
  2670. out.add("TotalExposureNum", m_nCalibTotalExposureNum);
  2671. out.add("CurrentCalibrationRound", 1);
  2672. out.add("ExposureNumCurrentRound", m_nCalibTotalExposureNum);
  2673. out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
  2674. out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
  2675. }
  2676. strCalibrationStepInfo = out.encode();
  2677. FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
  2678. return Ret;
  2679. }
  2680. //LMAM3-IZ85c不支持暂停校正
  2681. RET_STATUS nsFPD::CFPDDeviceAXS::PauseCalibration()
  2682. {
  2683. printf("--Func-- PauseCalibration\n");
  2684. FINFO("==========Fun PauseCalibration ==========");
  2685. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2686. FINFO("==============================PauseCalibration over");
  2687. return Ret;
  2688. }
  2689. bool nsFPD::CFPDDeviceAXS::CompleteCalibration()
  2690. {
  2691. printf("--func-- CompleteCalibration \n");
  2692. FINFO("==========Fun CompleteCalibration ==========");
  2693. m_eAppStatus = APP_STATUS_CAL_END;
  2694. ((CAXSCtrl*)m_pDetectors)->CompleteCalibration(this);
  2695. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2696. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  2697. if (m_bOnlyHaveFpd)
  2698. {
  2699. //通知子系统结束暗场校正太快了,导致后边的服务通知app的消息混乱了,故此处延时1s
  2700. printf("Sleep 1s,then send progress 100\n");
  2701. FINFO("Sleep 1s,then send progress 100");
  2702. Sleep(1000);
  2703. }
  2704. m_CalibUnit->SetCalibrationProgress("100");
  2705. FINFO("==============================CompleteCalibration over");
  2706. return true;
  2707. }
  2708. void nsFPD::CFPDDeviceAXS::AbortCalibration()
  2709. {
  2710. printf("--func-- AbortCalibration\n");
  2711. FINFO("==========Fun AbortCalibration ==========");
  2712. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  2713. if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
  2714. {
  2715. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2716. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  2717. m_CalibUnit->SetCalibrationProgress("100");
  2718. FINFO("==============================AbortCalibration over");
  2719. return;
  2720. }
  2721. m_eAppStatus = APP_STATUS_CAL_END;
  2722. ((CAXSCtrl*)m_pDetectors)->AbortCalibration();
  2723. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  2724. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
  2725. m_CalibUnit->SetCalibrationProgress("100");
  2726. m_AcqUnit->SendNoNeedWaitImage(true);//什么用意不太清楚
  2727. FINFO("==============================AbortCalibration over");
  2728. }
  2729. void nsFPD::CFPDDeviceAXS::OnProcessTemperature(int nID, float fTemperature)
  2730. {
  2731. string strWarnErrorCode = "";
  2732. float fMaxTempGap = 6.0f;
  2733. if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0)
  2734. {
  2735. fMaxTempGap = 12.0f;
  2736. }
  2737. if (fTemperature >= m_stDeviceConfig.fTemperMaxLimit)
  2738. {
  2739. FINFO("Exceed Max Temperature");
  2740. m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH;
  2741. if (m_stDeviceConfig.bActived)
  2742. {
  2743. strWarnErrorCode = "ERR_FPD_TEMPHIGH_NOT_ACQ";
  2744. //OnError(nID, strWarnErrorCode);
  2745. }
  2746. }
  2747. else if (fTemperature <= m_stDeviceConfig.fTemperMinLimit)
  2748. {
  2749. m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW;
  2750. if (m_stDeviceConfig.bActived)
  2751. {
  2752. FINFO("Exceed Min Temperature");
  2753. strWarnErrorCode = "ERR_FPD_TEMPLOW_NOT_ACQ";
  2754. //OnError(nID, strWarnErrorCode);
  2755. }
  2756. }
  2757. else if (fTemperature <= m_stDeviceConfig.fTemperLowLimit)
  2758. {
  2759. m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
  2760. FINFO("Exceed Temperature Low Warning");
  2761. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
  2762. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
  2763. strWarnErrorCode = "WAR_FPD_TEMPERTURE_LOW";
  2764. //OnWarn(nID, strWarnErrorCode);
  2765. }
  2766. else if (fTemperature > m_stDeviceConfig.fTemperWarning)
  2767. {
  2768. FINFO("Exceed Temperature High Warning");
  2769. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
  2770. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
  2771. m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
  2772. strWarnErrorCode = "WAR_FPD_TEMPERATURE_HIGH";
  2773. //OnWarn(nID, strWarnErrorCode);
  2774. }
  2775. else if ((m_stDeviceConfig.fCalibTemperature > 1.0f) && (abs(fTemperature - m_stDeviceConfig.fCalibTemperature) >= fMaxTempGap))
  2776. {
  2777. FINFO("Exceed Calibration Temperature");
  2778. m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
  2779. strWarnErrorCode = "WAR_FPD_EXCEED_CALB_TEMPER";
  2780. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
  2781. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
  2782. //OnWarn(nID, strWarnErrorCode);
  2783. }
  2784. else if ((fTemperature <= m_stDeviceConfig.fTemperWarning) && (fTemperature > m_stDeviceConfig.fTemperLowLimit))
  2785. {
  2786. FINFO("Temperature Normal");
  2787. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
  2788. //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
  2789. //m_stDeviceConfig.nTemperatureStatus = TEMP_NORMAL;
  2790. }
  2791. }
  2792. //慎重调用,可能会导致板出问题,硬reset需要很长时间
  2793. RET_STATUS nsFPD::CFPDDeviceAXS::Reset()
  2794. {
  2795. printf("--Func-- Reset\n");
  2796. FINFO("==========Fun Reset ==========");
  2797. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  2798. if (((CAXSCtrl*)m_pDetectors)->ResetDetector(this))
  2799. {
  2800. Ret = RET_STATUS::RET_SUCCEED;
  2801. }
  2802. else
  2803. {
  2804. Ret = RET_STATUS::RET_FAILED;
  2805. }
  2806. FINFO("==============================Reset over");
  2807. return Ret;
  2808. }
  2809. /***
  2810. * 客户端获取探测器信息
  2811. ***/
  2812. RET_STATUS nsFPD::CFPDDeviceAXS::GetDetectorInfo(string& strFDI)
  2813. {
  2814. ResDataObject strDetectorInfo;
  2815. string strTempTemp = " ";
  2816. FINFO("==========Fun GetDetectorInfo ==========");
  2817. if (m_stDeviceConfig.strPanelSerial == "")
  2818. {
  2819. FERROR("Get Detector Info Failed, Send Default Info");
  2820. strDetectorInfo.add("DetectorName", "Simulator");
  2821. strDetectorInfo.add("DetectorSN", "Simulator");
  2822. strDetectorInfo.add("Firmware", " ");
  2823. strDetectorInfo.add("APFirmware", " ");
  2824. strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
  2825. strDetectorInfo.add("SSID", " ");
  2826. strDetectorInfo.add("LifeTime", "0");
  2827. strDetectorInfo.add("PowerOn", "0");
  2828. strDetectorInfo.add("DateCode", " ");
  2829. strDetectorInfo.add("PartNumber", " ");
  2830. strDetectorInfo.add("WifiDataRate", " ");
  2831. strDetectorInfo.add("WifiChannel", "0");
  2832. strDetectorInfo.add("DetectorExist", "0");
  2833. strDetectorInfo.add("SystemAS", "0");
  2834. strDetectorInfo.add("CalibrationDate", "0");
  2835. strDetectorInfo.add("CalibrationDue", "0");
  2836. strDetectorInfo.add("CalibrationExist", "0");
  2837. strDetectorInfo.add("CommunicationStatus", "0");
  2838. strDetectorInfo.add("DetectorTemperature", "0");
  2839. strDetectorInfo.add("FDCalibrationTemperature", "0");
  2840. strDetectorInfo.add("TemperatureStatus", "0");
  2841. strDetectorInfo.add("WaitTime", "0");
  2842. strDetectorInfo.add("DetectorWifiSignal", "0");
  2843. strDetectorInfo.add("DetectorBattery", "0");
  2844. strDetectorInfo.add("ShockSensor", "NULL");
  2845. strDetectorInfo.add("FirmwareUpdate", "0");
  2846. //encode
  2847. strFDI = strDetectorInfo.encode();
  2848. return RET_STATUS::RET_SUCCEED;
  2849. }
  2850. strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
  2851. strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
  2852. strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str());
  2853. strDetectorInfo.add("APFirmware", "NULL");
  2854. strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
  2855. strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
  2856. strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime);
  2857. strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn);
  2858. //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str());
  2859. strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str());
  2860. strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str());
  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. if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0)
  2866. {
  2867. strDetectorInfo.add("SystemAS", 3);
  2868. }
  2869. else
  2870. {
  2871. strDetectorInfo.add("SystemAS", 2);
  2872. }
  2873. //DetectorCalibrationDate
  2874. if (m_stDeviceConfig.strCalibrationDate != " ")
  2875. {
  2876. if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos)
  2877. {
  2878. strDetectorInfo.add("CalibrationDate", "0");
  2879. strDetectorInfo.add("CalibrationDue", "0");
  2880. strDetectorInfo.add("CalibrationExist", 0);
  2881. }
  2882. else
  2883. {
  2884. strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/);
  2885. strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/);
  2886. strDetectorInfo.add("CalibrationExist", 1);
  2887. }
  2888. }
  2889. else
  2890. {
  2891. strDetectorInfo.add("CalibrationDate", "0");
  2892. strDetectorInfo.add("CalibrationDue", "0");
  2893. strDetectorInfo.add("CalibrationExist", 0);
  2894. }
  2895. if (m_stDeviceConfig.bConnectStatus)
  2896. {
  2897. strDetectorInfo.add("CommunicationStatus", 1);
  2898. }
  2899. else
  2900. {
  2901. strDetectorInfo.add("CommunicationStatus", 0);
  2902. }
  2903. strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature);
  2904. strDetectorInfo.add("ShockSensor", m_nShockCounts);
  2905. strDetectorInfo.add("FirmwareUpdate", 0);
  2906. strFDI = strDetectorInfo.encode();
  2907. return RET_STATUS::RET_SUCCEED;
  2908. }
  2909. RET_STATUS nsFPD::CFPDDeviceAXS::ResetConnect()
  2910. {
  2911. FINFO("==========Fun ResetConnect ==========");
  2912. ((CAXSCtrl*)m_pDetectors)->Disconnect();
  2913. ((CAXSCtrl*)m_pDetectors)->Connect(this,m_strWorkPath.c_str());
  2914. return RET_STATUS::RET_SUCCEED;
  2915. }
  2916. RET_STATUS nsFPD::CFPDDeviceAXS::SetExposureTimes(int nTimes)
  2917. {
  2918. FINFO("==========Fun SetExposureTimes ==========");
  2919. FINFO("SetExposureTimes nTimes:{$}", nTimes);
  2920. stringstream sValue;
  2921. sValue << nTimes;
  2922. EventCenter->OnNotify((int)ATTRACTION_SET, "ProjectionNum", sValue.str().c_str());
  2923. return RET_STATUS::RET_SUCCEED;
  2924. }