12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.AxsDM.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "AxsCtrl.h"
- #include <sys/stat.h>
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- //-----------------------------------------------------------------------------
- // CFPDDeviceAXS
- //-----------------------------------------------------------------------------
- extern CAXSCtrl* g_pDetector;
- //-----------------------------------------------------------------------------
- // GetIODriver & CreateIODriver
- //-----------------------------------------------------------------------------
- static nsFPD::CAXSDriver gIODriver;
- Log4CPP::Logger* gLogger = nullptr;
- extern const char* g_szMouldPath;
- /// <summary>
- /// [DONE.CHECKED.]
- /// </summary>
- /// <returns></returns>
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- /// <summary>
- /// [DONE.TO BE TESTED.]
- /// </summary>
- /// <returns></returns>
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsFPD::CAXSDriver();
- }
- /// <summary>
- /// 驱动构造函数
- /// [DONE.CHECKED.]
- /// </summary>
- nsFPD::CAXSDriver::CAXSDriver()
- {
- m_pObjDev = nullptr;
- m_bConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- /// <summary>
- /// [DONE.TO BE TESTED.]
- /// </summary>
- nsFPD::CAXSDriver::~CAXSDriver()
- {
- if (m_pObjDev != nullptr)
- {
- delete m_pObjDev;
- m_pObjDev = nullptr;
- }
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- /// <summary>
- /// 驱动的准备,可以做一些特殊的操作
- /// new完Driver后最先执行的函数
- /// </summary>
- void nsFPD::CAXSDriver::Prepare()
- {
- printf("--Driver-- prepare \r\n");
- string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("Module");
- FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
- #ifdef _WIN64
- FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #else
- FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #endif
- FINFO("Driver Prepare get logger");
- }
- /// <summary>
- /// 获取配置文件的配置信息并返回给web端显示,配置文件可配置读写权限和是否显示(重要)
- /// </summary>
- /// <returns>string</returns>
- std::string nsFPD::CAXSDriver::GetResource()
- {
- printf("AXS driver: GetResource m_ConfigFileName:%s\r\n", m_ConfigFileName.c_str());
- FINFO("AXS driver: GetResource m_ConfigFileName:{$}", m_ConfigFileName.c_str());
- 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; //用于读取整型配置信息
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- string strAccess = ""; //用于存储权限的类型 R/W/RW
- string strRequired = ""; // TRUE/FALSE
- string strDefaultValue = "";
- string strRangeMin = "";
- string strRangeMax = "";
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- 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());
- 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()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(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];
- auto temKey = std::to_string(nListIndex);
- ListTemp.add(temKey.c_str(), strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("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();
- //FINFO("GetResource res:{$}", res.c_str());
- printf("AXS driver module: get resource over \r\n");
- FINFO("AXS driver module: get resource over \r\n");
- return res;
- }
- /// <summary>
- /// 驱动的连接,创建设备对象 new CFPDDeviceAXS
- /// </summary>
- /// <returns></returns>
- bool nsFPD::CAXSDriver::Connect()
- {
- printf("AXS driver module: Connect \r\n");
- FINFO("--Func-- driver connect\n");
- //从IODriver继承的EventCenter和m_ConfigFileName
- m_pObjDev = new CFPDDeviceAXS(EventCenter, m_ConfigFileName);
- m_bConnect = true; //connect执行完毕,置为true
- printf("AXS driver module: Connect over new CFPDDeviceAXS\r\n");
- FINFO("AXS driver module: Connect over new CFPDDeviceAXS");
- return true;
- }
- /// <summary>
- /// 驱动创建设备丢下,然后 给 上层返回 IODevice 对象指针
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- auto nsFPD::CAXSDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("AXS driver module: CreateDevice \r\n");
- FINFO("--Func-- driver createdevice \n");
- auto Device = std::unique_ptr<IODevice>(new IODevice(m_pObjDev));
- m_pObjDev->CreateDevice();
- m_pObjDev->Register();
- return Device;
- }
- /// <summary>
- /// 驱动断开连接,释放设备对象
- /// </summary>
- void nsFPD::CAXSDriver::Disconnect()
- {
- printf("AXS driver module: Disconnect \r\n");
- FINFO("--Func-- driver disconnect \n");
- if (m_pObjDev != nullptr)
- {
- delete m_pObjDev;
- m_pObjDev = nullptr;
- }
- m_bConnect = false; //disconnect置为false
- }
- bool nsFPD::CAXSDriver::isConnected() const
- {
- printf("AXS driver module: isConnected \r\n");
- return m_bConnect;
- }
- /// <summary>
- /// 驱动信息检索 TODO : 需要重新定义
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::CAXSDriver::DriverProbe()
- {
- printf("AXS driver module: Driver Probe \r\n");
- 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", "Detector");
- HardwareInfo.add("MinorID", "DM");
- HardwareInfo.add("VendorID", "AXS");
- HardwareInfo.add("ProductID", "AXS");
- HardwareInfo.add("SerialID", "Driver");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /// <summary>
- /// 设备信息检索 TODO : 需要重新定义,TBD.
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::CAXSDriver::DeviceProbe()
- {
- printf("AXS driver module: Device Probe \r\n");
- 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", "AXS");
- HardwareInfo.add("ProductID", "AXS");
- HardwareInfo.add("SerialID", "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /// <summary>
- /// 设备配置读取接口
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="Cfg"></param>
- /// <returns></returns>
- bool nsFPD::CAXSDriver::GetDeviceConfig(std::string& Cfg)
- {
- Cfg = m_DeviceConfig.encode();
- FINFO("GetDeviceConfig Cfg:{$}",Cfg.c_str());
- return true;
- }
- /// <summary>
- /// 提供给web配置中心的 配置写入接口
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="Cfg"></param>
- /// <returns></returns>
- bool nsFPD::CAXSDriver::SetDeviceConfig(std::string Cfg)
- {
- FINFO("SetDeviceConfig Cfg:{$}", Cfg.c_str());
- ResDataObject DeviceConfig;
- DeviceConfig.decode(Cfg.c_str());
- ResDataObject DescriptionTempEx;
- DescriptionTempEx = DeviceConfig["DeviceConfig"];
- bool bSaveFile = false; //true:重新保存配置文件
- string strAccess = "";
- for (int i = 0; i < DescriptionTempEx.size(); i++)
- {
- ResDataObject temp = DescriptionTempEx[i];
- FINFO("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- FINFO("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess || "rw" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- FINFO("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, temp[j]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //4. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- /// <summary>
- /// 保存配置到文件
- /// [DONE.TO BE TESTED.]
- /// </summary>
- /// <param name="bSendNotify"></param>
- /// <returns></returns>
- bool nsFPD::CAXSDriver::SaveConfigFile(bool bSendNotify)
- {
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- FINFO("SaveConfigFile m_ConfigAll:{$}", m_ConfigAll.encode());
- return true;
- }
- /// <summary>
- /// 读取当前配置项
- /// TBD. 审视参数列表
- /// </summary>
- /// <param name="config"></param>
- /// <param name="pInnerKey"></param>
- /// <param name="nPathID"></param>
- /// <param name="strValue"></param>
- /// <returns></returns>
- bool nsFPD::CAXSDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
- {
- strValue = "";
- string strTemp = pInnerKey;
-
- 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 || RawImgWidth == strTemp || RawImgHeight == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- strValue = (string)config["ModeTable"]["DetectorMode"][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 || "CalibMode" == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp || OnlyHaveFpd == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- FERROR("Error Configuration item: {$}", pInnerKey);
- }
- }
- printf("GetDeviceConfigValue pInnerKey:%s,strValue:%s\n", pInnerKey, strValue.c_str());
- //FINFO("GetDeviceConfigValue pInnerKey:{$},strValue:{$}", pInnerKey, strValue.c_str());
- return true;
- }
- /// <summary>
- /// 设置写入设备参数实现,这里过滤需要设置本探测器接受的参数
- /// 参数项和内容来源于 探测器配置文件 <ConfigToolInfo> <AttributeInfo>
- /// TBD. 具体内容
- /// comment by chenggw 2023.2.7
- /// </summary>
- /// <param name="config"></param>
- /// <param name="pInnerKey"></param>
- /// <param name="nPathID"></param>
- /// <param name="szValue"></param>
- /// <returns></returns>
- bool nsFPD::CAXSDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- printf("SetDeviceConfigValue pInnerKey:%s,szValue:%s", pInnerKey, szValue);
- FINFO("SetDeviceConfigValue pInnerKey:{$},szValue:{$}", 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 || RawImgWidth == strTemp || RawImgHeight == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- config["ModeTable"]["DetectorMode"][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 || "CalibMode" == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp || OnlyHaveFpd == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else
- {
- FERROR("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- //CAXSDriver的Connect函数new CFPDDeviceAXS()时传入EventCenter 和 strConfigPath
- nsFPD::CFPDDeviceAXS::CFPDDeviceAXS(std::shared_ptr<IOEventCenter> center, std::string strConfigPath)
- : m_nCalibTotalExposureNum(0),
- m_nCalibCurrentCalibrationRound(0),
- m_nCalibCurrentExposureIndex(0),
- m_nCalibCurrentExposureNum(0),
- m_bImagePendingOrNot(false),
- m_bResetDetector(false)
- {
- m_pDetectors = nullptr;
- m_strWorkPath = GetProcessDirectory();
- m_bPreviewEnable = false;
- m_nImgBits = 16;
- m_nPreViewImgWidth = 0;
- m_nPreViewImgHeight = 0;
- m_nImgWidth = 0;
- m_nImgHeight = 0;
- m_pPreviewImageHead = nullptr;
- m_pImageHead = nullptr;
- m_pwPreviewImg = nullptr;
- m_pwRawImageData = nullptr;
- m_pwImageData = nullptr;
- m_nAngle = 0;
- m_nPixelSpacing = 0;
- m_fDose = 0.0f;
- m_fDoseParam = 0.0f;
- m_eAppStatus = APP_STATUS_IDLE;
- m_bConnect = false;
- m_eSyncMode = SYNC_AED;
- m_eCalibMode = CCOS_CALIBRATION_MODE_ZSKK;
- m_fFactorEXI2UGY = 0.0f;
- m_bForceGridSuppress = false;
- m_bAttached = false;
- m_nBatteryCapacity = 0;
- m_nBatteryCharges = 0;
- m_fBatteryTemperature = 0.0f;
- m_nShockCounts = 0;
- m_bOnlyHaveFpd = false;
- m_bFirstGetCalibImageLeft = true;
- m_nAcqMode = -1;
-
- m_DetectorCtrlUnit.reset(new CAxsCtrlUnit(center, this));
- m_AcqUnit.reset(new CAxsAcq(center, this));
- m_SyncUnit.reset(new CAxsSync(center, this));
- m_CalibUnit.reset(new CAxsCalib(center, this));
- m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
- //探测器告警及错误消息
- m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_MAX));
-
- EventCenter = center;
- }
- nsFPD::CFPDDeviceAXS::~CFPDDeviceAXS()
- {
- if (m_pPreviewImageHead)
- {
- delete m_pPreviewImageHead;
- m_pPreviewImageHead = nullptr;
- }
- if (m_pImageHead)
- {
- delete m_pImageHead;
- m_pImageHead = nullptr;
- }
- if (m_pwPreviewImg)
- {
- delete m_pwPreviewImg;
- m_pwPreviewImg = nullptr;
- }
- if (m_pwRawImageData)
- {
- delete m_pwRawImageData;
- m_pwRawImageData = nullptr;
- }
- if (m_pwImageData)
- {
- delete m_pwImageData;
- m_pwImageData = nullptr;
- }
- }
- std::string nsFPD::CFPDDeviceAXS::GetGUID() const
- {
- printf("AXS device module: GetGUID \r\n");
- return DetectorUnitType;
- }
- //在Driver Create Device时调用,读取配置信息,下发配置信息到ctrl
- bool nsFPD::CFPDDeviceAXS::CreateDevice()
- {
- printf("--Func-- CreateDevice \r\n");
- FINFO("================ CreateDevice");
- if (!LoadConfig())
- {
- return false;
- }
- if (nullptr == g_pDetector)
- {
- if (nullptr == m_pDetectors)
- {
- m_pDetectors = new CAXSCtrl();
- FINFO("Create SDK ctrl ok\n");
- g_pDetector = (CAXSCtrl*)m_pDetectors;
- }
- }
- else
- {
- m_pDetectors = g_pDetector;
- FERROR("SDK ctrl Already exit\n");
- }
- g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- return true;
- }
- //在Driver Create Device时调用
- void nsFPD::CFPDDeviceAXS::Register()
- {
- FINFO("--Func-- device register");
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- //RegisterAutonumous(Disp);
- }
- //在Register之后调用
- bool nsFPD::CFPDDeviceAXS::Prepare()
- {
- printf("AXS device module: Prepare \r\n");
- FINFO("--Func-- device prepare \n");
- EventCenter->OnMaxBlockSize("AxsDmQue",m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgHeight * 2, 3, 1500 * 1500 * 2, 1);
- Connect();
- return true;
- }
- //在device prepare时调用
- RET_STATUS nsFPD::CFPDDeviceAXS::Connect()
- {
- printf("==========Fun Connect ========== \r\n");
- FINFO("==========Fun Connect ==========");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
- {
- m_bConnect = true;
- ret = RET_STATUS::RET_SUCCEED;
- FINFO("FPD is connected!");
- }
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::EnterExam(int nExamMode)
- {
- FINFO("==========Fun EnterExam ==========");
- FINFO("EnterExam nExamMode:{$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS_WORK_END:
- FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- FINFO("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS_DETSHAR_END:
- m_eAppStatus = APP_STATUS_IDLE;
- FINFO("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS_CAL_BEGIN:
- FINFO("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS_CAL_END:
- FINFO("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_END;
- break;
- case APP_STATUS_WORK_IN_SENSITIVITY:
- FINFO("Enter into sensitivity test interface");
- m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
- break;
- default:
- break;
- }
- g_pDetector->EnterExamMode(nExamMode);
- return RET_STATUS::RET_SUCCEED;
- }
- /***
- * 这是切换探测器的接口
- ***/
- RET_STATUS nsFPD::CFPDDeviceAXS::ActiveDetector(int nDetectorIndex, bool bActive)
- {
- FINFO("==========Fun ActiveDetector ==========");
- printf("ActiveDetector (%d) to (%d) \r\n", nDetectorIndex, bActive);
- FINFO("ActiveDetector {$} to {$}\n", nDetectorIndex, bActive);
- RET_STATUS ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector == nullptr)
- {
- printf("AXSCtrl object is not exist, return RET_FAILED\n");
- FERROR("AXSCtrl object is not exist, return RET_FAILED");
- return RET_STATUS::RET_FAILED;
- }
-
- return ret;
- }
- bool nsFPD::CFPDDeviceAXS::GetLogicMode(string& strAcqMode, int& nLogicMode)
- {
- if (strAcqMode == "RAD")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "AEC")
- {
- nLogicMode = AEC;
- }
- else if (strAcqMode == "1")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "2")
- {
- nLogicMode = AEC;
- }
- else
- {
- FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- //设置采集模式 1-RAD 2-RAD-preview 3-动态
- RET_STATUS nsFPD::CFPDDeviceAXS::SetAcqMode(string strAcqMode)
- {
- FINFO("==========Fun SetAcqMode ==========");
- printf("SetAcqMode %s \n", strAcqMode.c_str());
- FINFO("SetAcqMode start, nMode:{$}", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- int nMode = RAD;
- bool bRet = GetLogicMode(strAcqMode,nMode);
- if (!bRet)
- {
- return ret;
- }
- if (m_nAcqMode == nMode)
- {
- FINFO("Same acq mode! return");
- ret = RET_STATUS::RET_SUCCEED;
- return ret;
- }
- else
- {
- m_nAcqMode = nMode;
- }
- bool m_config_have = false;
- //如果没连接,不执行
- try
- {
- ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
- int nModeCount = (int)objModeConfig["ModeTable"].GetKeyCount("DetectorMode");
- for (int i = 0; i < nModeCount; i++)
- {
- int nLogicMode = (int)objModeConfig["ModeTable"][i]["LogicMode"];
- if (nLogicMode == nMode)
- {
- printf("find LogicMode == AcqMode\n");
- FINFO("find LogicMode == AcqMode");
- m_config_have = true;
- m_bPreviewEnable = (int)objModeConfig["ModeTable"][i]["HavePreview"];
- m_nImgWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"];
- m_nImgHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"];
- m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
- //m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
- m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
- m_eSyncMode = (SYNC_MODE)(int)objModeConfig["ModeTable"][i]["SyncType"];
- string strDose = (string)objModeConfig["ModeTable"][i]["CalibConfig"]["NodeInfo"]["Dose"]; //先写死成一个校正点
- m_fDose = stof(strDose);
- /*if (m_nAngle == 90 || m_nAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(m_nImgWidth, m_nImgHeight, m_nImgBits, false);
- }*/
- if (m_bPreviewEnable)
- {
- m_nPreViewImgWidth = (int)objModeConfig["ModeTable"][i]["PreviewImageWidth"];
- m_nPreViewImgHeight = (int)objModeConfig["ModeTable"][i]["PreviewImageHeight"];
- m_AcqUnit->SetPrevImageInfo(true, m_nPreViewImgHeight, m_nPreViewImgWidth, false);
- }
- else
- {
- m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
- }
- m_AcqUnit->SetFulImageInfo(m_nImgHeight, m_nImgWidth, m_nImgBits, false);
- if (((CAXSCtrl*)m_pDetectors)->SetAcqMode(nLogicMode, this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- FINFO("config file LogicMode:{$} SyncType:{$}", nLogicMode, (int)m_eSyncMode);
- //读取DetectorMode配置,并为imagebuffer申请内存空间
- if (((CAXSCtrl*)m_pDetectors)->SelectExamMode(nLogicMode, this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- printf("m_eSyncMode (%d) \r\n", m_eSyncMode);
- FINFO("m_eSyncMode ({$})", (int)m_eSyncMode);
- g_pDetector->SetSynMode(m_eSyncMode);
- break;
- }
- }
- if (!m_config_have)
- {
- FERROR("Illegal mode!");
- ret = RET_STATUS::RET_FAILED;
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Read configuration failed, Error code: {$}", e.what());
- }
- FINFO("SetAcqMode end");
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::PrepareAcquisition()
- {
- printf("--Func-- PrepareAcquisition \n");
- FINFO("==========Fun PrepareAcquisition ==========");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- printf("PrepareAcquisition failed. Detector at Calibration status.\n");
- FERROR("PrepareAcquisition failed. Detector at Calibration status");
- return ret;
- }
- //如果已经调用StartAcquisition 那么直接返回成功
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("Detector already at Acq status.\n");
- FERROR("Detector already at Acq status");
- ret = RET_STATUS::RET_SUCCEED;
- }
- m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- //因为PrepareAcquisition会等待探测器回调ready消息,回调后在通知app Ready状态
- FINFO("set detector status standby");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else
- {
- FERROR("fail to prepare acquisition!");
- }
-
- FINFO("==============================PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::StartAcquisition(string in)
- {
- printf("--Func-- StartAcquisition \n");
- FINFO("==========Fun StartAcquisition ==========");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FINFO("StartAcquisition detector status is not standby!");
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- printf("StartAcquisition failed. Detector at Calibration status.\n");
- FERROR("StartAcquisition failed. Detector at Calibration status.");
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("Detector already at Acq status.\n");
- FERROR("Detector already at Acq status.");
- }
- }
- else
- {
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- else
- {
- printf("StartAcquisition fail!\n");
- FINFO("StartAcquisition fail!");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- FINFO("==============================StartAcquisition over");
- return ret;
- }
- //LMAM3-IZ85c一般情况下不会调用stop
- RET_STATUS nsFPD::CFPDDeviceAXS::StopAcquisition()
- {
- printf("--Func-- StopAcquisition \n");
- FINFO("==========Fun StopAcquisition ==========");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("Detector status already is standby\n");
- FINFO("Detector status already is standby");
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- FINFO("==============================StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- printf("--Func-- ActiveCalibration %d \n", eType);
- FINFO("==========Fun ActiveCalibration ==========");
- FINFO("ActiveCalibration type {$}", (int)eType);
- RET_STATUS ret = RET_SUCCEED;
- if (!m_bConnect)
- {
- printf("Detector not connected, return\n");
- FERROR("Detector not connected, return");
- ret = RET_STATUS::RET_FAILED;
- return ret;
- }
- if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
- {
- ret = RET_STATUS::RET_INVALID;
- return ret;
- }
- try
- {
- ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
- m_eCalibMode = (CCOS_CALIBRATION_MODE)(int)objModeConfig["CalibMode"];
- //告诉Ctrl 校正模式是ZSKK还是OTHER
- printf("m_eCalibMode (%d) \r\n", m_eCalibMode);
- FINFO("m_eCalibMode ({$})", (int)m_eCalibMode);
- g_pDetector->SetCalibMode(m_eCalibMode);
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Read configuration failed, Error code: {$}", e.what());
- }
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- //设置ZSKK GAIN 校正的校正轮次,OTHER GAIN 校正需要曝光的次数在GetCalibrationStep中获取
- if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK && eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- printf("ZSKK calibration, type: XRAY\n");
- FINFO("ZSKK calibration, type: XRAY");
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- g_pDetector->SetReferenceNum(nCalibrationRounds);
- //重置亮场校正流程参数
- m_nCalibCurrentCalibrationRound = 1;
- m_nCalibCurrentExposureIndex = 1;
- m_nCalibCurrentExposureNum = 0;
- }
- else if (m_eCalibMode == CCOS_CALIBRATION_MODE_OEM && eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- //开始激活校正的时候肯定是需要获取剩余需要曝光的图像张数的
- m_bFirstGetCalibImageLeft = true;
- }
- if (g_pDetector->ActiveCalibration(this, eType))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
- m_CalibUnit->SetCalibrationProgress("0");
- }
- else
- {
- printf("Active calibration failed!\n");
- FERROR("Active calibration failed!");
- ret = RET_STATUS::RET_FAILED;
- }
- printf("ActiveCalibration over\n");
- FINFO("==============================ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration------ \n");
- FINFO("==========Fun PrepareCalibration ==========");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- printf("Detector not connected, return\n");
- FERROR("Detector not connected, return");
- return ret;
- }
- m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
- if (g_pDetector->PrepareCalibration(this))
- {
- //此处不通知ready,等到探测器回调Ready事件后再通知
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- printf("Prepare calibration failed\n");
- FERROR("Prepare calibration failed");
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- printf("PrepareCalibration over\n");
- FINFO("==============================PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::GetRequestedDose(std::string& strDose)
- {
- FINFO("==========Fun GetRequestedDose ==========");
- printf("--Func-- GetRequestedDose------ \n");
- if (!m_stDeviceConfig.bConnectStatus)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- bool bGetDoseInfo = false;
- ResDataObject out;
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- FINFO("GetRequestedDose calib type is {$}",(int)nCalibrationType);
- printf("GetRequestedDose calib type is %d\n",nCalibrationType);
- if (CCOS_CALIBRATION_TYPE_DARK == 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 == nCalibrationType)
- {
- FINFO("calib dose list size is {$}",m_CalibDoseList.size());
- printf("calib dose list size is %d\n",(int)m_CalibDoseList.size());
- for (int i = 0; i < m_CalibDoseList.size(); i++)
- {
- ResDataObject temp = m_CalibDoseList[i];
- int nDose = temp["Dose"];
- int nDoseParem = (int)(m_fDoseParam * 1000);
- if (nDoseParem == nDose)
- {
- out.add("Dose", nDoseParem);
- out.add("kV", temp["kV"]);
- out.add("mA", temp["mA"]);
- out.add("ms", temp["ms"]);
- out.add("mAs", temp["mAs"]);
- bGetDoseInfo = true;
- FINFO("Find target dose parameter");
- break;
- }
- }
- }
- else
- {
- FERROR("Can not support CalibrationType({$})", (int)nCalibrationType);
- Ret = RET_STATUS::RET_FAILED;
- }
- if (bGetDoseInfo)
- {
- strDose = out.encode();
- FINFO("GetRequestedDose:{$}", strDose.c_str());
- }
- else
- {
- FERROR("GetRequestedDose failed");
- }
- FINFO("==============================GetRequestedDose over");
- return Ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::StartCalibration()
- {
- printf("--Func-- StartCalibration------ \n");
- FINFO("==========Fun StartCalibration ==========");
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("detector is not connected");
- return Ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- if (DETECTOR_STATUS_CALIB == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FERROR("StartCalibration Detector already at calibration status");
- Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- }
- if (((CAXSCtrl*)m_pDetectors)->StartCalibration(this))
- {
- printf("start calibration success set detector status\n");
- FINFO("start calibration success set detector status");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_CALIB));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- printf("StartCalibration over\n");
- FINFO("==============================StartCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::StopCalibration()
- {
- FINFO("==========Fun StopCalibration ==========");
- printf("--Func-- StopCalibration------ \n");
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return Ret;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- if (((CAXSCtrl*)m_pDetectors)->StopCalibration(this))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- FINFO("==============================StopCalibration over");
- return Ret;
- }
- //create device 时调用
- bool nsFPD::CFPDDeviceAXS::LoadConfig()
- {
- printf("--Func-- LoadConfig \r\n");
- FINFO("================ LoadConfig\n");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
- {
- FERROR("Load configuration file failed!!!");
- return false;
- }
- //获取校正模式 0-ZSKK 1-OTHER
- m_eCalibMode = (CCOS_CALIBRATION_MODE)m_stDeviceConfig.nCalibMode;
- //新增一个配置项代表当前系统中是否只有一个真是的平板探测器,其他设备没有或者是demo的
- size_t keyCount = m_DetectorConfiguration->m_Configurations.GetKeyCount("OnlyHaveFpd");
- FINFO("LoadConfig OnlyHaveFpd keyCount:{$}", keyCount);
- if (keyCount)
- {
- m_bOnlyHaveFpd = (bool)m_DetectorConfiguration->m_Configurations["OnlyHaveFpd"];
- if (m_bOnlyHaveFpd)
- FINFO("current system only have FPD!");
- }
- if (m_stDeviceConfig.nForceGridSuppress > 0)
- {
- m_bForceGridSuppress = true;
- }
- else
- {
- m_bForceGridSuppress = false;
- }
- int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag];
- if (nAttached == 1)
- {
- m_bAttached = true;
- m_DetectorCtrlUnit->SetAttachStatus("1");
- }
- else
- {
- m_bAttached = false;
- m_stDeviceConfig.bConnectStatus = false;
- }
- m_DetectorCtrlUnit->SetDetectorType("LMAM3-IZ85c");
- string strFPDinfo;
- strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"];
- m_DetectorCtrlUnit->SetDescription(strFPDinfo);
- m_DetectorCtrlUnit->SetDetectorConditionsNominalFlag("YES");
- auto strFinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI);
- m_DetectorCtrlUnit->SetFPDSensitivity(strFinfo);
- //子系统将UI的TargetEXI 乘以 FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头。还原原始值,不再用100去除。
- m_fFactorEXI2UGY = 100.0f / (float)atof(strFinfo.c_str()) * 1.0f;
- FINFO("m_fFactorEXI2UGY = {$}", m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetPixelData("");
- m_DetectorCtrlUnit->SetTargetEXI("5000");
- m_Battery.reset(new DeviceBatteryMould("GetRemainPowerValue", 0,
- m_stDeviceConfig.nBatteryLimit,
- m_stDeviceConfig.nBatteryWarning,
- 100, 0, 100, 100,
- 0, EventCenter));
- m_Temperature.reset(new DeviceTemperatureMould("GetTemperatureValue", 0.0f,
- m_stDeviceConfig.fTemperatureMin,
- m_stDeviceConfig.fTemperLowLimit,
- m_stDeviceConfig.fTemperatureMax,
- m_stDeviceConfig.fTemperMaxLimit,
- 0.0f, 0.0f, 0.0f, EventCenter));
- m_Wifi.reset(new DeviceWifiMould("GetWifiStrengthValue", 0,
- m_stDeviceConfig.nWifiLimit,
- m_stDeviceConfig.nWifiWarning,
- 100, 0, 100, 100,
- 0, EventCenter));
- ResDataObject CalibDoseList;
- string strCalibDose = m_strWorkPath + R"(\OEMDrivers\Detector\AXSDetector\CalibrationDose_AXS.xml)";
- FINFO("start load calib dose file: {$}", strCalibDose.c_str());
- struct stat buffer;
- if (stat(strCalibDose.c_str(), &buffer) == 0)
- {
- try
- {
- CalibDoseList.loadFile(strCalibDose.c_str());
- m_CalibDoseList = CalibDoseList["List"];
- FINFO("m_CalibDoseList: {$} ", m_CalibDoseList.encode());
- for (int i = 0; i < m_CalibDoseList.size(); i++)
- {
- ResDataObject temp = m_CalibDoseList[i];
- int nExpNum = temp["ExpNum"];
- m_nCalibTotalExposureNum += nExpNum;
- //FINFO("temp: {$} ", temp.encode());
- }
- FINFO("CalibTotalExposureNum: {$}", m_nCalibTotalExposureNum);
- }
- catch (exception e)
- {
- FERROR("Get calibDose error: {$}", e.what());
- }
- }
- else
- {
- FERROR("{$} file not exist!");
- }
- return true;
- }
- void nsFPD::CFPDDeviceAXS::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- Dispatch->Action.Push(ActionKey::AttachConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect);
- Dispatch->Action.Push(ActionKey::CancelAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach);
- Dispatch->Action.Push(ActionKey::ResetConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
- Dispatch->Action.Push(ActionKey::DisConnectFPD, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
- Dispatch->Action.Push(ActionKey::UpdateFirmware, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
- Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
- Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
- Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
- Dispatch->Action.Push(ActionKey::RecoverImage, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
- Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);
- Dispatch->Action.Push(ActionKey::SaveSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
- Dispatch->Action.Push(ActionKey::RESET, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
- Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
- Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
- Dispatch->Get.Push(AttrKey::DetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus);
- Dispatch->Get.Push(AttrKey::DetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
- Dispatch->Get.Push(AttrKey::DetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);//event
- Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
- Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- Dispatch->Get.Push(AttrKey::FPDShockSensorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
- Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);//event
- Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);//event
- Dispatch->Get.Push(AttrKey::FieldofViewShape, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
- Dispatch->Get.Push(AttrKey::FieldofViewDimension, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
- Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
- Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
- Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
- Dispatch->Get.Push(AttrKey::DateofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
- Dispatch->Get.Push(AttrKey::TimeofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
- Dispatch->Get.Push(AttrKey::DetectorConditionsNominalFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
- Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
- Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
- Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
- }
- void nsFPD::CFPDDeviceAXS::RegisterAcq(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
- Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
- Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
- Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
- Dispatch->Get.Push(AttrKey::AutonumousMapFinish, m_AcqUnit.get(), &AcqUnit::JSAutonumousMapFinish);
- }
- void nsFPD::CFPDDeviceAXS::RegisterSync(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
- Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
- Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
- Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
- Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
- Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
- Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
- Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
- Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
- Dispatch->Get.Push(AttrKey::XrayON, m_SyncUnit.get(), &SyncUnit::JSGetXrayON);
- }
- void nsFPD::CFPDDeviceAXS::RegisterCalib(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
- Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
- Dispatch->Action.Push(ActionKey::SetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose);
- Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
- Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
- Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
- Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
- Dispatch->Action.Push(ActionKey::AcceptCalibration, m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration);
- Dispatch->Action.Push(ActionKey::RejectCalibration, m_CalibUnit.get(), &CalibUnit::JSRejectCalibration);
- Dispatch->Action.Push(ActionKey::SaveCalibrationFile, m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile);
- Dispatch->Action.Push(ActionKey::GetCalibrationStep, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep);
- Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
- Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
- Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
- Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
- Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
- }
- void nsFPD::CFPDDeviceAXS::RegisterOthers(nsDetail::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);
- }
- void nsFPD::CFPDDeviceAXS::RegisterAutonumous(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("OfflineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOfflineFPD);
- Dispatch->Action.Push("OnlineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOnlineFPD);
- Dispatch->Action.Push("GetAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAutonumousImageList);
- Dispatch->Action.Push("RemoveAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousImageList);
- Dispatch->Action.Push("RemoveAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousAll);
- Dispatch->Action.Push("GetImageMetaData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetImageMetaData);
- Dispatch->Action.Push("ExportAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExportAutonumousAll);
- }
- void nsFPD::CFPDDeviceAXS::SendTemperatureValue(float fValue)
- {
- int nStatus = 0;
- m_Temperature->SetTemperature(fValue, nStatus);
- FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
- }
- void nsFPD::CFPDDeviceAXS::SendWifiValue(int nValue)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nValue, nStatus);
- FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
- }
- void nsFPD::CFPDDeviceAXS::SendBatteryValue(int nValue)
- {
- int nStatus = 0;
- m_Battery->SetRemainPowerValue(nValue, nStatus);
- FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
- }
- /// <summary>
- /// 探测器设备 所有 事件处理入口 @PZ_FPD
- /// conf/info/status/data/warning/error
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- 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::CFPDDeviceAXS::NotifyXWindowOn() {
- m_SyncUnit->XWindowOnNotify();
- }
- // 通知子系统关窗
- void nsFPD::CFPDDeviceAXS::NotifyXWindowOff() {
- m_SyncUnit->XWindowOffNotify();
- }
- bool nsFPD::CFPDDeviceAXS::GetOnlyHaveFpd()
- {
- return m_bOnlyHaveFpd;
- }
- int nsFPD::CFPDDeviceAXS::GetGainExposureNum()
- {
- return m_nCalibTotalExposureNum;
- }
- /// <summary>
- /// 探测器设备 配置 事件处理 @PZ_FPD
- /// 暂不支持 配置
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::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;
- FINFO("Receive Panel {$} SN {$}", nDetectorID, pszMsg);
- m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
- break;
- }
- case EVT_CONF_RAW_WIDTH:
- {
- if (m_stDeviceConfig.nFullImageWidth != nParam1)
- {
- m_stDeviceConfig.nFullImageWidth = nParam1;
- }
- FINFO("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth);
- break;
- }
- case EVT_CONF_RAW_HIGHT:
- {
- if (m_stDeviceConfig.nFullImageHeight != nParam1)
- {
- m_stDeviceConfig.nFullImageHeight = nParam1;
- }
- FINFO("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight);
- break;
- }
- case EVT_CONF_RAW_BITS:
- {
- m_stDeviceConfig.nImageBits = nParam1;
- FINFO("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits);
- break;
- }
- case EVT_CONF_PIXELSPACE:
- {
- m_stDeviceConfig.nPixelSpace = (int)fParam2;
- FINFO("Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
- break;
- }
- case EVT_CONF_PREVIEW_WIDTH:
- {
- if (m_stDeviceConfig.nPreviewWidth != nParam1)
- {
- m_stDeviceConfig.nPreviewWidth = nParam1;
- }
- FINFO("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
- break;
- }
- case EVT_CONF_PREVIEW_HIGHT:
- {
- if (m_stDeviceConfig.nPreviewHeight != nParam1)
- {
- m_stDeviceConfig.nPreviewHeight = nParam1;
- }
- FINFO("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_CONF_MODULE_TYPE:
- {
- //m_strModuleType = pszMsg;
- FINFO("Receive Panel {$} ModuleType {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_IP:
- {
- //m_strModuleIP = pszMsg;
- FINFO("Receive Panel {$} ModuleIP {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_SN:
- {
- //m_strModuleSN = pszMsg;
- FINFO("Receive Panel {$} ModuleSN {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_FIRWARE_UPDATE:
- {
- m_stDeviceConfig.nFirmwareStatus = nParam1;
- FINFO("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
- break;
- }
- case EVT_CONF_PART_NUMBER:
- {
- m_stDeviceConfig.strPartNumber = pszMsg;
- FINFO("Panel {$} PartNumber:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_BATTERY_SN:
- {
- //m_strBatterySN = pszMsg;
- FINFO("Panel {$} Battery SN:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_WIFI_SSID:
- {
- m_stDeviceConfig.strWifiSSID = pszMsg;
- FINFO("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_IFBOARD:
- {
- m_stDeviceConfig.strInterfaceBoard = pszMsg;
- FINFO("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_DATECODE:
- {
- m_stDeviceConfig.strDateCode = pszMsg;
- FINFO("Panel {$} DateCode:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_LIFETIME:
- {
- int nLifeTime = nParam1;
- if ((nLifeTime != m_stDeviceConfig.nLifeTime) /*&& (m_strBatterySN != "")*/)
- {
- FINFO("LifeTime:{$}", nLifeTime);
- m_stDeviceConfig.nLifeTime = nLifeTime;
- }
- break;
- }
- default:
- break;
- }
- }
- /// <summary>
- /// 探测器设备 Info 事件处理 @PZ_FPD
- /// 暂不支持 Info
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::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;
- FINFO("Detector {$} PowerOn:{$}", nID, nPowerOn);
- if ((nPowerOn != m_stDeviceConfig.nPowerOn) /*&& (m_strBatterySN != "")*/)
- {
- m_stDeviceConfig.nPowerOn = nPowerOn;
- }
- break;
- }
- case EVT_INFO_BATTERY_CAPACITY:
- {
- int nBatteryCapacity = nParam1;
- if ((nBatteryCapacity != m_nBatteryCapacity) /*&& (m_strBatterySN != "")*/)
- {
- FINFO("{$}", nBatteryCapacity);
- m_nBatteryCapacity = nBatteryCapacity;
- }
- break;
- }
- case EVT_INFO_BATTERY_TEMPERATURE:
- {
- float fBatteryTemper = fParam2;
- if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) /*&& (m_strBatterySN != "")*/)
- {
- FINFO("temperature:{$:f2}", fBatteryTemper);
- m_fBatteryTemperature = fBatteryTemper;
- }
- break;
- }
- case EVT_INFO_BATTERY_CHARGES:
- {
- int nBatteryCharges = nParam1;
- if ((nBatteryCharges != m_nBatteryCharges)/* && (m_strBatterySN != "")*/)
- {
- FINFO("Charge number:{$}", nBatteryCharges);
- m_nBatteryCharges = nBatteryCharges;
- }
- break;
- }
- case EVT_INFO_WIFI_DATARATE:
- {
- m_stDeviceConfig.nWifiDataRate = nParam1;
- FINFO("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate);
- break;
- }
- case EVT_INFO_WIFI_CHANNEL:
- {
- m_stDeviceConfig.nWifiChannel = nParam1;
- FINFO("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;
- FINFO("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower);
- break;
- }
- case EVT_INFO_FIRMWARE:
- {
- m_stDeviceConfig.strFirmware = pszMsg;
- FINFO("Panel {$} Firmware:{$}", nID, pszMsg);
- break;
- }
- case EVT_INFO_SHOCKSENSOR_INFO:
- {
- FINFO("Receive ShockSensor Info");
- //m_strShockSensor = pszMsg;
- //m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIME:
- {
- m_stDeviceConfig.strCalibrationDate = pszMsg;
- FINFO("Panel {$} Calibration Time:{$}", nID, pszMsg);
- m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
- m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration("");
- //m_stDeviceConfig.strCalibrationDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationDate);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIMEL:
- {
- m_stDeviceConfig.strCalibrationLTEDate = pszMsg;
- FINFO("Panel {$} Calibration LTE Time:{$}", nID, pszMsg);
- //m_stDeviceConfig.strCalibrationLTEDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationLTEDate);
- break;
- }
- case EVT_INFO_FPVOLTAGE:
- {
- //m_strVoltage = pszMsg;
- break;
- }
- default:
- break;
- }
- }
- /// <summary>
- /// 探测器设备状态事件 处理@PZ_FPD
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_STATUS_INIT:
- {
- if (PANEL_EVENT_END_OK == nParam1)
- {
- FINFO("Detector init success set connect status is true");
- m_stDeviceConfig.bConnectStatus = true;
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- 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)
- {
- FINFO("Start update firmware");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START));
- }
- else if (PANEL_EVENT_BEGIN == nParam1)
- {
- FINFO("Update firmware begin");
- m_stDeviceConfig.bConnectStatus = false;
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- FINFO("Update firmware failed");
- //SendDetectorInfo(); //更新探测器状态图标
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR));
- }
- else if (PANEL_EVENT_SUCCESS == nParam1)
- {
- FINFO("update firmware success");
- //SendDetectorInfo();
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS));
- }
- break;
- }
- case EVT_STATUS_SELFTEST:
- {
- break;
- }
- case EVT_STATUS_DETECTORSHARE:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_ATTACH_START:
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START)); //重置status,避免服务判重,两次attach失败时,不将第二次的失败信息发送给客户端
- FINFO("New Detector Attach start");
- break;
- case PANEL_ATTACH_OVER:
- FINFO("New Detector Attach Over,Prepare to Connecting");
- //m_DetectorCtrlUnit->SetAttachResult(true, m_stDeviceConfig.strDeviceName.c_str(), m_strModuleSN.c_str());
- break;
- case PANEL_ATTACH_FAILED: //UI显示Failed
- FERROR("New Detector Attach failed");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED));
- break;
- case PANEL_CONNECT_OK:
- FINFO("OnEventProcessStatus panel connect ok set connect status is true");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_stDeviceConfig.bConnectStatus = true;
- break;
- case 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;
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- break;
- case 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_XWINDOW_ON == nParam1) //Xwindow On
- {
- m_stImgCreateTime = { 0 };
- GetLocalTime(&m_stImgCreateTime);
- FINFO("XWindow on time {$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- m_stImgCreateTime = { 0 };
- GetLocalTime(&m_stImgCreateTime);
- FINFO("XWindow off time {$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
- m_SyncUnit->XWindowOffNotify();
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- m_SyncUnit->FPDReadyNotify(true);
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- }
- else if (PANEL_GAIN_READY_EXP == nParam1)
- {
- m_SyncUnit->FPDReadyNotify(true);
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- }
- else if (PANEL_XRAY_ON == nParam1)
- {
- m_SyncUnit->XrayOnNotify();
- }
- else if (PANEL_XRAY_OFF == nParam1)
- {
- m_SyncUnit->XrayOffNotify();
- }
- else if (PANEL_CLOSE == nParam1)
- {
- FINFO("notify FPD not ready");
- m_SyncUnit->FPDReadyNotify(false);
- //右上角图标变灰色
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN));
- }
- break;
- }
- case EVT_STATUS_CALIBRATIOIN:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_END_OK:
- FINFO("Calibration process end ok");
- CompleteCalibration();
- break;
- case PANEL_EVENT_END_ERROR:
- FINFO("Calibration process end error");
- break;
- case PANEL_EVENT_START:
- FINFO("Calibration process start");
- break;
- case PANEL_EVENT_SUCCESS:
- FINFO("Calibration process success");
- break;
- case PANEL_EVENT_END:
- FINFO("Calibration process end");
- break;
- case PANEL_EVENT_BEGIN:
- FINFO("Calibration process begin");
- break;
- case PANEL_EVENT_TIMEOUT:
- FINFO("Calibration timeout");
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SAVECALIB:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- FINFO("Begin to Save Calibration Files");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- FINFO("Save Calibration Files failed");
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- FINFO("Save Calibration Files Success");
- }
- break;
- }
- case EVT_STATUS_SAVEDEFECT:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- FINFO("Begin to Save Defect Files");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- FINFO("Save Defect Files failed");
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- FINFO("Save Defect Files Success");
- m_stDeviceConfig.bTaskEnd = true;
- }
- break;
- }
- case EVT_STATUS_ACQUISITION:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- FINFO("Acquisition start");
- break;
- case PANEL_EVENT_END_OK:
- FINFO("Acquisition end");
- break;
- case PANEL_EVENT_END_ERROR: //目前不会报错,不会走到这里
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SINGLEEXP:
- {
- if (DOSE_TOO_HIGH == nParam1)
- {
- FINFO("Dose too high");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_TOO_LOW == nParam1)
- {
- FINFO("Dose too low");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_OBJECT == nParam1)
- {
- FINFO("Dose object");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_ACCEPT == nParam1)
- {
- FINFO("Calibration Result is acceptable");
- //m_WarnAndError->OnErrorX("ERR_FPD_DOSE_INVALID");
- }
- else if (EVT_STATUS_LASTERROR == nParam1)
- {
- //m_strLastError = pszMsg;
- //FINFO("Panel {$} LastError {$}", nID, pszMsg);
- }
- 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(nID, "ERR_FPD_IMAGE_PENDING");
- }
- else
- {
- m_bResetDetector = false;//可以再次reset
- //m_WarnAndError->OnErrorX("ERR_FPD_IMAGE_PENDING");
- }
- break;
- }
- case EVT_STATUS_TEMPERATURE:
- {
- float fTemperature = fParam2;
- OnProcessTemperature(nDetectorID, fTemperature);
- m_stDeviceConfig.fCurrentTemperValue = fTemperature;
- FINFO("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature);
- SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
- break;
- }
- case EVT_STATUS_WIFI:
- {
- int nWifiLevel = nParam1;
- if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0)
- {
- nWifiLevel = int(nWifiLevel / 0.75);
- if (nWifiLevel > 100)
- {
- nWifiLevel = 100;
- }
- }
- FINFO("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel);
- //strWarnErrorCode = "ERR_FPD_WIFI_LOW";
- if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错
- {
- //m_WarnAndError->OnErrorX(strWarnErrorCode);
- }
- else if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
- {
- //wifi error
- //OnError(nID, strWarnErrorCode);
- }
- else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning)
- {
- //wifi error
- //m_WarnAndError->OnErrorX(strWarnErrorCode);
- //strWarnErrorCode = "WAR_FPD_WIFI_LOW";
- //OnWarn(nID, strWarnErrorCode);
- }
- else
- {
- //m_WarnAndError->OnErrorX(strWarnErrorCode);
- }
- FINFO("detector wifi level:{$}", nWifiLevel);
- if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue)
- {
- FINFO("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate);
- }
- //endif
- m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
- SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- int nBatteryValue = nParam1;
- FINFO("Detector {$} Battery:{$}", nDetectorID, nParam1);
- if (nBatteryValue < m_stDeviceConfig.nBatteryLimit)
- {
- //battery error
- //if (!m_bBatteryCharging) //如果没有充电;
- //{
- // strWarnErrorCode = "ERR_FPD_BATTERY_LOW";
- // OnError(nID, strWarnErrorCode);
- //}
- }
- else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
- {
- //battery error
- //strWarnErrorCode = "ERR_FPD_BATTERY_LOW";
- //m_WarnAndError->OnErrorX(strWarnErrorCode);
- //strWarnErrorCode = "WAR_FPD_BATTERY_LOW";
- //OnWarn(nID, strWarnErrorCode);
- }
- else
- {
- //strWarnErrorCode = "ERR_FPD_BATTERY_LOW";
- //m_WarnAndError->OnErrorX(strWarnErrorCode);
- }
- m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
- FINFO("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue);
- SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
- 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;
- //string strLog;
- //PRINTA_INFO("Panel %d Shock Sensor Number:%d", nID, m_nShockCounts);
- //if ((m_nShockCounts >= m_stDeviceConfig.nMaxShockNumber) && (m_stDeviceConfig.nShockTimes != m_nShockCounts))//避免频繁发送
- //{
- // PRINTA_INFO("Reach Max Shock Sensor Number");
- // OnWarn(nID, WAR_FPD_MAX_SHOCK_NUM);
- // SendInfoLog("DEV_LOG_FPD_SHOCKSENSOR", m_strShockSensor);
- //}
- //m_stDeviceConfig.nShockTimes = m_nShockCounts;
- break;
- }
- case EVT_STATUS_HALL_SENSOR:
- {
- //int nWorkstaion = nParam1;
- //PRINTA_INFO("Update Hall Status : %d ", nWorkstaion);
- //PRINTA_INFO("Panel %d WS:%d,Current OGP WS:%d ", nID, nWorkstaion, m_nWorkStation);
- //m_stDeviceConfig.nWorkstation = nWorkstaion;
- break;
- }
- case EVT_STATUS_PING:
- {
- break;
- }
- case EVT_STATUS_PMSNOTOPEN:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- FINFO("PMS isn't open");
- }
- break;
- }
- case EVT_STATUS_RESTOREFILES:
- {
- //string strTemp = pszMsg;
- //if (strTemp.find("true") != std::string::npos)
- //{
- // PRINTA_INFO("Restore calibration files");
- // string wcsPanelType = "3543dr";
- // if (m_stDeviceConfig.strDeviceName.find("3543EZ") >= 0)
- // {
- // wcsPanelType = "3543ezh";
- // }
- // else if (m_stDeviceConfig.strDeviceName.find("2430EZ") != std::string::npos)
- // {
- // wcsPanelType = "2430ez";
- // }
- // m_CalibProcess->UpdateFDCalibList(m_nLTEenable, m_stDeviceConfig.strPanelSerial, wcsPanelType.c_str());
- //}
- break;
- }
- case EVT_STATUS_LASTERROR:
- {
- //m_strLastError = pszMsg;
- //PRINTA_INFO("Panel {$} LastError {$}", nID, pszMsg);
- break;
- }
- case EVT_STATUS_RESET:
- {
- int nStatus = nParam1;
- if (PANEL_RESET_BEGIN == nStatus)
- {
- //弹出滚动条
- }
- else if (PANEL_RESET_OK == nStatus)
- {
- m_bResetDetector = false;
- }
- else if (PANEL_RESET_ERROR == nStatus)
- {
- // //OnError(nID,ERR_FPD_RESET,L"");
- }
- break;
- }
- case EVT_AUTONUMOUS_STATUS:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_CONNECT_ERROR:
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
- break;
- }
- case PANEL_CONNECT_OK:
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_stDeviceConfig.bConnectStatus = true;
- break;
- }
- case PANEL_DISCONNECT_SUCCESS:
- {
- m_nBatteryCapacity = 0;
- m_stDeviceConfig.bExisted = false;
- m_stDeviceConfig.bConnectStatus = false;
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- break;
- }
- case PANEL_DISCONNECT_ERROR:
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
- break;
- }
- case PANEL_START_STOREDIMAGE:
- {
- FINFO("Send start autonumous to server");
- m_AcqUnit->SendAutonumousMapFinish(0);
- break;
- }
- case PANEL_END_STOREDIMAGE:
- {
- FINFO("Send finish autonumous to server");
- m_AcqUnit->SendAutonumousMapFinish(1);
- break;
- }
- case PANEL_EXPORT_AUTONUMOUS_FINISH:
- {
- FINFO("Send finish export local autonumous to server");
- m_AcqUnit->SendAutonumousMapFinish(2);
- break;
- }
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- }
- /// <summary>
- /// 探测器设备图像数据事件 处理 @PZ_FPD
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::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:
- {
- FINFO("Image Arrived");
- if (APP_STATUS_IDLE == m_eAppStatus)
- {
- FERROR("Omit Image in Idle Status");
- return;
- }
- FINFO("Currenct FPD FullImage Width:{$},FullImage Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight);
- float fImageReferUGY = 2.5;
- if (APP_STATUS_WORK_BEGIN == m_eAppStatus) //如果是在检查中
- {
- fImageReferUGY = 2.5;
- }
- if (NULL == m_pwRawImageData)
- {
- m_pwRawImageData = new WORD[m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight];
- }
- memcpy(m_pwRawImageData, pParam, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * sizeof(WORD));
- OnProcessImage(m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight, fImageReferUGY);
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- FINFO("Preview Image Arrved");
- FINFO("Current FPD preview image width: {$}, height: {$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- m_SyncUnit->ImageReadingNotify();
- //因为AEC图像的像素大小是4 不是 2 故这里要再乘以2
- if (nullptr == m_pwPreviewImg)
- {
- m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2];
- }
- else
- {
- memset(m_pwPreviewImg, 0, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 4);
- }
- memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 4);
- OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_DATA_DOSEPARAM:
- {
- m_fDoseParam = fParam2;
- break;
- }
- default:
- FERROR("Not support this eventID ({$})", nEventID);
- break;
- }
- }
- /// <summary>
- /// 探测器设备 ERROR 事件处理 @PZ_FPD
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_ERR_COMMUNICATE:
- {
- //strErrorName = "ERR_FPD_DISCONNECT";
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_stDeviceConfig.nWorkstation = -1;
- m_stDeviceConfig.bConnectStatus = false;
- m_nBatteryCapacity = 0;
- m_stDeviceConfig.fCurrentTemperValue = 0.0f;
- m_stDeviceConfig.nCurrentWifiValue = 0;
- m_stDeviceConfig.nCurrentBatteryValue = 0;
- SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
- SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
- SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
- //OnError(nDetectorID, strErrorName);
- }
- else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo
- {
- m_stDeviceConfig.bConnectStatus = true;
- //if (m_WarnAndError->IsErrorExist("ERR_FPD_DISCONNECT")) //如果已经恢复了通讯,不再重复发送LOG
- //{
- // m_WarnAndError->OnErrorX(strErrorName);
- //}
- }
- break;
- }
- case EVT_ERR_EXP_REQUEST:
- FERROR("OnEventProcessError EVT_ERR_EXP_REQUEST");
- break;
- case EVT_ERR_GET_IMAGE:
- FERROR("OnEventProcessError EVT_ERR_GET_IMAGE");
- break;
- case EVT_ERR_MAX_NUMBER:
- FERROR("OnEventProcessError EVT_ERR_MAX_NUMBER");
- break;
- case EVT_ERR_SN_NOTINLIST:
- FERROR("OnEventProcessError EVT_ERR_SN_NOTINLIST");
- break;
- case EVT_ERR_POWER_OFF:
- FERROR("OnEventProcessError EVT_ERR_POWER_OFF");
- break;
- case EVT_ERR_INIT_FAILED:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- //AddErrMsg("6", "initialize error");
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- //一般不可恢复
- }
- break;
- }
- default:
- FERROR("Not support this error({$})", nEventID);
- break;
- }
- }
- /// <summary>
- /// 探测器设备 WARNING 事件 处理 @PZ_FPD
- /// 当前版本不支持,TBD.
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::CFPDDeviceAXS::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this warn({$})", nEventID);
- }
- bool nsFPD::CFPDDeviceAXS::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
- {
- FINFO("Currenct PreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- PrevImageDateArrived(pwRawImage);
- return true;
- }
- void nsFPD::CFPDDeviceAXS::PrevImageDateArrived(WORD* pImg)
- {
- //LMAM3-IZ85c的pre image 像素大小是4,单字节:宽*高*4 双字节:宽*高*2
- AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2);
- }
- void nsFPD::CFPDDeviceAXS::FullImageDateArrived(WORD* pImg)
- {
- //LMAM3-IZ85c的有效图像像素大小是2,单字节:宽*高*2 双字节:宽*高
- AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight);
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
- {
- string strImageHead = MakeImageHead(Type);
- FINFO("str image head:{$}",strImageHead.c_str());
- printf("str image head:%s", strImageHead.c_str());
- FINFO("FrameSize:{$}", FrameSize);
- return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
- }
- string nsFPD::CFPDDeviceAXS::MakeImageHead(IMAGE_VIEW_TYPE Type)
- {
- if (m_pImageHead != NULL)
- {
- delete m_pImageHead;
- m_pImageHead = nullptr;
- }
- if (Type == IMAGE_FULL)
- {
- if (m_pImageHead == NULL)
- {
- m_pImageHead = 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, "1");
- 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, 0.0f);
- m_pImageHead->add(SM_IMAGE_HEAD, json);
- }
- else
- {
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds;
- (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pImageHead).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, "1");
- 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();
- }
- }
- bool nsFPD::CFPDDeviceAXS::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY)
- {
- FINFO("CFPDDeviceAXS OnProcessImage");
- if (pwRawImage == NULL)
- {
- FERROR("OnProcessImage src ImgData is null!");
- return false;
- }
- if (!m_pwImageData)
- {
- m_pwImageData = new WORD[nImageWidth * nImageHeight];
- }
- if (!m_pwImageData)
- {
- FERROR("OnProcessImage new error!");
- return false;
- }
- memcpy(m_pwImageData, pwRawImage, nImageWidth * nImageHeight * sizeof(WORD));
- //图像预处理完成
- m_pwImageData[0] = 65535;//坐标原点 bug 8164
- //如果环境中只有探测器,那么这里增加一个推送状态
- if (m_bOnlyHaveFpd)
- {
- FINFO("OnProcessImage OnlyHaveFpd Sleep 1s then set fpd standby(4)");
- Sleep(1000);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- FullImageDateArrived(m_pwImageData);
- FINFO("OnProcessImage Write Frame Over");
- return true;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::AcceptCalibration()
- {
- FINFO("==========Fun AcceptCalibration ==========");
- printf("--func-- AcceptCalibration\n");
- RET_STATUS ret = RET_STATUS::RET_SUCCEED;
- if (((CAXSCtrl*)m_pDetectors)->AcceptCalibration())
- {
- FINFO("AcceptCalibration over");
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("AcceptCalibration error");
- ret = RET_STATUS::RET_FAILED;
- }
- if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK)
- {
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- //完成校正条件:轮数够了,曝光次数够了
- if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
- {
- FINFO("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_fDoseParam = nDose / 1000.0f;
- }
- else
- {
- m_nCalibCurrentExposureIndex++;
- }
- }
- else
- {
- if (m_nCalibCurrentExposureIndex == m_nCalibTotalExposureNum)
- {
- FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
- m_nCalibCurrentExposureIndex = 1;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- return ret;
- }
- else
- {
- m_fDoseParam = 2500 / 1000.0f;
- m_nCalibCurrentExposureIndex++;
- }
- }
- //在GetCalibrationStep中会把校正曝光的总次数和当前已接受的曝光次数传给app,app收到后会根据m_nCalibCurrentExposureNum和m_nCalibTotalExposureNum
- //进行比较,如果相同则认为亮场校正完成,app会主动调用CompleteCalibration
- m_nCalibCurrentExposureNum++;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- FINFO("==============================AcceptCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::RejectCalibration()
- {
- printf("--Func-- RejectCalibration \n");
- FINFO("==========Fun RejectCalibration ==========");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (((CAXSCtrl*)m_pDetectors)->RejectCalibration())
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("RejectCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- FINFO("==============================RejectCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::SaveCalibrationFile(bool bSaveFlag)
- {
- printf("--Func-- SaveCalibrationFile \n");
- FINFO("==========Fun SaveCalibrationFile ==========");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("SaveCalibrationFile by user: {$}", bSaveFlag);
- if (!bSaveFlag)
- {
- FERROR("Not save calibration file");
- return Ret;
- }
- if(m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK)
- {
- if (((CAXSCtrl*)m_pDetectors)->SaveCalibrationFile())
- {
- FINFO("SaveCalibrationFile over");
- m_CalibUnit->SetSaveCalibrationFileFinish(true);
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("SaveCalibrationFile error");
- m_CalibUnit->SetSaveCalibrationFileFinish(false);
- Ret = RET_STATUS::RET_FAILED;
- }
- }
-
- FINFO("==============================SaveCalibrationFile over");
- return Ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::SetRequestedDose(std::string strDose)
- {
- FINFO("==========Fun SetRequestedDose ==========");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
- {
- printf("--func-- GetCalibrationStep\n");
- FINFO("==========Fun GetCalibrationStep ==========");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("Calibration DetectorID: {$}", nDetectorID);
- ResDataObject out;
- if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK)
- {
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];//当前轮需要曝光的次数(有效)
- ((CAXSCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound);
- //告诉app曝光情况,根据m_nCalibTotalExposureNum和m_nCalibCurrentExposureNum判断是否亮场校正完成
- out.add("CalibrationRounds", (int)m_CalibDoseList.size());
- out.add("TotalExposureNum", m_nCalibTotalExposureNum);
- out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
- out.add("ExposureNumCurrentRound", nExposureNumCurrentRound);
- out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
- out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
- }
- else
- {
- if (m_bFirstGetCalibImageLeft)
- {
- //获取需要曝光的次数
- int nLeftCount = ((CAXSCtrl*)m_pDetectors)->GetCalImagesLeftCount();
- FINFO("First Get Calib Images Left,count:{$}",nLeftCount);
- m_nCalibTotalExposureNum = nLeftCount;
- m_bFirstGetCalibImageLeft = false;
- }
- ((CAXSCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, 1, m_nCalibCurrentExposureIndex, m_nCalibTotalExposureNum);
- out.add("CalibrationRounds", 1);
- out.add("TotalExposureNum", m_nCalibTotalExposureNum);
- out.add("CurrentCalibrationRound", 1);
- out.add("ExposureNumCurrentRound", m_nCalibTotalExposureNum);
- out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
- out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
- }
- strCalibrationStepInfo = out.encode();
- FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
- return Ret;
- }
- //LMAM3-IZ85c不支持暂停校正
- RET_STATUS nsFPD::CFPDDeviceAXS::PauseCalibration()
- {
- printf("--Func-- PauseCalibration\n");
- FINFO("==========Fun PauseCalibration ==========");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("==============================PauseCalibration over");
- return Ret;
- }
- bool nsFPD::CFPDDeviceAXS::CompleteCalibration()
- {
- printf("--func-- CompleteCalibration \n");
- FINFO("==========Fun CompleteCalibration ==========");
- m_eAppStatus = APP_STATUS_CAL_END;
- ((CAXSCtrl*)m_pDetectors)->CompleteCalibration(this);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- if (m_bOnlyHaveFpd)
- {
- //通知子系统结束暗场校正太快了,导致后边的服务通知app的消息混乱了,故此处延时1s
- printf("Sleep 1s,then send progress 100\n");
- FINFO("Sleep 1s,then send progress 100");
- Sleep(1000);
- }
-
- m_CalibUnit->SetCalibrationProgress("100");
- FINFO("==============================CompleteCalibration over");
- return true;
- }
- void nsFPD::CFPDDeviceAXS::AbortCalibration()
- {
- printf("--func-- AbortCalibration\n");
- FINFO("==========Fun AbortCalibration ==========");
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
- m_CalibUnit->SetCalibrationProgress("100");
- FINFO("==============================AbortCalibration over");
- return;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- ((CAXSCtrl*)m_pDetectors)->AbortCalibration();
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
- m_CalibUnit->SetCalibrationProgress("100");
- m_AcqUnit->SendNoNeedWaitImage(true);//什么用意不太清楚
- FINFO("==============================AbortCalibration over");
- }
- void nsFPD::CFPDDeviceAXS::OnProcessTemperature(int nID, float fTemperature)
- {
- string strWarnErrorCode = "";
- float fMaxTempGap = 6.0f;
- if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0)
- {
- fMaxTempGap = 12.0f;
- }
- if (fTemperature >= m_stDeviceConfig.fTemperMaxLimit)
- {
- FINFO("Exceed Max Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH;
- if (m_stDeviceConfig.bActived)
- {
- strWarnErrorCode = "ERR_FPD_TEMPHIGH_NOT_ACQ";
- //OnError(nID, strWarnErrorCode);
- }
- }
- else if (fTemperature <= m_stDeviceConfig.fTemperMinLimit)
- {
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW;
- if (m_stDeviceConfig.bActived)
- {
- FINFO("Exceed Min Temperature");
- strWarnErrorCode = "ERR_FPD_TEMPLOW_NOT_ACQ";
- //OnError(nID, strWarnErrorCode);
- }
- }
- else if (fTemperature <= m_stDeviceConfig.fTemperLowLimit)
- {
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- FINFO("Exceed Temperature Low Warning");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
- strWarnErrorCode = "WAR_FPD_TEMPERTURE_LOW";
- //OnWarn(nID, strWarnErrorCode);
- }
- else if (fTemperature > m_stDeviceConfig.fTemperWarning)
- {
- FINFO("Exceed Temperature High Warning");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- strWarnErrorCode = "WAR_FPD_TEMPERATURE_HIGH";
- //OnWarn(nID, strWarnErrorCode);
- }
- else if ((m_stDeviceConfig.fCalibTemperature > 1.0f) && (abs(fTemperature - m_stDeviceConfig.fCalibTemperature) >= fMaxTempGap))
- {
- FINFO("Exceed Calibration Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- strWarnErrorCode = "WAR_FPD_EXCEED_CALB_TEMPER";
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
- //OnWarn(nID, strWarnErrorCode);
- }
- else if ((fTemperature <= m_stDeviceConfig.fTemperWarning) && (fTemperature > m_stDeviceConfig.fTemperLowLimit))
- {
- FINFO("Temperature Normal");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ");
- //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ");
- //m_stDeviceConfig.nTemperatureStatus = TEMP_NORMAL;
- }
- }
- //慎重调用,可能会导致板出问题,硬reset需要很长时间
- RET_STATUS nsFPD::CFPDDeviceAXS::Reset()
- {
- printf("--Func-- Reset\n");
- FINFO("==========Fun Reset ==========");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (((CAXSCtrl*)m_pDetectors)->ResetDetector(this))
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("==============================Reset over");
- return Ret;
- }
- /***
- * 客户端获取探测器信息
- ***/
- RET_STATUS nsFPD::CFPDDeviceAXS::GetDetectorInfo(string& strFDI)
- {
- ResDataObject strDetectorInfo;
- string strTempTemp = " ";
- FINFO("==========Fun GetDetectorInfo ==========");
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- FERROR("Get Detector Info Failed, Send Default Info");
- 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);
- //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str());
- 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
- if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0)
- {
- strDetectorInfo.add("SystemAS", 3);
- }
- else
- {
- strDetectorInfo.add("SystemAS", 2);
- }
- //DetectorCalibrationDate
- if (m_stDeviceConfig.strCalibrationDate != " ")
- {
- if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos)
- {
- 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);
- strDetectorInfo.add("FirmwareUpdate", 0);
- strFDI = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::ResetConnect()
- {
- FINFO("==========Fun ResetConnect ==========");
- ((CAXSCtrl*)m_pDetectors)->Disconnect();
- ((CAXSCtrl*)m_pDetectors)->Connect(this,m_strWorkPath.c_str());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::CFPDDeviceAXS::SetExposureTimes(int nTimes)
- {
- FINFO("==========Fun SetExposureTimes ==========");
- FINFO("SetExposureTimes nTimes:{$}", nTimes);
- stringstream sValue;
- sValue << nTimes;
- EventCenter->OnNotify((int)ATTRACTION_SET, "ProjectionNum", sValue.str().c_str());
- return RET_STATUS::RET_SUCCEED;
- }
|