123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.CareRay.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "CareRayCtrl.h"
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- extern const char* g_szMouldPath;
- Log4CPP::Logger* //mLog::gLogger = nullptr;
- static std::unique_ptr <CareRayCtrl> g_pDetector;
- static nsFPD::CareRayDriver gIODriver;
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsFPD::CareRayDriver();
- }
- nsFPD::CareRayDriver::CareRayDriver()
- {
- pObjDev = nullptr;
- m_bConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::CareRayDriver::~CareRayDriver()
- {
- if (nullptr != pObjDev)
- {
- 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");
- }
- bool nsFPD::CareRayDriver::Connect()
- {
- //mLog::FINFO(__FUNCTION__);
- pObjDev = new FPDDeviceCareRay(EventCenter, m_ConfigFileName);
- m_bConnect = true; //connect执行完毕,置为true
- return true;
- }
- void nsFPD::CareRayDriver::Disconnect()
- {
- //mLog::FINFO(__FUNCTION__);
- if (nullptr != pObjDev)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- m_bConnect = false; //disconnect置为false
- }
- bool nsFPD::CareRayDriver::isConnected() const
- {
- return m_bConnect;
- }
- auto nsFPD::CareRayDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- //mLog::FINFO(__FUNCTION__);
- auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
- if (!pObjDev->CreateDevice())
- {
- return nullptr;
- }
- pObjDev->Register();
- return Device;
- }
- std::string nsFPD::CareRayDriver::DriverProbe()
- {
- //mLog::FINFO(__FUNCTION__);
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- auto Child = r_config[NODE_CONFIGURATION];
- HardwareInfo.add(NODE_MajorID, Child[NODE_MajorID]);
- HardwareInfo.add(NODE_MinorID, Child[NODE_MinorID]);
- HardwareInfo.add(NODE_VendorID, Child[NODE_VendorID]);
- HardwareInfo.add(NODE_ProductID, Child[NODE_ProductID]);
- HardwareInfo.add(NODE_SerialID, Child[NODE_SerialID]);
- }
- else
- {
- HardwareInfo.add(NODE_MajorID, "Detector");
- HardwareInfo.add(NODE_MinorID, "Driver");
- HardwareInfo.add(NODE_VendorID, "CareRay");
- HardwareInfo.add(NODE_ProductID, "CareRay");
- HardwareInfo.add(NODE_SerialID, "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /***
- ** 获取ID和配置
- ***/
- std::string nsFPD::CareRayDriver::GetResource()
- {
- printf("CareRay driver: GetResource m_ConfigFileName:%s\r\n", m_ConfigFileName.c_str());
- //mLog::FINFO("CareRay driver: GetResource m_ConfigFileName:{$}", m_ConfigFileName.c_str());
- ResDataObject temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- //mLog::FERROR("Load {$} failed!!!", m_ConfigFileName.c_str());
- return "";
- }
- m_ConfigAll = temp;
- m_Configurations = temp["CONFIGURATION"];
- ResDataObject DescriptionTemp;
- ResDataObject ListTemp;
- string strTemp = ""; //用于读取字符串配置信息
- string strIndex = ""; //用于读取配置信息中的List项
- int nTemp = -1; //用于读取整型配置信息
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- string strAccess = ""; //用于存储权限的类型 R/W/RW
- string strRequired = ""; // TRUE/FALSE
- string strDefaultValue = "";
- string strRangeMin = "";
- string strRangeMax = "";
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- m_pAttribute->clear();
- m_pDescription->clear();
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- DescriptionTemp.clear();
- ListTemp.clear();
- //AttributeType
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
- DescriptionTemp.add(AttributeType, strTemp.c_str());
- strType = strTemp; //记录配置项的类型
- //AttributeKey
- //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
- GetDeviceConfigValue(m_Configurations, strTemp.c_str(), nTemp, strValue);
- //2. 赋值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if ("int" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
- }
- //AttributeList
- nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
- if (nTemp > 0) //ListNum不大于0时说明不需要list配置
- {
- for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
- auto temKey = std::to_string(nListIndex);
- ListTemp.add(temKey.c_str(), strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (ResDataObjectExption& e)
- {
- //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("CareRay driver module: get resource over \r\n");
- //mLog::FINFO("CareRay driver module: get resource over \r\n");
- return res;
- }
- std::string nsFPD::CareRayDriver::DeviceProbe()
- {
- //mLog::FINFO(__FUNCTION__);
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- auto Child = r_config[NODE_CONFIGURATION];
- HardwareInfo.add(NODE_MajorID, Child[NODE_MajorID]);
- HardwareInfo.add(NODE_MinorID, "Device");
- HardwareInfo.add(NODE_VendorID, Child[NODE_VendorID]);
- HardwareInfo.add(NODE_ProductID, Child[NODE_ProductID]);
- HardwareInfo.add(NODE_SerialID, Child[NODE_SerialID]);
- }
- else
- {
- HardwareInfo.add(NODE_MajorID, "Detector");
- HardwareInfo.add(NODE_MinorID, "Device");
- HardwareInfo.add(NODE_VendorID, "CareRay");
- HardwareInfo.add(NODE_ProductID, "CareRay");
- HardwareInfo.add(NODE_SerialID, "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- bool nsFPD::CareRayDriver::GetDeviceConfig(std::string& Cfg)
- {
- ////mLog::FINFO("GetDeviceConfig Cfg:{$}", Cfg.c_str());
- Cfg = m_DeviceConfig.encode();
- return true;
- }
- bool nsFPD::CareRayDriver::SetDeviceConfig(std::string Cfg)
- {
- printf("SetDeviceConfig Cfg:%s\n",Cfg.c_str());
- ////mLog::FINFO("SetDeviceConfig Cfg:{$}", Cfg.c_str());
- ResDataObject DeviceConfig;
- DeviceConfig.decode(Cfg.c_str());
- ResDataObject DescriptionTempEx;
- DescriptionTempEx = DeviceConfig["DeviceConfig"];
- bool bSaveFile = false; //true:重新保存配置文件
- string strAccess = "";
- for (int i = 0; i < DescriptionTempEx.size(); i++)
- {
- ResDataObject temp = DescriptionTempEx[i];
- //mLog::FINFO("DeviceConfig: {$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- //mLog::FINFO("strKey:{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()][AttributeAccess];
- if ("rw" == strAccess || "RW" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到AttributeKey
- int nConfigInfoCount = (int)m_Configurations[NODE_ConfigToolInfo].GetKeyCount(NODE_AttributeInfo);
- string strTemp = "";
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations[NODE_ConfigToolInfo][nInfoIndex][NODE_AttributeKey];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations[NODE_ConfigToolInfo][nInfoIndex][NODE_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)
- {
- //4. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- bool nsFPD::CareRayDriver::SaveConfigFile(bool bSendNotify)
- {
- m_ConfigAll[NODE_CONFIGURATION] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- ////mLog::FINFO("SaveConfigFile m_ConfigAll:{$}", m_ConfigAll.encode());
- return true;
- }
- 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[NODE_connections][pInnerKey];
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp || DetectorDescription == strTemp
- || DetectorSerialNumber == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp || ImageWidth == strTemp || ImageHeight == strTemp
- || RawImgWidth == strTemp || RawImgHeight == strTemp || WidthOffset == strTemp || HeightOffset == strTemp
- || CcosXwindowSize == strTemp || IsSaveRaw == strTemp)
- {
- strValue = (string)config[NODE_ModeTable][NODE_DetectorMode][pInnerKey];
- }
- else if (TempMaxLimit == 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
- || ReConnect == strTemp || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp
- || CcosDetectorAttachedFlag == strTemp || AmplificationFactor == strTemp || SID == strTemp || SOD == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- //mLog::FERROR("Error Configuration item: {$}", pInnerKey);
- }
- }
- printf("GetDeviceConfigValue pInnerKey:%s,strValue:%s\n", pInnerKey, strValue.c_str());
- ////mLog::FINFO("GetDeviceConfigValue pInnerKey:{$},strValue:{$}", pInnerKey, strValue.c_str());
- return true;
- }
- bool nsFPD::CareRayDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- printf("SetDeviceConfigValue pInnerKey:%s,szValue:%s\n", pInnerKey, szValue);
- ////mLog::FINFO("SetDeviceConfigValue pInnerKey:{$},szValue:{$}", pInnerKey, szValue);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- config[NODE_connections][pInnerKey] = szValue;
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp || WidthOffset == strTemp || HeightOffset == strTemp ||
- CcosXwindowSize == strTemp || IsSaveRaw == strTemp)
- {
- config[NODE_ModeTable][NODE_DetectorMode][pInnerKey] = szValue;
- }
- else if (TempMaxLimit == 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 || ReConnect == strTemp || FPDExamMode == strTemp ||
- FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp ||
- AmplificationFactor == strTemp || SID == strTemp || SOD == 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_strWorkPath = GetProcessDirectory();
- m_pImgBuffer = nullptr;
- m_eAppStatus = APP_STATUS_IDLE;
- m_bConnect = false;
- m_eSyncMode = SYNC_HARDWARE;
- m_fFactorEXI2UGY = 0.0f;
- m_nCurrentMode = -1;
- m_nCurrentActiveDetectorID = -1;
- m_fCurrentDetectorTemperature = 0.0f;
- m_nCurrentBatteryValue = 0;
- m_nCurrentWifiValue = 0;
- 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));
- 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));
- EventCenter = center;
- }
- nsFPD::FPDDeviceCareRay::~FPDDeviceCareRay()
- {
- }
- std::string nsFPD::FPDDeviceCareRay::GetGUID() const
- {
- return DetectorUnitType;
- }
- bool nsFPD::FPDDeviceCareRay::Prepare()
- {
- //mLog::FINFO(__FUNCTION__);
- EventCenter->OnMaxBlockSize("CareRayDmQue", m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgHeight * 2, 3, 1500 * 1500 * 2, 1);
- Connect();
- return true;
- }
- bool nsFPD::FPDDeviceCareRay::CreateDevice()
- {
- if (!LoadConfig())
- {
- return false;
- }
- if (!g_pDetector)
- {
- g_pDetector.reset(new CareRayCtrl());
- }
- return g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- }
- void nsFPD::FPDDeviceCareRay::Register()
- {
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::Connect()
- {
- m_DetectorCtrlUnit->SetAttachStatus("1"); //没有attach功能,直接上发1,使客户端显示探测器状态
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
- {
- m_bConnect = true;
- ret = RET_STATUS::RET_SUCCEED;
- }
- return ret;
- }
- /***
- * 客户端获取探测器信息
- ***/
- RET_STATUS nsFPD::FPDDeviceCareRay::GetDetectorInfo(string& strFPDInfo)
- {
- ResDataObject strDetectorInfo;
- string strTempTemp = " ";
- //mLog::FINFO("Get Detector Info");
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- //mLog::FINFO("Get Detector Info Failed, Send Default Info");
- strDetectorInfo.add("DetectorName", "Simulator");
- strDetectorInfo.add("DetectorSN", "Simulator");
- //strDetectorInfo.add("Firmware", " ");
- //strDetectorInfo.add("APFirmware", " ");
- //strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- strDetectorInfo.add("SSID", " ");
- strDetectorInfo.add("LifeTime", "0");
- strDetectorInfo.add("PowerOn", "0");
- strDetectorInfo.add("DateCode", " ");
- strDetectorInfo.add("PartNumber", " ");
- strDetectorInfo.add("WifiDataRate", " ");
- strDetectorInfo.add("WifiChannel", "0");
- strDetectorInfo.add("DetectorExist", "0");
- strDetectorInfo.add("SystemAS", "0");
- strDetectorInfo.add("CalibrationDate", "0");
- strDetectorInfo.add("CalibrationDue", "0");
- strDetectorInfo.add("CalibrationExist", "0");
- strDetectorInfo.add("CommunicationStatus", "0");
- strDetectorInfo.add("DetectorTemperature", "0");
- strDetectorInfo.add("FDCalibrationTemperature", "0");
- strDetectorInfo.add("TemperatureStatus", "0");
- strDetectorInfo.add("WaitTime", "0");
- strDetectorInfo.add("DetectorWifiSignal", "0");
- strDetectorInfo.add("DetectorBattery", "0");
- strDetectorInfo.add("ShockSensor", "NULL");
- strDetectorInfo.add("FirmwareUpdate", "0");
- //encode
- strFPDInfo = 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);
- //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("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);
- ////mLog::FINFO( "{$}", strDetectorInfo.encode());
- strFPDInfo = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::EnterExam(int nExamMode)
- {
- //mLog::FINFO("{$} {$}",__FUNCTION__, nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- //mLog::FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS_WORK_END:
- //mLog::FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- 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:
- m_eAppStatus = APP_STATUS_IDLE;
- //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);
- return RET_STATUS::RET_SUCCEED;
- }
- /***
- * 激活对应的探测器
- ***/
- RET_STATUS nsFPD::FPDDeviceCareRay::ActiveDetector(bool bActive)
- {
- //mLog::FINFO("{$}", __FUNCTION__);
- int nDetectorID = 1;
- if (m_nCurrentActiveDetectorID == nDetectorID)
- {
- //mLog::FINFO("Same active detector ID, return true");
- return RET_STATUS::RET_SUCCEED;
- }
- else
- {
- m_nCurrentActiveDetectorID = nDetectorID;
- }
- if (!g_pDetector->ActiveDetector(nDetectorID)) //暂时就考虑一块探测器
- {
- return RET_STATUS::RET_FAILED;
- }
- return RET_STATUS::RET_SUCCEED;
- }
- bool nsFPD::FPDDeviceCareRay::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
- {
- //mLog::FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::SetAcqMode(string strAcqMode)
- {
- //mLog::FINFO("SetAcqMode strAcqMode:{$}", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接,不执行
- if (!m_bConnect)
- {
- //mLog::FERROR("Detector not connected, return");
- return ret;
- }
- int nMode = RAD;
- bool bRet = GetLogicMode(strAcqMode, nMode);
- if (!bRet)
- {
- return ret;
- }
- //ready后分三种情况
- //1、切换View
- //2、退出检查重新进View
- //3、正常曝光结束流程
- //不管哪种情况这里都把采集状态置为false,重新调用StartAcq
- g_pDetector->SetCanelFlag(true);
- g_pDetector->SetAcqStatus(false);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- //判重
- if(m_nCurrentMode == nMode)
- {
- //mLog::FINFO("Same mode, return true");
- return RET_STATUS::RET_SUCCEED;
- }
- //获取当前模式号对应的配置
- if (!m_DetectorConfiguration->GetDetModeInfo(m_stModeInfo, m_stCalibInfo, nMode))
- {
- //mLog::FERROR("Illegal mode!");
- return ret;
- }
- int nImgX = m_stModeInfo.nImageWidth;
- int nImgY = m_stModeInfo.nImageHeight;
- //申请图像内存
- if (nullptr != m_pImgBuffer)
- {
- delete m_pImgBuffer;
- m_pImgBuffer = nullptr;
- }
- m_pImgBuffer = new WORD[(size_t)nImgX * (size_t)nImgY];
- //发送图像信息
- if (m_stModeInfo.nRotateAngle == 90 || m_stModeInfo.nRotateAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(nImgX, nImgY, m_stModeInfo.nPhySizeInfoBit, false);
- }
- else
- {
- m_AcqUnit->SetFulImageInfo(nImgY, nImgX, m_stModeInfo.nPhySizeInfoBit, false);
- }
- m_AcqUnit->SetPrevImageInfo(true, 96, 96, false);
- m_fFactorEXI2UGY = 100.0f / (float)m_stModeInfo.nSensitivity * 1.0f;
- //mLog::FINFO("SyncType: {$}, EXI2UGY: {$}", m_stModeInfo.nSyncType, m_fFactorEXI2UGY);
- if (g_pDetector->SetAcqMode(m_stModeInfo, m_stCalibInfo, nMode))
- {
- m_nCurrentMode = nMode;
- ret = RET_STATUS::RET_SUCCEED;
- }
- //add by wxx for 万东:20230809
- int Sensitivity = (int)m_stModeInfo.nSensitivity;
- char szValue[64];
- sprintf(szValue, "%i", Sensitivity);
- m_DetectorCtrlUnit->SetFPDSensitivity(szValue);
- //mLog::FINFO("FPDSensitivity[{$}]", Sensitivity);
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::GetSyncMode(SYNC_MODE& eSyncMode)
- {
- eSyncMode = (SYNC_MODE)m_stModeInfo.nSyncType;
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::PrepareAcquisition()
- {
- //mLog::FINFO("PrepareAcquisition start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::FERROR("Detector not connected, return");
- return ret;
- }
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- //mLog::FERROR("PrepareAcquisition failed! Detector at Calibration status");
- return ret;
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //mLog::FERROR("Detector already at Acq status");
- return RET_STATUS::RET_SUCCEED;//进检查后退检查,如果再次调用prepare,在这里防护
- }
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- //mLog::FINFO("PrepareAcquisition over");
- }
- else
- {
- //mLog::FERROR("PrepareAcquisition fail!");
- }
-
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StartAcquisition(string in)
- {
- //mLog::FINFO("StartAcquisition start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::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))
- {
- //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status.");
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //mLog::FERROR("Detector already at Acq status.");
- ret = RET_STATUS::RET_SUCCEED;
- }
- }
- else
- {
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- else
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- //mLog::FINFO("StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StopAcquisition()
- {
- //mLog::FINFO(__FUNCTION__);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::FERROR("Detector not connected, return");
- return ret;
- }
- //if (g_pDetector->StopAcquisition(this)) //先不调用,避免影响采集时序 --ys
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- //mLog::FINFO("StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- //mLog::FINFO("{$} {$}", __FUNCTION__, (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::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())
- {
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //mLog::FERROR("ActiveCalibration failed. Detector at Acq status");
- }
- return RET_STATUS::RET_FAILED;
- }
- assert(g_pDetector);
- 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");
- }
- //mLog::FINFO("ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::PrepareCalibration()
- {
- //mLog::FINFO(__FUNCTION__);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->PrepareCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- //mLog::FERROR("Prepare calibration failed");
- }
- //mLog::FINFO("PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::GetRequestedDose(string& strDose)
- {
- //fDose = m_fDose;
- strDose = to_string(100); //暂时写死
- //mLog::FINFO("Dose request: {$}", strDose.c_str());
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StartCalibration()
- {
- //mLog::FINFO(__FUNCTION__);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::FERROR("Detector not connected, return");
- return ret;
- }
- if ((m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PAUSE) && (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- //mLog::FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus());
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //mLog::FERROR("Start calibration failed. Detector at Acq status");
- }
- return ret;
- }
- if (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING)
- {
- //mLog::FERROR("Detector already at calib status");
- return ret;
- }
- if (g_pDetector->StartCalibration(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- //mLog::FERROR("Start calibration failed");
- }
- //mLog::FINFO("StartCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceCareRay::StopCalibration()
- {
- //mLog::FINFO(__FUNCTION__);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- //mLog::FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->StopCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- }
- else
- {
- //mLog::FERROR("Start calibration failed");
- }
- //mLog::FINFO("StopCalibration over");
- return ret;
- }
- void nsFPD::FPDDeviceCareRay::ConfirmCalExposure()
- {
- //mLog::FINFO(__FUNCTION__);
- g_pDetector->ConfirmCalExposure();
- }
- void nsFPD::FPDDeviceCareRay::RejectCalExposure()
- {
- //mLog::FINFO(__FUNCTION__);
- g_pDetector->RejectCalExposure();
- }
- 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);
- }
- void nsFPD::FPDDeviceCareRay::SendTemperatureMaxLimit(float fValue)
- {
- m_Temperature->SetTemperatureErrorMax(to_string(fValue));
- //mLog::FINFO("SendTemperatureMaxLimit: {$}", fValue);
- }
- void nsFPD::FPDDeviceCareRay::SendTemperatureLowLimit(float fValue)
- {
- m_Temperature->SetTemperatureErrorMin(to_string(fValue));
- //mLog::FINFO("SendTemperatureLowLimit: {$}", fValue);
- }
- void nsFPD::FPDDeviceCareRay::SendTemperatureMaxWarn(float fValue)
- {
- m_Temperature->SetTemperatureWarningMax(to_string(fValue));
- //mLog::FINFO("SendTemperatureMaxWarn: {$}", fValue);
- }
- void nsFPD::FPDDeviceCareRay::SendTemperatureMinWarn(float fValue)
- {
- m_Temperature->SetTemperatureWarningMin(to_string(fValue));
- //mLog::FINFO("SendTemperatureMinWarn: {$}", fValue);
- }
- void nsFPD::FPDDeviceCareRay::SendWifiValue(int nValue)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nValue, nStatus);
- //mLog::FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
- }
- void nsFPD::FPDDeviceCareRay::SendWifiMinLimit(int nValue)
- {
- m_Wifi->SetSignalErrorMin(to_string(nValue));
- //mLog::FINFO("SendWifiMinLimit: {$}", nValue);
- }
- void nsFPD::FPDDeviceCareRay::SendWifiMinWarn(int nValue)
- {
- m_Wifi->SetSignalWarningMin(to_string(nValue));
- //mLog::FINFO("SendWifiMinWarn: {$}", nValue);
- }
- void nsFPD::FPDDeviceCareRay::SendBatteryValue(int nValue)
- {
- int nStatus = 0;
- m_Battery->SetRemainPowerValue(nValue, nStatus);
- //mLog::FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
- }
- void nsFPD::FPDDeviceCareRay::SendBatteryMinLimit(int nValue)
- {
- m_Battery->SetBatteryErrorMin(to_string(nValue));
- //mLog::FINFO("SendBatteryMinLimit: {$}", nValue);
- }
- void nsFPD::FPDDeviceCareRay::SendBatteryMinWarn(int nValue)
- {
- m_Battery->SetBatteryWarningMin(to_string(nValue));
- //mLog::FINFO("SendBatteryMinWarn: {$}", nValue);
- }
- bool nsFPD::FPDDeviceCareRay::LoadConfig()
- {
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
- {
- //mLog::FERROR("Load configuration file failed!!!");
- return false;
- }
- m_eSyncMode = (SYNC_MODE)m_stDeviceConfig.pDetModeInfoStruct[0].nSyncType; //临时方案,先加载同步配置,供子系统使用
- //mLog::FINFO("LoadConfig m_eSyncMode:{$}", (int)m_eSyncMode);
- m_DetectorCtrlUnit->SetDetectorType("SCINTILLATOR");
- //不同采集模式可能会有不同的值,后面在考虑
- auto strSensitivity = to_string(m_stDeviceConfig.pDetModeInfoStruct[0].nSensitivity);
- m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity);
- m_DetectorCtrlUnit->SetPixelData("");
- m_DetectorCtrlUnit->SetTargetEXI("5000");
- //暂时发特定值
- m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
- m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(m_stDeviceConfig.strCalibrationTime);
- m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0, m_stDeviceConfig.nBatteryLimit,
- m_stDeviceConfig.nBatteryWarning, 100, m_stDeviceConfig.nBatteryLimit, 100, 100, 0, EventCenter));
- m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f, m_stDeviceConfig.fTemperLowLimit,
- m_stDeviceConfig.fTemperMinWarn, m_stDeviceConfig.fTemperMaxWarn,
- m_stDeviceConfig.fTemperMinWarn, m_stDeviceConfig.fTemperMaxWarn,
- m_stDeviceConfig.fTemperMaxLimit, 0.0f, EventCenter));
- m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning,
- 100, m_stDeviceConfig.nWifiLimit, 100, 100, 0, EventCenter));
- return true;
- }
- void nsFPD::FPDDeviceCareRay::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- 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->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->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum);
- Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
- Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- }
- void nsFPD::FPDDeviceCareRay::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);
- }
- 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->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode);
- Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
- Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_SyncUnit.get(), &SyncUnit::JSGetConnectStatus);
- 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);
- }
- 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::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->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);
- }
- void nsFPD::FPDDeviceCareRay::RegisterOthers(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
- Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
- Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
- Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
- Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
- Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
- Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
- Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
- Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
- Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
- Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
- }
- 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)
- {
- switch (nEventID)
- {
- case EVT_CONF_PANEL_SERIAL:
- {
- m_stDeviceConfig.strPanelSerial = pszMsg;
- //mLog::FINFO("OnEventProcessConf: Detector {$} SN {$}", nDetectorID, pszMsg);
- m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
- break;
- }
- default:
- break;
- }
- }
- void nsFPD::FPDDeviceCareRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_INFO_CALIBRATIOIN_TIME:
- {
- m_stDeviceConfig.strCalibrationDate = pszMsg;
- //mLog::FINFO("OnEventProcessInfo: Detector {$} Calibration Time: {$}", nDetectorID, pszMsg);
- m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate);
- m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration("");
- break;
- }
- default:
- break;
- }
- }
- 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_PANEL:
- {
- ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
- if (PANEL_STANDBY == nParam1)
- {
- //mLog::FINFO("set detector standby");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else if (PANEL_END_ACQ == nParam1)
- {
- //mLog::FINFO("Panel Status: End acq");
- /*if (g_pDetector->StopAcquisition(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }*/
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else if (PANEL_AEC_PRE_END == nParam1)
- {
- //mLog::FINFO("Panel Status: AEC pre-shoot end");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- string strTemp = pszMsg;
- if (strTemp.find("true") != std::string::npos)
- {
- m_SyncUnit->ExpReadyNotify(m_stModeInfo.nXwindow);
- }
- else
- {
- m_SyncUnit->ExpReadyNotify(0);
- }
- }
- else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
- {
- m_stImgCreateTime = { 0 };
- GetLocalTime(&m_stImgCreateTime);
- //mLog::FINFO("Full image create time-{$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
- //mLog::FINFO("XWindow on SyncMode:{$}", (int)m_eSyncMode);
- if (SYNC_MANUAL == m_eSyncMode || SYNC_SOFTWARE == m_eSyncMode || SYNC_HARDWARE == m_eSyncMode)
- {
- m_SyncUnit->XWindowOnNotify();
- }
- else if (SYNC_AED == m_eSyncMode)
- {
- m_SyncUnit->FakeEIPONNotify();
- }
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- //mLog::FINFO("XWindow off SyncMode:{$}", (int)m_eSyncMode);
- if (SYNC_MANUAL == m_eSyncMode || SYNC_SOFTWARE == m_eSyncMode || SYNC_HARDWARE == m_eSyncMode) //探测器的关窗是模拟计算的,所以非软同步模式也没必要发送了
- {
- m_SyncUnit->XWindowOffNotify();
- }
- }
- else if(PANEL_CONNECT == nParam1)
- {
- //mLog::FINFO("Notify FPD Connect");
- m_SyncUnit->FPDConnectStatusNotify(true);
- }
- else if (PANEL_DISCONNECT == nParam1)
- {
- //mLog::FINFO("Notify FPD Disconnect");
- m_SyncUnit->FPDConnectStatusNotify(false);
- }
- break;
- }
- case EVT_STATUS_CALIBRATIOIN:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- break;
- case PANEL_EVENT_END_OK:
- 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_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:
- {
- float fTemperature = fParam2;
- m_fCurrentDetectorTemperature = fParam2;
- //达到温度高低警告值时、达到温度高低最大限制时向上通知
- if (fTemperature > m_stDeviceConfig.fTemperMaxLimit)
- {
- SendTemperatureMaxLimit(fTemperature);
- }
- else if (fTemperature > m_stDeviceConfig.fTemperMaxWarn)
- {
- SendTemperatureMaxWarn(fTemperature);
- }
- else if (fTemperature < m_stDeviceConfig.fTemperLowLimit)
- {
- SendTemperatureLowLimit(fTemperature);
- }
- else if (fTemperature < m_stDeviceConfig.fTemperMinWarn)
- {
- SendTemperatureMinWarn(fTemperature);
- }
- SendTemperatureValue(fTemperature);
- break;
- }
- case EVT_STATUS_WIFI:
- {
- int nWifiLevel = nParam1;
- m_nCurrentWifiValue = nParam1;
- //wifi信号达到警告值时,wifi信号达到最低限制时向上通知
- if (nWifiLevel < m_stDeviceConfig.nWifiLimit)
- {
- SendWifiMinLimit(nWifiLevel);
- }
- else if (nWifiLevel < m_stDeviceConfig.nWifiWarning)
- {
- SendWifiMinWarn(nWifiLevel);
- }
- SendWifiValue(nWifiLevel);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- int nBatteryValue = nParam1;
- m_nCurrentBatteryValue = nParam1;
- //电量达到警告值时,电量达到最低限制时向上通知
- if (nBatteryValue < m_stDeviceConfig.nBatteryLimit)
- {
- SendBatteryMinLimit(nBatteryValue);
- }
- else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning)
- {
- SendBatteryMinWarn(nBatteryValue);
- }
- SendBatteryValue(nBatteryValue);
- break;
- }
- default:
- //mLog::FERROR("Not support this status({$})", nEventID);
- break;
- }
- }
- 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("Image Arrived");
- int nImgX = m_stModeInfo.nImageWidth;
- int nImgY = m_stModeInfo.nImageHeight;
- int nAngle = m_stModeInfo.nRotateAngle;
- memcpy(m_pImgBuffer, pParam, (size_t)nImgX * (size_t)nImgY * sizeof(WORD));
- //单独通知ImagerPixelSpacing,否则会造成ImageSave崩溃
- m_AcqUnit->ImagerPixelSpacingNotify(m_stModeInfo.nPixelPitch);// DCS 像素间距
- m_AcqUnit->SidNotify(m_stDeviceConfig.fSid);
- m_AcqUnit->SodNotify(m_stDeviceConfig.fSod);
- m_AcqUnit->ErmfNotify(m_stDeviceConfig.fAmplificationFactor);
-
- //ImageHeader DICOM
- ResDataObject objImageHead, objTemp;
- objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
- objTemp.add(SM_IMAGE_BIT, 16);
- objTemp.add(SM_IMAGE_TAG, 1);
- objTemp.add(SM_IMAGE_INDEX, 1);
- objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
- objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
- objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
- objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
- objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
- objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
- objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
- objTemp.add(SM_IMAGE_LSB, "5000");
- objTemp.add(SM_IMAGE_DOSE, m_stModeInfo.nSensitivity);
- objTemp.add(SM_IMAGE_PIXELSPACING, m_stModeInfo.nPixelPitch / m_stDeviceConfig.fAmplificationFactor);// DCS / 放大因子( SID/(SOD-20))
- //mLog::FINFO("PixelSpacing:{$}", m_stModeInfo.nPixelPitch / m_stDeviceConfig.fAmplificationFactor);
- //objTemp.add(SM_IMAGE_PIXELSPACING, m_stModeInfo.nPixelPitch);// DCS / 放大因子( SID/(SOD-20))
- objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
- objTemp.add(SM_IMAGE_FLIP, "No");
- objTemp.add(SM_IMAGE_ORIGINX, "0");
- objTemp.add(SM_IMAGE_ORIGINY, "0");
- objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
- objTemp.add(SM_IMAGE_TEMP, m_fCurrentDetectorTemperature);
- if (0 != nAngle)
- {
- m_AcqUnit->RotateImage(m_pImgBuffer, nImgY, nImgX, nAngle);
- }
- if (90 == nAngle || 270 == nAngle)
- {
- objTemp.add(SM_IMAGE_WIDTH, nImgY);
- objTemp.add(SM_IMAGE_HEIGHT, nImgX);
- objTemp.add(SM_IMAGE_ROTATION, "Yes");
- }
- else
- {
- objTemp.add(SM_IMAGE_WIDTH, nImgX);
- objTemp.add(SM_IMAGE_HEIGHT, nImgY);
- objTemp.add(SM_IMAGE_ROTATION, "No");
- }
- objImageHead.add(SM_IMAGE_HEAD, objTemp);
- //mLog::FINFO("Full image head: {$}", objImageHead.encode());
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //mLog::FINFO("nImgX:{$},nImgY:{$}", nImgX, nImgY);
- ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pImgBuffer, nImgX * nImgY);
- //mLog::FINFO("Add image over, {$}", (int)ret);
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- //mLog::FINFO("Preview Image Arrived");
- int nImgX = 96;
- int nImgY = 96;
- int nAngle = m_stModeInfo.nRotateAngle;
- memcpy(m_pImgBuffer, pParam, (size_t)nImgX * (size_t)nImgY * sizeof(WORD));
- //暂时先用假值,有需要再改
- ResDataObject objImageHead, objTemp;
- objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_AEC_PREVIEW);
- objTemp.add(SM_IMAGE_BIT, 16);
- objTemp.add(SM_IMAGE_TAG, 1);
- objTemp.add(SM_IMAGE_INDEX, 1);
- objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear);
- objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth);
- objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay);
- objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour);
- objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute);
- objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond);
- objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds);
- objTemp.add(SM_IMAGE_LSB, "5000");
- objTemp.add(SM_IMAGE_DOSE, m_stModeInfo.nSensitivity);
- objTemp.add(SM_IMAGE_PIXELSPACING, m_stModeInfo.nPixelPitch);
- objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
- objTemp.add(SM_IMAGE_FLIP, "No");
- objTemp.add(SM_IMAGE_ORIGINX, "0");
- objTemp.add(SM_IMAGE_ORIGINY, "0");
- objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);
- objTemp.add(SM_IMAGE_TEMP, m_fCurrentDetectorTemperature);
- if (0 != nAngle)
- {
- m_AcqUnit->RotateImage(m_pImgBuffer, nImgY, nImgX, nAngle);
- }
- if (90 == nAngle || 270 == nAngle)
- {
- objTemp.add(SM_IMAGE_WIDTH, nImgY);
- objTemp.add(SM_IMAGE_HEIGHT, nImgX);
- objTemp.add(SM_IMAGE_ROTATION, "Yes");
- }
- else
- {
- objTemp.add(SM_IMAGE_WIDTH, nImgX);
- objTemp.add(SM_IMAGE_HEIGHT, nImgY);
- objTemp.add(SM_IMAGE_ROTATION, "No");
- }
- objImageHead.add(SM_IMAGE_HEAD, objTemp);
- //mLog::FINFO("Preview image head: {$}", objImageHead.encode());
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_AEC_PREVIEW, objImageHead.encode(), m_pImgBuffer, nImgX * nImgY);
- //mLog::FINFO("Add preview image over, {$}", (int)ret);
- 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)
- {
- SendTemperatureValue(0.0f);
- SendWifiValue(0);
- SendBatteryValue(0);
- }
- else if (strTemp.find("false") != std::string::npos)
- {
- }
- 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 event id:{$}", nEventID);
- }
|