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