12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911 |
- // CCOS.Dev.FPD.iRay.cpp : 定义 DLL 的导出函数。
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <OleAuto.h>
- #include <sys/stat.h>
- #include "FileVersion.hpp"
- #include "common_api.h"
- #include "GridSuppression.h"
- #include "CalEXI.h"
- #include "TemperatureCheck.h"
- #include "DICOMImageHeadKey.h"
- #include "CCOS.Dev.FPD.iRay.h"
- #include "IRayCtrl.h"
- #pragma comment(lib, "Version.lib")
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- Log4CPP::Logger* gLogger = nullptr;
- static nsFPD::IRayDriver gIODriver;
- //-----------------------------------------------------------------------------
- // GetIODriver & CreateIODriver
- //-----------------------------------------------------------------------------
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsFPD::IRayDriver();
- }
- //-----------------------------------------------------------------------------
- // IRayDriver
- //-----------------------------------------------------------------------------
- nsFPD::IRayDriver::IRayDriver()
- {
- dev = NULL;
- m_bConnect = false;
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::IRayDriver::~IRayDriver()
- {
- }
- extern const char* g_szMouldPath;
- void nsFPD::IRayDriver::Prepare()
- {
- //string strWorkPath = GetProcessDirectory();
- //string strLogPath = strWorkPath + DetectorLogPath; //GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)";
- //Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.iRayDR");
- //auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- //gLogger = Log4CPP::LogManager::GetLogger("FPD.iRayDR");
- string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("Module");
- #ifdef _WIN64
- Force("------------------------ Version: {$} (64-bit) ------------------------", FileVersion(g_szMouldPath).GetVersionString());
- #else
- Force("------------------------ Version: {$} (32-bit)------------------------", FileVersion(g_szMouldPath).GetVersionString());
- #endif
- dev = new FPDDeviceIRay(EventCenter, m_ConfigFileName);
- Info("new FPDDeviceIRay over");
- }
- bool nsFPD::IRayDriver::Connect()
- {
- Info("IRayDriver Connect");
- m_bConnect = dev->m_stDeviceConfig.bConnectStatus;
- return m_bConnect;
- }
- void nsFPD::IRayDriver::Disconnect()
- {
- Info("IRayDriver Disconnect");
- m_bConnect = false;
- }
- bool nsFPD::IRayDriver::isConnected() const
- {
- return m_bConnect;
- }
- auto nsFPD::IRayDriver::CreateDevice(int index) -> std::unique_ptr <IODevice>
- {
- Info("CreateDevice({$})", index);
- auto Driver = std::unique_ptr <IODevice>(new IODevice(dev));
- dev->CreateDevice();
- dev->Register();
- return Driver;
- }
- std::string nsFPD::IRayDriver::DriverProbe()
- {
- Info("nsFPD::IRayDriver::Driver_Probe");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Generator");
- HardwareInfo.add("MinorID", "Dr");
- HardwareInfo.add("VendorID", "iRay");
- HardwareInfo.add("ProductID", "Mars");
- HardwareInfo.add("SerialID", "Driver");
- }
- string ret = HardwareInfo.encode();
- return ret;
- }
- bool nsFPD::IRayDriver::GetDeviceConfig(std::string& Cfg)
- {
- Cfg = m_DeviceConfig.encode();
- Info("GetDeviceConfig over");
- return true;
- }
- bool nsFPD::IRayDriver::SetDeviceConfig(std::string Cfg)
- {
- Info("--Func-- SetDeviceConfig {$} ", Cfg.c_str());
- ResDataObject DeviceConfig;
- DeviceConfig.decode(Cfg.c_str());
- ResDataObject DescriptionTempEx;
- DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"];
- Info("Attribute:{$}", DescriptionTempEx.encode());
- bool bSaveFile = false; //true:重新保存配置文件
- string strAccess = "";
- for (int i = 0; i < DescriptionTempEx.size(); i++)
- {
- string strKey = DescriptionTempEx.GetKey(i);
- Info("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("rw" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- Info("ConfigInfo Count: {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- Info("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- else
- {
- Warn("without this attribute {$}", strKey.c_str());
- }
- }
- catch (...)
- {
- Error("SetDriverConfig crashed");
- return false;
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- Info("SetDriverConfig over");
- return true;
- }
- bool nsFPD::IRayDriver::SaveConfigFile(bool bSendNotify)
- {
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- Info("SaveConfigFile over");
- return true;
- }
- bool nsFPD::IRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
- {
- strValue = "";
- string strTemp = pInnerKey;
- //Trace("Inner key: {$}", strTemp);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- strValue = (string)config["connections"][pInnerKey];
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- strValue = (string)config["ModeTable"]["RAD"][pInnerKey];
- }
- else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- TempUpperLimit == strTemp || TempLowerLimit == strTemp || "TempMinLimit" == strTemp ||
- BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- ShowTemperature == strTemp || ShowWifi == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || "Attached" == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- Warn("Error Configuration item: {$}", pInnerKey);
- }
- }
- return true;
- }
- /***
- ** 说明: 设置配置文件内容
- ***/
- bool nsFPD::IRayDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- Trace("Begin to change {$} item value to {$}", pInnerKey, szValue);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- config["connections"][pInnerKey] = szValue;
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- config["ModeTable"]["RAD"][pInnerKey] = szValue;
- }
- else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
- BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- ShowTemperature == strTemp || ShowWifi == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else
- {
- Warn("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- std::string nsFPD::IRayDriver::GetResource()
- {
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- return "";
- }
- m_ConfigAll = temp;
- r_config = temp["CONFIGURATION"];
- m_Configurations = r_config;
- ResDataObject DescriptionTemp;
- ResDataObject ListTemp;
- string strTemp = ""; //用于读取字符串配置信息
- string strIndex = ""; //用于读取配置信息中的List项
- int nTemp = -1; //用于读取整型配置信息
- char sstream[10] = { 0 }; //用于转换值
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- /***
- * 1. 通过循环,将所有配置项写到pDeviceConfig
- * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
- ***/
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- //Trace(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
- m_pAttribute->clear();
- m_pDescription->clear();
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- DescriptionTemp.clear();
- ListTemp.clear();
- //AttributeType
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
- DescriptionTemp.add(AttributeType, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "--> {$}: {$}", AttributeType, strTemp.c_str());
- strType = strTemp; //记录配置项的类型
- //AttributeKey
- //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
- GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
- //2. 赋值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if ("int" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMax, strTemp.c_str());
- }
- //AttributeList
- nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
- if (nTemp > 0) //ListNum不大于0时说明不需要list配置
- {
- for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
- sprintf_s(sstream, "%d", nListIndex);
- ListTemp.add(sstream, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (exception e)
- {
- Error("Get config error: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
- m_DeviceConfig = DescriptionTempEx;
- string res = DescriptionTempEx.encode();
- return res;
- }
- std::string nsFPD::IRayDriver::DeviceProbe()
- {
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", "iRay");
- HardwareInfo.add("ProductID", "Mars");
- HardwareInfo.add("SerialID", "1234");
- }
- string ret = HardwareInfo.encode();
- return ret;
- }
- extern IRayCtrl* g_pIRayCtrl;
- const float ABS_ZERO_TEMPERATURE = -273.15f; //绝对零度
- nsFPD::FPDDeviceIRay::FPDDeviceIRay(std::shared_ptr <IOEventCenter> center, string ConfigPath)
- :m_strSDKPath(""),
- m_nDeviceIndex(0),
- m_eAppStatus(APP_STATUS_WORK_END),
- m_nGridLicense(0),
- m_strModuleIP(""),
- m_strModuleSN(""),
- m_strShockSensor(""),
- m_strBatterySN(""),
- m_strMotionStatus(""),
- m_strSelfTest(""),
- m_strLastError(""),
- m_strCalibTime(""),
- m_bOpened(false),
- m_bBatteryCharging(false),
- m_bRecoveringImage(false),
- m_bAbortRecover(false),
- m_bImagePendingOrNot(false),
- m_bResetDetector(false),
- m_nBatteryCapacity(0),
- m_nBatteryCharges(0),
- m_nShockCounts(0),
- m_nWorkStation(0),
- m_nDoseParam(0),
- m_nRawImgWidth(0),
- m_nRawImgHeight(0),
- m_nFullImgWidth(0),
- m_nFullImgHeight(0),
- m_nTopOffset(0),
- m_nLeftOffset(0),
- m_nImageBits(0),
- m_fFactorEXI2UGY(0.0f),
- m_bPreviewEnable(false),
- m_bTestSensitivity(false),
- m_fBatteryTemperature(0.0f),
- m_nXrayCalibNum(0),
- m_pwFullImageData(nullptr),
- m_pwRawImageData(nullptr),
- m_pwPreviewImg(nullptr),
- m_pPreviewImageHead(nullptr),
- m_pFullImageHead(nullptr),
- m_pDetectors(nullptr),
- m_bDisConnected(false),
- m_ExitEvt(NULL),
- m_bAttached(false),
- m_hNotifyThread(NULL),
- m_bRecoverImageStatusInit(false),
- m_bSaveRaw(false),
- m_bUIConfirmRecover(false),
- m_nCalibrationType(CCOS_CALIBRATION_TYPE_MAX),
- m_CalTemperlowWarn(0.0f),
- m_CalTemperupWarn(0.0f),
- m_CalTemperWarnInitialed(false),
- m_bNotifyCalWarn(true)
- {
- super::EventCenter = center;
- g_strAppPath = GetProcessDirectory() + "\\";
-
- m_AcqUnit.reset(new OemAcq(center, this));
- m_SyncUnit.reset(new OemSync(center, this));
- m_CalibUnit.reset(new OemCalib(center, this));
- m_DetectorCtrlUnit.reset(new OemDetectorCtrl(center, this));
- m_Battery.reset(new DeviceBatteryMould("DetectorIRayBattery", 0, 10, 20, 30, 40, 100, 100, 0, center));
- m_Temperature.reset(new DeviceTemperatureMould("DetectorIRayTemperature", ABS_ZERO_TEMPERATURE, 0.0f, 10.0f, 60.0f, 20.0f, 40.0f, 70.0f, 0.0f, center));
- m_Wifi.reset(new DeviceWifiMould("DetectorIRayWifi", 0, 20, 30, 40, 50, 100, 100, 0, center));
- m_DetectorConfiguration.reset(new DetectorConfiguration(ConfigPath));
- m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, g_strAppPath + "OEMDrivers\\Detector\\iRay\\iRayDR"));
- m_CalibProcess.reset(new CalibrationProcess());
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_WaitCalibDoseEvt = CreateEvent(0, 1, 0, 0);
- m_OffsetCalibrationEvt = CreateEvent(0, 0, 0, 0);
- m_PauseCalibrationEvt = CreateEvent(0, 1, 0, 0);
- m_CompleteCalibrationEvt = CreateEvent(0, 1, 0, 0);
- m_CrateCalibReportEvt = CreateEvent(0, 0, 0, 0);
- m_UploadCalibMapOver = CreateEvent(0, 1, 0, 0);
- m_ExitEvt = CreateEvent(0, 1, 0, 0);
- m_CalibGapEvt = CreateEvent(0, 1, 0, 0);
- m_WriteCumstomFileEvt = CreateEvent(0, 1, 0, 0);
- }
- nsFPD::FPDDeviceIRay::~FPDDeviceIRay()
- {
- SetEvent(m_ExitEvt);
- CloseHandle(m_WaitCalibDoseEvt);
- CloseHandle(m_OffsetCalibrationEvt);
- CloseHandle(m_PauseCalibrationEvt);
- CloseHandle(m_CompleteCalibrationEvt);
- CloseHandle(m_CrateCalibReportEvt);
- CloseHandle(m_WriteCumstomFileEvt);
- CloseHandle(m_UploadCalibMapOver);
- CloseHandle(m_CalibGapEvt);
- if (m_hNotifyThread != NULL)
- {
- CloseHandle(m_hNotifyThread);
- }
- }
- std::string nsFPD::FPDDeviceIRay::GetGUID() const
- {
- return DetectorUnitType;
- }
- bool nsFPD::FPDDeviceIRay::Prepare()
- {
- //SetMaxBlockSize(const char *pQueName, DWORD FullBlockSize, DWORD FullBlockCount, DWORD PrevBlockSize, DWORD PrevBlockCount)
- EventCenter->OnMaxBlockSize("DrQue", m_nRawImgWidth * m_nRawImgHeight * 2, 3, 1500 * 1500 * 2, 1);
- Connect();
- return true;
- }
- void nsFPD::FPDDeviceIRay::RegisterCtrl(nDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("GetFPDinformation", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
- Dispatch->Action.Push("ActiveDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- Dispatch->Action.Push("RESET", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
- Dispatch->Action.Push("EnterExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
- Dispatch->Action.Push("ExitExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
- Dispatch->Action.Push("AttachConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect);
- Dispatch->Action.Push("CancelAttach", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach);
- Dispatch->Action.Push("RecoverImage", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
- Dispatch->Action.Push("ResetConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
- Dispatch->Action.Push("DisConnectFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
- Dispatch->Action.Push("DisConnectFPDForce", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPDForce);
- Dispatch->Action.Push("UpdateFirmware", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
- Dispatch->Action.Push("SaveSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
- Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
- Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
- Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);
- Dispatch->Get.Push("DetectorStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
- Dispatch->Get.Push("DetectorConnectStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
- Dispatch->Get.Push("DetectorAttach", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);
- Dispatch->Get.Push("Attached", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- Dispatch->Get.Push("DetectorInitialStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus);
- Dispatch->Get.Push("DetectorUpdateFWStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
- Dispatch->Get.Push("FPDShockSensorInfo", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
- Dispatch->Get.Push("FieldofViewShape", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
- Dispatch->Get.Push("FieldofViewDimension", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
- Dispatch->Get.Push("DetectorType", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
- Dispatch->Get.Push("Description", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
- Dispatch->Get.Push("DetectorID", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
- Dispatch->Get.Push("DateofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
- Dispatch->Get.Push("TimeofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
- Dispatch->Get.Push("DetectorConditionsNominalFlag", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
- Dispatch->Get.Push("FPDSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
- Dispatch->Get.Push("FPDSensitivityResult", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivityResult);
- Dispatch->Get.Push("PixelData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
- Dispatch->Get.Push("TargetEXI", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
- Dispatch->Get.Push("FPDLastError", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetLastError);
- Dispatch->Get.Push("FirmwareStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFirmwareStatus);
- Dispatch->Update.Push(AttrKey::NotifyStatusTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateNotifyStatusTimePeriod);
- Dispatch->Update.Push(AttrKey::ReconnectTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateReconnectTimePeriod);
- }
- void nsFPD::FPDDeviceIRay::RegisterAcq(nDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("SetAcqMode", m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
- Dispatch->Get.Push("ZskkFPDState", m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
- Dispatch->Get.Push("NoNeedWaitImage", m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
- Dispatch->Get.Push("ImgDataInfo", m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
- }
- void nsFPD::FPDDeviceIRay::RegisterSync(nDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("SetSyncMode", m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
- Dispatch->Action.Push("SetXwindowSize", m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
- Dispatch->Action.Push("PrepareAcquisition", m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
- Dispatch->Action.Push("StartAcquisition", m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
- Dispatch->Action.Push("StopAcquisition", m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
- Dispatch->Action.Push("ActiveSyncMode", m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode);
- Dispatch->Get.Push("FPDReadyStatus", m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
- Dispatch->Get.Push("XwindowStatus", m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
- Dispatch->Get.Push("ImageReadingStatus", m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
- Dispatch->Get.Push("SupportSyncMode", m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode);
- }
- void nsFPD::FPDDeviceIRay::RegisterCalib(nDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("UploadCalibrationFiles", m_CalibUnit.get(), &CalibUnit::JSUploadCalibrationFiles);
- Dispatch->Action.Push("SetSID", m_CalibUnit.get(), &CalibUnit::JSSetSID);
- Dispatch->Action.Push("ActiveCalibration", m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
- Dispatch->Action.Push("GetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
- Dispatch->Action.Push("SetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose);
- Dispatch->Action.Push("PrepareCalibration", m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
- Dispatch->Action.Push("StartCalibration", m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
- Dispatch->Action.Push("StopCalibration", m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
- Dispatch->Action.Push("SetCorrectionType", m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
- Dispatch->Action.Push("GetCalibrationStep", m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep);
- Dispatch->Action.Push("SaveCalibrationFile", m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile);
- Dispatch->Action.Push("AcceptCalibration", m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration);
- Dispatch->Action.Push("RejectCalibration", m_CalibUnit.get(), &CalibUnit::JSRejectCalibration);
- Dispatch->Get.Push("HaveImgCalibration", m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
- Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
- Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
- Dispatch->Get.Push("UploadCalibrationFilesResult", m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
- Dispatch->Get.Push("SaveCalibrationFileFinish", m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
- Dispatch->Get.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSGetCalibMode);
- Dispatch->Get.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSGetLastCalibrationDate);
- Dispatch->Get.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpireTime);
- Dispatch->Set.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::SetLastCalibrationDate);
- Dispatch->Set.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpireTime);
- Dispatch->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode);
- Dispatch->Update.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSUpdateLastCalibrationDate);
- Dispatch->Update.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpireTime);
- Dispatch->Update.Push(AttrKey::CalibrationFileExpirationReminder,
- [this](std::string in, std::string& out) {out = in; this->m_bNotifyCalWarn = (in == "1")? true : false; return RET_STATUS::RET_SUCCEED; });
- }
- void nsFPD::FPDDeviceIRay::RegisterOthers(nDetail::Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
- Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
- Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
- //Dispatch->Get.Push(m_WarnAndError->m_MSGUnit->GetKey().c_str(), [this](std::string& out) { out = m_WarnAndError->m_MSGUnit->JSGet(); return RET_STATUS::RET_SUCCEED; });
- Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
- Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
- Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
- Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
- Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
- Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
- Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
- Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
- Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
- Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
- Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
- Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
- Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
- Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
- Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
- Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
- Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
- Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
- Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
- Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
- Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
- Dispatch->Update.Push(TemperatureCalibUpWarn, [](std::string in, std::string& out) {out = in; return RET_STATUS::RET_SUCCEED; });
- Dispatch->Update.Push(TemperatureCalibLowWarn, [](std::string in, std::string& out) {out = in; return RET_STATUS::RET_SUCCEED; });
- Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
- Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
- Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
- Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
- }
- void nsFPD::FPDDeviceIRay::Register()
- {
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- bool nsFPD::FPDDeviceIRay::LoadConfig()
- {
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig))
- {
- Fatal("Load configuration file failed!!! ");
- return false;
- }
- try
- {
- m_nRawImgWidth = m_stDeviceConfig.nRawWidth;
- m_nRawImgHeight = m_stDeviceConfig.nRawHeight;
- m_nFullImgWidth = m_stDeviceConfig.nFullImageWidth;
- m_nFullImgHeight = m_stDeviceConfig.nFullImageHeight;
- m_nImageBits = m_stDeviceConfig.nImageBits;
- m_nTopOffset = m_stDeviceConfig.nImageTopOffset;
- m_nBottomOffset = m_stDeviceConfig.nImageBottomOffset;
- m_nLeftOffset = m_stDeviceConfig.nImageLeftOffset;
- m_nRightOffset = m_stDeviceConfig.nImageRightOffset;
- m_bPreviewEnable = m_stDeviceConfig.bPreviewEnable;
- Debug("PreviewEnable: {$} ", m_bPreviewEnable ? "true" : "false");
- m_bAttached = true;
- SetAttachStatus(1);
- m_bSaveRaw = m_stDeviceConfig.nSaveRaw ? true : false;
- Debug("Set SaveRaw: {$} ", m_bSaveRaw ? "true" : "false");
- m_bForceGridSuppress = m_stDeviceConfig.nForceGridSuppress ? true : false;
- Debug("Set ForceGridSuppress: {$}", m_bForceGridSuppress ? "true" : "false");
- //SDK目录
- m_strSDKPath = (string)m_DetectorConfiguration->m_Configurations["SDKPath"];
- Info("SDKPath: {$}", m_strSDKPath);
- //SDK探测器工作目录
- m_stDeviceConfig.strWorkDir = g_strAppPath + m_strSDKPath + "\\work_dir\\" + m_stDeviceConfig.strDetectorModel;
- Info("SDK work path: {$}", m_stDeviceConfig.strWorkDir);
- string strFPDinfo;
- strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewShape"];
- m_DetectorCtrlUnit->SetFieldofViewShape(strFPDinfo);
- strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewDimension"];
- m_DetectorCtrlUnit->SetFieldofViewDimension(strFPDinfo);
- m_DetectorCtrlUnit->SetDetectorType("SCINTILLATOR");
- strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"];
- m_DetectorCtrlUnit->SetDescription(strFPDinfo);
- m_DetectorCtrlUnit->SetDetectorConditionsNominalFlag("YES");
- auto szFDinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI);
- m_fFactorEXI2UGY = 100.0f / (float)atof(szFDinfo.c_str()) * 1.0f; //统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
- Info("FactorEXI2UGY: {$} ", m_fFactorEXI2UGY);
- auto strFPDcoef = std::to_string(m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetFPDSensitivity(strFPDcoef);
- string strPixelData = std::to_string(m_stDeviceConfig.nImageBits);
- m_DetectorCtrlUnit->SetPixelData(strPixelData);
- m_DetectorCtrlUnit->SetTargetEXI("5000");
- m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate);
- m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime);
- m_bNotifyCalWarn = ((int)m_DetectorConfiguration->m_Configurations["CalibrationFileExpirationReminder"] == 1) ? true : false;
- //------------------------------------可支持的同步模式
- ResDataObject jsonSupportSyncType;
- jsonSupportSyncType = m_DetectorConfiguration->m_Configurations["SupportSyncMode"];
- Debug("SupportSyncMode: {$}", jsonSupportSyncType.encode());
- m_SyncUnit->JSSetSupportSyncMode(jsonSupportSyncType.encode());
- //--------------------------------------------------------------------------------
- //加载校正配置
- m_stDeviceConfig.nCalibMode = (int)m_DetectorConfiguration->m_Configurations["CalibMode"];
- Debug("Calibration mode: {$}", m_stDeviceConfig.nCalibMode);
- m_CalibDoseList = m_DetectorConfiguration->m_Configurations["CalibConfig"]["NodeInfo"];
- Debug("CalibDoseList: {$} ", m_CalibDoseList.encode());
- }
- catch (exception e)
- {
- Error("Get has exception error: {$}", e.what());
- }
- return true;
- }
- void nsFPD::FPDDeviceIRay::InitializeTemperatureConfigs()
- {
- auto temperuperror = m_stDeviceConfig.fTemperMaxLimit;
- auto temperupwarn = m_stDeviceConfig.fTemperUpLimit;
- auto temperlowwarn = m_stDeviceConfig.fTemperLowLimit;
- auto temperlowerror = m_stDeviceConfig.fTemperMinLimit;
- //Caliberation Temperature ranger
- m_CalTemperupWarn = m_stDeviceConfig.fCalibTemperUp;
- m_CalTemperlowWarn = m_stDeviceConfig.fCalibTemperLow;
- if (m_Temperature)
- {
- m_Temperature->SetTemperatureErrorMax(to_string(temperuperror));
- m_Temperature->SetTemperatureWarningMax(to_string(temperupwarn));
- m_Temperature->SetTemperatureCalibWarningMax(to_string(m_CalTemperupWarn));
- m_Temperature->SetTemperatureCalibWarningMin(to_string(m_CalTemperlowWarn));
- m_Temperature->SetTemperatureWarningMin(to_string(temperlowwarn));
- m_Temperature->SetTemperatureErrorMin(to_string(temperlowerror));
- }
- Info("Temperature config initialize result {$}<{$}<{$}<{$}<{$}<{$}",
- temperlowerror, temperlowwarn, m_CalTemperlowWarn, m_CalTemperupWarn, temperupwarn, temperuperror);
- }
- bool nsFPD::FPDDeviceIRay::CreateDevice()
- {
- if (!LoadConfig())
- {
- Info("Load configuration file failed!!! ");
- return false;
- }
- InitializeTemperatureConfigs();
- bool bDemo = false;
- int nDemo = (int)m_DetectorConfiguration->m_Configurations["DemoEnable"];
- if (nDemo != 0)
- {
- bDemo = true;
- }
- bool bRet = false;
- if (bDemo)
- {
- Info("iRay Drive run in demo");
- }
- else
- {
- if (g_pIRayCtrl == NULL)
- {
- m_pDetectors = new IRayCtrl();
- g_pIRayCtrl = m_pDetectors;
- m_pDetectors->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig);
- bRet = m_pDetectors->Init(g_strAppPath);
- Info("Create SDK ctrl ok ");
- }
- else
- {
- m_pDetectors = g_pIRayCtrl;
- Info("SDK ctrl Already exit ");
- m_pDetectors->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig);
- }
- }
- return bRet;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::Connect()
- {
- Info("------------------------ FPD type {$}, Device {$} Start running. ------------------------ ", m_stDeviceConfig.strDeviceName.c_str(), this);
- string strPath = g_strAppPath + m_strSDKPath + "\\FpdSys.dll";
- m_stDeviceConfig.strSoftware = GetFileVersion(strPath);
- Info("iRay SDK version: {$}", m_stDeviceConfig.strSoftware.c_str());
- if (m_stDeviceConfig.bConnectStatus)
- {
- Info("Already Connected, return");
- return RET_STATUS::RET_SUCCEED;
- }
- if (m_bDisConnected)
- {
- Info("Already DisConnected, just return");
- return RET_STATUS::RET_FAILED;
- }
- if (m_bOpened) //已经初始化连接设备
- {
- Info("Already init, return");
- return RET_STATUS::RET_SUCCEED;
- }
- if (m_hNotifyThread == NULL)
- {
- m_hNotifyThread = CreateThread(0, 0, OnNotify, this, 0, &m_NotifyThreadID);
- if (m_hNotifyThread == NULL)
- {
- Info("Start Exposure Thread Failed!");
- }
- else
- {
- Info("Start Exposure Thread End");
- }
- }
- //g_strAppPath = "C:\\SVN\\Ccos\\CcosDriver_V2\\Deliver\\Bin\\ReleaseX64";
- bool bRet = m_pDetectors->Connect(g_strAppPath, this);
- if (!bRet)
- {
- Error("Device connect failed!");
- return RET_STATUS::RET_FAILED;
- }
- m_bOpened = true;
- Info("call connect detector over ");
- return RET_STATUS::RET_SUCCEED;
- }
- DWORD nsFPD::FPDDeviceIRay::OnNotify(LPVOID pParam)
- {
- Info("OnNotify Loop Entry-----------");
- FPDDeviceIRay* pNotifyOpr = (FPDDeviceIRay*)pParam;
- HANDLE* pHandles = new HANDLE[6];
- pHandles[0] = pNotifyOpr->m_PauseCalibrationEvt;
- pHandles[1] = pNotifyOpr->m_CompleteCalibrationEvt;
- pHandles[2] = pNotifyOpr->m_OffsetCalibrationEvt;
- pHandles[3] = pNotifyOpr->m_CrateCalibReportEvt;
- pHandles[4] = pNotifyOpr->m_WriteCumstomFileEvt;
- pHandles[5] = pNotifyOpr->m_ExitEvt;
- int nHandlesNum = 6;
- DWORD nTimeOut = 5000;
- while (1)
- {
- DWORD dwResult = WaitForMultipleObjects(nHandlesNum, pHandles, FALSE, nTimeOut);
- if (dwResult == WAIT_TIMEOUT)
- {
- if (!pNotifyOpr->m_stDeviceConfig.bConnectStatus)
- {
- Info("connect to FPD not finished");
- continue;
- }
- }
- if (dwResult == WAIT_OBJECT_0)//m_PauseCalibrationEvt
- {
- Info("OnNotify get PauseCalibration evt");
- pNotifyOpr->PauseCalibration();
- }
- if (dwResult == WAIT_OBJECT_0 + 1)//m_CompleteCalibrationEvt
- {
- ResetEvent(pNotifyOpr->m_CompleteCalibrationEvt);
- Info("OnNotify get CompleteCalibration evt");
- pNotifyOpr->CompleteCalibration();
- }
- else if (dwResult == WAIT_OBJECT_0 + 2)//m_OffsetCalibrationEvt
- {
- Info("OnNotify get m_OffsetCalibrationEvt evt");
- }
- else if (dwResult == WAIT_OBJECT_0 + 3)//m_CrateCalibReportEvt
- {
- Info("OnNotify get m_CrateCalibReportEvt evt");
- pNotifyOpr->SaveFailedCalibFile();
- break;
- }
- else if (dwResult == WAIT_OBJECT_0 + 4)//m_WriteCumstomFileEvt
- {
- Info("OnNotify get m_WriteCumstomFileEvt evt");
- pNotifyOpr->m_pDetectors->WriteCumstomFile(pNotifyOpr->m_nDeviceIndex);
- break;
- }
- else if (dwResult == WAIT_OBJECT_0 + 5)//m_ExitEvt
- {
- Info("Exit OnNotify Thread");
- break;
- }
- }
- delete[] pHandles;
- CloseHandle(pNotifyOpr->m_ExitEvt);
- return 0;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::ActiveDetector(bool bActive)
- {
- if (bActive)
- {
- Info("ActiveDetector");
- bool bRet = (m_pDetectors)->ActivePanel(this, bActive);
- if (!bRet)
- {
- return RET_STATUS::RET_FAILED;
- }
- //SendAllError();
- }
- else
- {
- Info("UnActiveDetector");
- bool bRet = (m_pDetectors)->ActivePanel(this, bActive);
- if (!bRet)
- {
- return RET_STATUS::RET_FAILED;
- }
- //ClearAllError();
- }
- return RET_STATUS::RET_SUCCEED;
- }
- void nsFPD::FPDDeviceIRay::UnactiveBySDK(void* pActviedDPC)
- {
- if (pActviedDPC != this)
- {
- //goto Unactive status, clear errorlist
- }
- }
- RET_STATUS nsFPD::FPDDeviceIRay::PrepareAcquisition()
- {
- Info("[PrepareAcquisition]");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (RET_STATUS::RET_SUCCEED == m_pDetectors->PrepareAcquisition(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_SyncUnit->FPDReadyNotify(true);
- Ret = RET_STATUS::RET_SUCCEED;
- }
- Info("PrepareAcquisition over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::StartAcquisition(string in)
- {
- Info("[StartAcquisition]");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- m_bAbortRecover = false;//能执行StartAcq,说明没有错误可以ready曝光。不再影响abort后再次recoverimage功能
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartAcquisition(this))
- {
- Ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- else
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- Error("StartAcquisition failed");
- }
- Info("StartAcquisition over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::StopAcquisition()
- {
- Info("[StopAcquisition]");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (RET_STATUS::RET_SUCCEED == m_pDetectors->StopAcquisition(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- Ret = RET_STATUS::RET_SUCCEED;
- }
- Info("StopAcquisition over ");
- return Ret;
- }
- string nsFPD::FPDDeviceIRay::GetFileVersion(string strFilePathName)
- {
- DWORD dwVerSize = GetFileVersionInfoSize(strFilePathName.c_str(), NULL);
- if (dwVerSize == 0)
- {
- return "";
- }
- LPVOID pVersionBuffer = malloc(dwVerSize);
- if (nullptr == pVersionBuffer)
- {
- return "";
- }
- GetFileVersionInfo(strFilePathName.c_str(), 0, dwVerSize, pVersionBuffer);
- VS_FIXEDFILEINFO* pInfo;
- UINT nInfoLen;
- char szValue[MAX_PATH] = { 0 };
- if (VerQueryValue(pVersionBuffer, ("\\"), (void**)&pInfo, &nInfoLen))
- {
- sprintf_s(szValue, ("%d.%d.%d.%d"),
- HIWORD(pInfo->dwFileVersionMS), LOWORD(pInfo->dwFileVersionMS),
- HIWORD(pInfo->dwFileVersionLS), LOWORD(pInfo->dwFileVersionLS));
- }
- string strVersion = szValue;
- return strVersion;
- }
- void nsFPD::FPDDeviceIRay::SendTemperatureValue(float fTemp)
- {
- int nStatus = 0;
- m_Temperature->SetTemperature(fTemp, nStatus);
- Info("SendTemperatureValue: {$}, status {$} ", fTemp, nStatus);
- return;
- }
- void nsFPD::FPDDeviceIRay::SendWifiValue(int nWifi)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nWifi, nStatus);
- Info("SendWifiValue: {$}, status {$} ", nWifi, nStatus);
- return;
- }
- void nsFPD::FPDDeviceIRay::SendBatteryValue(int nBattery)
- {
- int nStatus = 0;
- m_Battery->SetRemainPowerValue(nBattery, nStatus);
- Info("SendBatteryValue: {$}, status {$} ", nBattery, nStatus);
- return;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::XWindowOnNotify()
- {
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- m_stImgCreateTime = { 0 };
- GetLocalTime(&m_stImgCreateTime);
- Info("Full image create time-{$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
- Info("WindowOn ");
- m_SyncUnit->XWindowOnNotify();
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::XWindowOffNotify()
- {
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- m_SyncUnit->XWindowOffNotify();
- Info("WindowOff ");
- return Ret;
- }
- //--------------------------------------------------------------------------------------------------校正相关
- RET_STATUS nsFPD::FPDDeviceIRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- Info("==============================ActiveCalibration is {$}", (int)eType);
- m_nCalibrationType = eType;
- m_DetectorCtrlUnit->SetFPDSensitivity("100");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
- {
- Error("type error {$} ", (int)eType);
- return RET_STATUS::RET_INVALID;
- }
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- ResetEvent(m_WaitCalibDoseEvt);
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- m_pDetectors->SetReferenceNum(nCalibrationRounds);
- }
- m_pDetectors->CancelOperation();
- RET_STATUS Ret = m_pDetectors->ActiveCalibration(eType, this);
- if (RET_STATUS::RET_SUCCEED == Ret)
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
- m_CalibUnit->SetCalibrationProgress("0");
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- Info("start to waitting CalibDoseEvt");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- }
- m_nXrayCalibNum = 0;
- }
- //重置校正流程参数
- m_nCalibCurrentCalibrationRound = 1;
- m_nCalibCurrentExposureIndex = 1;
- m_nCalibCurrentExposureNum = 0;
- Info("==============================ActiveCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::GetRequestedDose(std::string& strDose)
- {
- Info("GetRequestedDose");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- bool bGetDoseInfo = false;
- ResDataObject out;
- if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
- {
- out.add("Dose", 0.0f);
- out.add("kV", 0.0f);
- out.add("mA", 0.0f);
- out.add("ms", 0.0f);
- out.add("mAs", 0.0f);
- bGetDoseInfo = true;
- }
- else if (CCOS_CALIBRATION_TYPE_XRAY == m_nCalibrationType)
- {
- for (int i = 0; i < m_CalibDoseList.size(); i++)
- {
- ResDataObject temp = m_CalibDoseList[i];
- int nDose = temp["Dose"];
- Info("Target dose: {$}, config dose: {$}", m_nDoseParam, nDose);
- if (m_nDoseParam == nDose)
- {
- out.add("Dose", nDose);
- out.add("kV", temp["kV"]);
- out.add("mA", temp["mA"]);
- out.add("ms", temp["ms"]);
- out.add("mAs", temp["mAs"]);
- bGetDoseInfo = true;
- break;
- }
- }
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- if (bGetDoseInfo)
- {
- strDose = out.encode();
- Info("GetRequestedDose {$} over", strDose.c_str());
- }
- else
- {
- Error("GetRequestedDose failed");
- }
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetRequestedDose(std::string strDose)
- {
- Info("==============================SetRequestedDose");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::PrepareCalibration()
- {
- Info("==============================PrepareCalibration");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- m_SyncUnit->FPDReadyNotify(false);
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (RET_STATUS::RET_SUCCEED == m_pDetectors->PrepareCalibration(this))
- {
- m_SyncUnit->FPDReadyNotify(true);
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- Info("==============================PrepareCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::StartCalibration()
- {
- Info("==============================StartCalibration");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- //暗场
- if (m_nCalibrationType == CCOS_CALIBRATION_TYPE_DARK)
- {
- Info("DarkCalibration start...");
- m_pDetectors->StartCalibration(this);
- return RET_STATUS::RET_SUCCEED;
- }
- //亮场
- if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartCalibration(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- Info("==============================StartCalibration over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::PauseCalibration()
- {
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- m_nXrayCalibNum++;
- if (m_nXrayCalibNum != 20)
- {
- Info("start to waitting CalibDoseEvt");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- }
- ResetEvent(m_PauseCalibrationEvt);
- ResetEvent(m_WaitCalibDoseEvt);
- m_AcqUnit->SendNoNeedWaitImage(true);
- if (m_nXrayCalibNum != 20)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->PauseCalibration();
- }
- Info("Driver PauseCalibration over,m_nXrayCalibNum {$}", m_nXrayCalibNum);
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::StopCalibration()
- {
- Info("StopCalibration");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- m_pDetectors->CancelOperation();
- if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- Info("StopDarkCalibration over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- m_eAppStatus = APP_STATUS_CAL_END;
- /*if (RET_STATUS::RET_SUCCEED == m_pDetectors->AbortCalibration(this))
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }*/
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
- m_CalibUnit->SetCalibrationProgress("100");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_AcqUnit->SendNoNeedWaitImage(true);
- Info("StopXRAYCalibration over");
- return RET_STATUS::RET_SUCCEED;
- }
- void nsFPD::FPDDeviceIRay::AbortCalibration()
- {
- Info("AbortCalibration ");
- if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- Info("AbortDarkCalibration over ");
- return;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- m_pDetectors->AbortCalibration(this);
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
- m_CalibUnit->SetCalibrationProgress("100");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_AcqUnit->SendNoNeedWaitImage(true);
- Info("AbortXrayCalibration over");
- return;
- }
- void nsFPD::FPDDeviceIRay::StopCalibrationInside()
- {
- Info("StopCalibrationInside");
- if (CCOS_CALIBRATION_TYPE_DARK == m_nCalibrationType)
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- Info("StopCalibrationInside dark over");
- return;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- m_pDetectors->AbortCalibration(this);
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_AcqUnit->SendNoNeedWaitImage(true);
- Info("StopCalibrationInside xray over");
- return;
- }
- bool nsFPD::FPDDeviceIRay::CompleteCalibration()
- {
- m_stDeviceConfig.fCalibTemperature2 = m_stDeviceConfig.fCurrentTemperValue;
- m_stDeviceConfig.fCalibTemperature = (m_stDeviceConfig.fCalibTemperature1 + m_stDeviceConfig.fCalibTemperature2) / 2;
- ResetEvent(m_UploadCalibMapOver);
- m_pDetectors->CompleteCalibration(this);
- DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000);
- if (WAIT_OBJECT_0 == nRet)
- {
- Info("got event m_UploadCalibMapOver");
- }
- else if (WAIT_TIMEOUT == nRet)
- {
- Info("wait event m_UploadCalibMapOver timeout");
- }
- else
- {
- Info("wait event m_UploadCalibMapOver error");
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- return true;
- }
- void nsFPD::FPDDeviceIRay::SaveFailedCalibFile()
- {
- m_pDetectors->SaveFailedCalibFiles(m_nDeviceIndex, false);
- }
- RET_STATUS nsFPD::FPDDeviceIRay::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
- {
- Info("## GetCalibrationStep ##");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- Info("Calibration DetectorID: {$}", nDetectorID);
- ResDataObject out;
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- if (m_pDetectors->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound))
- {
- Info("GetCalibrationStep over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Error("GetCalibrationStep error");
- Ret = RET_STATUS::RET_FAILED;
- }
- out.add("CalibrationRounds", (int)m_CalibDoseList.size());
- out.add("TotalExposureNum", m_nCalibTotalExposureNum);
- out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
- out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]);
- out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
- out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
- strCalibrationStepInfo = out.encode();
- Info("GetCalibrationStep over \n{$}", strCalibrationStepInfo.c_str());
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::AcceptCalibration()
- {
- Info("## AcceptCalibration ##");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (m_pDetectors->AcceptCalibration())
- {
- Info("AcceptCalibration over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Error("AcceptCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- //完成校正条件:轮数够了,曝光次数够了
- if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
- {
- Info("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- return Ret;
- }
- if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
- {
- m_nCalibCurrentCalibrationRound++;
- m_nCalibCurrentExposureIndex = 1;
- ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
- int nDose = temp["Dose"];
- m_nDoseParam = nDose;
- }
- else
- {
- m_nCalibCurrentExposureIndex++;
- }
- m_nCalibCurrentExposureNum++;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::RejectCalibration()
- {
- Info("## RejectCalibration ##");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (m_pDetectors->RejectCalibration())
- {
- Info("RejectCalibration over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Error("RejectCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SaveCalibrationFile(bool bSaveFlag)
- {
- Info("## SaveCalibrationFile ##");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- Info("SaveCalibrationFile by user: {$}", bSaveFlag);
- if (!bSaveFlag)
- {
- Warn("Not save calibration file");
- return Ret;
- }
- if (m_pDetectors->SaveCalibrationFile())
- {
- Info("SaveCalibrationFile over");
- m_CalibUnit->SetSaveCalibrationFileFinish(true);
- Ret = RET_STATUS::RET_SUCCEED;
- //更新配置文件中校正日期和时间
- time_t localtime = time(NULL);
- string strLocalTime = DatetimeToString(localtime);
- Info("strLocalTime:{$}", strLocalTime);
- m_CalibUnit->SetLastCalibrationDate(strLocalTime);
- //清除校正文件相关警告
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
- }
- else
- {
- Error("SaveCalibrationFile error");
- m_CalibUnit->SetSaveCalibrationFileFinish(false);
- Ret = RET_STATUS::RET_FAILED;
- }
- return Ret;
- }
- //--------------------------------------------------------------------------------------------------------------------
- RET_STATUS nsFPD::FPDDeviceIRay::ResetConnect()
- {
- Info("Reset Connect");
- m_pDetectors->ResetFPD(this);
- Info("FPDDeviceIRay::ResetConnect over ");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::DisConnectFPD()
- {
- Info("DisConnectFPD");
- if (!m_pDetectors->DisConnect(this))
- {
- Error("DisConnectFPD failed");
- return RET_STATUS::RET_FAILED;
- }
- SendWifiValue(0);
- SendBatteryValue(0);
- SendTemperatureValue(ABS_ZERO_TEMPERATURE);
- m_bDisConnected = true;
- ResetAllError();
- Info("DisConnectFPD over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::UpdateFirmware()
- {
- m_pDetectors->OnUpdateFirmware(this);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::AttachConnect()
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START));
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::CancelAttach()
- {
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetAttachStatus(int nStatus)
- {
- return m_DetectorCtrlUnit->SetAttachStatus(to_string(nStatus));
- }
- void nsFPD::FPDDeviceIRay::FullImageDateArrived(WORD* pImg)
- {
- AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight);
- }
- void nsFPD::FPDDeviceIRay::PrevImageDateArrived(WORD* pImg)
- {
- AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight);
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetXwindow(float XwindowSize)
- {
- Info("SetXwindowSize {$}", XwindowSize);
- Info("SetXwindowSize over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::EnterExam(int nExamStatus)
- {
- Info("EnterExam");
- switch (nExamStatus)
- {
- case APP_STATUS_WORK_BEGIN:
- Info("Enter into Exam Windows");
- OnErrorX(ERR_FPD_DOSE_LOW);
- OnErrorX(ERR_FPD_DOSE_HIGH);
- OnErrorX(ERR_FPD_DOSE_OBJ);//清除之前校正的错误,如果有的话
- CheckCalibartionDue();
- break;
- case APP_STATUS_WORK_END:
- Info("Quit Exam Windows");
- m_bTestSensitivity = false;
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- Info("Enter into Detector Share Windows");
- break;
- case APP_STATUS_DETSHAR_END:
- Info("Quit Detector Share Windows");
- break;
- case APP_STATUS_CAL_BEGIN:
- Info("Enter into Calibration Windows");
- break;
- case APP_STATUS_CAL_END:
- Info("Quit Calibration Windows");
- break;
- default:
- Warn("Undefined app status");
- break;
- }
- m_eAppStatus = (APP_STATUS)nExamStatus;
- m_pDetectors->EnterExam(m_eAppStatus);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetAcqMode(int mode)
- {
- if (!m_stDeviceConfig.bConnectStatus)
- {
- Error("Detector communication is error!");
- return RET_STATUS::RET_FAILED;
- }
- if (nullptr == m_pwFullImageData)
- {
- m_pwFullImageData = new WORD[m_nFullImgWidth * m_nFullImgHeight];
- }
- m_AcqUnit->SetFulImageInfo(m_nFullImgWidth, m_nFullImgHeight, m_nImageBits, false);
- m_AcqUnit->SetPrevImageInfo(m_stDeviceConfig.bPreviewEnable, m_stDeviceConfig.nPreviewHeight, m_stDeviceConfig.nPreviewWidth, false);
- if (!m_pDetectors->SelectExamMode(1, this))
- {
- Error("Set acqmode failed");
- return RET_STATUS::RET_FAILED;
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode)
- {
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- //return (m_pDetectors)->SetSyncMode(nSyncMode, TriggerMode);
- return RET_STATUS::RET_SUCCEED;
- }
- void nsFPD::FPDDeviceIRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- m_nDeviceIndex = nDetectorID;
- switch (nEventLevel)
- {
- case EVT_LEVEL_CONFIGURATION:
- {
- OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_INFORMATOION:
- {
- OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_STATUS:
- {
- OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_DATA:
- {
- OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_WARNING:
- {
- OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_ERROR:
- {
- OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- void nsFPD::FPDDeviceIRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_CONF_PANEL_SERIAL:
- {
- m_stDeviceConfig.strPanelSerial = pszMsg;
- Info("Receive Panel {$} SN {$}", nDetectorID, pszMsg);
- char cDetectorID[17] = { 0 };
- memcpy(cDetectorID, m_stDeviceConfig.strPanelSerial.c_str(), 16);
- string strDetectorID = cDetectorID;
- m_DetectorCtrlUnit->SetDetectorID(strDetectorID);
- Info("SedDetectorID {$}", strDetectorID.c_str());
- if (!m_bRecoverImageStatusInit)
- {
- m_RecoverImageStatus.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
- m_RecoverImageStatus.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
- m_RecoverImageStatus.add("DetectorWifiSignal", "1");
- m_RecoverImageStatus.add("Result", "-1");
- m_bRecoverImageStatusInit = true;
- }
- break;
- }
- case EVT_CONF_RAW_WIDTH:
- {
- if (m_stDeviceConfig.nFullImageWidth != nParam1)
- {
- m_stDeviceConfig.nFullImageWidth = nParam1;
- }
- Info("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth);
- break;
- }
- case EVT_CONF_RAW_HIGHT:
- {
- if (m_stDeviceConfig.nFullImageHeight != nParam1)
- {
- m_stDeviceConfig.nFullImageHeight = nParam1;
- }
- Info("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight);
- break;
- }
- case EVT_CONF_RAW_BITS:
- {
- if (m_stDeviceConfig.nImageBits != nParam1)
- {
- m_stDeviceConfig.nImageBits = nParam1;
- }
- m_stDeviceConfig.nImageBits = nParam1;
- Info("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits);
- break;
- }
- case EVT_CONF_PIXELSPACE:
- {
- m_stDeviceConfig.nPixelSpace = nParam1;
- Info("Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
- break;
- }
- case EVT_CONF_PREVIEW_WIDTH:
- {
- if (m_stDeviceConfig.nPreviewWidth != nParam1)
- {
- m_stDeviceConfig.nPreviewWidth = nParam1;
- }
- Info("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
- break;
- }
- case EVT_CONF_PREVIEW_HIGHT:
- {
- if (m_stDeviceConfig.nPreviewHeight != nParam1)
- {
- m_stDeviceConfig.nPreviewHeight = nParam1;
- }
- Info("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_CONF_MODULE_TYPE:
- {
- Info("Receive Panel {$} ModuleType {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_IP:
- {
- m_strModuleIP = pszMsg;
- Info("Receive Panel {$} ModuleIP {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_SN:
- {
- m_strModuleSN = pszMsg;
- Info("Receive Panel {$} ModuleSN {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_FIRWARE_UPDATE:
- {
- m_stDeviceConfig.nFirmwareStatus = nParam1;
- m_DetectorCtrlUnit->SetFirmwareStatus(to_string(nParam1));
- Info("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
- break;
- }
- case EVT_CONF_PART_NUMBER:
- {
- m_stDeviceConfig.strPartNumber = pszMsg;
- Info("Panel {$} PartNumber:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_BATTERY_SN:
- {
- m_strBatterySN = pszMsg;
- Info("Panel {$} Battery SN:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_WIFI_SSID:
- {
- m_stDeviceConfig.strWifiSSID = pszMsg;
- Info("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_IFBOARD:
- {
- Info("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_DATECODE:
- {
- m_stDeviceConfig.strDateCode = pszMsg;
- Info("Panel {$} DateCode:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_LIFETIME:
- {
- int nLifeTime = nParam1;
- if (nLifeTime != m_stDeviceConfig.nLifeTime)
- {
- Info("LifeTime:{$}", nLifeTime);
- m_stDeviceConfig.nLifeTime = nLifeTime;
- }
- break;
- }
- default:
- {
- break;
- }
- }
- }
- void nsFPD::FPDDeviceIRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- int nID = nDetectorID;
- switch (nEventID)
- {
- case EVT_INFO_POWER_ON:
- {
- int nPowerOn = nParam1;
- Info("Detector {$} PowerOn:{$}", nID, nPowerOn);
- m_stDeviceConfig.nPowerOn = nPowerOn;
- if ((nPowerOn != m_stDeviceConfig.nPowerOn) && (m_strBatterySN != ""))
- {
- }
- break;
- }
- case EVT_INFO_BATTERY_CAPACITY:
- {
- int nBatteryCapacity = nParam1;
- if ((nBatteryCapacity != m_nBatteryCapacity) && (m_strBatterySN != ""))
- {
- Info("{$},SN:{$}", nBatteryCapacity, m_strBatterySN);
- m_nBatteryCapacity = nBatteryCapacity;
- }
- break;
- }
- case EVT_INFO_BATTERY_TEMPERATURE:
- {
- float fBatteryTemper = fParam2;
- if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) && (m_strBatterySN != ""))
- {
- Info("SN:{$} ,temperature:{$}", m_strBatterySN, fBatteryTemper);
- m_fBatteryTemperature = fBatteryTemper;
- }
- break;
- }
- case EVT_INFO_BATTERY_CHARGES:
- {
- int nBatteryCharges = nParam1;
- if ((nBatteryCharges != m_nBatteryCharges) && (m_strBatterySN != ""))
- {
- Info("SN:{$},Charge number:{$}", m_strBatterySN, nBatteryCharges);
- m_nBatteryCharges = nBatteryCharges;
- }
- break;
- }
- case EVT_INFO_WIFI_DATARATE:
- {
- if (nParam1 != m_stDeviceConfig.nWifiDataRate)
- {
- }
- m_stDeviceConfig.nWifiDataRate = nParam1;
- Info("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate);
- break;
- }
- case EVT_INFO_WIFI_CHANNEL:
- {
- m_stDeviceConfig.nWifiChannel = nParam1;
- Info("Panel {$} WifiChannel:{$}", nID, m_stDeviceConfig.nWifiChannel);
- break;
- }
- case EVT_INFO_WIFI_SIGNALPOWER:
- {
- m_stDeviceConfig.nWifiSignalPower = nParam1;
- break;
- }
- case EVT_INFO_WIFI_NOISEPOWER:
- {
- m_stDeviceConfig.nWifiNoisePower = nParam1;
- Info("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower);
- break;
- }
- case EVT_INFO_FIRMWARE:
- {
- m_stDeviceConfig.strFirmware = pszMsg;
- Info("Panel {$} Firmware:{$}", nID, pszMsg);
- break;
- }
- case EVT_INFO_SHOCKSENSOR_INFO:
- {
- Info("Receive ShockSensor Info");
- m_strShockSensor = pszMsg;
- m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_DATE:
- {
- //m_stDeviceConfig.strCalibrationDate = pszMsg;
- Info("Panel {$} STE Calibration Date:{$}", nID, pszMsg);
- //m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
- //m_stDeviceConfig.strCalibrationDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationDate);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_DATEL:
- {
- //m_stDeviceConfig.strCalibrationLTEDate = pszMsg;
- Info("Panel {$} LTE Calibration Date:{$}", nID, pszMsg);
- //m_stDeviceConfig.strCalibrationLTEDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationLTEDate);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIME:
- {
- Info("Panel {$} STE Calibration Time:{$}", nID, pszMsg);
- m_stDeviceConfig.strCalibrationTime = pszMsg;
- m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(m_stDeviceConfig.strCalibrationTime);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIMEL:
- {
- m_stDeviceConfig.strCalibrationLTETime = pszMsg;
- Info("Panel {$} LTE Calibration Time:{$}", nID, pszMsg);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- void nsFPD::FPDDeviceIRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- int nID = nDetectorID;
- string strWarnErrorCode = "";
- switch (nEventID)
- {
- case EVT_STATUS_INIT:
- {
- if (PANEL_EVENT_END_OK == nParam1)
- {
- OnInitResult(true);
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
- Info("connect FPD ok. Start Status Polling");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- OnInitResult(false);
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_FAILED));
- }
- else if (PANEL_EVENT_END == nParam1) //未连接探测器
- {
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
- }
- else if (PANEL_EVENT_START == nParam1)
- {
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START));
- }
- break;
- }
- case EVT_STATUS_MOTION:
- {
- m_strMotionStatus = pszMsg;
- break;
- }
- case EVT_STATUS_UPDATE_FIRMWARE:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- Info("Start update firmware");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START));
- }
- else if (PANEL_EVENT_BEGIN == nParam1)
- {
- Info("Update firmware begin");
- m_stDeviceConfig.bConnectStatus = false;
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- Info("Update firmware failed");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR));
- }
- else if (PANEL_EVENT_SUCCESS == nParam1)
- {
- Info("update firmware success");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS));
- }
- else if (PANEL_EVENT_FWU_ERROR_BATTERY == nParam1)
- {
- Info("update firmware failed, battery < 50");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR_BATTERY));
- }
- else if (PANEL_EVENT_FWU_ERROR_OMIT == nParam1)
- {
- Info("update firmware failed, Omit");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR_OMIT));
- }
- break;
- }
- case EVT_STATUS_SELFTEST:
- {
- bool bLTE = false;
- if (nParam1 == 1)
- {
- bLTE = true;
- }
- break;
- }
- case EVT_STATUS_DETECTORSHARE:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_ATTACH_START:
- Info("SetConnectStatus(PANEL_ATTACH_START)");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START)); //重置status,避免服务判重,两次attach失败时,不将第二次的失败信息发送给客户端
- break;
- case PANEL_ATTACH_OVER:
- {
- Info("New Detector Attach Over,Prepare to Connecting");
- }
- break;
- case PANEL_ATTACH_FAILED: //UI显示Failed
- Info("New Detector Attach failed");
- Info("SetConnectStatus(PANEL_ATTACH_FAILED)");
- if (m_eAppStatus == APP_STATUS_DETSHARE_BEGIN)
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED));
- }
- break;
- case PANEL_CONNECT_OK:
- {
- Info("SetConnectStatus(PANEL_CONNECT_OK)");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_stDeviceConfig.bConnectStatus = true;
- SetAttachStatus(1);
- m_bAttached = true;
- break;
- }
- case PANEL_CONNECT_ERROR:
- {
- Info("SetConnectStatus(PANEL_CONNECT_ERROR)");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
- }
- break;
- case PANEL_DISCONNECT_SUCCESS:
- {
- m_nBatteryCapacity = 0;
- m_strBatterySN = "";
- m_stDeviceConfig.bExisted = false;
- m_stDeviceConfig.bConnectStatus = false;
- Info("SetConnectStatus(PANEL_DISCONNECT_SUCCESS)");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- break;
- }
- case PANEL_DISCONNECT_ERROR:
- Info("SetConnectStatus(PANEL_DISCONNECT_ERROR)");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SINGLEINIT:
- {
- break;
- }
- case EVT_STATUS_SELECTPANEL:
- {
- break;
- }
- case EVT_STATUS_PANEL:
- {
- ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
- if (PANEL_STANDBY == nParam1)
- {
- Info("Panel Status:PREPARE");
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- Info("Panel Status:READY");
- Action_ExpReady();
- }
- else if (PANEL_OFFSET_CAL == nParam1)
- {
- Info("Panel Status:PANEL_OFFSET_CAL");
- }
- else if (PANEL_OFFSET_FINISH == nParam1)
- {
- Info("Panel Status:PANEL_OFFSET_FINISH");
- StopCalibrationInside();
- }
- else if (PANEL_OFFSET_FAILED == nParam1)
- {
- Info("Panel Status:PANEL_OFFSET_FAILED");
- AbortCalibration();
- }
- else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
- {
- Info("Panel Status:XWINDOW_ON");
- XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1) //Xwindow Off
- {
- Info("Panel Status:XWINDOW_OFF");
- XWindowOffNotify();
- }
- else if (PANEL_GAIN_FINISH == nParam1)
- {
- Info("Panel Status:CALIBRATION_FINISH");
- }
- else if (PANEL_GAIN_PREPARE == nParam1)
- {
- Info("Detector Notify Xray Prepare");
- }
- else if (PANEL_GAIN_READY_EXP == nParam1)
- {
- Action_ExpReady();
- }
- else if (PANEL_AED_XRAY_ON == nParam1)
- {
- Info("AED or inner2 xray on");
- m_SyncUnit->XrayOnNotify();
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- else if (PANEL_AED_XRAY_OFF == nParam1)
- {
- Info("AED or inner2 xray off");
- m_SyncUnit->XrayOffNotify();
- }
- else
- {
- Info("Panel {$} Status is :{$}", nID, (int)m_ePanelStatus);
- }
- break;
- }
- case EVT_STATUS_CALIBRATIOIN:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- break;
- case PANEL_EVENT_END_OK:
- Info("Calibration process is success");
- SetEvent(m_CompleteCalibrationEvt);
- break;
- case PANEL_EVENT_END_ERROR:
- Info("Calibration process is failed");
- break;
- case PANEL_EVENT_TIMEOUT:
- Error("Calibration timeout");
- break;
- case PANEL_EVENT_CALIB_REPORT:
- Info("Create Calibration Report failed");
- SetEvent(m_CrateCalibReportEvt);
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SAVECALIB:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- Info("Begin to Save Calibration Files");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- SetEvent(m_UploadCalibMapOver);
- Info("Save Calibration Files failed");
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- SetEvent(m_UploadCalibMapOver);
- Info("Save Calibration Files Success");
- }
- break;
- }
- case EVT_STATUS_SAVEDEFECT:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- Info("Begin to Save Defect Files");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- SetEvent(m_UploadCalibMapOver);
- Info("Save Defect Files failed");
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- m_stDeviceConfig.bTaskEnd = true;
- Info("Save Defect Files Success");
- SetEvent(m_UploadCalibMapOver);
- }
- break;
- }
- case EVT_STATUS_ACQUISITION:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- break;
- }
- case PANEL_EVENT_END_OK:
- break;
- case PANEL_EVENT_END_ERROR: //由于断线造成指令执行失败
- {
- string strWarnErrorCode = ERR_FPD_ACQ_FAILED;
- OnError(strWarnErrorCode);
- break;
- }
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_PREPARE_EDNCALIBRATION:
- break;
- case EVT_STATUS_SINGLEEXP:
- {
- if (DOSE_TOO_HIGH == nParam1)
- {
- Info("Dose too high");
- m_strLastError = "Current dose level is too high and beyond the tolerance interval";
- OnError(ERR_FPD_DOSE_HIGH, m_strLastError);
- AbortCalibration();
- }
- else if (DOSE_TOO_LOW == nParam1)
- {
- Info("Dose too low");
- m_strLastError = "Current dose level is too low and beyond the tolerance interval";
- OnError(ERR_FPD_DOSE_LOW, m_strLastError);
- AbortCalibration();
- }
- else if (DOSE_OBJECT == nParam1)
- {
- Info("Dose object");
- m_strLastError = "Calibration has failed. Please check emergency stop button or calibration switch, otherwise call service.";
- OnError(ERR_FPD_DOSE_OBJ, m_strLastError);
- AbortCalibration();
- }
- else if (DOSE_ACCEPT == nParam1)
- {
- Info("Calibration Result is acceptable");
- m_strLastError = "";
- OnErrorX(ERR_FPD_DOSE_LOW);
- OnErrorX(ERR_FPD_DOSE_HIGH);
- OnErrorX(ERR_FPD_DOSE_OBJ);
- SetEvent(m_PauseCalibrationEvt);
- }
- else if (PANEL_EVENT_END_OK == nParam1)
- {
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- AbortCalibration();
- }
- //endif
- break;
- }
- case EVT_STATUS_IMAGEPENDING:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_bImagePendingOrNot = true;
- }
- else
- {
- m_bImagePendingOrNot = false;
- }
- if (m_bImagePendingOrNot) // && !m_bResetDetector
- {
- OnError(ERR_FPD_IMAGE_PENDING);
- }
- else
- {
- m_bResetDetector = false;//可以再次reset
- OnErrorX(ERR_FPD_IMAGE_PENDING);
- }
- break;
- }
- case EVT_STATUS_IMAGERECOVERAUTO:
- {
- OnErrorX(ERR_FPD_IMAGE_PENDING);
- m_RecoverImageStatus["Result"] = "0";
- Info("m_RecoverImageStatus[Result] = 0 by auto");
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- m_bAbortRecover = false; //终止恢复图像的变量也要重置
- m_bRecoveringImage = false; //不再恢复图像过程中
- m_nRecoverImageTimes = 0; //下次恢复图像,重置
- m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
- break;
- }
- case EVT_STATUS_TEMPERATURE:
- {
- float fTemperature = fParam2;
- OnProcessTemperature(nID, fTemperature);
- m_stDeviceConfig.fCurrentTemperValue = fTemperature;
- Info("Detector {$} Temperature Value:{$}", nID, fTemperature);
- SendTemperatureValue(fTemperature);
- break;
- }
- case EVT_STATUS_WIFI:
- {
- int nWifiLevel = nParam1;
- Info("Detector {$} Wifi Value:{$}", nID, nWifiLevel);
- strWarnErrorCode = ERR_FPD_WIFI_LOW;
- if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错
- {
- OnErrorX(strWarnErrorCode);
- }
- else if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
- {
- //wifi error
- OnWarnX(WAR_FPD_WIFI_LOW);
- OnError(strWarnErrorCode);
- }
- else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning)
- {
- //wifi error
- OnErrorX(strWarnErrorCode);
- strWarnErrorCode = WAR_FPD_WIFI_LOW;
- OnWarn(nID, strWarnErrorCode);
- }
- else
- {
- OnErrorX(strWarnErrorCode);
- strWarnErrorCode = WAR_FPD_WIFI_LOW;
- OnWarnX(strWarnErrorCode);
- }
- if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue)
- {
- Info("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}",
- m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate);
- }
- m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
- SendWifiValue(nWifiLevel);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- int nBatteryValue = nParam1;
- Info("Detector {$} Battery:{$}", nID, nParam1);
- if (nBatteryValue < m_stDeviceConfig.nBatteryLimit)
- {
- if (!m_bBatteryCharging) //如果没有充电;
- {
- strWarnErrorCode = ERR_FPD_BATTERY_LOW;
- OnError(strWarnErrorCode);
- strWarnErrorCode = WAR_FPD_BATTERY_LOW;
- OnWarnX(strWarnErrorCode);
- }
- }
- else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
- {
- //battery error
- strWarnErrorCode = ERR_FPD_BATTERY_LOW;
- OnErrorX(strWarnErrorCode);
- strWarnErrorCode = WAR_FPD_BATTERY_LOW;
- //这里需要滤波,如果2次以上都检测到低于告警值才上报该警告
- OnWarn(nID, strWarnErrorCode);
- }
- else
- {
- strWarnErrorCode = ERR_FPD_BATTERY_LOW;
- OnErrorX(strWarnErrorCode);
- strWarnErrorCode = WAR_FPD_BATTERY_LOW;
- OnWarnX(strWarnErrorCode);
- }
- m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
- Info("Detector {$} Battery Value:{$}", nID, nBatteryValue);
- if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
- {
- //防止探测器电池电量状态异常跳变
- SendBatteryValue(nBatteryValue);
- }
- else
- {
- SendBatteryValue(nBatteryValue);
- }
- break;
- }
- case EVT_STATUS_BATTERY_CHARGING:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_bBatteryCharging = true;
- }
- else
- {
- m_bBatteryCharging = false;
- }
- break;
- }
- case EVT_STATUS_SHOCK_SENSOR:
- {
- m_nShockCounts = nParam1;
- Info("Panel {$} Shock Sensor Number:{$}", nID, m_nShockCounts);
- m_stDeviceConfig.nShockTimes = m_nShockCounts;
- break;
- }
- case EVT_STATUS_HALL_SENSOR:
- {
- int nWorkstaion = nParam1;
- Info("Update Hall Status : {$} ", nWorkstaion);
- Info("Panel {$} WS:{$},Current OGP WS:{$} ", nID, nWorkstaion, m_nWorkStation);
- m_stDeviceConfig.nWorkstation = nWorkstaion;
- break;
- }
- case EVT_STATUS_PING:
- {
- break;
- }
- case EVT_STATUS_PMSNOTOPEN:
- {
- break;
- }
- case EVT_STATUS_RESTOREFILES:
- {
- break;
- }
- case EVT_STATUS_LASTERROR:
- {
- m_strLastError = pszMsg;
- Info("Panel {$} LastError {$}", nID, pszMsg);
- break;
- }
- case EVT_STATUS_RESET:
- {
- break;
- }
- default:
- {
- break;
- }
- }
- }
- //保存RAW图数据
- void nsFPD::FPDDeviceIRay::SaveRawImage(const char* pImgName, const WORD* pRawImg, int nWidth, int nHeight)
- {
- Info("Begin SaveRawImage: {$}, width: {$}, height: {$}", pImgName, nWidth, nHeight);
- if (pRawImg == NULL || pImgName == NULL)
- {
- Error("Undefined parameter");
- return;
- }
- string strImagePath = g_strAppPath + "Image\\" + pImgName;
- FILE* fp;
- if ((fp = fopen(strImagePath.c_str(), "wb")) == NULL)
- {
- DWORD dw = GetLastError();
- Error("fopen {$} failed, {$}", strImagePath.c_str(), dw);
- return;
- }
- fwrite(pRawImg, sizeof(WORD), nWidth * nHeight, fp);
- fclose(fp);
- Info("End SaveRawImage");
- return;
- }
- void nsFPD::FPDDeviceIRay::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_DATA_RAW_IMAGE:
- {
- Info("Image Arrved");
- if (APP_STATUS_IDLE == m_eAppStatus)
- {
- Error("Omit Image in Idle Status");
- return;
- }
- float fImageReferUGY = 2.5;
- memcpy(m_pwFullImageData, pParam, m_nFullImgWidth * m_nFullImgHeight * sizeof(WORD));
- OnProcessImage(m_pwFullImageData, m_nFullImgWidth, m_nFullImgHeight, fImageReferUGY);
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- Info("Preview Image Arrved");
- m_SyncUnit->ImageReadingNotify();
- if (NULL == m_pwPreviewImg)
- {
- m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight];
- }
- memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD));
- OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_DATA_DOSEPARAM:
- {
- m_nDoseParam = nParam1;
- Info("calibration dose->{$}", nParam1);
- SetEvent(m_WaitCalibDoseEvt);
- break;
- }
- default:
- {
- break;
- }
- }
- }
- void nsFPD::FPDDeviceIRay::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- string strErrorName = "";
- switch (nEventID)
- {
- case EVT_ERR_COMMUNICATE:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_stDeviceConfig.nWorkstation = -1;
- m_stDeviceConfig.bConnectStatus = false;
- m_stDeviceConfig.nCurrentWifiValue = 0;
- m_stDeviceConfig.nCurrentBatteryValue = 0;
- SendWifiValue(0);
- SendBatteryValue(0);
- //断开连接时温度保留当前值,清除温度相关告警信息
- ProcessTempreatureOnLostCommunicate();
- OnError(ERR_FPD_DISCONNECT, "");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
- }
- else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo
- {
- if (m_stDeviceConfig.nCurrentWifiValue != -1)
- {
- SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
- SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
- SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
- }
- m_stDeviceConfig.bConnectStatus = true;
- OnErrorX(ERR_FPD_DISCONNECT);
- OnErrorX(ERR_FPD_ACQ_FAILED);
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- }
- break;
- }
- case EVT_ERR_EXP_REQUEST:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- //SendCmd(nID, Sequence_C, L"FRM", String_C, _T("00040000")); //帧曝光失败
- }
- else
- {
- return;
- }
- strErrorName = ERR_FPD_ACQ_FAILED;
- break;
- }
- case EVT_ERR_GET_IMAGE:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- if (APP_STATUS_WORK_BEGIN != m_eAppStatus) //如果不在检查界面;
- {
- Fatal("there are image exist in current detector,do you want to continue");
- }
- else //if (m_bSiemensCmd)
- {
- Fatal("FPD has exposed Image!");
- CallSiemensRecoverAction(true);
- }
- //endif
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- if (m_bRecoveringImage)
- {
- CallSiemensRecoverAction(false);
- }
- else
- {
- m_bAbortRecover = false; //终止恢复图像的变量也要重置
- m_bRecoveringImage = false; //不再恢复图像过程中
- m_nRecoverImageTimes = 0; //下次恢复图像,重置
- m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
- }
- }
- break;
- }
- case EVT_ERR_MAX_NUMBER:
- {
- break;
- }
- case EVT_ERR_SN_NOTINLIST:
- {
- break;
- }
- case EVT_ERR_POWER_OFF:
- {
- strErrorName = ERR_FPD_DISCONNECT;
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- ProcessTempreatureOnLostCommunicate();
- OnError(strErrorName);
- m_stDeviceConfig.bConnectStatus = false;
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- OnErrorX(strErrorName);
- }
- break;
- }
- case EVT_ERR_INIT_FAILED:
- {
- break;
- }
- default:
- {
- break;
- }
- }
- }
- void nsFPD::FPDDeviceIRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- string strWarnName = "";
- }
- bool nsFPD::FPDDeviceIRay::OnInitResult(bool bSuccess)
- {
- if (bSuccess)
- {
- m_stDeviceConfig.bConnectStatus = true;
- m_stDeviceConfig.bInitOK = true;
- }
- else
- {
- m_stDeviceConfig.bConnectStatus = false;
- }
- m_stDeviceConfig.bExisted = true;
- auto temperuperror = m_stDeviceConfig.fTemperMaxLimit;
- auto temperlowerror = m_stDeviceConfig.fTemperMinLimit;
- auto temperupwarn = m_stDeviceConfig.fTemperUpLimit;
- auto temperlowwarn = m_stDeviceConfig.fTemperLowLimit;
- if (m_Temperature)
- {
- m_Temperature->SetTemperatureErrorMax(to_string(temperuperror));
- m_Temperature->SetTemperatureWarningMax(to_string(temperupwarn));
- m_Temperature->SetTemperatureCalibWarningMax(to_string(m_CalTemperupWarn));
- m_Temperature->SetTemperatureCalibWarningMin(to_string(m_CalTemperlowWarn));
- m_Temperature->SetTemperatureWarningMin(to_string(temperlowwarn));
- m_Temperature->SetTemperatureErrorMin(to_string(temperlowerror));
- }
- auto wifiWarning = m_stDeviceConfig.nWifiWarning;
- auto wifiError = m_stDeviceConfig.nWifiLimit;
- if (m_Wifi)
- {
- m_Wifi->SetSignalWarningMin(to_string(wifiWarning));
- m_Wifi->SetSignalErrorMin(to_string(wifiError));
- }
- return true;
- }
- //-----------------------------------------------------------------------------
- //
- // 函数名称 : CheckCalibartionDue
- // 函数描述 : 检查校正文件是否过期
- // 返回类型 : 过期true or false
- // 接口参数 :
- //
- //-----------------------------------------------------------------------------
- bool nsFPD::FPDDeviceIRay::CheckCalibartionDue()
- {
- Info("[Checking Calibration Date]");
- Info("LastCalibrationDate: {$}, DueDay: {$}", m_stDeviceConfig.strLastCalibrationDate, m_stDeviceConfig.strCalibrationFileExpireTime);
- if (!m_bNotifyCalWarn)
- {
- Info("skip notify calibration");
- return true;
- }
- //进检查时判断当前校正文件是否过期,如果即将过期或者已过期都向上通知
- if (m_stDeviceConfig.strLastCalibrationDate == "0000-00-00 00:00:00")
- {
- //没有做过校正
- Warn("No calibration file, please make a calibration!");
- m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_NOT_EXIST, "");
- }
- else
- {
- time_t lastCalibDate = StringToDatetime(m_stDeviceConfig.strLastCalibrationDate);
- int nExpireTime = std::stoi(m_stDeviceConfig.strCalibrationFileExpireTime);//单位:天
- Info("nExpireTime:{$}", nExpireTime);
- time_t localtime = time(NULL);
- //判断是否过期
- if (localtime > lastCalibDate + nExpireTime * 24 * 3600)
- {
- //过期了报错
- Warn("Calibration file is expired! please make a calibration!");
- m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_OUTDATE, "");
- }
- }
- return true;
- }
- bool nsFPD::FPDDeviceIRay::LoadSensitivity()
- {
- Info("Load Sensitivity.txt");
- string strTemp = m_stDeviceConfig.strPanelSerial + "_Sensitivity.txt";
- string strPath = g_strAppPath + "references\\" + strTemp;
- char* pszSensitivity = NULL;
- FILE* pFile;
- if ((pFile = fopen(strPath.c_str(), "rb")) == NULL)
- {
- Info("Read {$} File Error", strPath.c_str());
- return false;
- }
- Info("Open {$} over", strPath.c_str());
- fseek(pFile, 0, SEEK_END); ///将文件指针移动文件结尾
- long nLen = ftell(pFile); ///求出当前文件指针距离文件开始的字节数
- Info("Length is :{$}", nLen);
- pszSensitivity = new char[nLen + 1];
- memset(pszSensitivity, 0, nLen + 1);
- fseek(pFile, 0, SEEK_SET); ///将文件指针移动文件头
- size_t rLen = fread(pszSensitivity, (size_t)1, nLen, pFile);
- Info("read Length is :{$} {$}", rLen, pszSensitivity);
- if (rLen != nLen)
- {
- delete[] pszSensitivity;
- fclose(pFile);
- Info("Read Sensitivity info Error");
- return false;
- }
- fclose(pFile);
- m_fFactorEXI2UGY = (float)atof(pszSensitivity);
- auto strSensitivity = std::to_string(m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity);
- Info("Sensitivity is :{$}", m_fFactorEXI2UGY);
- if (pszSensitivity)
- {
- delete[] pszSensitivity;
- pszSensitivity = NULL;
- }
- Info("Read Sensitivity Over");
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SaveSensitivity()
- {
- Info("Save Sensitivity");
- ResetEvent(m_WriteCumstomFileEvt);
- int nRawImageWidth = m_stDeviceConfig.nFullImageWidth;
- int nRawImageHeight = m_stDeviceConfig.nFullImageHeight;
- float fTargetEXI = 250.0f;
- float fDoes = 2.5f;
- float fSysDoesOrAECDoes = 2.5f;
- float fROIMean = 0.0f;
- Info("Calculate EXI Coef");
- int nResult = GetCoef(m_pwRawImageData, nRawImageWidth, nRawImageHeight, fTargetEXI, fDoes, fSysDoesOrAECDoes, m_fFactorEXI2UGY, fROIMean);
- Info("EXI Coef :{$},ROI mean value:{$}", m_fFactorEXI2UGY, fROIMean);
- if (m_pFullImageHead != NULL)
- {
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_EXI2UGY] = m_fFactorEXI2UGY;
- }
- else
- {
- MakeImageHead(IMAGE_FULL);
- }
- auto strSensitivity = std::to_string(m_fFactorEXI2UGY);
- // char strSensitivity[10];
- // sprintf(strSensitivity, "%f", m_fFactorEXI2UGY);
- string strTemp = m_stDeviceConfig.strPanelSerial + "_Sensitivity.txt";
- string strPath = g_strAppPath + "references\\" + strTemp;
- FILE* pFile;
- if ((pFile = fopen(strPath.c_str(), "wb")) == NULL)
- {
- Info("Read {$} File Error", strPath.c_str());
- return RET_STATUS::RET_FAILED;
- }
- fwrite(strSensitivity.c_str(), 1, strSensitivity.size(), pFile);
- fclose(pFile);
- Info("Save Sensitivity Success");
- m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity);
- string strDesPath = g_strAppPath + "references\\CalibrationData\\" + strTemp;
- //上传到探测器端 ;
- m_pDetectors->CopyFile2Folder(strPath, strDesPath);
- string strLog;
- strDesPath = g_strAppPath + "references\\" + m_stDeviceConfig.strPanelSerial;
- if (!PathFileExists(strDesPath.c_str()))
- {
- bool bRtn = CreateDirectory(strDesPath.c_str(), NULL);
- if (bRtn)
- {
- strLog = "create " + strDesPath + " ok";
- Info("{$}", strLog.c_str());
- }
- else
- {
- strLog = "create " + strDesPath + " failed";
- Info("{$}", strLog.c_str());
- }
- }
- else
- {
- strLog = strPath + " already exist";
- Info("{$}", strLog.c_str());
- }
- strDesPath = g_strAppPath + "references\\" + m_stDeviceConfig.strPanelSerial + "\\" + strTemp;
- m_pDetectors->CopyFile2Folder(strPath, strDesPath);
- SetEvent(m_WriteCumstomFileEvt);
- return RET_STATUS::RET_SUCCEED;
- }
- //预览图
- bool nsFPD::FPDDeviceIRay::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
- {
- Info("Currenct PreviewImage Width: {$}, Height: {$}", nWidth, nHeight);
- if (m_stDeviceConfig.nSaveRaw > 1)
- {
- SaveRawImage("PreviewImage.raw", pwRawImage, nWidth, nHeight);
- }
- PrevImageDateArrived(pwRawImage);
- Info("Write PreviewImage Over");
- return true;
- }
- //大图
- bool nsFPD::FPDDeviceIRay::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY)
- {
- Info("Process Full Image");
- Info("Image EXI2UGY factor:{$},Image Refer UGY: {$}", m_fFactorEXI2UGY, fImageReferUGY);
- Info("Grid {$} Setting:{$}", m_bForceGridSuppress, m_stDeviceConfig.nGridSuppressed);
- if (m_bTestSensitivity)
- {
- try
- {
- float fROIMeanCal = 0.0f;
- int nResult = GetCenterROIEXI(pwRawImage, m_nFullImgWidth, m_nFullImgHeight, m_fFactorEXI2UGY, fROIMeanCal);
- if (nResult > 0)
- {
- auto strNote = std::to_string(m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetFPDSensitivity(strNote);
- m_DetectorCtrlUnit->SetFPDSensitivityResult("1");
- }
- else
- {
- m_DetectorCtrlUnit->SetFPDSensitivityResult("2");
- Info("Get ROI EXI error result {$}. Width {$}, Height {$}, FactorEXI2UGY {$}", nResult, m_nFullImgWidth, m_nFullImgHeight, m_fFactorEXI2UGY);
- FILE* fp;
- string strFileName = g_strAppPath + "DemoImage\\EXIfailed.raw";
- if ((fp = fopen(strFileName.c_str(), "wb")) == NULL)
- {
- DWORD dw = GetLastError();
- Error("fopen {$} failed, {$}", strFileName.c_str(), dw);
- }
- else
- {
- fwrite(pwRawImage, sizeof(WORD), m_nFullImgWidth * m_nFullImgHeight, fp);
- fclose(fp);
- }
- }
- }
- catch (...)
- {
- Info("Exception occur when cal ROIEXI");
- auto strNote = std::to_string(m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetFPDSensitivity(strNote);
- }
- }
- pwRawImage[0] = 65535;
- //图像预处理完成
- FullImageDateArrived(pwRawImage);
- Info("Write Frame Over");
- return true;
- }
- int nsFPD::FPDDeviceIRay::NewGridSuppressed(int nHeight, int nWidth, int nImageBits, unsigned short* puImageData)
- {
- return 0;
- }
- void nsFPD::FPDDeviceIRay::OnProcessTemperature(int nID, float fTemperature)
- {
- string strWarnErrorCode = "";
- auto lowerror = m_stDeviceConfig.fTemperMinLimit;
- auto uperror = m_stDeviceConfig.fTemperMaxLimit;
- auto lowwarn = m_stDeviceConfig.fTemperLowLimit;
- auto upwarn = m_stDeviceConfig.fTemperUpLimit;
- auto calupwarn = m_CalTemperupWarn;
- auto callowwarn = m_CalTemperlowWarn;
- //should be lowerror < lowwarn < callowwarn < calupwarn < upwarn < uperror
- m_stDeviceConfig.nTemperatureStatus = TEMP_NORMAL;
- if (fTemperature > callowwarn && fTemperature < calupwarn)
- {
- //normal,clear all warns&errors
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- }
- else if ((fTemperature <= callowwarn && fTemperature > lowwarn)
- || (fTemperature >= calupwarn && fTemperature < upwarn)
- )
- {//out of cal range
- Info("Exceed Calibration Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- //OnWarn(nID, strWarnErrorCode);
- }
- else if (fTemperature > lowerror && fTemperature <= lowwarn)
- {//low warn
- Info("Exceed Temperature Low Warning");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- /*strWarnErrorCode = WAR_FPD_TEMPERTURE_LOW;
- OnWarn(nID, strWarnErrorCode);*/
- }
- else if (fTemperature <= lowerror)
- {//low error
- Info("Exceed Min Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW;
- if (m_stDeviceConfig.bActived)
- {
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- /*strWarnErrorCode = ERR_FPD_TEMPERATURE_LOW;
- OnError(strWarnErrorCode);*/
- }
- }
- else if (fTemperature >= upwarn && fTemperature < uperror)
- {//up warn
- Info("Exceed Temperature High Warning");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- OnWarn(nID, WAR_FPD_TEMPERATURE_HIGH);
- }
- else if (fTemperature >= uperror)
- {//up error
- Info("Exceed Max Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH;
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- OnError(ERR_FPD_TEMPERATURE_HIGH);
- }
- }
- void nsFPD::FPDDeviceIRay::Action_ExpReady()
- {
- m_SyncUnit->FPDReadyNotify(true);
- }
- bool nsFPD::FPDDeviceIRay::GetCalibrationTime(bool ExpMode)
- {
- string strValue = "";
- m_strCalibTime = strValue;
- Info("CalibrationTime {$}", m_strCalibTime.c_str());
- return true;
- }
- bool nsFPD::FPDDeviceIRay::SaveConfigFile(bool bSendNotify)
- {
- m_DetectorConfiguration->SaveConfig();
- Info("SaveConfigFile over");
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetSID(int nSID)
- {
- if (nSID < 0 || nSID > 200)
- {
- return RET_STATUS::RET_INVALID;
- }
- m_stDeviceConfig.nSID = nSID;
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::UploadCalibrationFiles(string strFileName)
- {
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- Info("Update Calibration Defect map:{$}", strFileName.c_str());
- bool bLTEenable = false;
- if ((strFileName.find("defect_") == string::npos) || (strFileName.find(".dft") == string::npos))
- {
- Info("the defect map is invalid");
- m_CalibUnit->SetUploadCalibrationFilesResult("false");
- return RET_STATUS::RET_FAILED;
- }
- m_pDetectors->SetLTEMode(bLTEenable);
- m_stDeviceConfig.bTaskEnd = false;
- ResetEvent(m_UploadCalibMapOver);
- bool bRet = m_pDetectors->UploadCalibrationFiles(this, strFileName);
- if (!bRet)
- {
- Info("UploadCalibrationFiles failed");
- m_CalibUnit->SetUploadCalibrationFilesResult("false");
- return RET_STATUS::RET_FAILED;
- }
- DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000);
- if (WAIT_OBJECT_0 == nRet)
- {
- m_CalibUnit->SetUploadCalibrationFilesResult("true");
- Info("got event m_UploadCalibMapOver");
- }
- else if (WAIT_TIMEOUT == nRet)
- {
- m_CalibUnit->SetUploadCalibrationFilesResult("false");
- Info("wait event m_UploadCalibMapOver timeout");
- return RET_STATUS::RET_FAILED;
- }
- else
- {
- m_CalibUnit->SetUploadCalibrationFilesResult("false");
- Info("wait event m_UploadCalibMapOver error");
- return RET_STATUS::RET_FAILED;
- }
- if (!m_stDeviceConfig.bTaskEnd)
- {
- m_CalibUnit->SetUploadCalibrationFilesResult("false");
- Info("the FPD UploadCalibrationFiles failed");
- return RET_STATUS::RET_FAILED;
- }
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::GetRecoverImageState(string& RCI)
- {
- Info("GetRecoverImageState");
- m_bSendRecoverMessage = true;
- RCI = m_RecoverImageStatus.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::RecoverImage(bool bRecoverIt)
- {
- Info("Recover Image {$}", bRecoverIt);
- m_bUIConfirmRecover = true;
- int nRecoverOrNot = 0;
- if (bRecoverIt)
- {
- nRecoverOrNot = 1;
- }
- if (nRecoverOrNot != 0)
- {
- string strResult = (string)m_RecoverImageStatus["Result"];
- if (strResult == "0")
- {
- Info("already recover success,just return");
- return RET_STATUS::RET_SUCCEED;
- }
- m_RecoverImageStatus["Result"] = "1";
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- if (!(m_pDetectors)->RecoverLastImage())
- {
- m_RecoverImageStatus["Result"] = "2";
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- m_bUIConfirmRecover = false;
- }
- m_nRecoverImageTimes++;
- }
- else
- {
- Info("Abort Recovering Image");
- m_bAbortRecover = true; //终止恢复图像的变量也要重置
- m_bRecoveringImage = false; //不再恢复图像过程中
- m_nRecoverImageTimes = 0; //下次恢复图像,重置
- m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
- m_pDetectors->CancelImageRecover();
- if (m_stDeviceConfig.bConnectStatus)
- {
- if (m_bImagePendingOrNot)
- {
- OnError(ERR_FPD_IMAGE_PENDING);
- }
- else
- {
- OnErrorX(ERR_FPD_IMAGE_PENDING);
- }
- }
- else
- {
- OnError(ERR_FPD_IMAGE_PENDING);
- OnError(ERR_FPD_DISCONNECT);
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- bool nsFPD::FPDDeviceIRay::CallSiemensRecoverAction(bool bErrorResult)
- {
- string strRecoverInfo = "";
- if (bErrorResult)
- {
- if (m_bAbortRecover)
- {
- Info("Recover Image is Cancelled");
- return true;
- }
- SendWifiValue(0);
- SendBatteryValue(0);
- SendTemperatureValue(ABS_ZERO_TEMPERATURE);
- if (!m_bRecoveringImage)
- {
- m_RecoverImageStatus["Result"] = "-1";//新的imagerecover流程开始,防止之前成功recover过,上层查询状态引发误解
- m_DetectorCtrlUnit->SetRecoverImageEvent("0");
- OnError(ERR_FPD_IMAGE_PENDING);
- m_bRecoveringImage = true;
- m_bUIConfirmRecover = false;
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- Info("SetRecoverImageEvent");
- return true;
- }
- m_RecoverImageStatus["Result"] = "2";
- }
- else
- {
- m_bAbortRecover = false; //终止恢复图像的变量也要重置
- m_bRecoveringImage = false; //不再恢复图像过程中
- m_nRecoverImageTimes = 0; //下次恢复图像,重置
- m_bSendRecoverMessage = false; //下次恢复图像仍需判断;
- if (m_bUIConfirmRecover)
- {
- Info("Recover Image Success");
- m_RecoverImageStatus["Result"] = "0";
- Info("m_RecoverImageStatus[Result] = 0");
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- m_bUIConfirmRecover = false;
- Info("send RecoverImageState over");
- }
- else
- {
- m_RecoverImageStatus["Result"] = "3";
- Info("m_RecoverImageStatus[Result] = 3");
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- Warn("UI do not confirm, image have been abandoned");
- m_RecoverImageStatus["Result"] = "0";
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- return true;
- }
- Info("CallSiemensRecoverAction {$}", m_RecoverImageStatus.encode());
- if (m_bSendRecoverMessage)
- {
- if (m_bUIConfirmRecover)
- {
- m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode());
- m_bUIConfirmRecover = false;
- Info("send RecoverImageState over");
- }
- else
- {
- Warn("UI do not confirm omit send result");
- }
- }
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::GetDetectorInfo(string& strFDI)
- {
- ResDataObject strDetectorInfo;
- string strTempTemp = " ";
- Info("Get Detector Info");
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- Info("Get Detector Info Failed");
- strDetectorInfo.add("DetectorName", "Simulator");
- strDetectorInfo.add("DetectorSN", "Simulator");
- strDetectorInfo.add("Firmware", " ");
- strDetectorInfo.add("APFirmware", " ");
- strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- strDetectorInfo.add("SSID", " ");
- strDetectorInfo.add("LifeTime", "0");
- strDetectorInfo.add("PowerOn", "0");
- strDetectorInfo.add("DateCode", " ");
- strDetectorInfo.add("PartNumber", " ");
- strDetectorInfo.add("WifiDataRate", " ");
- strDetectorInfo.add("WifiChannel", "0");
- strDetectorInfo.add("DetectorExist", "0");
- strDetectorInfo.add("SystemAS", "0");
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", "0");
- strDetectorInfo.add("CommunicationStatus", "0");
- strDetectorInfo.add("DetectorTemperature", "0");
- strDetectorInfo.add("FDCalibrationTemperature", "0");
- strDetectorInfo.add("TemperatureStatus", "0");
- strDetectorInfo.add("WaitTime", "0");
- strDetectorInfo.add("DetectorWifiSignal", "0");
- strDetectorInfo.add("DetectorBattery", "0");
- strDetectorInfo.add("ShockSensor", "NULL");
- strDetectorInfo.add("FirmwareUpdate", "0");
- //encode
- strFDI = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
- strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
- strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str());
- strDetectorInfo.add("APFirmware", "NULL");
- strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
- strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime);
- strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn);
- if (m_strSelfTest != "")
- {
- ResDataObject strDetectorSelfTest;
- strDetectorSelfTest.decode(m_strSelfTest.c_str());
- strDetectorInfo += strDetectorSelfTest;
- }
- strDetectorInfo.add("FD_Voltage_List1", "NULL");
- strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str());
- strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str());
- strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate);
- strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel);
- strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted);
- //System Workstation
- strDetectorInfo.add("SystemAS", m_stDeviceConfig.nWorkstation);
- //DetectorCalibrationDate
- Info("DetectorCalibrationDate {$}", m_stDeviceConfig.strCalibrationDate.c_str());
- if (m_stDeviceConfig.strCalibrationDate != " ")
- {
- if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos)
- {
- Info("find 19700101");
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", 0);
- }
- else
- {
- strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/);
- strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/);
- strDetectorInfo.add("CalibrationExist", 1);
- }
- }
- else
- {
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", 0);
- }
- if (m_stDeviceConfig.bConnectStatus)
- {
- strDetectorInfo.add("CommunicationStatus", 1);
- }
- else
- {
- strDetectorInfo.add("CommunicationStatus", 0);
- }
- strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature);
- strDetectorInfo.add("ShockSensor", m_nShockCounts);
- if (FW_MANDATORY_UPDATE == m_stDeviceConfig.nFirmwareStatus && m_stDeviceConfig.bConnectStatus) //需要升级
- {
- strDetectorInfo.add("FirmwareUpdate", 1);
- }
- else
- {
- strDetectorInfo.add("FirmwareUpdate", 0);
- }
- Trace("{$}", strDetectorInfo.encode());
- strFDI = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- string nsFPD::FPDDeviceIRay::MakeImageHead(IMAGE_VIEW_TYPE Type)
- {
- if (Type == IMAGE_FULL)
- {
- if (m_pFullImageHead == NULL)
- {
- m_pFullImageHead = new ResDataObject;
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nFullImageWidth);
- json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nFullImageHeight);
- json.add(SM_IMAGE_BIT, 16);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
- json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
- json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
- json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
- json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
- json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
- json.add(SM_IMAGE_LSB, "5000");
- json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
- json.add(SM_IMAGE_PIXELREPRESENTATION, "0");
- json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
- json.add(SM_IMAGE_ROTATION, "No");
- json.add(SM_IMAGE_FLIP, "No");
- json.add(SM_IMAGE_ORIGINX, "0");
- json.add(SM_IMAGE_ORIGINY, "0");
- json.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
- json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
- m_pFullImageHead->add(SM_IMAGE_HEAD, json);
- }
- else
- {
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pFullImageHead).encode();
- }
- else
- {
- if (m_pPreviewImageHead == NULL)
- {
- m_pPreviewImageHead = new ResDataObject;
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth);
- json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight);
- json.add(SM_IMAGE_BIT, 16);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
- json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
- json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
- json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
- json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
- json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
- json.add(SM_IMAGE_LSB, "5000");
- json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI);
- json.add(SM_IMAGE_ROTATION, "No");
- json.add(SM_IMAGE_FLIP, "No");
- json.add(SM_IMAGE_ORIGINX, "0");
- json.add(SM_IMAGE_ORIGINY, "0");
- json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace);
- json.add(SM_IMAGE_PIXELREPRESENTATION, "0");
- json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
- m_pPreviewImageHead->add(SM_IMAGE_HEAD, json);
- }
- else
- {
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pPreviewImageHead).encode();
- }
- return "";
- }
- RET_STATUS nsFPD::FPDDeviceIRay::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
- {
- string strImageHead = MakeImageHead(Type);
- return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
- }
- void nsFPD::FPDDeviceIRay::ClearAllError()
- {
- m_WarnAndError->ClearAllError();
- }
- void nsFPD::FPDDeviceIRay::SyncErrorList()
- {
- m_WarnAndError->SendAllError();
- m_WarnAndError->SendAllWarn();
- }
- void nsFPD::FPDDeviceIRay::OnErrorX(string strErrCode)
- {
- m_WarnAndError->ClearError(strErrCode);
- }
- void nsFPD::FPDDeviceIRay::OnError(string strErrCode, string strErr)
- {
- m_WarnAndError->SendError(strErrCode, strErr);
- }
- void nsFPD::FPDDeviceIRay::OnWarn(int nIndex, string strWarnCode, string strWarn)
- {
- m_WarnAndError->SendWarn(strWarnCode, strWarn);
- }
- void nsFPD::FPDDeviceIRay::OnWarnX(string strWarnCode)
- {
- m_WarnAndError->ClearWarn(strWarnCode);
- }
- RET_STATUS nsFPD::FPDDeviceIRay::ResetError()
- {
- Info("ResetError");
- OnErrorX(ERR_FPD_DOSE_LOW);
- OnErrorX(ERR_FPD_DOSE_HIGH);
- OnErrorX(ERR_FPD_DOSE_OBJ); //清除之前的错误,如果有的话
- return RET_STATUS::RET_SUCCEED;
- }
- void nsFPD::FPDDeviceIRay::SendAllError()
- {
- m_WarnAndError->SendAllError();
- }
- void nsFPD::FPDDeviceIRay::ProcessTempreatureOnLostCommunicate()
- {
- SendTemperatureValue(ABS_ZERO_TEMPERATURE);
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- OnWarnX(WAR_FPD_WIFI_LOW);
- OnWarnX(WAR_FPD_BATTERY_LOW);
- OnErrorX(ERR_FPD_WIFI_LOW);
- OnErrorX(ERR_FPD_BATTERY_LOW);
- }
- void nsFPD::FPDDeviceIRay::ResetAllError()
- {
- OnWarnX(WAR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_HIGH);
- OnErrorX(ERR_FPD_TEMPERATURE_LOW);
- OnWarnX(WAR_FPD_WIFI_LOW);
- OnWarnX(WAR_FPD_BATTERY_LOW);
- OnErrorX(ERR_FPD_WIFI_LOW);
- OnErrorX(ERR_FPD_BATTERY_LOW);
- OnErrorX(ERR_FPD_DISCONNECT);
- OnErrorX(ERR_FPD_DISCONNECT);
- OnErrorX(ERR_FPD_ACQ_FAILED);
- OnErrorX(ERR_FPD_DOSE_LOW);
- OnErrorX(ERR_FPD_DOSE_HIGH);
- OnErrorX(ERR_FPD_DOSE_OBJ);
- OnErrorX(ERR_FPD_IMAGE_PENDING);
- }
- RET_STATUS nsFPD::FPDDeviceIRay::SetCorrectionType(CCOS_CORRECTION_TYPE in)
- {
- return RET_STATUS::RET_SUCCEED;
- }
- //设置同步模式
- RET_STATUS nsFPD::FPDDeviceIRay::ActiveSyncMode(int nSyncMode)
- {
- Info("=====ActiveSyncMode: {$}", nSyncMode);
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_FAILED;
- }
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (m_pDetectors->ActiveSyncMode(this, nSyncMode))
- {
- Ret = RET_STATUS::RET_SUCCEED;
- Info("ActiveSyncMode success");
- }
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceIRay::UpdateNotifyStatusTimePeriod(int nTime)
- {
- Info("=====UpdateNotifyStatusTimePeriod: {$}", nTime);
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_FAILED;
- }
- m_pDetectors->m_nStatusPeriod = nTime;
- return RET_STATUS::RET_SUCCEED;
- }
|