DIOS.Dev.FPD.PZMedicalDR.cpp 98 KB

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