12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.PZMedicalDR.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "PZMedicalCtrl.h"
- #include <sys/stat.h>
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- extern PZMedicalCtrl* g_pDetector;
- static nsFPD::PZMedicalDriver gIODriver;
- Log4CPP::Logger* gLogger = nullptr;
- extern const char* g_szMouldPath;
- PZMedicalDriver* gDriver = nullptr;
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- gDriver = new nsFPD::PZMedicalDriver();
- return gDriver;
- }
- nsFPD::PZMedicalDriver::PZMedicalDriver()
- {
- m_pObjDev = nullptr;
- m_bDriverConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::PZMedicalDriver::~PZMedicalDriver()
- {
- if (m_pObjDev != nullptr)
- {
- delete m_pObjDev;
- m_pObjDev = nullptr;
- }
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- auto nsFPD::PZMedicalDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("--Driver-- CreateDevice \r\n");
- FINFO("--Driver-- createdevice");
- m_pObjDev = new FPDDevicePZMedical(EventCenter, m_ConfigFileName);
- auto Device = std::unique_ptr<IODevice>(new IODevice(m_pObjDev));
- m_pObjDev->CreateDevice();
- m_pObjDev->Register();
- return Device;
- }
- void nsFPD::PZMedicalDriver::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");
- }
- bool nsFPD::PZMedicalDriver::Connect()
- {
- printf("--Driver-- Connect \r\n");
- FINFO("--Driver-- connect");
- if (m_pObjDev && g_pDetector && !m_bDriverConnect)
- {
- RET_STATUS ret = m_pObjDev->Connect();
- if (ret != RET_SUCCEED)
- {
- FERROR("Connect fail!");
- return false;
- }
- }
-
- return m_bDriverConnect;
- }
- bool nsFPD::PZMedicalDriver::isConnected() const
- {
- return m_bDriverConnect;
- }
- void nsFPD::PZMedicalDriver::Disconnect()
- {
- printf("--Driver-- Disconnect \r\n");
- FINFO("--Driver-- disconnect");
- if (m_pObjDev != nullptr)
- {
- delete m_pObjDev;
- m_pObjDev = nullptr;
- }
- m_bDriverConnect = false;
- }
- /// <summary>
- /// 驱动信息检索 TODO : 需要重新定义
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::PZMedicalDriver::DriverProbe()
- {
- printf("PZMedical 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", "PZMedical");
- HardwareInfo.add("ProductID", "PZMedical");
- HardwareInfo.add("SerialID", "Driver");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /// <summary>
- /// 从配置文件中返回给上层 配置对象
- /// 标准代码
- /// [DONE.CHECKED.]
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::PZMedicalDriver::GetResource()
- {
- printf("PZMedical driver: GetResource \r\n");
- FINFO("PZMedical driver: GetResource");
- printf("m_ConfigFileName:%s\n", m_ConfigFileName.c_str());
- FINFO("m_ConfigFileName:{$}", m_ConfigFileName);
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- return "";
- }
- m_ConfigAll = temp;
- r_config = temp["CONFIGURATION"];
- m_Configurations = r_config;
- ResDataObject DescriptionTemp;
- ResDataObject ListTemp;
- string strTemp = ""; //用于读取字符串配置信息
- string strIndex = ""; //用于读取配置信息中的List项
- int nTemp = -1; //用于读取整型配置信息
- char sstream[10] = { 0 }; //用于转换值
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- string strAccess = ""; //用于存储权限的类型 R/W/RW
- string strRequired = ""; // TRUE/FALSE
- string strDefaultValue = "";
- string strRangeMin = "";
- string strRangeMax = "";
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- //FINFO(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
- m_pAttribute->clear();
- m_pDescription->clear();
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- DescriptionTemp.clear();
- ListTemp.clear();
- //AttributeType
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
- DescriptionTemp.add(AttributeType, strTemp.c_str());
- //FINFO("DescriptionTemp--> {$}: {$}", 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];
- //sprintf_s(sstream, "{$}", 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();
- printf("PZMedical driver module: get resource over \r\n");
- return res;
- }
- /// <summary>
- /// 设备信息检索 TODO : 需要重新定义,TBD.
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::PZMedicalDriver::DeviceProbe()
- {
- printf("PZMedical 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", "PZMedical");
- HardwareInfo.add("ProductID", "PZMedical");
- HardwareInfo.add("SerialID", "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /// <summary>
- /// 设备配置读取接口
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="Cfg"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::GetDeviceConfig(std::string& Cfg)
- {
- Cfg = m_DeviceConfig.encode();
- FINFO("GetDeviceConfig over");
- return true;
- }
- /// <summary>
- /// 提供给web配置中心的 配置写入接口
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="Cfg"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::SetDeviceConfig(std::string Cfg)
- {
- FINFO("--Func-- SetDeviceConfig {$}\n", 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::PZMedicalDriver::SaveConfigFile(bool bSendNotify)
- {
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- FINFO("SaveConfigFile over, 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::PZMedicalDriver::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 || ImageWidth == strTemp
- || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp)
- {
- strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
- }
- else if (TempMaxLimit == strTemp || TempMinLimit == strTemp || TempUpperLimit == strTemp
- || TempLowerLimit == strTemp || ReConnect == strTemp || BatLowerLimit == strTemp
- || BatMiniLimit == strTemp || BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp
- || WifiMiniLimit == strTemp || HighPowerTimeout == strTemp
- || ShowTemperature == strTemp || ShowWifi == strTemp
- || ShowBattery == strTemp || ShowBluetooth == strTemp
- || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp
- || CcosDetectorAttachedFlag == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- FERROR("Error Configuration item: {$}", pInnerKey);
- }
- }
- 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::PZMedicalDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- FINFO("Begin to change {$} item value to {$}", pInnerKey, szValue);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- config["connections"][pInnerKey] = szValue;
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp || ImageWidth == strTemp
- || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp)
- {
- config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
- }
- else if (TempMaxLimit == strTemp || TempMinLimit == strTemp || TempUpperLimit == strTemp
- || TempLowerLimit == strTemp || ReConnect == strTemp || BatLowerLimit == strTemp
- || BatMiniLimit == strTemp || BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp
- || WifiMiniLimit == strTemp || HighPowerTimeout == strTemp
- || ShowTemperature == strTemp || ShowWifi == strTemp
- || ShowBattery == strTemp || ShowBluetooth == strTemp
- || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp
- || CcosDetectorAttachedFlag == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else
- {
- FERROR("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- nsFPD::FPDDevicePZMedical::FPDDevicePZMedical(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_bConnect = false;
- m_nFullImageHeight = 0;
- m_nFullImageWidth = 0;
- m_nImageBits = 0;
- m_nPixelSpacing = 0;
- m_nSensitivity = 0;
- m_eSyncMode = SYNC_AED;
- m_eAppStatus = APP_STATUS_IDLE;
- m_pwFullImageData = nullptr;
- m_pwPreviewImg = nullptr;
- m_strWorkPath = GetProcessDirectory();
- m_DetectorCtrlUnit.reset(new OemCtrl(center, this));
- m_AcqUnit.reset(new OemAcq(center, this));
- m_SyncUnit.reset(new OemSync(center, this));
- m_CalibUnit.reset(new OemCalib(center, this));
- m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
- //探测器告警及错误消息
- string fullpath = g_szMouldPath;
- string::size_type firstHit = fullpath.find_last_of('\\');
- if (firstHit == string::npos || firstHit == 0)
- {
- FERROR("Get DLL path error!");
- }
- else
- {
- FINFO("g_szMouldPath:{$}", g_szMouldPath);
- }
- string strInfoPath = fullpath.substr(0, firstHit);
- m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, strInfoPath));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_WaitCalibDoseEvt = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_PauseCalibrationEvt = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_UploadCalibMapOver = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_pFullImageHead = nullptr;
- m_pPreviewImageHead = nullptr;
- EventCenter = center;
- m_strCurrentAcqMode = "";
- }
- nsFPD::FPDDevicePZMedical::~FPDDevicePZMedical()
- {
- if (m_pwFullImageData)
- {
- delete[]m_pwFullImageData;
- m_pwFullImageData = nullptr;
- }
- if (m_pwPreviewImg)
- {
- delete[]m_pwPreviewImg;
- m_pwPreviewImg = nullptr;
- }
- if (m_WaitCalibDoseEvt)
- {
- CloseHandle(m_WaitCalibDoseEvt);
- m_WaitCalibDoseEvt = nullptr;
- }
- if (m_PauseCalibrationEvt)
- {
- CloseHandle(m_PauseCalibrationEvt);
- m_PauseCalibrationEvt = nullptr;
- }
- if (m_UploadCalibMapOver)
- {
- CloseHandle(m_UploadCalibMapOver);
- m_UploadCalibMapOver = nullptr;
- }
- }
- std::string nsFPD::FPDDevicePZMedical::GetGUID() const
- {
- printf("--Func-- GetGUID \r\n");
- return DetectorUnitType;
- }
- bool nsFPD::FPDDevicePZMedical::Prepare()
- {
- printf("--Func-- Prepare \r\n");
- FINFO("--Func-- device prepare");
- EventCenter->OnMaxBlockSize("PZDrQue", 4000 * 8000 * 2, 3, 1500 * 1500 * 4, 1);
- return true;
- }
- bool nsFPD::FPDDevicePZMedical::CreateDevice()
- {
- printf("--Func-- CreateDevice \r\n");
- FINFO("--Func-- CreateDevice");
- if (!LoadConfig())
- {
- return false;
- }
- if (nullptr == g_pDetector)
- {
- FINFO("Create PZMedicalCtrl");
- g_pDetector = new PZMedicalCtrl();
- }
- else
- {
- FERROR("PZMedicalCtrl Already exit");
- }
- g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- //把通知状态信息的时间间隔传给ctrl
- m_DetectorCtrlUnit->SetAttachStatus("1");
- g_pDetector->SetNotifyStatusTimePeriod(m_stDeviceConfig.nNotifyStatusTimePeriod);
- g_pDetector->SetReconnectTimePeriod(m_stDeviceConfig.nReconnectTimePeriod);
- m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode);
- m_CalibUnit->SetCalibMode(std::to_string(m_stDeviceConfig.nCalibMode));
- m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate);
- m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime);
- string strTemp = "";
- strTemp = (string)m_DetectorConfiguration->m_Configurations["DetectorType"];
- m_DetectorCtrlUnit->SetDetectorType(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["Description"];
- m_DetectorCtrlUnit->SetDescription(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["SerialNumber"];
- m_DetectorCtrlUnit->SetSerialNumber(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["DetectorWiredIP"];
- m_DetectorCtrlUnit->SetDetectorWiredIP(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["DetectorWirelessIP"];
- m_DetectorCtrlUnit->SetDetectorWirelessIP(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["LocalIP"];
- m_DetectorCtrlUnit->SetLocalIP(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowTemperature"];
- m_DetectorCtrlUnit->SetShowTemperature(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowWifi"];
- m_DetectorCtrlUnit->SetShowWifi(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowBattery"];
- m_DetectorCtrlUnit->SetShowBattery(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowBluetooth"];
- m_DetectorCtrlUnit->SetShowBluetooth(strTemp);
- return true;
- }
- void nsFPD::FPDDevicePZMedical::Register()
- {
- printf("--Func-- Register \r\n");
- FINFO("--Func-- Register");
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::Connect()
- {
- printf("--Func-- Connect \r\n");
- FINFO("--Func-- Connect");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- FINFO("Connect m_strWorkPath:{$}", m_strWorkPath.c_str());
- if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::EnterExam(int nExamMode)
- {
- FINFO("--Func-- EnterExam {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- FINFO("strLastCalibrationDate:{$},strCalibrationFileExpirationReminder:{$}", m_stDeviceConfig.strLastCalibrationDate, m_stDeviceConfig.strCalibrationFileExpirationReminder);
- if (m_stDeviceConfig.strCalibrationFileExpirationReminder == "1")
- {
- //进检查时判断当前校正文件是否过期,如果即将过期或者已过期都向上通知
- if (m_stDeviceConfig.strLastCalibrationDate == "0000-00-00 00:00:00")
- {
- //没有做过校正
- FWARN("No calibration file, please make a calibration!");
- m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_NOT_EXIST, "");
- }
- else
- {
- time_t lastCalibDate = StringToDatetime(m_stDeviceConfig.strLastCalibrationDate);
- int nExpireTime = std::stoi(m_stDeviceConfig.strCalibrationFileExpireTime);//单位:天
- FINFO("nExpireTime:{$}", nExpireTime);
- time_t localtime = time(NULL);
- //判断是否过期
- if (localtime > lastCalibDate + nExpireTime * 24 * 3600)
- {
- //过期了报错
- FWARN("Calibration file is expired! please make a calibration!");
- m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_OUTDATE, "");
- }
- }
- }
- break;
- case APP_STATUS_WORK_END:
- FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- FINFO("strCalibrationFileExpirationReminder:{$}", m_stDeviceConfig.strCalibrationFileExpirationReminder);
- if (m_stDeviceConfig.strCalibrationFileExpirationReminder == "1")
- {
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
- }
- 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::FPDDevicePZMedical::ActiveDetector(int nDetectorIndex, bool bActive)
- {
- printf("--Func-- ActiveDetector(%d) to (%d) \r\n", nDetectorIndex, bActive);
- FINFO("--Func-- ActiveDetector {$} to {$}", nDetectorIndex, bActive);
- RET_STATUS ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector == nullptr)
- {
- printf("PZMedicalCtrl object is not exist, return RET_FAILED\n");
- FERROR("PZMedicalCtrl object is not exist, return RET_FAILED");
- return RET_STATUS::RET_FAILED;
- }
- return ret;
- }
- bool nsFPD::FPDDevicePZMedical::GetLogicMode(string& strAcqMode, int& nLogicMode)
- {
- if (strAcqMode == "RAD")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "1")
- {
- nLogicMode = RAD;
- }
- else
- {
- FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- //设置采集模式 1-RAD 2-AEC
- RET_STATUS nsFPD::FPDDevicePZMedical::SetAcqMode(string strAcqMode)
- {
- printf("--Func-- SetAcqMode %s \n", strAcqMode.c_str());
- FINFO("--Func-- SetAcqMode {$}", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接则返回
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (m_strCurrentAcqMode == strAcqMode)
- {
- FINFO("Same acq mode, return true");
- return RET_STATUS::RET_SUCCEED;
- }
- int nMode = RAD;
- bool bRet = GetLogicMode(strAcqMode, nMode);
- if (!bRet)
- {
- return ret;
- }
- try
- {
- ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
- int nModeCount = (int)objModeConfig["ModeTable"].size();
- for (int i = 0; i < nModeCount; i++)
- {
- int nLogicMode = (int)objModeConfig["ModeTable"][i]["LogicMode"];
- if (nLogicMode == nMode)
- {
- FINFO("find LogicMode == AcqMode");
- //m_nFullImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"];
- //m_nFullImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"];
- m_nImageBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
- m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
- m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"];
- //m_eSyncMode = (SYNC_MODE)(int)objModeConfig["ModeTable"][i]["SyncType"];
- FINFO("m_nImageBits:{$},m_nPixelSpacing:{$},m_nSensitivity:{$},m_eSyncMode:{$}",
- m_nImageBits, m_nPixelSpacing, m_nSensitivity, (int)m_eSyncMode);
- string strSensitivity = to_string(m_nSensitivity);
- m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity);
- //子系统将UI的TargetEXI 乘以 FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头
- m_fFactorEXI2UGY = 100.0f / (float)atof(strSensitivity.c_str()) * 1.0f;
- FINFO("m_fFactorEXI2UGY = {$}", m_fFactorEXI2UGY);
- //读取DetectorMode配置,并为imagebuffer申请内存空间
- if (g_pDetector->SetAcqMode(nLogicMode, this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- break;
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Read configuration failed, Error code: {$}", e.what());
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::PrepareAcquisition()
- {
- printf("--Func-- PrepareAcquisition \n");
- FINFO("--Func-- PrepareAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- FINFO("--Func-- PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StartAcquisition(string in)
- {
- printf("--Func-- StartAcquisition \n");
- FINFO("--Func-- 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())
- {
- 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.");
- }
- 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;
- }
- else
- {
- printf("StartAcquisition fail!\n");
- FINFO("StartAcquisition fail!");
- }
- }
- FINFO("--Func-- StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StopAcquisition()
- {
- FINFO("--Func-- StopAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//StopAcquisition
- }
- FINFO("--Func-- StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- FINFO("--Func-- ActiveCalibration type {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
- {
- return RET_STATUS::RET_INVALID;
- }
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- FINFO("calibration type: Gain");
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- g_pDetector->SetReferenceNum(nCalibrationRounds);
- }
- if (g_pDetector->ActiveCalibration(this, eType))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
- m_CalibUnit->SetCalibrationProgress("0");
- m_nXrayCalibNum = 0;
- }
- else
- {
- printf("Active calibration failed!\n");
- FERROR("Active calibration failed!");
- return ret;
- }
- //重置校正流程参数
- m_nCalibCurrentCalibrationRound = 1;
- m_nCalibCurrentExposureIndex = 1;
- m_nCalibCurrentExposureNum = 0;
- ret = RET_STATUS::RET_SUCCEED;
- FINFO("--Func-- ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration------ \n");
- FINFO("--Func-- PrepareCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- printf("Detector not connected, return\n");
- FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->PrepareCalibration(this))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_PREPARE));
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("Prepare calibration failed");
- }
- FINFO("--Func-- PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::GetRequestedDose(std::string& strDose)
- {
- FINFO("--Func-- GetRequestedDose");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- ResDataObject out;
- if (!m_bConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- FINFO("GetRequestedDose calib type is {$}", (int)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);
- }
- else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
- {
- FINFO("calib dose list size is {$}", m_CalibDoseList.size());
- ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
- int nTargetExi = (int)temp["TargetGainEXI"];
- m_DetectorCtrlUnit->SetTargetEXI(std::to_string(nTargetExi));
- FINFO("nTargetExi:{$}", nTargetExi);
- out.add("Dose", nTargetExi);
- out.add("kV", temp["KV"]);
- out.add("mA", temp["MA"]);
- out.add("ms", temp["MS"]);
- out.add("mAs", temp["MAS"]);
- }
- else
- {
- FERROR("Don't support CalibrationType($)", (int)nCalibrationType);
- return ret;
- }
- strDose = out.encode();
- FINFO("GetRequestedDose:{$}", strDose);
- ret = RET_STATUS::RET_SUCCEED;
- FINFO("--Func-- GetRequestedDose over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StartCalibration()
- {
- FINFO("--Func-- StartCalibration");
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Ret = RET_STATUS::RET_THREAD_INVALID;
- FERROR("detector is not connected");
- return Ret;
- }
- if (g_pDetector->StartCalibration(this))
- {
- FINFO("start calibration success set detector status");
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- StartCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StopCalibration()
- {
- FINFO("--Func-- StopCalibration");
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return Ret;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- if (g_pDetector->StopCalibration(this))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//StopCalibration
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- StopCalibration over");
- return Ret;
- }
- //create device 时调用
- bool nsFPD::FPDDevicePZMedical::LoadConfig()
- {
- FINFO("--Func-- LoadConfig");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_CalibDoseList, m_nCalibTotalExposureNum))
- {
- FERROR("Load configuration file failed!!!");
- return false;
- }
- FINFO("m_CalibDoseList:{$}", m_CalibDoseList.encode());
- FINFO("m_nCalibTotalExposureNum:{$}", m_nCalibTotalExposureNum);
- //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0,
- m_stDeviceConfig.nBatteryLimit,
- m_stDeviceConfig.nBatteryWarning,
- 100,
- m_stDeviceConfig.nBatLowerLimitInCali,
- 100, 100, 0, EventCenter));
- //const char* strkey, float initialvalue, float min, float WarnMin, float WarnMax, float CalibWarnMin, float CalibWarnMax, float max, float accuracy,std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f,
- m_stDeviceConfig.fTemperatureErrorMin,
- m_stDeviceConfig.fTemperatureWarnMin,
- m_stDeviceConfig.fTemperatureWarnMax,
- m_stDeviceConfig.fTemperatureWarnMin,
- m_stDeviceConfig.fTemperatureWarnMax,
- m_stDeviceConfig.fTemperatureErrorMax,
- 0.0f, EventCenter));
- //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0,
- m_stDeviceConfig.nWifiLimit,
- m_stDeviceConfig.nWifiWarning,
- 100,
- m_stDeviceConfig.nWifiWarning,
- 100, 100, 0, EventCenter));
- return true;
- }
- void nsFPD::FPDDevicePZMedical::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::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::RecoverImage, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
- Dispatch->Action.Push(ActionKey::SaveSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
- Dispatch->Action.Push(ActionKey::RESET, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
- 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::FPDShockSensorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
- Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
- Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- Dispatch->Get.Push(AttrKey::DetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);
- 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);
- Dispatch->Get.Push(AttrKey::DetectorWiredIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWiredIP);
- Dispatch->Get.Push(AttrKey::DetectorWirelessIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWirelessIP);
- Dispatch->Get.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSerialNumber);
- Dispatch->Get.Push(LocalIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetLocalIP);
- Dispatch->Get.Push(ShowTemperature, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowTemperature);
- Dispatch->Get.Push(ShowWifi, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowWifi);
- Dispatch->Get.Push(ShowBattery, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowBattery);
- Dispatch->Get.Push(ShowBluetooth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowBluetooth);
- Dispatch->Set.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetConnectStatus);
- Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus);
- Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType);
- Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription);
- Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID);
- Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData);
- Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI);
- Dispatch->Set.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus);
- Dispatch->Set.Push(AttrKey::DetectorWiredIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorWiredIP);
- Dispatch->Set.Push(AttrKey::DetectorWirelessIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorWirelessIP);
- Dispatch->Set.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSerialNumber);
- Dispatch->Set.Push(LocalIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetLocalIP);
- Dispatch->Set.Push(ShowTemperature, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowTemperature);
- Dispatch->Set.Push(ShowWifi, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowWifi);
- Dispatch->Set.Push(ShowBattery, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowBattery);
- Dispatch->Set.Push(ShowBluetooth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowBluetooth);
- Dispatch->Update.Push(AttrKey::NotifyStatusTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateNotifyStatusTimePeriod);
- Dispatch->Update.Push(AttrKey::ReconnectTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateReconnectTimePeriod);
- Dispatch->Update.Push(AttrKey::DetectorWiredIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateDetectorWiredIP);
- Dispatch->Update.Push(AttrKey::DetectorWirelessIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateDetectorWirelessIP);
- Dispatch->Update.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateSerialNumber);
- Dispatch->Update.Push(LocalIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateLocalIP);
- Dispatch->Update.Push(ShowTemperature, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowTemperature);
- Dispatch->Update.Push(ShowWifi, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowWifi);
- Dispatch->Update.Push(ShowBattery, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowBattery);
- Dispatch->Update.Push(ShowBluetooth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowBluetooth);
- }
- void nsFPD::FPDDevicePZMedical::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);
- Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState);
- Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage);
- }
- void nsFPD::FPDDevicePZMedical::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->Action.Push(ActionKey::ActiveSyncMode, m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode);
- 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::XrayON, m_SyncUnit.get(), &SyncUnit::JSGetXrayON);
- Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
- Dispatch->Get.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode);
- Dispatch->Set.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSSetFPDReady);
- Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus);
- Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
- Dispatch->Set.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::SetSupportSyncMode);
- }
- void nsFPD::FPDDevicePZMedical::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);
- Dispatch->Get.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSGetCalibMode);
- Dispatch->Get.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSGetLastCalibrationDate);
- Dispatch->Get.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpireTime);
- Dispatch->Get.Push(AttrKey::CalibrationFileExpirationReminder, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpirationReminder);
- Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus);
- Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress);
- Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult);
- Dispatch->Set.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::SetCalibMode);
- Dispatch->Set.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::SetLastCalibrationDate);
- Dispatch->Set.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpireTime);
- Dispatch->Set.Push(AttrKey::CalibrationFileExpirationReminder, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpirationReminder);
- Dispatch->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode);
- Dispatch->Update.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSUpdateLastCalibrationDate);
- Dispatch->Update.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpireTime);
- Dispatch->Update.Push(AttrKey::CalibrationFileExpirationReminder, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpirationReminder);
- }
- void nsFPD::FPDDevicePZMedical::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);
- Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
- Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
- Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
- Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
- Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax);
- Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin);
- Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
- Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
- Dispatch->Get.Push(BatLowerLimitInCali, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryCalibWarningMin);
- Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
- Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
- //Error
- Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
- Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
- Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
- Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
- Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
- Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax);
- Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin);
- Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
- Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
- Dispatch->Set.Push(BatLowerLimitInCali, m_Battery.get(), &DeviceBatteryMould::SetBatLowerLimitInCalib);
- Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
- Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
- Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
- Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
- Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
- Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
- Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax);
- Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin);
- Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
- Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
- Dispatch->Update.Push(BatLowerLimitInCali, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatLowerLimitInCalib);
- Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
- Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
- }
- void nsFPD::FPDDevicePZMedical::SendTemperatureValue(float fValue)
- {
- int nStatus = 0;
- m_Temperature->SetTemperature(fValue, nStatus);
- FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
- }
- void nsFPD::FPDDevicePZMedical::SendWifiValue(int nValue)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nValue, nStatus);
- FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
- }
- void nsFPD::FPDDevicePZMedical::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::FPDDevicePZMedical::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;
- }
- }
- int nsFPD::FPDDevicePZMedical::GetGainExposureNum()
- {
- return m_nCalibTotalExposureNum;
- }
- WORD* nsFPD::FPDDevicePZMedical::GetFullImageData()
- {
- return m_pwFullImageData;
- }
- /// <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::FPDDevicePZMedical::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("Detector ID:{$}, SN {$}", nDetectorID, pszMsg);
- m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
- break;
- }
- case EVT_CONF_RAW_WIDTH:
- {
- m_nFullImageWidth = nParam1;
- m_stDeviceConfig.nFullImageWidth = nParam1;
- FINFO("Detector ID:{$}, Image Width:{$}", nDetectorID, m_nFullImageWidth);
- break;
- }
- case EVT_CONF_RAW_HIGHT:
- {
- m_nFullImageHeight = nParam1;
- m_stDeviceConfig.nFullImageHeight = nParam1;
- FINFO("Detector ID:{$}, Image Height:{$}", nDetectorID, m_nFullImageHeight);
- break;
- }
- case EVT_CONF_RAW_BITS:
- {
- m_stDeviceConfig.nImageBits = nParam1;
- m_nImageBits = nParam1;
- FINFO("Detector ID:{$}, Image Bit:{$}", nDetectorID, m_nImageBits);
- break;
- }
- case EVT_CONF_PIXELSPACE:
- {
- m_stDeviceConfig.nPixelSpace = (int)fParam2;
- FINFO("Detector ID:{$}, nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
- break;
- }
- case EVT_CONF_PREVIEW_WIDTH:
- {
- if (m_stDeviceConfig.nPreviewWidth != nParam1)
- {
- m_stDeviceConfig.nPreviewWidth = nParam1;
- }
- FINFO("Detector ID:{$}, nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
- break;
- }
- case EVT_CONF_PREVIEW_HIGHT:
- {
- if (m_stDeviceConfig.nPreviewHeight != nParam1)
- {
- m_stDeviceConfig.nPreviewHeight = nParam1;
- }
- FINFO("Detector ID:{$}, nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_CONF_MODULE_TYPE:
- {
- //m_strModuleType = pszMsg;
- FINFO("Detector ID:{$}, ModuleType {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_IP:
- {
- //m_strModuleIP = pszMsg;
- FINFO("Detector ID:{$}, ModuleIP {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_SN:
- {
- //m_strModuleSN = pszMsg;
- FINFO("Detector ID:{$}, ModuleSN {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_FIRWARE_UPDATE:
- {
- m_stDeviceConfig.nFirmwareStatus = nParam1;
- FINFO("Detector ID:{$}, FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
- break;
- }
- case EVT_CONF_PART_NUMBER:
- {
- m_stDeviceConfig.strPartNumber = pszMsg;
- FINFO("Detector ID:{$}, PartNumber:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_BATTERY_SN:
- {
- //m_strBatterySN = pszMsg;
- FINFO("Detector ID:{$}, Battery SN:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_WIFI_SSID:
- {
- m_stDeviceConfig.strWifiSSID = pszMsg;
- FINFO("Detector ID:{$}, WifiSSID:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_IFBOARD:
- {
- m_stDeviceConfig.strInterfaceBoard = pszMsg;
- FINFO("Detector ID:{$}, InterfaceBoard:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_DATECODE:
- {
- m_stDeviceConfig.strDateCode = pszMsg;
- FINFO("Detector ID:{$}, DateCode:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_LIFETIME:
- {
- int nLifeTime = nParam1;
- if ((nLifeTime != m_stDeviceConfig.nLifeTime))
- {
- 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::FPDDevicePZMedical::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:%.2f", 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("");
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIMEL:
- {
- m_stDeviceConfig.strCalibrationLTEDate = pszMsg;
- FINFO("Panel {$} Calibration LTE Time:{$}", nID, pszMsg);
- 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::FPDDevicePZMedical::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("EVT_STATUS_INIT PANEL_EVENT_END_OK");
- 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_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;
- m_bConnect = 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\n");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED));
- break;
- }
- case PANEL_CONNECT_OK:
- {
- FINFO("EVT_STATUS_DETECTORSHARE PANEL_CONNECT_OK");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- 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_bConnect = 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_CLOSE == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
- m_stDeviceConfig.nWorkstation = -1;
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = false;
- gDriver->m_bDriverConnect = 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);
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- m_WarnAndError->SendError(ERR_FPD_DISCONNECT, "");
- }
- else if (PANEL_CONNECT == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
- m_stDeviceConfig.bConnectStatus = true;
- m_bConnect = true;
- gDriver->m_bDriverConnect = true;
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PANEL_READY_EXP
- }
- else if (PANEL_XWINDOW_ON == nParam1)
- {
- m_SystemTime = { 0 };
- GetLocalTime(&m_SystemTime);
- FINFO("XWindow on time {$}:{$}:{$}:{$}", m_SystemTime.wHour, m_SystemTime.wMinute, m_SystemTime.wSecond, m_SystemTime.wMilliseconds);
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1)
- {
- m_SystemTime = { 0 };
- GetLocalTime(&m_SystemTime);
- FINFO("XWindow off time {$}:{$}:{$}:{$}", m_SystemTime.wHour, m_SystemTime.wMinute, m_SystemTime.wSecond, m_SystemTime.wMilliseconds);
- m_SyncUnit->XWindowOffNotify();
- }
- else if (PANEL_START_ACQ == nParam1)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- else if (PANEL_XRAY_ON == nParam1)
- {
- m_SyncUnit->XrayOnNotify();
- }
- else if (PANEL_XRAY_OFF == nParam1)
- {
- m_SyncUnit->XrayOffNotify();
- }
- 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");
- SetEvent(m_UploadCalibMapOver);
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- FINFO("Save Calibration Files Success");
- SetEvent(m_UploadCalibMapOver);
- }
- 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");
- SetEvent(m_UploadCalibMapOver);
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- FINFO("Save Defect Files Success");
- m_stDeviceConfig.bTaskEnd = true;
- SetEvent(m_UploadCalibMapOver);
- }
- 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");//make progress
- 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");//make progress
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_OBJECT == nParam1)
- {
- FINFO("Dose object");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- //m_CalibUnit->SetCalibrationProgress(100);//make progress
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_ACCEPT == nParam1)
- {
- FINFO("Calibration Result is acceptable");
- SetEvent(m_PauseCalibrationEvt);
- }
- 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;
- }
- 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("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0)
- {
- nWifiLevel = int(nWifiLevel / 0.75);
- if (nWifiLevel > 100)
- {
- nWifiLevel = 100;
- }
- }
- FINFO("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel);
- if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错
- {
- FINFO("nWifiLevel == 0, wired connection");
- }
- else if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
- {
- //达到wifi最低值限制
- }
- else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning)
- {
- //达到wifi警告值
- }
- FINFO("detector wifi level:%d", nWifiLevel);
- if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue)
- {
- FINFO("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate);
- }
- m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
- SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- int nBatteryValue = nParam1;
- m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
- FINFO("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue);
- SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
- break;
- }
- case EVT_STATUS_BATTERY_CHARGING:
- {
- break;
- }
- case EVT_STATUS_SHOCK_SENSOR:
- {
- break;
- }
- case EVT_STATUS_HALL_SENSOR:
- {
- 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:
- {
- break;
- }
- case EVT_STATUS_LASTERROR:
- {
- 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:
- {
- FINFO("EVT_AUTONUMOUS_STATUS PANEL_CONNECT_OK");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_stDeviceConfig.bConnectStatus = true;
- m_bConnect = true;//EVT_AUTONUMOUS_STATUS
- break;
- }
- case PANEL_DISCONNECT_SUCCESS:
- {
- m_nBatteryCapacity = 0;
- m_stDeviceConfig.bExisted = false;
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = 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::FPDDevicePZMedical::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 Width:{$},Image Height:{$}", m_nFullImageWidth, m_nFullImageHeight);
- m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImageBits, false);
- m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
- if (m_pwFullImageData)
- {
- delete m_pwFullImageData;
- m_pwFullImageData = nullptr;
- }
- m_pwFullImageData = new WORD[m_nFullImageWidth * m_nFullImageHeight];
- memcpy(m_pwFullImageData, pParam, m_nFullImageWidth * m_nFullImageHeight * sizeof(WORD));
- OnProcessImage(m_pwFullImageData, m_nFullImageWidth, m_nFullImageHeight);
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- FINFO("Preview Image Arrved");
- FINFO("Current FPD preview image width: %d, height: %d", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- m_SyncUnit->ImageReadingNotify();
- if (NULL == m_pwPreviewImg)
- {
- m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight];
- }
- memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD));
- OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_DATA_DOSEPARAM:
- {
- m_fDoseParam = fParam2;
- SetEvent(m_WaitCalibDoseEvt);
- break;
- }
- default:
- FERROR("Not support this eventID (%d)", 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::FPDDevicePZMedical::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_ERR_COMMUNICATE:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_stDeviceConfig.nWorkstation = -1;
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = false;
- gDriver->m_bDriverConnect = 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);
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- m_WarnAndError->SendError(ERR_FPD_DISCONNECT, "");
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- FINFO("EVT_ERR_COMMUNICATE false");
- m_stDeviceConfig.bConnectStatus = true;
- m_bConnect = true;
- gDriver->m_bDriverConnect = true;
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
- }
- 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)
- {
- FERROR("Initialize detector error!");
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- FINFO("Initialize detector success!");
- }
- 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::FPDDevicePZMedical::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this warn(%d)", nEventID);
- }
- bool nsFPD::FPDDevicePZMedical::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
- {
- FINFO("--Func-- OnProcessPreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- PrevImageDateArrived(pwRawImage);
- return true;
- }
- void nsFPD::FPDDevicePZMedical::PrevImageDateArrived(WORD* pImg)
- {
- AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight);
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
- {
- string strImageHead = MakeImageHead(Type);
- FINFO("str image head:{$}", strImageHead);
- return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
- }
- string nsFPD::FPDDevicePZMedical::MakeImageHead(IMAGE_VIEW_TYPE Type)
- {
- if (m_pFullImageHead != NULL)
- {
- delete m_pFullImageHead;
- m_pFullImageHead = nullptr;
- }
- m_SystemTime = { 0 };
- GetLocalTime(&m_SystemTime);
- if (Type == IMAGE_FULL)
- {
- if (m_pFullImageHead == NULL)
- {
- m_pFullImageHead = new ResDataObject;
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
- json.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
- json.add(SM_IMAGE_BIT, m_nImageBits);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, m_SystemTime.wYear);
- json.add(SM_IMAGE_MONTH, m_SystemTime.wMonth);
- json.add(SM_IMAGE_DAY, m_SystemTime.wDay);
- json.add(SM_IMAGE_HOUR, m_SystemTime.wHour);
- json.add(SM_IMAGE_MINUTE, m_SystemTime.wMinute);
- json.add(SM_IMAGE_SEC, m_SystemTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, m_SystemTime.wMilliseconds);
- json.add(SM_IMAGE_LSB, "5000");
- json.add(SM_IMAGE_DOSE, m_nSensitivity);
- json.add(SM_IMAGE_PIXELREPRESENTATION, "1");
- json.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
- 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_pFullImageHead->add(SM_IMAGE_HEAD, json);
- }
- else
- {
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_SystemTime.wYear;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_SystemTime.wMonth;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_SystemTime.wDay;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_SystemTime.wHour;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_SystemTime.wMinute;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_SystemTime.wSecond;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_SystemTime.wMilliseconds;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pFullImageHead).encode();
- }
- else
- {
- if (m_pPreviewImageHead == NULL)
- {
- m_pPreviewImageHead = new ResDataObject;
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth);
- json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight);
- json.add(SM_IMAGE_BIT, 16);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, m_SystemTime.wYear);
- json.add(SM_IMAGE_MONTH, m_SystemTime.wMonth);
- json.add(SM_IMAGE_DAY, m_SystemTime.wDay);
- json.add(SM_IMAGE_HOUR, m_SystemTime.wHour);
- json.add(SM_IMAGE_MINUTE, m_SystemTime.wMinute);
- json.add(SM_IMAGE_SEC, m_SystemTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, m_SystemTime.wMilliseconds);
- json.add(SM_IMAGE_LSB, "5000");
- json.add(SM_IMAGE_DOSE, m_nSensitivity);
- 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_nPixelSpacing);
- 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_SystemTime.wYear;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_SystemTime.wMonth;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_SystemTime.wDay;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_SystemTime.wHour;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_SystemTime.wMinute;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_SystemTime.wSecond;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_SystemTime.wMilliseconds;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pPreviewImageHead).encode();
- }
- }
- bool nsFPD::FPDDevicePZMedical::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight)
- {
- FINFO("--Func-- OnProcessImage");
- if (pwRawImage == NULL)
- {
- FERROR("OnProcessImage pwRawImage is null!");
- return false;
- }
- FullImageDateArrived(pwRawImage);
- FINFO("Write Frame Over");
- return true;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::AcceptCalibration()
- {
- printf("--Func-- AcceptCalibration\n");
- FINFO("--Func-- AcceptCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->AcceptCalibration())
- {
- FINFO("AcceptCalibration over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("AcceptCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- //完成校正条件:轮数够了,曝光次数够了
- if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
- {
- FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AcceptCalibration expose over
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- return Ret;
- }
- if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
- {
- m_nCalibCurrentCalibrationRound++;
- m_nCalibCurrentExposureIndex = 1;
- }
- else
- {
- m_nCalibCurrentExposureIndex++;
- }
- m_nCalibCurrentExposureNum++;
- FINFO("--Func-- AcceptCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::RejectCalibration()
- {
- printf("--Func-- RejectCalibration \n");
- FINFO("--Func-- RejectCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->RejectCalibration())
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("RejectCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- RejectCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::SaveCalibrationFile(bool bSaveFlag)
- {
- printf("--Func-- SaveCalibrationFile \n");
- FINFO("--Func-- SaveCalibrationFile");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("SaveCalibrationFile by user: {$}", bSaveFlag);
- if (!bSaveFlag)
- {
- FERROR("Not save calibration file");
- return Ret;
- }
- if (g_pDetector->SaveCalibrationFile())
- {
- FINFO("SaveCalibrationFile over");
- m_CalibUnit->SetSaveCalibrationFileFinish(true);
- Ret = RET_STATUS::RET_SUCCEED;
- //更新配置文件中校正日期和时间
- time_t localtime = time(NULL);
- string strLocalTime = DatetimeToString(localtime);
- FINFO("strLocalTime:{$}", strLocalTime);
- m_CalibUnit->SetLastCalibrationDate(strLocalTime);
- //清除校正文件相关警告
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
- }
- else
- {
- FERROR("SaveCalibrationFile error");
- m_CalibUnit->SetSaveCalibrationFileFinish(false);
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- SaveCalibrationFile over");
- return Ret;
- }
- void nsFPD::FPDDevicePZMedical::FullImageDateArrived(WORD* pImg)
- {
- FINFO("--Func-- FullImageDateArrived");
- AddFrameWithRawHead(IMAGE_FULL, pImg, m_nFullImageWidth * m_nFullImageHeight);
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::SetRequestedDose(std::string strDose)
- {
- FINFO("--Func-- SetRequestedDose");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
- {
- printf("--Func-- GetCalibrationStep\n");
- FINFO("--Func-- GetCalibrationStep");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("Calibration DetectorID: {$}", nDetectorID);
- ResDataObject out;
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- if (g_pDetector->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound))
- {
- FINFO("GetCalibrationStep success");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("GetCalibrationStep error");
- Ret = RET_STATUS::RET_FAILED;
- }
- out.add("CalibrationRounds", (int)m_CalibDoseList.size());
- out.add("TotalExposureNum", m_nCalibTotalExposureNum);
- out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
- out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]);
- out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
- out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
- strCalibrationStepInfo = out.encode();
- FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::PauseCalibration()
- {
- printf("--Func-- PauseCalibration\n");
- FINFO("--Func-- PauseCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- m_nXrayCalibNum++;
- int nDose = (int)m_fDoseParam;
- if (nDose == 25 && m_nXrayCalibNum == 10)
- {
- FINFO("start to waitting CalibDoseEvt");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- }
- else if (nDose != 25)
- {
- if (m_nXrayCalibNum != 13)
- {
- FINFO("start to waitting CalibDoseEvt");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- }
- }
- if (m_nXrayCalibNum != 13)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PauseCalibration
- }
- FINFO("Driver PauseCalibration over,m_nXrayCalibNum {$}", m_nXrayCalibNum);
- FINFO("--Func-- PauseCalibration over");
- return Ret;
- }
- bool nsFPD::FPDDevicePZMedical::CompleteCalibration()
- {
- FINFO("--Func-- CompleteCalibration");
- g_pDetector->CompleteCalibration(this);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//CompleteCalibration
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- FINFO("--Func-- CompleteCalibration over");
- return true;
- }
- void nsFPD::FPDDevicePZMedical::AbortCalibration()
- {
- FINFO("--Func-- AbortCalibration");
- m_eAppStatus = APP_STATUS_CAL_END;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- m_AcqUnit->SendNoNeedWaitImage(true);
- g_pDetector->AbortCalibration(this);
- FINFO("--Func-- AbortCalibration over");
- }
- void nsFPD::FPDDevicePZMedical::OnProcessTemperature(int nID, float fTemperature)
- {
- string strWarnErrorCode = "";
- float fMaxTempGap = 6.0f;
- if (m_stDeviceConfig.strDeviceName.find("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0)
- {
- fMaxTempGap = 12.0f;
- }
- if (fTemperature >= m_stDeviceConfig.fTemperatureErrorMax)
- {
- FINFO("Exceed Max Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH;
- if (m_stDeviceConfig.bActived)
- {
- strWarnErrorCode = "ERR_FPD_TEMPHIGH_NOT_ACQ";
- }
- }
- else if (fTemperature <= m_stDeviceConfig.fTemperatureErrorMin)
- {
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW;
- if (m_stDeviceConfig.bActived)
- {
- FINFO("Exceed Min Temperature");
- strWarnErrorCode = "ERR_FPD_TEMPLOW_NOT_ACQ";
- }
- }
- else if (fTemperature <= m_stDeviceConfig.fTemperatureWarnMin)
- {
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- FINFO("Exceed Temperature Low Warning");
- strWarnErrorCode = "WAR_FPD_TEMPERTURE_LOW";
- }
- else if (fTemperature > m_stDeviceConfig.fTemperatureWarnMax)
- {
- FINFO("Exceed Temperature High Warning");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- strWarnErrorCode = "WAR_FPD_TEMPERATURE_HIGH";
- }
- else if ((fTemperature <= m_stDeviceConfig.fTemperatureWarnMax) && (fTemperature > m_stDeviceConfig.fTemperatureWarnMin))
- {
- //FINFO("Temperature Normal");
- }
- }
- //慎重调用,可能会导致板出问题,硬reset需要很长时间
- RET_STATUS nsFPD::FPDDevicePZMedical::Reset()
- {
- FINFO("--Func-- Reset");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->ResetDetector(this))
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- Reset over");
- return Ret;
- }
- /***
- * 客户端获取探测器信息
- ***/
- RET_STATUS nsFPD::FPDDevicePZMedical::GetDetectorInfo(string& strFDI)
- {
- ResDataObject strDetectorInfo;
- FINFO("GetDetectorInfo m_stDeviceConfig.strPanelSerial:{$}", m_stDeviceConfig.strPanelSerial);
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- FERROR("strPanelSerial is null!!! 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");
- 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("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("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0)
- {
- strDetectorInfo.add("SystemAS", 3);
- }
- else
- {
- strDetectorInfo.add("SystemAS", 3);
- }
- //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("ShockSensor", m_nShockCounts);
- strDetectorInfo.add("FirmwareUpdate", 0);
- strFDI = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::ActiveSyncMode(int nSyncMode)
- {
- FINFO("--Func-- ActiveSyncMode nSyncMode:{$}", nSyncMode);
- m_eSyncMode = (SYNC_MODE)nSyncMode;
- bool bRet = g_pDetector->ActiveSyncMode(nSyncMode);
- if (bRet)
- {
- FINFO("ActiveSyncMode Success!");
- return RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("ActiveSyncMode Fail!");
- return RET_STATUS::RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode)
- {
- FINFO("--Func-- UpdateCalibMode eCalibMode:{$}", (int)eCalibMode);
- m_stDeviceConfig.nCalibMode = (int)eCalibMode;
- if (g_pDetector->UpdateCalibMode(eCalibMode))
- {
- FINFO("UpdateCalibMode success!");
- return RET_SUCCEED;
- }
- else
- {
- FERROR("UpdateCalibMode fail!");
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateNotifyStatusTimePeriod(int nTime)
- {
- FINFO("--Func-- UpdateNotifyStatusTimePeriod nTime:{$}", nTime);
- m_stDeviceConfig.nNotifyStatusTimePeriod = nTime;
- g_pDetector->SetNotifyStatusTimePeriod(nTime);
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateReconnectTimePeriod(int nTime)
- {
- FINFO("--Func-- UpdateReconnectTimePeriod nTime:{$}", nTime);
- m_stDeviceConfig.nReconnectTimePeriod = nTime;
- g_pDetector->SetReconnectTimePeriod(nTime);
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateDetectorWiredIP(string strWiredIP)
- {
- FINFO("--Func-- UpdateDetectorWiredIP strWiredIP:{$}", strWiredIP);
- bool bRet = g_pDetector->SetDetectorWiredIP(strWiredIP);
- if (!bRet)
- {
- return RET_FAILED;
- }
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateDetectorWirelessIP(string strWirelessIP)
- {
- FINFO("--Func-- UpdateDetectorWirelessIP strWirelessIP:{$}", strWirelessIP);
- bool bRet = g_pDetector->SetDetectorWirelessIP(strWirelessIP);
- if (!bRet)
- {
- return RET_FAILED;
- }
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateLastCalibrationDate(std::string in)
- {
- FINFO("--Func-- UpdateLastCalibrationDate in:{$}", in);
- m_stDeviceConfig.strLastCalibrationDate = in;
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateCalibrationFileExpireTime(std::string in)
- {
- FINFO("--Func-- UpdateCalibrationFileExpireTime in:{$}", in);
- m_stDeviceConfig.strCalibrationFileExpireTime = in;
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::UpdateCalibrationFileExpirationReminder(std::string in)
- {
- FINFO("--Func-- UpdateCalibrationFileExpirationReminder in:{$}", in);
- m_stDeviceConfig.strCalibrationFileExpirationReminder = in;
- return RET_SUCCEED;
- }
|