123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.CareRayDR.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "Detector_CareRayDR.h"
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- //-----------------------------------------------------------------------------
- // FPDDeviceCareRay
- //-----------------------------------------------------------------------------
- extern Detector_CareRayDR* g_pDetector;
- static nsFPD::CareRayDriver gIODriver;
- Log4CPP::Logger* //mLog::gLogger = nullptr;
- extern const char* g_szMouldPath;
- CareRayDriver* g_Driver = nullptr;
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- g_Driver = new nsFPD::CareRayDriver();
- return g_Driver;
- }
- nsFPD::CareRayDriver::CareRayDriver()
- {
- pObjDev = nullptr;
- m_bDriverConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::CareRayDriver::~CareRayDriver()
- {
- if (pObjDev != nullptr)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- //mLog::Close();
- Log4CPP::ThreadContext::Map::Clear();
- //mLog::gLogger = nullptr;
- }
- void nsFPD::CareRayDriver::Prepare()
- {
- printf("--Driver-- prepare \r\n");
- string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- //mLog::gLogger = Log4CPP::LogManager::GetLogger("Module");
- //mLog::FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
- #ifdef _WIN64
- //mLog::FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #else
- //mLog::FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #endif
- //mLog::FINFO("Driver Prepare get logger");
- }
- auto nsFPD::CareRayDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("--Driver-- CreateDevice \r\n");
- //mLog::FINFO("--Driver-- CreateDevice");
- pObjDev = new FPDDeviceCareRay(EventCenter, m_ConfigFileName);
- auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
- pObjDev->CreateDevice();
- pObjDev->Register();
- return Device;
- }
- bool nsFPD::CareRayDriver::Connect()
- {
- printf("--Driver-- Connect \r\n");
- //mLog::FINFO("--Driver-- connect m_bDriverConnect:{$}", m_bDriverConnect);
- if (pObjDev && g_pDetector && !m_bDriverConnect)
- {
- RET_STATUS ret = pObjDev->Connect();
- if (ret != RET_SUCCEED)
- {
- //mLog::FERROR("Connect error!");
- }
- }
-
- return m_bDriverConnect;
- }
- void nsFPD::CareRayDriver::Disconnect()
- {
- printf("--Driver-- Disconnect \r\n");
- //mLog::FINFO("--Driver-- Disconnect");
- if (pObjDev != nullptr)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- m_bDriverConnect = false; //disconnect置为false
- }
- bool nsFPD::CareRayDriver::isConnected() const
- {
- return m_bDriverConnect;
- }
- std::string nsFPD::CareRayDriver::DriverProbe()
- {
- printf("--Driver-- DriverProbe \r\n");
- //mLog::FINFO("--Driver-- DriverProbe config name:{$}", m_ConfigFileName);
- 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", "DR");
- HardwareInfo.add("VendorID", "CareRay");
- HardwareInfo.add("ProductID", "CareRay");
- HardwareInfo.add("SerialID", "Driver");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- std::string nsFPD::CareRayDriver::GetResource()
- {
- printf("--Driver-- GetResource \r\n");
- //mLog::FINFO("--Driver-- GetResource");
- ResDataObject r_config, temp;
- printf("m_ConfigFileName:%s\n", m_ConfigFileName.c_str());
- //mLog::FINFO("m_ConfigFileName:{$}", m_ConfigFileName);
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- return "";
- }
- m_ConfigAll = temp;
- r_config = temp["CONFIGURATION"];
- m_Configurations = r_config;
- ResDataObject DescriptionTemp;
- ResDataObject ListTemp;
- //ResDataObject m_pAttribute;
- //ResDataObject m_pDescription;
- 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");
- ////mLog::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());
- ////mLog::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)
- {
- //mLog::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("CareRayDriver module: get resource over \r\n");
- //mLog::FINFO("CareRayDriver module: get resource over");
- return res;
- }
- std::string nsFPD::CareRayDriver::DeviceProbe()
- {
- printf("--Driver-- DeviceProbe \r\n");
- //mLog::FINFO("--Driver-- DeviceProbe");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", "CareRay");
- HardwareInfo.add("ProductID", "CareRay");
- HardwareInfo.add("SerialID", "1234");
- }
- string str = HardwareInfo.encode();
- //mLog::FINFO("CareRayDriver module DeviceProbe over");
- return str;
- }
- bool nsFPD::CareRayDriver::GetDeviceConfig(std::string& Cfg)
- {
- Cfg = m_DeviceConfig.encode();
- //mLog::FINFO("--Driver-- GetDeviceConfig Cfg:{$}", Cfg);
- return true;
- }
- bool nsFPD::CareRayDriver::SetDeviceConfig(std::string Cfg)
- {
- //mLog::FINFO("--Driver-- SetDeviceConfig {$}", 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];
- //mLog::FINFO("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- //mLog::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");
- //mLog::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
- {
- //mLog::FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- //mLog::FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- bool nsFPD::CareRayDriver::SaveConfigFile(bool bSendNotify)
- {
- //mLog::FINFO("--Driver-- SaveConfigFile m_ConfigFileName:{$}", m_ConfigFileName);
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- bool ret = m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- if (ret)
- {
- //mLog::FINFO("SaveConfigFile Success!");
- return true;
- }
- else
- {
- //mLog::FERROR("SaveConfigFile Fail!");
- return false;
- }
- }
- bool nsFPD::CareRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey,
- int nPathID, string& strValue)
- {
- strValue = "";
- string strTemp = pInnerKey;
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- strValue = (string)config["connections"][pInnerKey];
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
- }
- else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp ||
- BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- ShowTemperature == strTemp || ShowWifi == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp ||
- CcosDetectorAttachedFlag == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- //mLog::FERROR("Error Configuration item: {$}", pInnerKey);
- }
- }
- ////mLog::FINFO("GetDeviceConfigValue pInnerKey:{$},nPathID:{$},strValue:{$}", pInnerKey, nPathID, strValue);
- return true;
- }
- bool nsFPD::CareRayDriver::SetDeviceConfigValue(ResDataObject &config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- //mLog::FINFO("--Driver-- SetDeviceConfigValue change {$} item value to {$}", pInnerKey, szValue);
- string strTemp = pInnerKey;
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- config["connections"][pInnerKey] = szValue;
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
- }
- else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
- BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- ShowTemperature == strTemp || ShowWifi == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp ||
- CcosDetectorAttachedFlag == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else
- {
- //mLog::FERROR("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- nsFPD::FPDDeviceCareRay::FPDDeviceCareRay(std::shared_ptr<IOEventCenter> center,std::string strConfigPath)
- : m_nCalibTotalExposureNum(0),
- m_nCalibCurrentCalibrationRound(0),
- m_nCalibCurrentExposureIndex(0),
- m_nCalibCurrentExposureNum(0)
- {
- m_bDeviceConnect = false;
- m_nFullImageHeight = 0;
- m_nFullImageWidth = 0;
- m_nPreviewEnable = 0;
- m_nPreviewImageWidth = 0;
- m_nPreviewImageHeight = 0;
- m_pFullImgBuffer = nullptr;
- m_pPreviewImgBuffer = nullptr;
- m_nImgBits = 0;
- m_nAngle = 0;
- m_nPixelSpacing = 0;
- m_nSensitivity = 0;
- m_eSyncMode = SYNC_SOFTWARE;
- m_fFactorEXI2UGY = 0.0f;
- m_strWorkPath = GetProcessDirectory();
- m_DetectorCtrlUnit.reset(new OemCtrl(center, this));
- m_AcqUnit.reset(new OemAcq(center, this));
- m_SyncUnit.reset(new OemSync(center, this));
- m_CalibUnit.reset(new OemCalib(center, this));
- m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
- string fullpath = g_szMouldPath;
- string::size_type firstHit = fullpath.find_last_of('\\');
- if (firstHit == string::npos || firstHit == 0)
- {
- //mLog::FERROR("Get DLL path error!");
- }
- else
- {
- //mLog::FINFO("g_szMouldPath:{$}", g_szMouldPath);
- }
- string strInfoPath = fullpath.substr(0, firstHit);
- m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, strInfoPath));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
- EventCenter = center;
- m_eAppStatus = APP_STATUS_IDLE;
- m_bEnterAcqStatus = false;
- m_CalibType = CCOS_CALIBRATION_TYPE_NONE;
- }
- nsFPD::FPDDeviceCareRay::~FPDDeviceCareRay()
- {
- if (nullptr != m_pFullImgBuffer)
- {
- delete[]m_pFullImgBuffer;
- m_pFullImgBuffer = nullptr;
- }
- if (nullptr != m_pPreviewImgBuffer)
- {
- delete[]m_pPreviewImgBuffer;
- m_pPreviewImgBuffer = nullptr;
- }
- }
- std::string nsFPD::FPDDeviceCareRay::GetGUID() const
- {
- return DetectorUnitType;
- }
- bool nsFPD::FPDDeviceCareRay::Prepare()
- {
- printf("--Func-- device Prepare \r\n");
- //mLog::FINFO("--Func-- device prepare");
- //如果同SDK双板的场景,一个图大一个图小,如果图小的申请了共享内存后,当切换到图大的板时,上图时就会因为共享内存不够大导致崩溃的问题,所以这里写死5000*5000
- EventCenter->OnMaxBlockSize("CareRayDrQue", 5000 * 5000 * 2, 5, 4000 * 4000 * 2, 1);
- return true;
- }
- bool nsFPD::FPDDeviceCareRay::CreateDevice()
- {
- //mLog::FINFO("--Func-- CreateDevice start");
- if (!LoadConfig())
- {
- //mLog::FERROR("LoadConfig fail!");
- return false;
- }
- if (nullptr == g_pDetector)
- {
- g_pDetector = new Detector_CareRayDR();
- }
- g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- //把通知状态信息的时间间隔传给ctrl
- g_pDetector->SetNotifyStatusTimePeriod(m_stDeviceConfig.nNotifyStatusTimePeriod);
- g_pDetector->SetReconnectTimePeriod(m_stDeviceConfig.nReconnectTimePeriod);
- m_DetectorCtrlUnit->SetAttachStatus("1"); //没有attach功能,直接上发1,使客户端显示探测器状态
- m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode);
- m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate);
- m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime);
- string strTemp = (string)m_DetectorConfiguration->m_Configurations["SerialNumber"];
- m_DetectorCtrlUnit->SetSerialNumber(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["DetectorType"];
- m_DetectorCtrlUnit->SetDetectorType(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["Description"];
- m_DetectorCtrlUnit->SetDescription(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["DetectorWiredIP"];
- m_DetectorCtrlUnit->SetDetectorWiredIP(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["DetectorWirelessIP"];
- m_DetectorCtrlUnit->SetDetectorWirelessIP(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["LocalIP"];
- m_DetectorCtrlUnit->SetLocalIP(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowTemperature"];
- m_DetectorCtrlUnit->SetShowTemperature(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowWifi"];
- m_DetectorCtrlUnit->SetShowWifi(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowBattery"];
- m_DetectorCtrlUnit->SetShowBattery(strTemp);
- strTemp = (string)m_DetectorConfiguration->m_Configurations["ShowBluetooth"];
- m_DetectorCtrlUnit->SetShowBluetooth(strTemp);
- if (m_stDeviceConfig.bSupportDDR) //是否支持DDR采集功能
- {
- m_DetectorCtrlUnit->SetSupportDDR("1");
- }
- else
- {
- m_DetectorCtrlUnit->SetSupportDDR("0");
- }
- //mLog::FINFO("CreateDevice end");
- return true;
- }
- void nsFPD::FPDDeviceCareRay::Register()
- {
- //mLog::FINFO("--Func-- Register");
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::Connect()
- {
- printf("--Func-- device Connect \r\n");
- //mLog::FINFO("--Func-- device Connect");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::EnterExam(int nExamMode)
- {
- //mLog::FINFO("--Func-- EnterExam {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- //mLog::FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- //mLog::FINFO("strLastCalibrationDate:{$},strCalibrationFileExpirationReminder:{$}", m_stDeviceConfig.strLastCalibrationDate, m_stDeviceConfig.strCalibrationFileExpirationReminder);
- if (m_stDeviceConfig.strCalibrationFileExpirationReminder == "1")
- {
- //进检查时判断当前校正文件是否过期,如果即将过期或者已过期都向上通知
- if (m_stDeviceConfig.strLastCalibrationDate == "0000-00-00 00:00:00")
- {
- //没有做过校正
- //mLog::FWARN("No calibration file, please make a calibration!");
- m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_NOT_EXIST, "");
- }
- else
- {
- time_t lastCalibDate = StringToDatetime(m_stDeviceConfig.strLastCalibrationDate);
- int nExpireTime = std::stoi(m_stDeviceConfig.strCalibrationFileExpireTime);//单位:天
- //mLog::FINFO("nExpireTime:{$}", nExpireTime);
- time_t localtime = time(NULL);
- //判断是否过期
- if (localtime > lastCalibDate + nExpireTime * 24 * 3600)
- {
- //过期了报错
- //mLog::FWARN("Calibration file is expired! please make a calibration!");
- m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_OUTDATE, "");
- }
- }
- }
- break;
- case APP_STATUS_WORK_END:
- //mLog::FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- //mLog::FINFO("strCalibrationFileExpirationReminder:{$}", m_stDeviceConfig.strCalibrationFileExpirationReminder);
- if (m_stDeviceConfig.strCalibrationFileExpirationReminder == "1")
- {
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
- }
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- //mLog::FINFO("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS_DETSHAR_END:
- //mLog::FINFO("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS_CAL_BEGIN:
- //mLog::FINFO("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS_CAL_END:
- //mLog::FINFO("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_END;
- break;
- case APP_STATUS_WORK_IN_SENSITIVITY:
- //mLog::FINFO("Enter into sensitivity test interface");
- m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
- break;
- default:
- break;
- }
- g_pDetector->EnterExamMode(nExamMode);
- if (nExamMode == APP_STATUS_WORK_END || nExamMode == APP_STATUS_CAL_END)
- {
- if (m_bEnterAcqStatus)
- {
- RET_STATUS ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- //mLog::FERROR("EnterExam StopAcquisition fail!");
- return ret;
- }
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- bool nsFPD::FPDDeviceCareRay::GetLogicMode(string& strAcqMode, int& nLogicMode)
- {
- if (strAcqMode == "RAD")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "DualEnergy")
- {
- nLogicMode = DUALENERGY;
- }
- else if (strAcqMode == "DDR")
- {
- nLogicMode = DDR;
- }
- else if (strAcqMode == "1")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "2")
- {
- nLogicMode = DUALENERGY;
- }
- else if (strAcqMode == "3")
- {
- nLogicMode = DDR;
- }
- else
- {
- //mLog::FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::SetAcqMode(string strAcqMode)
- {
- //mLog::FINFO("--Func-- SetAcqMode({$})", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接,不执行
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- //设置采集模式时发一次非Standby状态,配合子系统走流程,使界面ready状态和探测器同步
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- 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)
- {
- m_nFullImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"];
- m_nFullImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"];
- m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
- m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
- m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
- m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"];
- m_nPreviewEnable = (int)objModeConfig["ModeTable"][i]["PreviewEnable"];
- m_nPreviewImageWidth = (int)objModeConfig["ModeTable"][i]["PreviewWidth"];
- m_nPreviewImageHeight = (int)objModeConfig["ModeTable"][i]["PreviewHeight"];
- if (m_nPreviewEnable)
- {
- m_AcqUnit->SetPrevImageInfo(true, m_nPreviewImageHeight, m_nPreviewImageWidth, 0);
- if (!m_pPreviewImgBuffer)
- {
- m_pPreviewImgBuffer = new WORD[m_nPreviewImageWidth * m_nPreviewImageHeight];
- }
- }
- if (nullptr != m_pFullImgBuffer)
- {
- delete[]m_pFullImgBuffer;
- m_pFullImgBuffer = nullptr;
- }
- m_pFullImgBuffer = new WORD[m_nFullImageWidth * m_nFullImageHeight];
- if (m_nAngle == 90 || m_nAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(m_nFullImageWidth, m_nFullImageHeight, m_nImgBits, false);
- }
- else
- {
- m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false);
- }
- string strDoseOfExi = std::to_string(m_nSensitivity);
- m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
- //mLog::FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
- if (g_pDetector->SetAcqMode(nMode))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_AcqUnit->AcqModeNotify(strAcqMode);
- }
- else
- {
- ret = RET_STATUS::RET_FAILED;
- }
- break;
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- //mLog::FERROR("Read configuration failed, Error code: {$}", e.what());
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::GetSyncMode(SYNC_MODE& eSyncMode)
- {
- //mLog::FINFO("--Func-- GetSyncMode");
- eSyncMode = m_eSyncMode;
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::PrepareAcquisition()
- {
- //mLog::FINFO("--Func-- PrepareAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- //mLog::FINFO("m_bEnterAcqStatus:{$}", m_bEnterAcqStatus);
- if (m_bEnterAcqStatus)
- {
- //mLog::FINFO("Detector is acq status need to stop");
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_bEnterAcqStatus = false;
- }
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- //mLog::FERROR("StopAcquisition fail!");
- return ret;
- }
- }
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- if (m_eSyncMode == SYNC_AED)
- {
- m_bEnterAcqStatus = true;
- }
- }
-
- //mLog::FINFO("PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StartAcquisition(string in)
- {
- printf("--Func-- StartAcquisition \r\n");
- //mLog::FINFO("--Func-- StartAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- if (m_eSyncMode == SYNC_AED)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartAcquisition
- m_SyncUnit->XWindowOnNotify();
- }
- }
- else
- {
- //mLog::FERROR("StartAcquisition fail!");
- return ret;
- }
-
- //mLog::FINFO("StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StopAcquisition()
- {
- printf("--Func-- StopAcquisition \r\n");
- //mLog::FINFO("--Func-- StopAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- //调用stop前探测器需处于采集状态,否则会报错
- if (m_bEnterAcqStatus)
- {
- if (g_pDetector->StopAcquisition(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_bEnterAcqStatus = false;
- ret = RET_STATUS::RET_SUCCEED;
- }
- }
- else
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
-
- //mLog::FINFO("StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- printf("--Func-- ActiveCalibration %d \r\n", eType);
- //mLog::FINFO("--Func-- ActiveCalibration {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
- {
- //mLog::FERROR("calibration type is invalid!");
- return RET_STATUS::RET_INVALID;
- }
- else
- {
- m_CalibType = eType;
- }
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- //mLog::FINFO("calibration type: XRAY");
- int nCalibrationRounds = (int)m_CalibDoseList.size();
- g_pDetector->SetCalibRounds(nCalibrationRounds);
- }
- if (g_pDetector->ActiveCalibration(this, eType))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
- m_CalibUnit->SetCalibrationProgress("0");
- }
- else
- {
- //mLog::FERROR("Active calibration failed");
- ret = RET_STATUS::RET_FAILED;
- }
- //重置校正流程参数
- m_nCalibCurrentCalibrationRound = 1;
- m_nCalibCurrentExposureIndex = 1;
- m_nCalibCurrentExposureNum = 0;
- //mLog::FINFO("ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration------ \n");
- //mLog::FINFO("--Func-- PrepareCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- //mLog::FINFO("m_bEnterAcqStatus:{$}", m_bEnterAcqStatus);
- if (m_bEnterAcqStatus)
- {
- //mLog::FINFO("Detector is acq status need to stop");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- //mLog::FERROR("StopAcquisition fail!");
- return ret;
- }
- }
- if (g_pDetector->PrepareCalibration(this))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_PREPARE));
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- if (nCalibrationType == CCOS_CALIBRATION_TYPE_XRAY && m_eSyncMode == SYNC_AED)
- {
- //mLog::FINFO("set m_bEnterAcqStatus true");
- m_bEnterAcqStatus = true;
- }
- ret = RET_STATUS::RET_SUCCEED;
- //m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else
- {
- printf("PrepareCalibration failed!\n");
- //mLog::FERROR("PrepareCalibration failed!");
- return ret;
- }
-
- //mLog::FINFO("--Func-- PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::GetRequestedDose(std::string& strDose)
- {
- //mLog::FINFO("--Func-- GetRequestedDose");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- ResDataObject out;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- //mLog::FINFO("GetRequestedDose calib type is {$}", (int)nCalibrationType);
- if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
- {
- out.add("Dose", 0.0f);
- out.add("kV", 0.0f);
- out.add("mA", 0.0f);
- out.add("ms", 0.0f);
- out.add("mAs", 0.0f);
- }
- else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
- {
- //mLog::FINFO("calib dose list size is {$}", m_CalibDoseList.size());
- ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
- int nTargetExi = (int)temp["TargetGainEXI"];
- m_DetectorCtrlUnit->SetTargetEXI(std::to_string(nTargetExi));
- //mLog::FINFO("nTargetExi:{$}", nTargetExi);
- out.add("Dose", nTargetExi);
- out.add("kV", temp["KV"]);
- out.add("mA", temp["MA"]);
- out.add("ms", temp["MS"]);
- out.add("mAs", temp["MAS"]);
- }
- else
- {
- //mLog::FERROR("Don't support CalibrationType($)", (int)nCalibrationType);
- return ret;
- }
- strDose = out.encode();
- //mLog::FINFO("GetRequestedDose:{$}", strDose);
- ret = RET_STATUS::RET_SUCCEED;
- //mLog::FINFO("--Func-- GetRequestedDose over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::SetRequestedDose(std::string strDose)
- {
- //mLog::FINFO("--Func-- SetRequestedDose");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
- {
- printf("--Func-- GetCalibrationStep\n");
- //mLog::FINFO("--Func-- GetCalibrationStep DetectorID:{$}", nDetectorID);
- RET_STATUS ret = RET_STATUS::RET_SUCCEED;
- 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))
- {
- //mLog::FINFO("GetCalibrationStep success");
- }
- else
- {
- //mLog::FERROR("GetCalibrationStep error");
- ret = RET_STATUS::RET_FAILED;
- return ret;
- }
- 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();
- //mLog::FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StartCalibration()
- {
- printf("--Func-- StartCalibration \r\n");
- //mLog::FINFO("--Func-- StartCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- if (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PREPARE)
- {
- printf("CCOS_CALIBRATION_STATUS = %d\r\n", (int)m_CalibUnit->GetCalibrationStatus());
- //mLog::FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus());
- return ret;
- }
- if (g_pDetector->StartCalibration(this))
- {
- printf("start calibration success set detector status\n");
- //mLog::FINFO("start calibration success set detector status");
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- ret = RET_STATUS::RET_SUCCEED;
- if (m_eSyncMode == SYNC_AED)
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartCalibration
- }
- }
- else
- {
- //mLog::FERROR("StartCalibration failed");
- ret = RET_STATUS::RET_FAILED;
- return ret;
- }
- //mLog::FINFO("StartCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StopCalibration()
- {
- //mLog::FINFO("--Func-- StopCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- //mLog::FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- m_eAppStatus = APP_STATUS_CAL_END;
-
- if (g_pDetector->StopCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED));
- }
- else
- {
- //mLog::FERROR("StopCalibration failed");
- }
- //这里也应该判断探测器的采集状态,如果是采集状态再调用停止采集
- if (m_bEnterAcqStatus)
- {
- //mLog::FINFO("Detector is acq status need to stop");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- //mLog::FERROR("StopAcquisition fail!");
- return ret;
- }
- }
- //mLog::FINFO("StopCalibration over");
- return ret;
- }
- void nsFPD::FPDDeviceCareRay::AbortCalibration()
- {
- //mLog::FINFO("--Func-- AbortCalibration");
- m_eAppStatus = APP_STATUS_CAL_END;
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR));
- m_CalibUnit->SetCalibrationProgress("100");
- if(CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
- {
- g_pDetector->AbortCalibration(this);
- m_AcqUnit->SendNoNeedWaitImage(true);
- }
- //如果中止的时候探测器在采集状态需要停止采集
- //mLog::FINFO("--Func-- AbortCalibration over");
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::AcceptCalibration()
- {
- //mLog::FINFO("--Func-- AcceptCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->AcceptCalibration())
- {
- //mLog::FINFO("AcceptCalibration over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- //mLog::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))
- {
- //mLog::FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- return Ret;
- }
- if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数
- {
- m_nCalibCurrentCalibrationRound++;
- m_nCalibCurrentExposureIndex = 1;
- }
- else
- {
- m_nCalibCurrentExposureIndex++;
- }
- m_nCalibCurrentExposureNum++;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- //mLog::FINFO("--Func-- AcceptCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::RejectCalibration()
- {
- printf("--Func-- RejectCalibration \n");
- //mLog::FINFO("--Func-- RejectCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->RejectCalibration())
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- //mLog::FERROR("RejectCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- //mLog::FINFO("--Func-- RejectCalibration over");
- return Ret;
- }
- bool nsFPD::FPDDeviceCareRay::CompleteCalibration()
- {
- printf("--Func-- CompleteCalibration \n");
- //mLog::FINFO("--Func-- CompleteCalibration");
- if (!g_pDetector->CompleteCalibration(this))
- {
- //mLog::FERROR("CompleteCalibration fail!");
- return false;
- }
- if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_DARK)
- {
- printf("CompleteCalibration Calibration Type DARK\n");
- //mLog::FINFO("CompleteCalibration Calibration Type DARK");
- }
- else if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_XRAY)
- {
- printf("CompleteCalibration Calibration Type XRAY\n");
- //mLog::FINFO("CompleteCalibration Calibration Type XRAY");
- m_eAppStatus = APP_STATUS_CAL_END;
- }
- //mLog::FINFO("CompleteCalibration set detector status standby");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- //mLog::FINFO("--Func-- CompleteCalibration over");
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::SaveCalibrationFile(bool bSaveFlag)
- {
- printf("--Func-- SaveCalibrationFile \n");
- //mLog::FINFO("--Func-- SaveCalibrationFile");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- //mLog::FINFO("SaveCalibrationFile bSaveFlag: {$}", bSaveFlag);
- if (!bSaveFlag)
- {
- //mLog::FERROR("Not save calibration file");
- return Ret;
- }
- //点击save按钮时先调用compelte再调用save
- CompleteCalibration();
- if (g_pDetector->SaveCalibrationFile())
- {
- m_CalibUnit->SetSaveCalibrationFileFinish(true);
- Ret = RET_STATUS::RET_SUCCEED;
- //更新配置文件中校正日期和时间
- time_t localtime = time(NULL);
- string strLocalTime = DatetimeToString(localtime);
- //mLog::FINFO("strLocalTime:{$}", strLocalTime);
- m_CalibUnit->SetLastCalibrationDate(strLocalTime);
- //清除校正文件相关警告
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST);
- m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE);
- }
- else
- {
- //mLog::FERROR("SaveCalibrationFile error");
- m_CalibUnit->SetSaveCalibrationFileFinish(false);
- Ret = RET_STATUS::RET_FAILED;
- }
- //mLog::FINFO("--Func-- SaveCalibrationFile over");
- return Ret;
- }
- bool nsFPD::FPDDeviceCareRay::Support_DarkCalib()
- {
- return true;
- }
- bool nsFPD::FPDDeviceCareRay::Support_XrayCalib()
- {
- return true;
- }
- void nsFPD::FPDDeviceCareRay::SendTemperatureValue(float fValue)
- {
- int nStatus = 0;
- m_Temperature->SetTemperature(fValue, nStatus);
- //mLog::FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
- return;
- }
- void nsFPD::FPDDeviceCareRay::SendWifiValue(int nValue)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nValue, nStatus);
- //mLog::FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
- return;
- }
- void nsFPD::FPDDeviceCareRay::SendBatteryValue(int nValue)
- {
- int nStatus = 0;
- m_Battery->SetRemainPowerValue(nValue, nStatus);
- //mLog::FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
- return;
- }
- bool nsFPD::FPDDeviceCareRay::LoadConfig()
- {
- //mLog::FINFO("--Func-- LoadConfig start");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_CalibDoseList, m_nCalibTotalExposureNum))
- {
- //mLog::FERROR("Load configuration file failed!!!");
- return false;
- }
- //mLog::FINFO("m_CalibDoseList:{$}", m_CalibDoseList.encode());
- //mLog::FINFO("m_nCalibTotalExposureNum:{$}", m_nCalibTotalExposureNum);
-
- //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0,
- m_stDeviceConfig.nBatteryLimit,
- m_stDeviceConfig.nBatteryWarning,
- 90, 20, 90, 100, 0, EventCenter));
- //const char* strkey, float initialvalue, float min, float WarnMin, float WarnMax, float CalibWarnMin, float CalibWarnMax, float max, float accuracy,std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f,
- m_stDeviceConfig.fTemperatureErrorMin,
- m_stDeviceConfig.fTemperatureWarnMin,
- m_stDeviceConfig.fTemperatureWarnMax,
- 20.0f, 100.0f,
- m_stDeviceConfig.fTemperatureErrorMax,
- 0.0f, EventCenter));
- //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0, m_stDeviceConfig.nWifiLimit,
- m_stDeviceConfig.nWifiWarning, 100, 10, 100, 100, 0, EventCenter));
- //mLog::FINFO("--Func-- LoadConfig end");
- return true;
- }
- void nsFPD::FPDDeviceCareRay::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
- Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
- Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
- Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
- Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum);
- Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
- Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
- 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::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
- Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
- Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
- Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR);
- Dispatch->Get.Push(AttrKey::DetectorWiredIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWiredIP);
- Dispatch->Get.Push(AttrKey::DetectorWirelessIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWirelessIP);
- Dispatch->Get.Push(LocalIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetLocalIP);
- Dispatch->Get.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSerialNumber);
- Dispatch->Get.Push(ShowTemperature, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowTemperature);
- Dispatch->Get.Push(ShowWifi, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowWifi);
- Dispatch->Get.Push(ShowBattery, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowBattery);
- Dispatch->Get.Push(ShowBluetooth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShowBluetooth);
- Dispatch->Set.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetConnectStatus);
- Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus);
- Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType);
- Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription);
- Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID);
- Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData);
- Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI);
- Dispatch->Set.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus);
- Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR);
- Dispatch->Set.Push(AttrKey::DetectorWiredIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorWiredIP);
- Dispatch->Set.Push(AttrKey::DetectorWirelessIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorWirelessIP);
- Dispatch->Set.Push(LocalIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetLocalIP);
- Dispatch->Set.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSerialNumber);
- Dispatch->Set.Push(ShowTemperature, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowTemperature);
- Dispatch->Set.Push(ShowWifi, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowWifi);
- Dispatch->Set.Push(ShowBattery, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowBattery);
- Dispatch->Set.Push(ShowBluetooth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetShowBluetooth);
- Dispatch->Update.Push(AttrKey::NotifyStatusTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateNotifyStatusTimePeriod);
- Dispatch->Update.Push(AttrKey::ReconnectTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateReconnectTimePeriod);
- Dispatch->Update.Push(AttrKey::DetectorWiredIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateDetectorWiredIP);
- Dispatch->Update.Push(AttrKey::DetectorWirelessIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateDetectorWirelessIP);
- Dispatch->Update.Push(LocalIP, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateLocalIP);
- Dispatch->Update.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateSerialNumber);
- Dispatch->Update.Push(ShowTemperature, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowTemperature);
- Dispatch->Update.Push(ShowWifi, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowWifi);
- Dispatch->Update.Push(ShowBattery, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowBattery);
- Dispatch->Update.Push(ShowBluetooth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateShowBluetooth);
- }
- void nsFPD::FPDDeviceCareRay::RegisterAcq(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
- Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode);
- 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->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState);
- Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage);
- }
- void nsFPD::FPDDeviceCareRay::RegisterSync(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
- Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
- Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
- Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
- Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
- Dispatch->Action.Push(ActionKey::ActiveSyncMode, m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode);
- Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
- Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
- Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
- Dispatch->Get.Push(AttrKey::FPDExpReady, m_SyncUnit.get(), &SyncUnit::JSGetExpReadyStatus);
- Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
- Dispatch->Get.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode);
- Dispatch->Set.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSSetFPDReady);
- Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus);
- Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
- Dispatch->Set.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::SetSupportSyncMode);
- }
- void nsFPD::FPDDeviceCareRay::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::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
- Dispatch->Get.Push(AttrKey::SupportCalibrationType, m_CalibUnit.get(), &CalibUnit::JSGetSupportCalibrationType);
- Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration);
- Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish);
- Dispatch->Get.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSGetCalibMode);
- Dispatch->Get.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSGetLastCalibrationDate);
- Dispatch->Get.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpireTime);
- Dispatch->Get.Push(AttrKey::CalibrationFileExpirationReminder, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpirationReminder);
- Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus);
- Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress);
- Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult);
- Dispatch->Set.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::SetCalibMode);
- Dispatch->Set.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::SetLastCalibrationDate);
- Dispatch->Set.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpireTime);
- Dispatch->Set.Push(AttrKey::CalibrationFileExpirationReminder, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpirationReminder);
- Dispatch->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode);
- Dispatch->Update.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSUpdateLastCalibrationDate);
- Dispatch->Update.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpireTime);
- Dispatch->Update.Push(AttrKey::CalibrationFileExpirationReminder, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpirationReminder);
- }
- void nsFPD::FPDDeviceCareRay::RegisterOthers(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
- Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
- Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
- Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
- Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
- Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
- Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
- Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax);
- Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin);
- Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
- Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
- Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
- Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
- //Error
- Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
- Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
- Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
- Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
- Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
- Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax);
- Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin);
- Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
- Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
- Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
- Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
- Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
- Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
- Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
- Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
- Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax);
- Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin);
- Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
- Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
- Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
- Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
- }
- void nsFPD::FPDDeviceCareRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventLevel)
- {
- case EVT_LEVEL_CONFIGURATION:
- {
- OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_INFORMATOION:
- {
- OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_STATUS:
- {
- OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_DATA:
- {
- OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_WARNING:
- {
- OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- case EVT_LEVEL_ERROR:
- {
- OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
- break;
- }
- default:
- break;
- }
- }
- void nsFPD::FPDDeviceCareRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- //mLog::FERROR("Not support this conf({$})", nEventID);
- }
- void nsFPD::FPDDeviceCareRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- //mLog::FERROR("Not support this info({$})", nEventID);
- }
- void nsFPD::FPDDeviceCareRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_STATUS_INIT:
- {
- //mLog::FINFO("EVT_STATUS_INIT nParam1:{$}", nParam1);
- break;
- }
- case EVT_STATUS_PANEL:
- {
- PanelStatus m_ePanelStatus = (PanelStatus)nParam1;
- if (PANEL_CLOSE == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
- m_bDeviceConnect = false;
- g_Driver->m_bDriverConnect = false;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- m_WarnAndError->SendError(ERR_FPD_DISCONNECT,"");
- }
- else if (PANEL_CONNECT == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
- g_Driver->m_bDriverConnect = true;
- m_bDeviceConnect = true;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
- }
- else if (PANEL_STANDBY == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_STANDBY");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_READY_EXP");
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- }
- else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
- {
- m_stImgCreateTime = { 0 };
- GetLocalTime(&m_stImgCreateTime);
- //mLog::FINFO("XWindowOn at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}",
- m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
- m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
-
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- m_stImgCreateTime = { 0 };
- GetLocalTime(&m_stImgCreateTime);
- //mLog::FINFO("XWindowOff at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}",
- m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
- m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
-
- m_SyncUnit->XWindowOffNotify();
- }
- else if (PANEL_START_ACQ == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_START_ACQ");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//PANEL_START_ACQ
- m_bEnterAcqStatus = true;
- }
- else if (PANEL_XRAY_ON == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_XRAY_ON");
- m_SyncUnit->XrayOnNotify();
- }
- else if (PANEL_XRAY_OFF == nParam1)
- {
- //mLog::FINFO("EVT_STATUS_PANEL PANEL_XRAY_OFF");
- m_SyncUnit->XrayOffNotify();
- }
- break;
- }
- case EVT_STATUS_CALIBRATIOIN:
- {
- //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_CALIBRATIOIN");
- PanelEventState eStatus = (PanelEventState)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- break;
- case PANEL_EVENT_END_OK:
- case PANEL_EVENT_END_ERROR:
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- break;
- case PANEL_EVENT_TIMEOUT:
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SAVECALIB:
- {
- //mLog::FINFO("EVT_STATUS_SAVECALIB");
- PanelEventState eStatus = (PanelEventState)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- {
- //mLog::FINFO("save calib file start");
- break;
- }
- case PANEL_EVENT_END:
- {
- //mLog::FINFO("save calib file end");
- break;
- }
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SINGLEEXP:
- {
- //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_SINGLEEXP");
- if (DOSE_ACCEPT == nParam1)
- {
- //mLog::FINFO("Calibration Result is acceptable");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_CalibUnit->PauseCalibration();
- }
- else
- {
- //mLog::FERROR("Not support this param({$})", nParam1);
- }
- break;
- }
- case EVT_STATUS_TEMPERATURE:
- {
- //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_TEMPERATURE");
- float fTemperature = fParam2;
- // if (fTemperature > m_fTemperMaxLimit)
- // {
- // AddErrMsg("14", "temperature_toohigh");
- // }
- // else if (fTemperature >= m_fTemperWarning)
- // {
- // AddWarnMsg("14", "temperature_high");
- // }
- // else if (fTemperature < m_fTemperMinLimit)
- // {
- // AddErrMsg("14", "temperature_toolow");
- // }
- // else if (fTemperature <= m_fTemperLowLimit)
- // {
- // AddWarnMsg("14", "temperature_low");
- // }
- // else
- // {
- // DelErrMsg("14");
- // }
- SendTemperatureValue(fTemperature);
- break;
- }
- case EVT_STATUS_WIFI:
- {
- //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_WIFI");
- int nWifiLevel = nParam1;
- // if (nWifiLevel < m_nWifiLimit)
- // {
- // AddErrMsg("15", "wifi_toolow");
- // }
- // else if (nWifiLevel <= m_nWifiWarning)
- // {
- // AddWarnMsg("15", "wifi_low");
- // }
- // else
- // {
- // DelErrMsg("15");
- // }
- SendWifiValue(nWifiLevel);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- //mLog::FINFO("EVT_STATUS_PANEL EVT_STATUS_BATTERY_VALUE");
- int nBatteryValue = nParam1;
- // if (nBatteryValue < m_nBatteryLimit)
- // {
- // AddErrMsg("16", "battery_toolow");
- // }
- // else if (nBatteryValue <= m_nBatteryWarning)
- // {
- // AddWarnMsg("16", "battery_low");
- // }
- // else
- // {
- // DelErrMsg("16");
- // }
- SendBatteryValue(nBatteryValue);
- break;
- }
- default:
- //mLog::FERROR("Not support this event({$})", nEventID);
- break;
- }
- }
- string nsFPD::FPDDeviceCareRay::MakeImageHead(IMAGE_VIEW_TYPE Type)
- {
- ResDataObject pFullImageHead;
- ResDataObject pPreviewImageHead;
- SYSTEMTIME SystemTime = { 0 };
- GetLocalTime(&SystemTime);
- if (Type == IMAGE_FULL)
- {
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_BIT, m_nImgBits);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, SystemTime.wYear);
- json.add(SM_IMAGE_MONTH, SystemTime.wMonth);
- json.add(SM_IMAGE_DAY, SystemTime.wDay);
- json.add(SM_IMAGE_HOUR, SystemTime.wHour);
- json.add(SM_IMAGE_MINUTE, SystemTime.wMinute);
- json.add(SM_IMAGE_SEC, SystemTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, 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_nAngle || 270 == m_nAngle)
- {
- json.add(SM_IMAGE_WIDTH, m_nFullImageHeight);
- json.add(SM_IMAGE_HEIGHT, m_nFullImageWidth);
- 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");
- }
- pFullImageHead.add(SM_IMAGE_HEAD, json);
- return pFullImageHead.encode();
- }
- else
- {
- ResDataObject json;
- json.add(SM_IMAGE_TYPE, (int)Type);
- json.add(SM_IMAGE_WIDTH, m_nPreviewImageWidth);
- json.add(SM_IMAGE_HEIGHT, m_nPreviewImageHeight);
- json.add(SM_IMAGE_BIT, m_nImgBits);
- json.add(SM_IMAGE_TAG, 1);
- json.add(SM_IMAGE_INDEX, 1);
- json.add(SM_IMAGE_YEAR, SystemTime.wYear);
- json.add(SM_IMAGE_MONTH, SystemTime.wMonth);
- json.add(SM_IMAGE_DAY, SystemTime.wDay);
- json.add(SM_IMAGE_HOUR, SystemTime.wHour);
- json.add(SM_IMAGE_MINUTE, SystemTime.wMinute);
- json.add(SM_IMAGE_SEC, SystemTime.wSecond);
- json.add(SM_IMAGE_MILLSEC, 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);
- pPreviewImageHead.add(SM_IMAGE_HEAD, json);
- return pPreviewImageHead.encode();
- }
- }
- void nsFPD::FPDDeviceCareRay::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:
- {
- //mLog::FINFO("EVT_DATA_RAW_IMAGE");
- m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
- memcpy(m_pFullImgBuffer, pParam, (size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight * sizeof(WORD));
- string strImageHeader = MakeImageHead(IMAGE_FULL);
- //mLog::FINFO("Full image head: {$}", strImageHeader);
-
- if (0 != m_nAngle)
- {
- m_AcqUnit->RotateImage(m_pFullImgBuffer, m_nFullImageHeight, m_nFullImageWidth, m_nAngle);
- }
- m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, strImageHeader, m_pFullImgBuffer, m_nFullImageWidth * m_nFullImageHeight);
- //mLog::FINFO("Add image over");
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- //mLog::FINFO("EVT_DATA_PREVIEW_IMAGE");
- memcpy(m_pPreviewImgBuffer, pParam, (size_t)m_nPreviewImageWidth * (size_t)m_nPreviewImageHeight * sizeof(WORD));
- string strImageHeader = MakeImageHead(IMAGE_PREVIEW);
- //mLog::FINFO("Preview image head: {$}", strImageHeader);
- m_AcqUnit->AddFrameWithRawHead(IMAGE_PREVIEW, strImageHeader, m_pPreviewImgBuffer, m_nPreviewImageWidth * m_nPreviewImageHeight);
- break;
- }
- case EVT_DATA_DOSEPARAM:
- {
- m_nTargetCalibExi = nParam1;
- //mLog::FINFO("EVT_DATA_DOSEPARAM m_nTargetCalibExi:{$}", m_nTargetCalibExi);
- break;
- }
- default:
- //mLog::FERROR("Not support this data({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceCareRay::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)
- // {
- // AddErrMsg("0", "communication error");
- // SendTemperatureValue(0);
- // SendWifiValue(0);
- // SendBatteryValue(0);
- // }
- // else if (strTemp.find("false") != std::string::npos)
- // {
- // DelErrMsg("0");
- // }
- //}
- 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:
- //mLog::FERROR("Not support this error({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceCareRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- //mLog::FERROR("Not support this warn({$})", nEventID);
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::ActiveSyncMode(int nSyncMode)
- {
- //mLog::FINFO("--Func-- ActiveSyncMode nSyncMode:{$}", nSyncMode);
- m_eSyncMode = (SYNC_MODE)nSyncMode;
- if (g_pDetector->SetSyncMode(nSyncMode))
- {
- return RET_SUCCEED;
- }
- else
- {
- //mLog::FERROR("ActiveSyncMode fail!");
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::ActiveDetector(bool bActive)
- {
- //mLog::FINFO("--Func-- ActiveDetector bActive:{$}", bActive);
- if (g_pDetector->ActiveDetector(this, bActive))
- {
- if (bActive)
- {
- //mLog::FINFO("ActiveDetector success!");
- }
- else
- {
- //mLog::FINFO("InActiveDetector success!");
- }
- return RET_SUCCEED;
- }
- else
- {
- if (bActive)
- {
- //mLog::FERROR("ActiveDetector fail!");
- }
- else
- {
- //mLog::FERROR("InActiveDetector fail!");
- }
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode)
- {
- //mLog::FINFO("--Func-- UpdateCalibMode eCalibMode:{$}", (int)eCalibMode);
- m_stDeviceConfig.nCalibMode = (int)eCalibMode;
- if (g_pDetector->UpdateCalibMode(eCalibMode))
- {
- //mLog::FINFO("UpdateCalibMode success!");
- return RET_SUCCEED;
- }
- else
- {
- //mLog::FERROR("UpdateCalibMode fail!");
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::UpdateNotifyStatusTimePeriod(int nTime)
- {
- //mLog::FINFO("--Func-- UpdateNotifyStatusTimePeriod nTime:{$}", nTime);
- m_stDeviceConfig.nNotifyStatusTimePeriod = nTime;
- g_pDetector->SetNotifyStatusTimePeriod(nTime);
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::UpdateReconnectTimePeriod(int nTime)
- {
- //mLog::FINFO("--Func-- UpdateReconnectTimePeriod nTime:{$}", nTime);
- m_stDeviceConfig.nReconnectTimePeriod = nTime;
- g_pDetector->SetReconnectTimePeriod(nTime);
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::UpdateLastCalibrationDate(std::string in)
- {
- //mLog::FINFO("--Func-- UpdateLastCalibrationDate in:{$}", in);
- m_stDeviceConfig.strLastCalibrationDate = in;
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::UpdateCalibrationFileExpireTime(std::string in)
- {
- //mLog::FINFO("--Func-- UpdateCalibrationFileExpireTime in:{$}", in);
- m_stDeviceConfig.strCalibrationFileExpireTime = in;
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::UpdateCalibrationFileExpirationReminder(std::string in)
- {
- //mLog::FINFO("--Func-- UpdateCalibrationFileExpirationReminder in:{$}", in);
- m_stDeviceConfig.strCalibrationFileExpirationReminder = in;
- return RET_SUCCEED;
- }
- /***
- * 客户端获取探测器信息
- ***/
- RET_STATUS nsFPD::FPDDeviceCareRay::GetDetectorInfo(string& strInfo)
- {
- //mLog::FINFO("--Func-- GetDetectorInfo");
- ResDataObject strDetectorInfo;
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- //mLog::FWARN("strPanelSerial is null, Send Default Info");
- strDetectorInfo.add("DetectorName", "Simulator");
- strDetectorInfo.add("DetectorSN", "Simulator");
- 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");
- strInfo = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
- strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
- //strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str());
- //strDetectorInfo.add("APFirmware", "NULL");
- //strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- //strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
- //strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime);
- //strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn);
- //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str());
- //strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str());
- //strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str());
- //strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate);
- //strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel);
- //strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted);
- //strDetectorInfo.add("SystemAS", m_stDeviceConfig.pDetModeInfoStruct[0].nWorkStation);
- strInfo = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
|