1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.PZMedicalDM.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "PZMedicalCtrl.h"
- #include <sys/stat.h>
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- //-----------------------------------------------------------------------------
- // FPDDevicePZMedical
- //-----------------------------------------------------------------------------
- extern PZMedicalCtrl* g_pDetector;
- //-----------------------------------------------------------------------------
- // GetIODriver & CreateIODriver
- //-----------------------------------------------------------------------------
- static nsFPD::PZMedicalDriver gIODriver;
- Log4CPP::Logger* gLogger = nullptr;
- extern const char* g_szMouldPath;
- /// <summary>
- /// [DONE.CHECKED.]
- /// </summary>
- /// <returns></returns>
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- /// <summary>
- /// [DONE.TO BE TESTED.]
- /// </summary>
- /// <returns></returns>
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsFPD::PZMedicalDriver();
- }
- /// <summary>
- /// 驱动构造函数
- /// [DONE.CHECKED.]
- /// </summary>
- nsFPD::PZMedicalDriver::PZMedicalDriver()
- {
- m_pObjDev = nullptr;
- m_bDriverConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- /// <summary>
- /// [DONE.TO BE TESTED.]
- /// </summary>
- nsFPD::PZMedicalDriver::~PZMedicalDriver()
- {
- if(m_pObjDev != nullptr)
- {
- delete m_pObjDev;
- m_pObjDev = nullptr;
- }
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- /// <summary>
- /// 驱动的准备,可以做一些特殊的操作
- /// [DONE.CHECKED.] TBD.
- /// </summary>
- void nsFPD::PZMedicalDriver::Prepare()
- {
- printf("--Driver-- prepare \r\n");
- string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("Module");
- FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
- #ifdef _WIN64
- FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #else
- FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #endif
- FINFO("Driver Prepare get logger");
- }
- /// <summary>
- /// 驱动的连接,创建设备对象
- /// [DONE.CHECKED.]
- /// </summary>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::Connect()
- {
- printf("PZMedical driver module: Connect \r\n");
- FINFO("--Func-- driver connect");
- m_pObjDev = new FPDDevicePZMedical(EventCenter, m_ConfigFileName);
- m_bDriverConnect = true; //connect执行完毕,置为true
- printf("PZMedical driver module: Connect over\r\n");
- return true;
- }
- /// <summary>
- /// 驱动断开连接,释放设备对象
- /// </summary>
- void nsFPD::PZMedicalDriver::Disconnect()
- {
- printf("PZMedical driver module: Disconnect \r\n");
- FINFO("--Func-- driver disconnect");
- if (m_pObjDev != nullptr)
- {
- delete m_pObjDev;
- m_pObjDev = nullptr;
- }
- m_bDriverConnect = false; //disconnect置为false
- }
- bool nsFPD::PZMedicalDriver::isConnected() const
- {
- return m_bDriverConnect;
- }
- /// <summary>
- /// 驱动创建设备丢下,然后 给 上层返回 IODevice 对象指针
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- auto nsFPD::PZMedicalDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("PZMedical driver module: CreateDevice \r\n");
- FINFO("--Func-- driver createdevice");
- auto Device = std::unique_ptr<IODevice>(new IODevice(m_pObjDev));
- m_pObjDev->CreateDevice();
- m_pObjDev->Register();
- return Device;
- }
- /// <summary>
- /// 驱动信息检索 TODO : 需要重新定义
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::PZMedicalDriver::DriverProbe()
- {
- printf("PZMedical driver module: Driver Probe \r\n");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "DM");
- HardwareInfo.add("VendorID", "PZMedical");
- HardwareInfo.add("ProductID", "PZMedical");
- HardwareInfo.add("SerialID", "Driver");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /// <summary>
- /// 从配置文件中返回给上层 配置对象
- /// 标准代码
- /// [DONE.CHECKED.]
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::PZMedicalDriver::GetResource()
- {
- printf("PZMedical driver: GetResource \r\n");
- FINFO("PZMedical driver: GetResource");
- printf("m_ConfigFileName:%s\n", m_ConfigFileName.c_str());
- FINFO("m_ConfigFileName:{$}", m_ConfigFileName);
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- return "";
- }
- m_ConfigAll = temp;
- r_config = temp["CONFIGURATION"];
- m_Configurations = r_config;
- ResDataObject DescriptionTemp;
- ResDataObject ListTemp;
- string strTemp = ""; //用于读取字符串配置信息
- string strIndex = ""; //用于读取配置信息中的List项
- int nTemp = -1; //用于读取整型配置信息
- char sstream[10] = { 0 }; //用于转换值
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- string strAccess = ""; //用于存储权限的类型 R/W/RW
- string strRequired = ""; // TRUE/FALSE
- string strDefaultValue = "";
- string strRangeMin = "";
- string strRangeMax = "";
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- //FINFO(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
- m_pAttribute->clear();
- m_pDescription->clear();
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- DescriptionTemp.clear();
- ListTemp.clear();
- //AttributeType
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
- DescriptionTemp.add(AttributeType, strTemp.c_str());
- //FINFO("DescriptionTemp--> {$}: {$}", AttributeType, strTemp.c_str());
- strType = strTemp; //记录配置项的类型
- //AttributeKey
- //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
- GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
- //2. 赋值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if ("int" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
- }
- //AttributeList
- nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
- if (nTemp > 0) //ListNum不大于0时说明不需要list配置
- {
- for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
- //sprintf_s(sstream, "{$}", nListIndex);
- auto temKey = std::to_string(nListIndex);
- ListTemp.add(temKey.c_str(), strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Get config error: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
- m_DeviceConfig = DescriptionTempEx;
- string res = DescriptionTempEx.encode();
-
- printf("PZMedical driver module: get resource over \r\n");
- return res;
- }
- /// <summary>
- /// 设备信息检索 TODO : 需要重新定义,TBD.
- /// </summary>
- /// <returns></returns>
- std::string nsFPD::PZMedicalDriver::DeviceProbe()
- {
- printf("PZMedical driver module: Device Probe \r\n");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", "PZMedical");
- HardwareInfo.add("ProductID", "PZMedical");
- HardwareInfo.add("SerialID", "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /// <summary>
- /// 设备配置读取接口
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="Cfg"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::GetDeviceConfig(std::string& Cfg)
- {
- Cfg = m_DeviceConfig.encode();
- FINFO("GetDeviceConfig over");
- return true;
- }
- /// <summary>
- /// 提供给web配置中心的 配置写入接口
- /// [DONE.CHECKED.]
- /// </summary>
- /// <param name="Cfg"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::SetDeviceConfig(std::string Cfg)
- {
- FINFO("--Func-- SetDeviceConfig {$}\n", Cfg.c_str());
- ResDataObject DeviceConfig;
- DeviceConfig.decode(Cfg.c_str());
- ResDataObject DescriptionTempEx;
- DescriptionTempEx = DeviceConfig["DeviceConfig"];
- bool bSaveFile = false; //true:重新保存配置文件
- string strAccess = "";
- for (int i = 0; i < DescriptionTempEx.size(); i++)
- {
- ResDataObject temp = DescriptionTempEx[i];
- FINFO("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- FINFO("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess || "rw" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //4. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- /// <summary>
- /// 保存配置到文件
- /// [DONE.TO BE TESTED.]
- /// </summary>
- /// <param name="bSendNotify"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::SaveConfigFile(bool bSendNotify)
- {
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- FINFO("SaveConfigFile over, m_ConfigAll:{$}", m_ConfigAll.encode());
- return true;
- }
- /// <summary>
- /// 读取当前配置项
- /// TBD. 审视参数列表
- /// </summary>
- /// <param name="config"></param>
- /// <param name="pInnerKey"></param>
- /// <param name="nPathID"></param>
- /// <param name="strValue"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
- {
- strValue = "";
- string strTemp = pInnerKey;
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- strValue = (string)config["connections"][pInnerKey];
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp || ImageWidth == strTemp || IsSaveRaw == strTemp
- || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp || WidthOffset == strTemp || HeightOffset == strTemp)
- {
- strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
- }
- else if (TempMaxLimit == strTemp || TempMinLimit == strTemp || TempUpperLimit == strTemp
- || TempLowerLimit == strTemp || ReConnect == strTemp || BatLowerLimit == strTemp
- || BatMiniLimit == strTemp || BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp
- || WifiMiniLimit == strTemp || HighPowerTimeout == strTemp
- || ShowTemperature == strTemp || ShowWifi == strTemp
- || ShowBattery == strTemp || ShowBluetooth == strTemp
- || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp
- || CcosDetectorAttachedFlag == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- FERROR("Error Configuration item: {$}", pInnerKey);
- }
- }
- return true;
- }
- /// <summary>
- /// 设置写入设备参数实现,这里过滤需要设置本探测器接受的参数
- /// 参数项和内容来源于 探测器配置文件 <ConfigToolInfo> <AttributeInfo>
- /// TBD. 具体内容
- /// comment by chenggw 2023.2.7
- /// </summary>
- /// <param name="config"></param>
- /// <param name="pInnerKey"></param>
- /// <param name="nPathID"></param>
- /// <param name="szValue"></param>
- /// <returns></returns>
- bool nsFPD::PZMedicalDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- FINFO("Begin to change {$} item value to {$}", pInnerKey, szValue);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- config["connections"][pInnerKey] = szValue;
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp || ImageWidth == strTemp || IsSaveRaw == strTemp
- || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp || WidthOffset == strTemp || HeightOffset == strTemp)
- {
- config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
- }
- else if (TempMaxLimit == strTemp || TempMinLimit == strTemp || TempUpperLimit == strTemp
- || TempLowerLimit == strTemp || ReConnect == strTemp || BatLowerLimit == strTemp
- || BatMiniLimit == strTemp || BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp
- || WifiMiniLimit == strTemp || HighPowerTimeout == strTemp
- || ShowTemperature == strTemp || ShowWifi == strTemp
- || ShowBattery == strTemp || ShowBluetooth == strTemp
- || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp
- || CcosDetectorAttachedFlag == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else
- {
- FERROR("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- nsFPD::FPDDevicePZMedical::FPDDevicePZMedical(std::shared_ptr<IOEventCenter> center, std::string strConfigPath)
- : m_nCalibTotalExposureNum(0),
- m_nCalibCurrentCalibrationRound(0),
- m_nCalibCurrentExposureIndex(0),
- m_nCalibCurrentExposureNum(0),
- m_bImagePendingOrNot(false),
- m_bResetDetector(false)
- {
- m_bConnect = false;
- m_nFullImageHeight = 0;
- m_nFullImageWidth = 0;
- m_nImageBits = 0;
- m_nPixelSpacing = 0;
- m_pwFullImageData = nullptr;
- m_pwPreviewImg = nullptr;
- m_nSensitivity = 0;
- m_nRotateAngle = 180;
- m_eAppStatus = APP_STATUS_IDLE;
- m_eSyncMode = SYNC_SOFTWARE;
- m_nShockCounts = 0;
- m_strWorkPath = GetProcessDirectory();
- m_DetectorCtrlUnit.reset(new PZMedicalCtrlUnit(center, this));
- m_AcqUnit.reset(new PZMedicalAcq(center, this));
- m_SyncUnit.reset(new PZMedicalSync(center, this));
- m_CalibUnit.reset(new PZMedicalCalib(center, this));
- m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
- //探测器告警及错误消息
- m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_WaitCalibDoseEvt = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_PauseCalibrationEvt = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_UploadCalibMapOver = CreateEvent(NULL, FALSE, FALSE, NULL);
- m_pFullImageHead = nullptr;
- m_pPreviewImageHead = nullptr;
- EventCenter = center;
- m_strCurrentAcqMode = "";
- }
- nsFPD::FPDDevicePZMedical::~FPDDevicePZMedical()
- {
- if (m_pwFullImageData)
- {
- delete[]m_pwFullImageData;
- m_pwFullImageData = nullptr;
- }
- if (m_pwPreviewImg)
- {
- delete[]m_pwPreviewImg;
- m_pwPreviewImg = nullptr;
- }
- if (m_WaitCalibDoseEvt)
- {
- CloseHandle(m_WaitCalibDoseEvt);
- m_WaitCalibDoseEvt = nullptr;
- }
- if (m_PauseCalibrationEvt)
- {
- CloseHandle(m_PauseCalibrationEvt);
- m_PauseCalibrationEvt = nullptr;
- }
- if (m_UploadCalibMapOver)
- {
- CloseHandle(m_UploadCalibMapOver);
- m_UploadCalibMapOver = nullptr;
- }
- }
- std::string nsFPD::FPDDevicePZMedical::GetGUID() const
- {
- printf("--Func-- GetGUID \r\n");
- FINFO("--Func-- GetGUID");
- return DetectorUnitType;
- }
- bool nsFPD::FPDDevicePZMedical::Prepare()
- {
- printf("--Func-- Prepare \r\n");
- FINFO("--Func-- device prepare");
- EventCenter->OnMaxBlockSize("PZDmQue", 4000 * 4000 * 2, 3, 1500 * 1500 * 2, 1);
- Connect();
- return true;
- }
- bool nsFPD::FPDDevicePZMedical::CreateDevice()
- {
- printf("--Func-- CreateDevice \r\n");
- FINFO("--Func-- CreateDevice");
- if (!LoadConfig())
- {
- return false;
- }
- if (nullptr == g_pDetector)
- {
- g_pDetector = new PZMedicalCtrl();
- FINFO("Create PZMedicalCtrl");
- }
- else
- {
- FERROR("PZMedicalCtrl Already exit");
- }
- g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- return true;
- }
- void nsFPD::FPDDevicePZMedical::Register()
- {
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::Connect()
- {
- printf("--Func-- Connect \r\n");
- FINFO("--Func-- Connect");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- FINFO("Connect m_strWorkPath:{$}", m_strWorkPath.c_str());
- if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::EnterExam(int nExamMode)
- {
- FINFO("--Func-- EnterExam {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS_WORK_END:
- FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- FINFO("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS_DETSHAR_END:
- m_eAppStatus = APP_STATUS_IDLE;
- FINFO("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS_CAL_BEGIN:
- FINFO("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS_CAL_END:
- FINFO("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_END;
- break;
- case APP_STATUS_WORK_IN_SENSITIVITY:
- FINFO("Enter into sensitivity test interface");
- m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
- break;
- default:
- break;
- }
- g_pDetector->EnterExamMode(nExamMode);
- return RET_STATUS::RET_SUCCEED;
- }
- /***
- * 这是切换探测器的接口
- ***/
- RET_STATUS nsFPD::FPDDevicePZMedical::ActiveDetector(int nDetectorIndex, bool bActive)
- {
- printf("--Func-- ActiveDetector(%d) to (%d) \r\n", nDetectorIndex, bActive);
- FINFO("--Func-- ActiveDetector {$} to {$}", nDetectorIndex, bActive);
- RET_STATUS ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector == nullptr)
- {
- printf("PZMedicalCtrl object is not exist, return RET_FAILED\n");
- FERROR("PZMedicalCtrl object is not exist, return RET_FAILED");
- return RET_STATUS::RET_FAILED;
- }
-
- return ret;
- }
- //品臻板目前不支持AEC
- bool nsFPD::FPDDevicePZMedical::GetLogicMode(string& strAcqMode, int& nLogicMode)
- {
- if (strAcqMode == "RAD")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "AEC")
- {
- nLogicMode = AEC;
- }
- else if (strAcqMode == "1")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "2")
- {
- nLogicMode = AEC;
- }
- else
- {
- FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- //设置采集模式 1-RAD 2-AEC
- RET_STATUS nsFPD::FPDDevicePZMedical::SetAcqMode(string strAcqMode)
- {
- printf("--Func-- SetAcqMode %s \n", strAcqMode.c_str());
- FINFO("--Func-- SetAcqMode {$}", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接则返回
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (m_strCurrentAcqMode == strAcqMode)
- {
- FINFO("Same acq mode, return true");
- return RET_STATUS::RET_SUCCEED;
- }
- int nMode = RAD;
- bool bRet = GetLogicMode(strAcqMode, nMode);
- if (!bRet)
- {
- return ret;
- }
- try
- {
- ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
- int nModeCount = (int)objModeConfig["ModeTable"].size();
- for (int i = 0; i < nModeCount; i++)
- {
- int nLogicMode = (int)objModeConfig["ModeTable"][i]["LogicMode"];
- if (nLogicMode == nMode)
- {
- FINFO("find LogicMode == AcqMode");
- //由于3025ZF出图的宽高不定,所以宽高不从配置文件读取,上图之前调用接口查询宽高然后再推图
- //m_nFullImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"];
- //m_nFullImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"];
- m_nImageBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
- m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
- m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"];
- m_eSyncMode = (SYNC_MODE)(int)objModeConfig["ModeTable"][i]["SyncType"];
- m_nRotateAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
- FINFO("m_nImageBits:{$},m_nPixelSpacing:{$},m_nSensitivity:{$},m_eSyncMode:{$},RotateAngle:{$}",
- m_nImageBits, m_nPixelSpacing, m_nSensitivity, (int)m_eSyncMode, m_nRotateAngle);
- string strSensitivity = to_string(m_nSensitivity);
- m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity);
- m_fFactorEXI2UGY = 100.0f / (float)atof(strSensitivity.c_str()) * 1.0f;//子系统将UI的TargetEXI 乘以 FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头
- FINFO("m_fFactorEXI2UGY = {$}", m_fFactorEXI2UGY);
- //读取DetectorMode配置,并为imagebuffer申请内存空间
- if (g_pDetector->SetAcqMode(nLogicMode, this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- break;
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Read configuration failed, Error code: {$}", e.what());
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::PrepareAcquisition()
- {
- printf("--Func-- PrepareAcquisition \n");
- FINFO("--Func-- PrepareAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
-
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- printf("PrepareAcquisition failed. Detector at Calibration status.\n");
- FERROR("PrepareAcquisition failed. Detector at Calibration status");
- return ret;
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("Detector already at Acq status.\n");
- FERROR("Detector already at Acq status");
- ret = RET_STATUS::RET_SUCCEED; //进检查后退检查,如果再次调用prepare,在这里防护
- }
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- FINFO("--Func-- PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StartAcquisition(string in)
- {
- printf("--Func-- StartAcquisition \n");
- FINFO("--Func-- StartAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- printf("PrepareAcquisition failed. Detector at Calibration status.\n");
- FERROR("PrepareAcquisition failed. Detector at Calibration status.");
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("Detector already at Acq status.\n");
- FERROR("Detector already at Acq status.");
- }
- }
- else
- {
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- printf("StartAcquisition fail!\n");
- FINFO("StartAcquisition fail!");
- }
- }
- FINFO("--Func-- StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StopAcquisition()
- {
- printf("--Func-- StopAcquisition \n");
- FINFO("--Func-- StopAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("Detector status already is standby\n");
- FINFO("Detector status already is standby");
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- printf("StopAcquisition 111\n");
- FINFO("StopAcquisition 111");
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//StopAcquisition
- }
- }
- FINFO("--Func-- StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- printf("--Func-- ActiveCalibration %d \n", eType);
- FINFO("--Func-- ActiveCalibration type {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- printf("Detector not connected, return\n");
- FERROR("Detector not connected, return");
- return ret;
- }
- if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
- {
- return RET_STATUS::RET_INVALID;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("detector status is not standby!\n");
- FERROR("detector status is not standby!");
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- printf("ActiveCalibration->Detector at Acq status need stop acquisition\n");
- FERROR("ActiveCalibration->Detector at Acq status need stop acquisition");
- printf("ActiveCalibration stop acquisition\n");
- FERROR("ActiveCalibration stop acquisition");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- printf("stop acquisition error\n");
- FERROR("stop acquisition error");
- return ret;
- }
- }
- }
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- printf("calibration type: CCOS_CALIBRATION_TYPE_XRAY\n");
- FINFO("calibration type: CCOS_CALIBRATION_TYPE_XRAY");
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- g_pDetector->SetReferenceNum(nCalibrationRounds);
- }
- if (g_pDetector->ActiveCalibration(this, eType))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
- m_CalibUnit->SetCalibrationProgress("0");
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- FINFO("start to waitting CalibDoseEvt");
- printf("start to waitting CalibDoseEvt\n");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- }
- m_nXrayCalibNum = 0;
- }
- else
- {
- printf("Active calibration failed!\n");
- FERROR("Active calibration failed!");
- }
- //重置校正流程参数
- m_nCalibCurrentCalibrationRound = 1;
- m_nCalibCurrentExposureIndex = 1;
- m_nCalibCurrentExposureNum = 0;
- ret = RET_STATUS::RET_SUCCEED;
- printf("ActiveCalibration over\n");
- FINFO("--Func-- ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration------ \n");
- FINFO("--Func-- PrepareCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- printf("Detector not connected, return\n");
- FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->PrepareCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("Prepare calibration failed");
- }
- FINFO("--Func-- PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::GetRequestedDose(std::string& strDose)
- {
- printf("--Func-- GetRequestedDose------ \n");
- FINFO("--Func-- GetRequestedDose");
- if (!m_bConnect)
- {
- return RET_STATUS::RET_THREAD_INVALID;
- }
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- bool bGetDoseInfo = false;
- ResDataObject out;
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- FINFO("GetRequestedDose calib type is {$}",(int)nCalibrationType);
- printf("GetRequestedDose calib type is %d\n",nCalibrationType);
- if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
- {
- out.add("Dose", 0.0f);
- out.add("kV", 0.0f);
- out.add("mA", 0.0f);
- out.add("ms", 0.0f);
- out.add("mAs", 0.0f);
- bGetDoseInfo = true;
- }
- else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
- {
- FINFO("calib dose list size is {$}",m_CalibDoseList.size());
- printf("calib dose list size is %d\n",(int)m_CalibDoseList.size());
- for (int i = 0; i < m_CalibDoseList.size(); i++)
- {
- ResDataObject temp = m_CalibDoseList[i];
- int nDose = temp["Dose"];
- int nDoseParem = (int)(m_fDoseParam * 1000);
- if (nDoseParem == nDose)
- {
- out.add("Dose", nDoseParem);
- out.add("kV", temp["kV"]);
- out.add("mA", temp["mA"]);
- out.add("ms", temp["ms"]);
- out.add("mAs", temp["mAs"]);
- bGetDoseInfo = true;
- FINFO("Find target dose parameter");
- break;
- }
- }
- }
- else
- {
- FERROR("Can not support CalibrationType($)", (int)nCalibrationType);
- Ret = RET_STATUS::RET_FAILED;
- }
- if (bGetDoseInfo)
- {
- strDose = out.encode();
- FINFO("GetRequestedDose:{$}", strDose.c_str());
- }
- else
- {
- FERROR("GetRequestedDose failed");
- }
- FINFO("--Func-- GetRequestedDose over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StartCalibration()
- {
- printf("--Func-- StartCalibration------ \n");
- FINFO("--Func-- StartCalibration");
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Ret = RET_STATUS::RET_THREAD_INVALID;
- FERROR("detector is not connected");
- return Ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FERROR("ActiveCalibration failed. Detector at Acq status");
- }
- Ret = RET_STATUS::RET_FAILED;
- return Ret;
- }
- if (g_pDetector->StartCalibration(this))
- {
- printf("start calibration success set detector status\n");
- FINFO("start calibration success set detector status");
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- printf("StartCalibration over\n");
- FINFO("--Func-- StartCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::StopCalibration()
- {
- printf("--Func-- StopCalibration------ \n");
- FINFO("--Func-- StopCalibration");
- RET_STATUS Ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return Ret;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- if (RET_STATUS::RET_SUCCEED == g_pDetector->AbortCalibration(this))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- Ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- StopCalibration over");
- return Ret;
- }
- //create device 时调用
- bool nsFPD::FPDDevicePZMedical::LoadConfig()
- {
- printf("--Func-- LoadConfig \r\n");
- FINFO("--Func-- LoadConfig");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
- {
- FERROR("Load configuration file failed!!!");
- return false;
- }
- if (!m_DetectorConfiguration->LoadCalibrationDose(m_strWorkPath, m_CalibDoseList, m_nCalibTotalExposureNum))
- {
- FERROR("Load Calibration Dose failed!!!");
- return false;
- }
- if (m_stDeviceConfig.nForceGridSuppress > 0)
- {
- m_bForceGridSuppress = true;
- }
- else
- {
- m_bForceGridSuppress = false;
- }
- int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag];
- if (nAttached == 1)
- {
- m_DetectorCtrlUnit->SetAttachStatus("1");
- }
- else
- {
- m_DetectorCtrlUnit->SetAttachStatus("0");
- }
- string strTemp = (string)m_DetectorConfiguration->m_Configurations[DetectorModel];
- m_DetectorCtrlUnit->SetDetectorType(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations[DetectorDescription];
- m_DetectorCtrlUnit->SetDescription(strTemp);
- m_DetectorCtrlUnit->SetTargetEXI("5000");
- m_Battery.reset(new DeviceBatteryMould("GetRemainPowerValue", 0,
- m_stDeviceConfig.nBatteryLimit,
- m_stDeviceConfig.nBatteryWarning,
- 100, 0, 100, 100,
- 0, EventCenter));
- m_Temperature.reset(new DeviceTemperatureMould("GetTemperatureValue", 0.0f,
- m_stDeviceConfig.fTemperatureMin,
- m_stDeviceConfig.fTemperLowLimit,
- m_stDeviceConfig.fTemperatureMax,
- m_stDeviceConfig.fTemperMaxLimit,
- 0.0f, 0.0f, 0.0f, EventCenter));
- m_Wifi.reset(new DeviceWifiMould("GetWifiStrengthValue", 0,
- m_stDeviceConfig.nWifiLimit,
- m_stDeviceConfig.nWifiWarning,
- 100, 0, 100, 100,
- 0, EventCenter));
-
- return true;
- }
- void nsFPD::FPDDevicePZMedical::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- Dispatch->Action.Push(ActionKey::AttachConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect);
- Dispatch->Action.Push(ActionKey::CancelAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach);
- Dispatch->Action.Push(ActionKey::ResetConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
- Dispatch->Action.Push(ActionKey::DisConnectFPD, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
- Dispatch->Action.Push(ActionKey::UpdateFirmware, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
- Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
- Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
- Dispatch->Action.Push(ActionKey::RecoverImage, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
- Dispatch->Action.Push(ActionKey::SaveSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
- Dispatch->Action.Push(ActionKey::RESET, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
- Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
- Dispatch->Get.Push(AttrKey::DetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus);
- Dispatch->Get.Push(AttrKey::DetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
- Dispatch->Get.Push(AttrKey::FPDShockSensorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
- Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
- Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- Dispatch->Get.Push(AttrKey::DetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);
- Dispatch->Get.Push(AttrKey::FieldofViewShape, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
- Dispatch->Get.Push(AttrKey::FieldofViewDimension, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
- Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
- Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
- Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
- Dispatch->Get.Push(AttrKey::DateofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
- Dispatch->Get.Push(AttrKey::TimeofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
- Dispatch->Get.Push(AttrKey::DetectorConditionsNominalFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
- Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
- Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
- Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
- }
- void nsFPD::FPDDevicePZMedical::RegisterAcq(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
- Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
- Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
- Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
- Dispatch->Get.Push(AttrKey::AutonumousMapFinish, m_AcqUnit.get(), &AcqUnit::JSAutonumousMapFinish);
- }
- void nsFPD::FPDDevicePZMedical::RegisterSync(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
- Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
- Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
- Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
- Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
- Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
- Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
- Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
- Dispatch->Get.Push(AttrKey::XrayON, m_SyncUnit.get(), &SyncUnit::JSGetXrayON);
- Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
- }
- void nsFPD::FPDDevicePZMedical::RegisterCalib(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
- Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
- Dispatch->Action.Push(ActionKey::SetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose);
- Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
- Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
- Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
- Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
- Dispatch->Action.Push(ActionKey::AcceptCalibration, m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration);
- Dispatch->Action.Push(ActionKey::RejectCalibration, m_CalibUnit.get(), &CalibUnit::JSRejectCalibration);
- Dispatch->Action.Push(ActionKey::SaveCalibrationFile, m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile);
- Dispatch->Action.Push(ActionKey::GetCalibrationStep, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep);
- Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
- Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
- Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
- Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
- Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
- }
- void nsFPD::FPDDevicePZMedical::RegisterOthers(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
- Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
- Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
- }
- void nsFPD::FPDDevicePZMedical::SendTemperatureValue(float fValue)
- {
- int nStatus = 0;
- m_Temperature->SetTemperature(fValue, nStatus);
- FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
- }
- void nsFPD::FPDDevicePZMedical::SendWifiValue(int nValue)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nValue, nStatus);
- FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
- }
- void nsFPD::FPDDevicePZMedical::SendBatteryValue(int nValue)
- {
- int nStatus = 0;
- m_Battery->SetRemainPowerValue(nValue, nStatus);
- FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
- }
- /// <summary>
- /// 探测器设备 所有 事件处理入口 @PZ_FPD
- /// conf/info/status/data/warning/error
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventLevel)
- {
- case EVT_LEVEL_CONFIGURATION:
- {
- OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_INFORMATOION:
- {
- OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_STATUS:
- {
- OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_DATA:
- {
- OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_WARNING:
- {
- OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_ERROR:
- {
- OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- default:
- break;
- }
- }
- int nsFPD::FPDDevicePZMedical::GetGainExposureNum()
- {
- return m_nCalibTotalExposureNum;
- }
- WORD* nsFPD::FPDDevicePZMedical::GetFullImageData()
- {
- return m_pwFullImageData;
- }
- /// <summary>
- /// 探测器设备 配置 事件处理 @PZ_FPD
- /// 暂不支持 配置
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_CONF_PANEL_SERIAL:
- {
- m_stDeviceConfig.strPanelSerial = pszMsg;
- FINFO("Detector ID:{$}, SN {$}", nDetectorID, pszMsg);
- m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
- break;
- }
- case EVT_CONF_RAW_WIDTH:
- {
- m_nFullImageWidth = nParam1;
- m_stDeviceConfig.nFullImageWidth = nParam1;
- FINFO("Call back Detector ID:{$}, Image Width:{$}", nDetectorID, m_nFullImageWidth);
- break;
- }
- case EVT_CONF_RAW_HIGHT:
- {
- m_nFullImageHeight = nParam1;
- m_stDeviceConfig.nFullImageHeight = nParam1;
- FINFO("Call back Detector ID:{$}, Image Height:{$}", nDetectorID, m_nFullImageHeight);
- break;
- }
- case EVT_CONF_RAW_BITS:
- {
- m_nImageBits = nParam1;
- m_stDeviceConfig.nImageBits = nParam1;
- FINFO("Detector ID:{$}, Image Bit:{$}", nDetectorID, m_nImageBits);
- break;
- }
- case EVT_CONF_PIXELSPACE:
- {
- m_nPixelSpacing = (int)fParam2;;
- m_stDeviceConfig.nPixelSpace = (int)fParam2;
- FINFO("Detector ID:{$}, nPixelSpace:{$}", nDetectorID, m_nPixelSpacing);
- break;
- }
- case EVT_CONF_PREVIEW_WIDTH:
- {
- if (m_stDeviceConfig.nPreviewWidth != nParam1)
- {
- m_stDeviceConfig.nPreviewWidth = nParam1;
- }
- FINFO("Detector ID:{$}, nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth);
- break;
- }
- case EVT_CONF_PREVIEW_HIGHT:
- {
- if (m_stDeviceConfig.nPreviewHeight != nParam1)
- {
- m_stDeviceConfig.nPreviewHeight = nParam1;
- }
- FINFO("Detector ID:{$}, nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_CONF_MODULE_TYPE:
- {
- //m_strModuleType = pszMsg;
- FINFO("Detector ID:{$}, ModuleType {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_IP:
- {
- //m_strModuleIP = pszMsg;
- FINFO("Detector ID:{$}, ModuleIP {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_SN:
- {
- //m_strModuleSN = pszMsg;
- FINFO("Detector ID:{$}, ModuleSN {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_FIRWARE_UPDATE:
- {
- m_stDeviceConfig.nFirmwareStatus = nParam1;
- FINFO("Detector ID:{$}, FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
- break;
- }
- case EVT_CONF_PART_NUMBER:
- {
- m_stDeviceConfig.strPartNumber = pszMsg;
- FINFO("Detector ID:{$}, PartNumber:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_BATTERY_SN:
- {
- //m_strBatterySN = pszMsg;
- FINFO("Detector ID:{$}, Battery SN:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_WIFI_SSID:
- {
- m_stDeviceConfig.strWifiSSID = pszMsg;
- FINFO("Detector ID:{$}, WifiSSID:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_IFBOARD:
- {
- m_stDeviceConfig.strInterfaceBoard = pszMsg;
- FINFO("Detector ID:{$}, InterfaceBoard:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_DATECODE:
- {
- m_stDeviceConfig.strDateCode = pszMsg;
- FINFO("Detector ID:{$}, DateCode:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_LIFETIME:
- {
- int nLifeTime = nParam1;
- if ((nLifeTime != m_stDeviceConfig.nLifeTime))
- {
- FINFO("LifeTime:{$}", nLifeTime);
- m_stDeviceConfig.nLifeTime = nLifeTime;
- }
- break;
- }
- default:
- break;
- }
- }
- /// <summary>
- /// 探测器设备 Info 事件处理 @PZ_FPD
- /// 暂不支持 Info
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- int nID = nDetectorID;
- switch (nEventID)
- {
- case EVT_INFO_POWER_ON:
- {
- int nPowerOn = nParam1;
- FINFO("Detector {$} PowerOn:{$}", nID, nPowerOn);
- if ((nPowerOn != m_stDeviceConfig.nPowerOn) /*&& (m_strBatterySN != "")*/)
- {
- m_stDeviceConfig.nPowerOn = nPowerOn;
- }
- break;
- }
- case EVT_INFO_BATTERY_CAPACITY:
- {
- int nBatteryCapacity = nParam1;
- if ((nBatteryCapacity != m_nBatteryCapacity) /*&& (m_strBatterySN != "")*/)
- {
- FINFO("{$}", nBatteryCapacity);
- m_nBatteryCapacity = nBatteryCapacity;
- }
- break;
- }
- case EVT_INFO_BATTERY_TEMPERATURE:
- {
- float fBatteryTemper = fParam2;
- if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) /*&& (m_strBatterySN != "")*/)
- {
- FINFO("temperature:%.2f", fBatteryTemper);
- m_fBatteryTemperature = fBatteryTemper;
- }
- break;
- }
- case EVT_INFO_BATTERY_CHARGES:
- {
- int nBatteryCharges = nParam1;
- if ((nBatteryCharges != m_nBatteryCharges)/* && (m_strBatterySN != "")*/)
- {
- FINFO("Charge number:{$}", nBatteryCharges);
- m_nBatteryCharges = nBatteryCharges;
- }
- break;
- }
- case EVT_INFO_WIFI_DATARATE:
- {
- m_stDeviceConfig.nWifiDataRate = nParam1;
- FINFO("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate);
- break;
- }
- case EVT_INFO_WIFI_CHANNEL:
- {
- m_stDeviceConfig.nWifiChannel = nParam1;
- FINFO("Panel {$} WifiChannel:{$}", nID, m_stDeviceConfig.nWifiChannel);
- break;
- }
- case EVT_INFO_WIFI_SIGNALPOWER:
- {
- m_stDeviceConfig.nWifiSignalPower = nParam1;
- break;
- }
- case EVT_INFO_WIFI_NOISEPOWER:
- {
- m_stDeviceConfig.nWifiNoisePower = nParam1;
- FINFO("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower);
- break;
- }
- case EVT_INFO_FIRMWARE:
- {
- m_stDeviceConfig.strFirmware = pszMsg;
- FINFO("Panel {$} Firmware:{$}", nID, pszMsg);
- break;
- }
- case EVT_INFO_SHOCKSENSOR_INFO:
- {
- FINFO("Receive ShockSensor Info");
- //m_strShockSensor = pszMsg;
- //m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor);
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIME:
- {
- m_stDeviceConfig.strCalibrationDate = pszMsg;
- FINFO("Panel {$} Calibration Time:{$}", nID, pszMsg);
- m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
- m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration("");
- break;
- }
- case EVT_INFO_CALIBRATIOIN_TIMEL:
- {
- m_stDeviceConfig.strCalibrationLTEDate = pszMsg;
- FINFO("Panel {$} Calibration LTE Time:{$}", nID, pszMsg);
- break;
- }
- case EVT_INFO_FPVOLTAGE:
- {
- //m_strVoltage = pszMsg;
- break;
- }
- default:
- break;
- }
- }
- /// <summary>
- /// 探测器设备状态事件 处理@PZ_FPD
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_STATUS_INIT:
- {
- if (PANEL_EVENT_END_OK == nParam1)
- {
- FINFO("EVT_STATUS_INIT PANEL_EVENT_END_OK");
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_FAILED));
- }
- else if (PANEL_EVENT_END == nParam1) //未连接探测器
- {
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS));
- }
- else if (PANEL_EVENT_START == nParam1)
- {
- m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START));
- }
- break;
- }
- case EVT_STATUS_MOTION:
- {
- //m_strMotionStatus = pszMsg;
- break;
- }
- case EVT_STATUS_UPDATE_FIRMWARE:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- FINFO("Start update firmware");
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START));
- }
- else if (PANEL_EVENT_BEGIN == nParam1)
- {
- FINFO("Update firmware begin");
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = false;
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- FINFO("Update firmware failed");
- //SendDetectorInfo(); //更新探测器状态图标
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR));
- }
- else if (PANEL_EVENT_SUCCESS == nParam1) //
- {
- FINFO("update firmware success");
- //SendDetectorInfo();
- m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS));
- }
- break;
- }
- case EVT_STATUS_SELFTEST:
- {
- break;
- }
- case EVT_STATUS_DETECTORSHARE:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_ATTACH_START:
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START)); //重置status,避免服务判重,两次attach失败时,不将第二次的失败信息发送给客户端
- FINFO("New Detector Attach start");
- break;
- case PANEL_ATTACH_OVER:
- {
- FINFO("New Detector Attach Over,Prepare to Connecting");
- //m_DetectorCtrlUnit->SetAttachResult(true, m_stDeviceConfig.strDeviceName.c_str(), m_strModuleSN.c_str());
- }
- break;
- case PANEL_ATTACH_FAILED: //UI显示Failed
- {
- FERROR("New Detector Attach failed\n");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED));
- break;
- }
- case PANEL_CONNECT_OK:
- {
- FINFO("EVT_STATUS_DETECTORSHARE PANEL_CONNECT_OK");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- break;
- }
- case PANEL_CONNECT_ERROR:
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
- break;
- }
- case PANEL_DISCONNECT_SUCCESS:
- {
- m_nBatteryCapacity = 0;
- //m_strBatterySN = "";
- m_stDeviceConfig.bExisted = false;
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = false;
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- break;
- }
- case PANEL_DISCONNECT_ERROR:
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SINGLEINIT:
- {
- break;
- }
- case EVT_STATUS_SELECTPANEL:
- {
- break;
- }
- case EVT_STATUS_PANEL:
- {
- ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
- if (PANEL_XWINDOW_ON == nParam1)
- {
- m_SystemTime = { 0 };
- GetLocalTime(&m_SystemTime);
- FINFO("XWindow on time {$}:{$}:{$}:{$}", m_SystemTime.wHour, m_SystemTime.wMinute, m_SystemTime.wSecond, m_SystemTime.wMilliseconds);
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1)
- {
- m_SystemTime = { 0 };
- GetLocalTime(&m_SystemTime);
- FINFO("XWindow off time {$}:{$}:{$}:{$}", m_SystemTime.wHour, m_SystemTime.wMinute, m_SystemTime.wSecond, m_SystemTime.wMilliseconds);
- m_SyncUnit->XWindowOffNotify();
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PANEL_READY_EXP
- }
- else if (PANEL_XRAY_ON == nParam1)
- {
- m_SyncUnit->XrayOnNotify();
- }
- else if (PANEL_XRAY_OFF == nParam1)
- {
- m_SyncUnit->XrayOffNotify();
- }
- else if (PANEL_START_ACQ == nParam1)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- break;
- }
- case EVT_STATUS_CALIBRATIOIN:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_END_OK:
- FINFO("Calibration process end ok");
- CompleteCalibration();
- break;
- case PANEL_EVENT_END_ERROR:
- FINFO("Calibration process end error");
- break;
- case PANEL_EVENT_START:
- FINFO("Calibration process start");
- break;
- case PANEL_EVENT_SUCCESS:
- FINFO("Calibration process success");
- break;
- case PANEL_EVENT_END:
- FINFO("Calibration process end");
- break;
- case PANEL_EVENT_BEGIN:
- FINFO("Calibration process begin");
- break;
- case PANEL_EVENT_TIMEOUT:
- FINFO("Calibration timeout");
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SAVECALIB:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- FINFO("Begin to Save Calibration Files");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- FINFO("Save Calibration Files failed");
- SetEvent(m_UploadCalibMapOver);
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- FINFO("Save Calibration Files Success");
- SetEvent(m_UploadCalibMapOver);
- }
- break;
- }
- case EVT_STATUS_SAVEDEFECT:
- {
- if (PANEL_EVENT_START == nParam1)
- {
- FINFO("Begin to Save Defect Files");
- }
- else if (PANEL_EVENT_END_ERROR == nParam1)
- {
- FINFO("Save Defect Files failed");
- SetEvent(m_UploadCalibMapOver);
- }
- else if (PANEL_EVENT_END == nParam1)
- {
- FINFO("Save Defect Files Success");
- m_stDeviceConfig.bTaskEnd = true;
- SetEvent(m_UploadCalibMapOver);
- }
- break;
- }
- case EVT_STATUS_ACQUISITION:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- FINFO("Acquisition start");
- break;
- case PANEL_EVENT_END_OK:
- FINFO("Acquisition end");
- break;
- case PANEL_EVENT_END_ERROR: //目前不会报错,不会走到这里
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SINGLEEXP:
- {
- if (DOSE_TOO_HIGH == nParam1)
- {
- FINFO("Dose too high");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");//make progress
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_TOO_LOW == nParam1)
- {
- FINFO("Dose too low");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");//make progress
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_OBJECT == nParam1)
- {
- FINFO("Dose object");
- StopCalibration();
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- //m_CalibUnit->SetCalibrationProgress(100);//make progress
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- else if (DOSE_ACCEPT == nParam1)
- {
- FINFO("Calibration Result is acceptable");
- //m_WarnAndError->OnErrorX("ERR_FPD_DOSE_INVALID");
- SetEvent(m_PauseCalibrationEvt);
- }
- else if (EVT_STATUS_LASTERROR == nParam1)
- {
- //m_strLastError = pszMsg;
- //FINFO("Panel {$} LastError {{$}}", nID, pszMsg);
- }
- break;
- }
- case EVT_STATUS_IMAGEPENDING:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_bImagePendingOrNot = true;
- }
- else
- {
- m_bImagePendingOrNot = false;
- }
- break;
- }
- case EVT_STATUS_TEMPERATURE:
- {
- float fTemperature = fParam2;
- OnProcessTemperature(nDetectorID, fTemperature);
- m_stDeviceConfig.fCurrentTemperValue = fTemperature;
- //FINFO("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature);
- SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
- break;
- }
- case EVT_STATUS_WIFI:
- {
- int nWifiLevel = nParam1;
- if (m_stDeviceConfig.strDeviceName.find("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0)
- {
- nWifiLevel = int(nWifiLevel / 0.75);
- if (nWifiLevel > 100)
- {
- nWifiLevel = 100;
- }
- }
- FINFO("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel);
- if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错
- {
- FINFO("nWifiLevel == 0, wired connection");
- }
- else if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
- {
- //达到wifi最低值限制
- }
- else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning)
- {
- //达到wifi警告值
- }
- FINFO("detector wifi level:%d", nWifiLevel);
- if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue)
- {
- FINFO("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate);
- }
- m_stDeviceConfig.nCurrentWifiValue = nWifiLevel;
- SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- int nBatteryValue = nParam1;
- m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue;
- FINFO("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue);
- SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
- break;
- }
- case EVT_STATUS_BATTERY_CHARGING:
- {
- break;
- }
- case EVT_STATUS_SHOCK_SENSOR:
- {
- break;
- }
- case EVT_STATUS_HALL_SENSOR:
- {
- break;
- }
- case EVT_STATUS_PING:
- {
- break;
- }
- case EVT_STATUS_PMSNOTOPEN:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- FINFO("PMS isn't open");
- }
- break;
- }
- case EVT_STATUS_RESTOREFILES:
- {
- break;
- }
- case EVT_STATUS_LASTERROR:
- {
- break;
- }
- case EVT_STATUS_RESET:
- {
- int nStatus = nParam1;
- if (PANEL_RESET_BEGIN == nStatus)
- {
- //弹出滚动条
- }
- else if (PANEL_RESET_OK == nStatus)
- {
- m_bResetDetector = false;
- }
- else if (PANEL_RESET_ERROR == nStatus)
- {
- // //OnError(nID,ERR_FPD_RESET,L"");
- }
- break;
- }
- case EVT_AUTONUMOUS_STATUS:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_CONNECT_ERROR:
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR));
- break;
- }
- case PANEL_CONNECT_OK:
- {
- FINFO("EVT_AUTONUMOUS_STATUS PANEL_CONNECT_OK");
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_stDeviceConfig.bConnectStatus = true;
- m_bConnect = true;//EVT_AUTONUMOUS_STATUS
- break;
- }
- case PANEL_DISCONNECT_SUCCESS:
- {
- m_nBatteryCapacity = 0;
- m_stDeviceConfig.bExisted = false;
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = false;
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- break;
- }
- case PANEL_DISCONNECT_ERROR:
- {
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR));
- break;
- }
- case PANEL_START_STOREDIMAGE:
- {
- FINFO("Send start autonumous to server");
- m_AcqUnit->SendAutonumousMapFinish(0);
- break;
- }
- case PANEL_END_STOREDIMAGE:
- {
- FINFO("Send finish autonumous to server");
- m_AcqUnit->SendAutonumousMapFinish(1);
- break;
- }
- case PANEL_EXPORT_AUTONUMOUS_FINISH:
- {
- FINFO("Send finish export local autonumous to server");
- m_AcqUnit->SendAutonumousMapFinish(2);
- break;
- }
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- }
- /// <summary>
- /// 探测器设备图像数据事件 处理 @PZ_FPD
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_DATA_RAW_IMAGE:
- {
- FINFO("Image Arrived Width:{$},Image Height:{$}", m_nFullImageWidth, m_nFullImageHeight);
- if (m_nRotateAngle == 90 || m_nRotateAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(m_nFullImageWidth, m_nFullImageHeight, m_nImageBits, false);
- }
- else
- {
- m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImageBits, false);
- }
- m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
- if (nullptr != m_pwFullImageData)
- {
- delete m_pwFullImageData;
- m_pwFullImageData = nullptr;
- }
- m_pwFullImageData = new WORD[m_nFullImageWidth * m_nFullImageHeight];
- memcpy(m_pwFullImageData, pParam, m_nFullImageWidth * m_nFullImageHeight * sizeof(WORD));
- if (0 != m_nRotateAngle)
- {
- FINFO("rotate image, m_nRotateAngle:{$}", m_nRotateAngle);
- m_AcqUnit->RotateImage(m_pwFullImageData, m_nFullImageHeight, m_nFullImageWidth, m_nRotateAngle);
- }
- OnProcessImage(m_pwFullImageData);
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- FINFO("Preview Image Arrved");
- FINFO("Current FPD preview image width: %d, height: %d", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- m_SyncUnit->ImageReadingNotify();
- if (NULL == m_pwPreviewImg)
- {
- m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight];
- }
- memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD));
- OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- break;
- }
- case EVT_DATA_DOSEPARAM:
- {
- m_fDoseParam = fParam2;
- SetEvent(m_WaitCalibDoseEvt);
- break;
- }
- default:
- FERROR("Not support this eventID (%d)", nEventID);
- break;
- }
- }
- /// <summary>
- /// 探测器设备 ERROR 事件处理 @PZ_FPD
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_ERR_COMMUNICATE:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_stDeviceConfig.nWorkstation = -1;
- m_stDeviceConfig.bConnectStatus = false;
- m_bConnect = false;
- m_nBatteryCapacity = 0;
- m_stDeviceConfig.fCurrentTemperValue = 0.0f;
- m_stDeviceConfig.nCurrentWifiValue = 0;
- m_stDeviceConfig.nCurrentBatteryValue = 0;
- SendWifiValue(m_stDeviceConfig.nCurrentWifiValue);
- SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue);
- SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue);
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- FINFO("EVT_ERR_COMMUNICATE false");
- m_stDeviceConfig.bConnectStatus = true;
- m_bConnect = true;//EVT_ERR_COMMUNICATE
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- }
- break;
- }
- case EVT_ERR_EXP_REQUEST:
- FERROR("OnEventProcessError EVT_ERR_EXP_REQUEST");
- break;
- case EVT_ERR_GET_IMAGE:
- FERROR("OnEventProcessError EVT_ERR_GET_IMAGE");
- break;
- case EVT_ERR_MAX_NUMBER:
- FERROR("OnEventProcessError EVT_ERR_MAX_NUMBER");
- break;
- case EVT_ERR_SN_NOTINLIST:
- FERROR("OnEventProcessError EVT_ERR_SN_NOTINLIST");
- break;
- case EVT_ERR_POWER_OFF:
- FERROR("OnEventProcessError EVT_ERR_POWER_OFF");
- break;
- case EVT_ERR_INIT_FAILED:
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- //AddErrMsg("6", "initialize error");
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- //一般不可恢复
- }
- break;
- }
- default:
- FERROR("Not support this error(%d)", nEventID);
- break;
- }
- }
- /// <summary>
- /// 探测器设备 WARNING 事件 处理 @PZ_FPD
- /// 当前版本不支持,TBD.
- /// </summary>
- /// <param name="nDetectorID"></param>
- /// <param name="nEventID"></param>
- /// <param name="nEventLevel"></param>
- /// <param name="pszMsg"></param>
- /// <param name="nParam1"></param>
- /// <param name="fParam2"></param>
- /// <param name="nPtrParamLen"></param>
- /// <param name="pParam"></param>
- void nsFPD::FPDDevicePZMedical::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this warn(%d)", nEventID);
- }
- bool nsFPD::FPDDevicePZMedical::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight)
- {
- FINFO("--Func-- OnProcessPreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight);
- PrevImageDateArrived(pwRawImage);
- return true;
- }
- void nsFPD::FPDDevicePZMedical::PrevImageDateArrived(WORD* pImg)
- {
- AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight);
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize)
- {
- string strImageHead = MakeImageHead(Type);
- FINFO("str image head:{$}",strImageHead);
- return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize);
- }
- string nsFPD::FPDDevicePZMedical::MakeImageHead(IMAGE_VIEW_TYPE Type)
- {
- if (m_pFullImageHead != NULL)
- {
- delete m_pFullImageHead;
- m_pFullImageHead = nullptr;
- }
- m_SystemTime = { 0 };
- GetLocalTime(&m_SystemTime);
- if (Type == IMAGE_FULL)
- {
- if (m_pFullImageHead == NULL)
- {
- m_pFullImageHead = new ResDataObject;
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_BIT, 16);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, m_SystemTime.wYear);
- json.add(SM_IMAGE_MONTH, m_SystemTime.wMonth);
- json.add(SM_IMAGE_DAY, m_SystemTime.wDay);
- json.add(SM_IMAGE_HOUR, m_SystemTime.wHour);
- json.add(SM_IMAGE_MINUTE, m_SystemTime.wMinute);
- json.add(SM_IMAGE_SEC, m_SystemTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, m_SystemTime.wMilliseconds);
- json.add(SM_IMAGE_LSB, "5000");
- json.add(SM_IMAGE_DOSE, m_nSensitivity);
- json.add(SM_IMAGE_PIXELREPRESENTATION, "1");
- json.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
- json.add(SM_IMAGE_FLIP, "No");
- json.add(SM_IMAGE_ORIGINX, "0");
- json.add(SM_IMAGE_ORIGINY, "0");
- json.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
- json.add(SM_IMAGE_TEMP, 0.0f);
- if (90 == m_nRotateAngle || 270 == m_nRotateAngle)
- {
- json.add(SM_IMAGE_WIDTH, m_nFullImageHeight);
- json.add(SM_IMAGE_HEIGHT, m_nFullImageWidth);
- json.add(SM_IMAGE_ROTATION, "Yes");
- }
- else if (180 == m_nRotateAngle)
- {
- json.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
- json.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
- json.add(SM_IMAGE_ROTATION, "Yes");
- }
- else
- {
- json.add(SM_IMAGE_WIDTH, m_nFullImageWidth);
- json.add(SM_IMAGE_HEIGHT, m_nFullImageHeight);
- json.add(SM_IMAGE_ROTATION, "No");
- }
- m_pFullImageHead->add(SM_IMAGE_HEAD, json);
- }
- else
- {
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_SystemTime.wYear;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_SystemTime.wMonth;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_SystemTime.wDay;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_SystemTime.wHour;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_SystemTime.wMinute;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_SystemTime.wSecond;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_SystemTime.wMilliseconds;
- (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pFullImageHead).encode();
- }
- else
- {
- if (m_pPreviewImageHead == NULL)
- {
- m_pPreviewImageHead = new ResDataObject;
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth);
- json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight);
- json.add(SM_IMAGE_BIT, 16);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, m_SystemTime.wYear);
- json.add(SM_IMAGE_MONTH, m_SystemTime.wMonth);
- json.add(SM_IMAGE_DAY, m_SystemTime.wDay);
- json.add(SM_IMAGE_HOUR, m_SystemTime.wHour);
- json.add(SM_IMAGE_MINUTE, m_SystemTime.wMinute);
- json.add(SM_IMAGE_SEC, m_SystemTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, m_SystemTime.wMilliseconds);
- json.add(SM_IMAGE_LSB, "5000");
- json.add(SM_IMAGE_DOSE, m_nSensitivity);
- json.add(SM_IMAGE_ROTATION, "No");
- json.add(SM_IMAGE_FLIP, "No");
- json.add(SM_IMAGE_ORIGINX, "0");
- json.add(SM_IMAGE_ORIGINY, "0");
- json.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
- json.add(SM_IMAGE_PIXELREPRESENTATION, "1");
- json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue);
- m_pPreviewImageHead->add(SM_IMAGE_HEAD, json);
- }
- else
- {
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_SystemTime.wYear;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_SystemTime.wMonth;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_SystemTime.wDay;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_SystemTime.wHour;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_SystemTime.wMinute;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_SystemTime.wSecond;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_SystemTime.wMilliseconds;
- (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue;
- }
- return (*m_pPreviewImageHead).encode();
- }
- }
- bool nsFPD::FPDDevicePZMedical::OnProcessImage(WORD* pwRawImage)
- {
- FINFO("--Func-- OnProcessImage");
- if (pwRawImage == NULL)
- {
- FERROR("pwRawImage is null!");
- return false;
- }
- FullImageDateArrived(pwRawImage);
- FINFO("OnProcessImage Write Frame Over");
- return true;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::AcceptCalibration()
- {
- printf("--func-- AcceptCalibration\n");
- FINFO("--Func-- AcceptCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->AcceptCalibration())
- {
- FINFO("AcceptCalibration over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("AcceptCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- //完成校正条件:轮数够了,曝光次数够了
- if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
- {
- FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//expose over
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- return Ret;
- }
- if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
- {
- m_nCalibCurrentCalibrationRound++;
- m_nCalibCurrentExposureIndex = 1;
- ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
- int nDose = temp["Dose"];
- m_fDoseParam = nDose / 1000.0f;
- }
- else
- {
- m_nCalibCurrentExposureIndex++;
- }
- m_nCalibCurrentExposureNum++;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AcceptCalibration
- FINFO("--func-- AcceptCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::RejectCalibration()
- {
- printf("--Func-- RejectCalibration \n");
- FINFO("--func-- RejectCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->RejectCalibration())
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("RejectCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//RejectCalibration
- FINFO("--func-- RejectCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::SaveCalibrationFile(bool bSaveFlag)
- {
- printf("--Func-- SaveCalibrationFile \n");
- FINFO("--func-- SaveCalibrationFile");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("SaveCalibrationFile by user: {$}", bSaveFlag);
- if (!bSaveFlag)
- {
- FERROR("Not save calibration file");
- return Ret;
- }
- if (g_pDetector->SaveCalibrationFile())
- {
- FINFO("SaveCalibrationFile over");
- m_CalibUnit->SetSaveCalibrationFileFinish(true);
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("SaveCalibrationFile error");
- m_CalibUnit->SetSaveCalibrationFileFinish(false);
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--func-- SaveCalibrationFile over");
- return Ret;
- }
- void nsFPD::FPDDevicePZMedical::FullImageDateArrived(WORD* pImg)
- {
- FINFO("--func-- FullImageDateArrived");
- AddFrameWithRawHead(IMAGE_FULL, pImg, m_nFullImageWidth * m_nFullImageHeight);
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::SetRequestedDose(std::string strDose)
- {
- FINFO("--func-- SetRequestedDose");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
- {
- printf("--func-- GetCalibrationStep\n");
- FINFO("--func-- GetCalibrationStep");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("Calibration DetectorID: {$}", nDetectorID);
- ResDataObject out;
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- if (g_pDetector->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound))
- {
- FINFO("PZMedicalCtrl GetCalibrationStep success");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("GetCalibrationStep error");
- Ret = RET_STATUS::RET_FAILED;
- }
- out.add("CalibrationRounds", (int)m_CalibDoseList.size());
- out.add("TotalExposureNum", m_nCalibTotalExposureNum);
- out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound);
- out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]);
- out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex);
- out.add("CurrentExposureNum", m_nCalibCurrentExposureNum);
- strCalibrationStepInfo = out.encode();
- FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
- return Ret;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::PauseCalibration()
- {
- printf("--Func-- PauseCalibration\n");
- FINFO("--func-- PauseCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- m_nXrayCalibNum++;
- int nDose = (int)m_fDoseParam;
- if (nDose == 25 && m_nXrayCalibNum == m_nCalibTotalExposureNum)
- {
- FINFO("start to waitting CalibDoseEvt");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- //m_nXrayCalibNum = 0;
- }
- else if (nDose != 25)
- {
- if (m_nXrayCalibNum != m_nCalibTotalExposureNum)
- {
- FINFO("start to waitting CalibDoseEvt");
- DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE);
- }
- }
- if (m_nXrayCalibNum != m_nCalibTotalExposureNum)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PauseCalibration
- m_CalibUnit->PauseCalibration();
- }
- FINFO("Driver PauseCalibration over,m_nXrayCalibNum {$}", m_nXrayCalibNum);
- FINFO("--func-- PauseCalibration over");
- return Ret;
- }
- bool nsFPD::FPDDevicePZMedical::CompleteCalibration()
- {
- printf("--func-- CompleteCalibration \n");
- FINFO("--func-- CompleteCalibration");
- m_stDeviceConfig.fCalibTemperature2 = m_stDeviceConfig.fCurrentTemperValue;
- m_stDeviceConfig.fCalibTemperature = (m_stDeviceConfig.fCalibTemperature1 + m_stDeviceConfig.fCalibTemperature2) / 2;
- g_pDetector->CompleteCalibration(this);
-
- if (g_pDetector->GetPZMedicalCtrlCalibType() == CCOS_CALIBRATION_TYPE_DARK)
- {
- FINFO("CompleteCalibration get Calibration Type:{$}", (int)CCOS_CALIBRATION_TYPE_DARK);
- printf("CompleteCalibration get Calibration Type: dark\n");
- }
- else if (g_pDetector->GetPZMedicalCtrlCalibType() == CCOS_CALIBRATION_TYPE_XRAY)
- {
- FINFO("PZMedical Ctrl Calibration Type:{$}", (int)CCOS_CALIBRATION_TYPE_XRAY);
- printf("CompleteCalibration get Calibration Type: xray\n");
- DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000);
- if (WAIT_OBJECT_0 == nRet)
- {
- FINFO("got event m_UploadCalibMapOver");
- }
- else if (WAIT_TIMEOUT == nRet)
- {
- FINFO("wait event m_UploadCalibMapOver timeout");
- }
- else
- {
- FINFO("wait event m_UploadCalibMapOver error");
- }
- }
- printf("CompleteCalibration set detector status standby\n");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//CompleteCalibration
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
-
- //通知子系统结束暗场校正太快了,导致后边的服务通知app的消息混乱了(不是一个进程的原因)acqservice,故此处延时1s
- printf("Sleep 1s,then send progress 100\n");
- FINFO("Sleep 1s,then send progress 100");
- Sleep(1000);
-
- m_CalibUnit->SetCalibrationProgress("100");
- FINFO("--func-- CompleteCalibration over");
- return true;
- }
- void nsFPD::FPDDevicePZMedical::AbortCalibration()
- {
- printf("--func-- AbortCalibration\n");
- FINFO("--func--AbortCalibration");
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration dark
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- FINFO("--func-- AbortCalibration over");
- return;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
- g_pDetector->AbortCalibration(this);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration gain
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- m_AcqUnit->SendNoNeedWaitImage(true);
- FINFO("--func-- AbortCalibration over");
- }
- void nsFPD::FPDDevicePZMedical::OnProcessTemperature(int nID, float fTemperature)
- {
- string strWarnErrorCode = "";
- float fMaxTempGap = 6.0f;
- if (m_stDeviceConfig.strDeviceName.find("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0)
- {
- fMaxTempGap = 12.0f;
- }
- if (fTemperature >= m_stDeviceConfig.fTemperMaxLimit)
- {
- FINFO("Exceed Max Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH;
- if (m_stDeviceConfig.bActived)
- {
- strWarnErrorCode = "ERR_FPD_TEMPHIGH_NOT_ACQ";
- }
- }
- else if (fTemperature <= m_stDeviceConfig.fTemperMinLimit)
- {
- m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW;
- if (m_stDeviceConfig.bActived)
- {
- FINFO("Exceed Min Temperature");
- strWarnErrorCode = "ERR_FPD_TEMPLOW_NOT_ACQ";
- }
- }
- else if (fTemperature <= m_stDeviceConfig.fTemperLowLimit)
- {
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- FINFO("Exceed Temperature Low Warning");
- strWarnErrorCode = "WAR_FPD_TEMPERTURE_LOW";
- }
- else if (fTemperature > m_stDeviceConfig.fTemperUpperLimit)
- {
- FINFO("Exceed Temperature High Warning");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- strWarnErrorCode = "WAR_FPD_TEMPERATURE_HIGH";
- }
- else if ((m_stDeviceConfig.fCalibTemperature > 1.0f) && (abs(fTemperature - m_stDeviceConfig.fCalibTemperature) >= fMaxTempGap))
- {
- FINFO("Exceed Calibration Temperature");
- m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING;
- strWarnErrorCode = "WAR_FPD_EXCEED_CALB_TEMPER";
- }
- else if ((fTemperature <= m_stDeviceConfig.fTemperUpperLimit) && (fTemperature > m_stDeviceConfig.fTemperLowLimit))
- {
- //FINFO("Temperature Normal");
- }
- }
- //慎重调用,可能会导致板出问题,硬reset需要很长时间
- RET_STATUS nsFPD::FPDDevicePZMedical::Reset()
- {
- printf("--Func-- Reset\n");
- FINFO("--func-- Reset");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->ResetDetector(this))
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--func-- Reset over");
- return Ret;
- }
- /***
- * 客户端获取探测器信息
- ***/
- RET_STATUS nsFPD::FPDDevicePZMedical::GetDetectorInfo(string& strFDI)
- {
- ResDataObject strDetectorInfo;
- FINFO("GetDetectorInfo m_stDeviceConfig.strPanelSerial:{$}", m_stDeviceConfig.strPanelSerial);
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- FERROR("strPanelSerial is null!!! Send Default Info");
- strDetectorInfo.add("DetectorName", "Simulator");
- strDetectorInfo.add("DetectorSN", "Simulator");
- strDetectorInfo.add("Firmware", " ");
- strDetectorInfo.add("APFirmware", " ");
- strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- strDetectorInfo.add("SSID", " ");
- strDetectorInfo.add("LifeTime", "0");
- strDetectorInfo.add("PowerOn", "0");
- strDetectorInfo.add("DateCode", " ");
- strDetectorInfo.add("PartNumber", " ");
- strDetectorInfo.add("WifiDataRate", " ");
- strDetectorInfo.add("WifiChannel", "0");
- strDetectorInfo.add("DetectorExist", "0");
- strDetectorInfo.add("SystemAS", "0");
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", "0");
- strDetectorInfo.add("CommunicationStatus", "0");
- strDetectorInfo.add("DetectorTemperature", "0");
- strDetectorInfo.add("FDCalibrationTemperature", "0");
- strDetectorInfo.add("TemperatureStatus", "0");
- strDetectorInfo.add("WaitTime", "0");
- strDetectorInfo.add("DetectorWifiSignal", "0");
- strDetectorInfo.add("DetectorBattery", "0");
- strDetectorInfo.add("ShockSensor", "NULL");
- strDetectorInfo.add("FirmwareUpdate", "0");
- strFDI = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
- strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
- strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str());
- strDetectorInfo.add("APFirmware", "NULL");
- strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
- strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime);
- strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn);
- strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str());
- strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str());
- strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate);
- strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel);
- strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted);
- //System Workstation
- if (m_stDeviceConfig.strDeviceName.find("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0)
- {
- strDetectorInfo.add("SystemAS", 3);
- }
- else
- {
- strDetectorInfo.add("SystemAS", 3);
- }
- //DetectorCalibrationDate
- if (m_stDeviceConfig.strCalibrationDate != " ")
- {
- if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos)
- {
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", 0);
- }
- else
- {
- strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/);
- strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/);
- strDetectorInfo.add("CalibrationExist", 1);
- }
- }
- else
- {
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", 0);
- }
- if (m_stDeviceConfig.bConnectStatus)
- {
- strDetectorInfo.add("CommunicationStatus", 1);
- }
- else
- {
- strDetectorInfo.add("CommunicationStatus", 0);
- }
- strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature);
- strDetectorInfo.add("ShockSensor", m_nShockCounts);
- strDetectorInfo.add("FirmwareUpdate", 0);
- strFDI = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDevicePZMedical::ResetConnect()
- {
- FINFO("--Func-- ResetConnect");
- g_pDetector->Disconnect();
- g_pDetector->Connect(this,m_strWorkPath.c_str());
- return RET_STATUS::RET_SUCCEED;
- }
|