1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.KonicaDR.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "KonicaCtrl.h"
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- //-----------------------------------------------------------------------------
- // FPDDeviceKonica
- //-----------------------------------------------------------------------------
- extern KonicaCtrl* g_pDetector;
- static nsFPD::KonicaDriver gIODriver;
- Log4CPP::Logger* gLogger = nullptr;
- extern const char* g_szMouldPath;
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsFPD::KonicaDriver();
- }
- nsFPD::KonicaDriver::KonicaDriver()
- {
- pObjDev = nullptr;
- m_bDriverConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::KonicaDriver::~KonicaDriver()
- {
- if (pObjDev != nullptr)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- void nsFPD::KonicaDriver::Prepare()
- {
- printf("CareRayDR driver module: prepare \r\n");
- string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)";
- Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.CareRayDR");
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("FPD.CareRayDR");
- #ifdef _WIN64
- FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #else
- FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #endif
- FINFO("CareRayDR Driver Prepare get logger");
- }
- bool nsFPD::KonicaDriver::Connect()
- {
- printf("CareRay driver module: Connect \r\n");
- FINFO("--Func-- driver connect \n");
- pObjDev = new FPDDeviceKonica(EventCenter, m_ConfigFileName);
- m_bDriverConnect = true; //connect执行完毕,置为true
- printf("CareRay driver module: Connect over\r\n");
- return true;
- }
- void nsFPD::KonicaDriver::Disconnect()
- {
- printf("CareRay driver module: Disconnect \r\n");
- FINFO("--Func-- driver disconnect \n");
- if (pObjDev != nullptr)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- m_bDriverConnect = false; //disconnect置为false
- }
- bool nsFPD::KonicaDriver::isConnected() const
- {
- return m_bDriverConnect;
- }
- auto nsFPD::KonicaDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("CareRay driver module: CreateDevice \r\n");
- FINFO("--Func-- driver createdevice \n");
- auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
- pObjDev->CreateDevice();
- pObjDev->Register();
- return Device;
- }
- std::string nsFPD::KonicaDriver::DriverProbe()
- {
- printf("KonicaDriver::DriverProbe \r\n");
- FINFO("KonicaDriver::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;
- }
- /***
- ** 获取ID和配置
- ***/
- std::string nsFPD::KonicaDriver::GetResource()
- {
- printf("KonicaDriver GetResource \r\n");
- FINFO("KonicaDriver GetResource");
- ResDataObject r_config, temp;
- printf("m_ConfigFileName:%s\n", m_ConfigFileName.c_str());
- 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");
- //FINFO(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
- m_pAttribute->clear();
- m_pDescription->clear();
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- DescriptionTemp.clear();
- ListTemp.clear();
- //AttributeType
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
- DescriptionTemp.add(AttributeType, strTemp.c_str());
- //FINFO("DescriptionTemp--> {$}: {$}", AttributeType, strTemp.c_str());
- strType = strTemp; //记录配置项的类型
- //AttributeKey
- //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
- GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
- //2. 赋值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if ("int" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
- }
- //AttributeList
- nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
- if (nTemp > 0) //ListNum不大于0时说明不需要list配置
- {
- for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
- //sprintf_s(sstream, "{$}", nListIndex);
- auto temKey = std::to_string(nListIndex);
- ListTemp.add(temKey.c_str(), strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Get config error: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
- m_DeviceConfig = DescriptionTempEx;
- string res = DescriptionTempEx.encode();
- printf("KonicaDriver module: get resource over \r\n");
- FINFO("KonicaDriver module: get resource over");
- return res;
- }
- std::string nsFPD::KonicaDriver::DeviceProbe()
- {
- printf("KonicaDriver module: DeviceProbe \r\n");
- FINFO("KonicaDriver module: 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();
- FINFO("KonicaDriver module DeviceProbe over");
- return str;
- }
- bool nsFPD::KonicaDriver::GetDeviceConfig(std::string& Cfg)
- {
- Cfg = m_DeviceConfig.encode();
- FINFO("GetDeviceConfig Cfg:{$}", Cfg);
- FINFO("GetDeviceConfig over");
- return true;
- }
- bool nsFPD::KonicaDriver::SetDeviceConfig(std::string Cfg)
- {
- FINFO("--Func-- 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];
- FINFO("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- FINFO("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess || "rw" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- bool nsFPD::KonicaDriver::SaveConfigFile(bool bSendNotify)
- {
- FINFO("SaveConfigFile m_ConfigFileName:{$}", m_ConfigFileName);
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- bool ret = m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- if (ret)
- {
- FINFO("SaveConfigFile Success!");
- return true;
- }
- else
- {
- FERROR("SaveConfigFile Fail!");
- return false;
- }
- }
- bool nsFPD::KonicaDriver::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 = "";
- FERROR("Error Configuration item: {$}", pInnerKey);
- }
- }
- //FINFO("GetDeviceConfigValue pInnerKey:{$},nPathID:{$},strValue:{$}", pInnerKey, nPathID, strValue);
- return true;
- }
- bool nsFPD::KonicaDriver::SetDeviceConfigValue(ResDataObject &config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- FINFO("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
- {
- FERROR("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- nsFPD::FPDDeviceKonica::FPDDeviceKonica(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));
- 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_ERROR));
- EventCenter = center;
- m_eAppStatus = APP_STATUS_IDLE;
- m_bEnterAcqStatus = false;
- m_CalibType = CCOS_CALIBRATION_TYPE_NONE;
- }
- nsFPD::FPDDeviceKonica::~FPDDeviceKonica()
- {
- if (nullptr != m_pFullImgBuffer)
- {
- delete[]m_pFullImgBuffer;
- m_pFullImgBuffer = nullptr;
- }
- if (nullptr != m_pPreviewImgBuffer)
- {
- delete[]m_pPreviewImgBuffer;
- m_pPreviewImgBuffer = nullptr;
- }
- }
- std::string nsFPD::FPDDeviceKonica::GetGUID() const
- {
- return DetectorUnitType;
- }
- bool nsFPD::FPDDeviceKonica::Prepare()
- {
- FINFO("--Func-- device prepare");
- EventCenter->OnMaxBlockSize("KonicaDrQue", m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgWidth * 2, 1, 4000 * 4000 * 2, 1);
- Connect();
- return true;
- }
- bool nsFPD::FPDDeviceKonica::CreateDevice()
- {
- FINFO("CreateDevice start");
- if (!LoadConfig())
- {
- FERROR("LoadConfig fail, return false");
- return false;
- }
- if (nullptr == g_pDetector)
- {
- g_pDetector = new KonicaCtrl();
- }
- g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- FINFO("CreateDevice end");
- return true;
- }
- void nsFPD::FPDDeviceKonica::Register()
- {
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- RET_STATUS nsFPD::FPDDeviceKonica::Connect()
- {
- FINFO("--Func-- device Connect");
- m_DetectorCtrlUnit->SetAttachStatus("1"); //没有attach功能,直接上发1,使客户端显示探测器状态
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (g_pDetector->Connect(this, m_strWorkPath.c_str()))
- {
- ret = RET_STATUS::RET_SUCCEED;
- if (m_stDeviceConfig.bSupportDDR) //是否支持DDR采集功能
- {
- m_DetectorCtrlUnit->SetSupportDDR("YES");
- }
- else
- {
- m_DetectorCtrlUnit->SetSupportDDR("NO");
- }
- //把通知状态信息的时间间隔传给ctrl
- g_pDetector->SetNotifyStatusTimePeriod(m_stDeviceConfig.nNotifyStatusTimePeriod);
- g_pDetector->SetReconnectTimePeriod(m_stDeviceConfig.nReconnectTimePeriod);
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::EnterExam(int nExamMode)
- {
- FINFO("--Func-- EnterExam {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS_WORK_END:
- FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- FINFO("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS_DETSHAR_END:
- FINFO("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS_CAL_BEGIN:
- FINFO("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS_CAL_END:
- FINFO("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_END;
- break;
- case APP_STATUS_WORK_IN_SENSITIVITY:
- FINFO("Enter into sensitivity test interface");
- m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
- break;
- default:
- break;
- }
- g_pDetector->EnterExamMode(nExamMode);
- if (nExamMode == APP_STATUS_WORK_END || nExamMode == APP_STATUS_CAL_END)
- {
- if (m_bEnterAcqStatus)
- {
- RET_STATUS ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- FERROR("EnterExam StopAcquisition fail!");
- return ret;
- }
- m_bEnterAcqStatus = false;
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- bool nsFPD::FPDDeviceKonica::GetLogicMode(string& strAcqMode, int& nLogicMode)
- {
- if (strAcqMode == "RAD")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "1")
- {
- nLogicMode = RAD;
- }
- else
- {
- FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::SetAcqMode(string strAcqMode)
- {
- FINFO("--Func-- SetAcqMode({$})", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接,不执行
- if (!m_bDeviceConnect)
- {
- 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_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"];
- FINFO("m_nImgBits:{$},m_nAngle:{$},m_nPixelSpacing:{$},m_nSensitivity:{$},m_nPreviewEnable:{$}",
- m_nImgBits, m_nAngle, m_nPixelSpacing, m_nSensitivity, m_nPreviewEnable);
- string strDoseOfExi = std::to_string(m_nSensitivity);
- m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
- 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)
- {
- FERROR("Read configuration failed, Error code: {$}", e.what());
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::GetSyncMode(SYNC_MODE& eSyncMode)
- {
- FINFO("--Func-- GetSyncMode");
- eSyncMode = m_eSyncMode;
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::PrepareAcquisition()
- {
- FINFO("--Func-- PrepareAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- FINFO("m_bEnterAcqStatus:{$}", m_bEnterAcqStatus);
- if (m_bEnterAcqStatus)
- {
- 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)
- {
- FERROR("StopAcquisition fail!");
- return ret;
- }
- }
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
-
- FINFO("PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::StartAcquisition(string in)
- {
- printf("--Func-- StartAcquisition \r\n");
- FINFO("--Func-- StartAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartAcquisition
- m_SyncUnit->XWindowOnNotify();//StartAcquisition
- }
- else
- {
- FERROR("StartAcquisition fail!");
- return ret;
- }
-
- FINFO("StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::StopAcquisition()
- {
- printf("--Func-- StopAcquisition \r\n");
- FINFO("--Func-- StopAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- //调用stop前探测器需处于采集状态,否则会报错
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//StopAcquisition
- m_bEnterAcqStatus = false;
- }
-
- FINFO("StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- printf("--Func-- ActiveCalibration %d \r\n", eType);
- FINFO("--Func-- ActiveCalibration {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
- {
- FERROR("calibration type is invalid!");
- return RET_STATUS::RET_INVALID;
- }
- else
- {
- m_CalibType = eType;
- }
- FINFO("m_bEnterAcqStatus:{$}", m_bEnterAcqStatus);
- if (m_bEnterAcqStatus)
- {
- FINFO("Detector is acq status need to stop");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- FERROR("StopAcquisition fail!");
- return ret;
- }
- }
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- if (eType == CCOS_CALIBRATION_TYPE_XRAY)
- {
- 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
- {
- FERROR("Active calibration failed");
- ret = RET_STATUS::RET_FAILED;
- }
- //重置校正流程参数
- m_nCalibCurrentCalibrationRound = 1;
- m_nCalibCurrentExposureIndex = 1;
- m_nCalibCurrentExposureNum = 0;
- FINFO("ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration------ \n");
- FINFO("--Func-- PrepareCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- if (g_pDetector->PrepareCalibration(this))
- {
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_PREPARE));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PrepareCalibration
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- printf("PrepareCalibration failed!\n");
- FERROR("PrepareCalibration failed!");
- return ret;
- }
-
- FINFO("--Func-- PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::GetRequestedDose(std::string& strDose)
- {
- FINFO("--Func-- GetRequestedDose");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- ResDataObject out;
- if (!m_bDeviceConnect)
- {
- FERROR("m_bDeviceConnect is false, detector not connect, return");
- return ret;
- }
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- FINFO("GetRequestedDose calib type is {$}", (int)nCalibrationType);
- if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
- {
- out.add("Dose", 0.0f);
- out.add("kV", 0.0f);
- out.add("mA", 0.0f);
- out.add("ms", 0.0f);
- out.add("mAs", 0.0f);
- }
- else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
- {
- FINFO("calib dose list size is {$}", m_CalibDoseList.size());
- ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1];
- int nTargetExi = (int)temp["TargetGainEXI"];
- m_DetectorCtrlUnit->SetTargetEXI(std::to_string(nTargetExi));
- FINFO("nTargetExi:{$}", nTargetExi);
- out.add("Dose", nTargetExi);
- out.add("kV", temp["KV"]);
- out.add("mA", temp["MA"]);
- out.add("ms", temp["MS"]);
- out.add("mAs", temp["MAS"]);
- }
- else
- {
- FERROR("Don't support CalibrationType($)", (int)nCalibrationType);
- return ret;
- }
- strDose = out.encode();
- FINFO("GetRequestedDose:{$}", strDose);
- ret = RET_STATUS::RET_SUCCEED;
- FINFO("--Func-- GetRequestedDose over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::SetRequestedDose(std::string strDose)
- {
- FINFO("--Func-- SetRequestedDose");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo)
- {
- printf("--Func-- GetCalibrationStep\n");
- 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))
- {
- FINFO("GetCalibrationStep success");
- }
- else
- {
- 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();
- FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str());
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::StartCalibration()
- {
- printf("--Func-- StartCalibration \r\n");
- FINFO("--Func-- StartCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- 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());
- 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");
- FINFO("start calibration success set detector status");
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartCalibration
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("StartCalibration failed");
- ret = RET_STATUS::RET_FAILED;
- return ret;
- }
- FINFO("StartCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::StopCalibration()
- {
- FINFO("--Func-- StopCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- 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
- {
- FERROR("StopCalibration failed");
- }
- //这里也应该判断探测器的采集状态,如果是采集状态再调用停止采集
- if (m_bEnterAcqStatus)
- {
- FINFO("Detector is acq status need to stop");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- FERROR("StopAcquisition fail!");
- return ret;
- }
- }
- FINFO("StopCalibration over");
- return ret;
- }
- void nsFPD::FPDDeviceKonica::AbortCalibration()
- {
- FINFO("--Func-- AbortCalibration");
- m_eAppStatus = APP_STATUS_CAL_END;
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration
- 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);
- }
- //如果中止的时候探测器在采集状态需要停止采集
- FINFO("--Func-- AbortCalibration over");
- }
- RET_STATUS nsFPD::FPDDeviceKonica::AcceptCalibration()
- {
- FINFO("--Func-- AcceptCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->AcceptCalibration())
- {
- FINFO("AcceptCalibration over");
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("AcceptCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];
- //完成校正条件:轮数够了,曝光次数够了
- if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound))
- {
- FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex);
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AcceptCalibration1
- 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));//AcceptCalibration2
- FINFO("--Func-- AcceptCalibration over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::RejectCalibration()
- {
- printf("--Func-- RejectCalibration \n");
- FINFO("--Func-- RejectCalibration");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- if (g_pDetector->RejectCalibration())
- {
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("RejectCalibration error");
- Ret = RET_STATUS::RET_FAILED;
- }
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//RejectCalibration
- FINFO("--Func-- RejectCalibration over");
- return Ret;
- }
- bool nsFPD::FPDDeviceKonica::CompleteCalibration()
- {
- printf("--Func-- CompleteCalibration \n");
- FINFO("--Func-- CompleteCalibration");
- if (!g_pDetector->CompleteCalibration(this))
- {
- FERROR("CompleteCalibration fail!");
- return false;
- }
- if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_DARK)
- {
- printf("CompleteCalibration Calibration Type DARK\n");
- FINFO("CompleteCalibration Calibration Type DARK");
- }
- else if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_XRAY)
- {
- printf("CompleteCalibration Calibration Type XRAY\n");
- FINFO("CompleteCalibration Calibration Type XRAY");
- m_eAppStatus = APP_STATUS_CAL_END;
- }
- FINFO("CompleteCalibration set detector status standby");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//CompleteCalibration
- m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
- m_CalibUnit->SetCalibrationProgress("100");
- FINFO("--Func-- CompleteCalibration over");
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::SaveCalibrationFile(bool bSaveFlag)
- {
- printf("--Func-- SaveCalibrationFile \n");
- FINFO("--Func-- SaveCalibrationFile");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- FINFO("SaveCalibrationFile bSaveFlag: {$}", bSaveFlag);
- if (!bSaveFlag)
- {
- FERROR("Not save calibration file");
- return Ret;
- }
- //点击save按钮时先调用compelte再调用save
- CompleteCalibration();
- if (g_pDetector->SaveCalibrationFile())
- {
- m_CalibUnit->SetSaveCalibrationFileFinish(true);
- Ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("SaveCalibrationFile error");
- m_CalibUnit->SetSaveCalibrationFileFinish(false);
- Ret = RET_STATUS::RET_FAILED;
- }
- FINFO("--Func-- SaveCalibrationFile over");
- return Ret;
- }
- bool nsFPD::FPDDeviceKonica::Support_DarkCalib()
- {
- return true;
- }
- bool nsFPD::FPDDeviceKonica::Support_XrayCalib()
- {
- return true;
- }
- void nsFPD::FPDDeviceKonica::SendTemperatureValue(float fValue)
- {
- int nStatus = 0;
- m_Temperature->SetTemperature(fValue, nStatus);
- FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus);
- return;
- }
- void nsFPD::FPDDeviceKonica::SendWifiValue(int nValue)
- {
- int nStatus = 0;
- m_Wifi->SetSignalValue(nValue, nStatus);
- FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus);
- return;
- }
- void nsFPD::FPDDeviceKonica::SendBatteryValue(int nValue)
- {
- int nStatus = 0;
- m_Battery->SetRemainPowerValue(nValue, nStatus);
- FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus);
- return;
- }
- bool nsFPD::FPDDeviceKonica::LoadConfig()
- {
- FINFO("--Func-- LoadConfig start");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_CalibDoseList, m_nCalibTotalExposureNum))
- {
- FERROR("Load configuration file failed!!!");
- return false;
- }
- FINFO("m_CalibDoseList:{$}", m_CalibDoseList.encode());
- FINFO("m_nCalibTotalExposureNum:{$}", m_nCalibTotalExposureNum);
- m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode);
- //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));
- FINFO("--Func-- LoadConfig end");
- return true;
- }
- void nsFPD::FPDDeviceKonica::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- 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::CcosActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- 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(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR);
- 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(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus);
- Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR);
- Dispatch->Update.Push(AttrKey::NotifyStatusTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateNotifyStatusTimePeriod);
- Dispatch->Update.Push(AttrKey::ReconnectTimePeriod, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateReconnectTimePeriod);
- }
- void nsFPD::FPDDeviceKonica::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::FPDDeviceKonica::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::FPDDeviceKonica::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->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->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode);
- }
- void nsFPD::FPDDeviceKonica::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);
- 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::FPDDeviceKonica::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::FPDDeviceKonica::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_CONF_PANEL_SERIAL:
- {
- m_stDeviceConfig.strPanelSerial = pszMsg;
- FINFO("Detector ID:{$}, SN {$}", nDetectorID, pszMsg);
- m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
- break;
- }
- case EVT_CONF_RAW_WIDTH:
- {
- m_nFullImageWidth = nParam1;
- m_stDeviceConfig.nFullImageWidth = nParam1;
- FINFO("Detector ID:{$}, Image Width:{$}", nDetectorID, m_nFullImageWidth);
- break;
- }
- case EVT_CONF_RAW_HIGHT:
- {
- m_nFullImageHeight = nParam1;
- m_stDeviceConfig.nFullImageHeight = nParam1;
- FINFO("Detector ID:{$}, Image Height:{$}", nDetectorID, m_nFullImageHeight);
- break;
- }
- case EVT_CONF_RAW_BITS:
- {
- m_stDeviceConfig.nImageBits = nParam1;
- m_nImgBits = nParam1;
- FINFO("Detector ID:{$}, Image Bit:{$}", nDetectorID, m_nImgBits);
- break;
- }
- case EVT_CONF_PIXELSPACE:
- {
- m_stDeviceConfig.nPixelSpace = (int)fParam2;
- FINFO("Detector ID:{$}, nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace);
- break;
- }
- case EVT_CONF_PREVIEW_WIDTH:
- {
- m_nPreviewImageWidth = nParam1;
- m_stDeviceConfig.nPreviewWidth = nParam1;
- FINFO("Detector ID:{$}, nPreviewWidth:{$}", nDetectorID, m_nPreviewImageWidth);
- break;
- }
- case EVT_CONF_PREVIEW_HIGHT:
- {
- m_nPreviewImageHeight = nParam1;
- m_stDeviceConfig.nPreviewHeight = nParam1;
- FINFO("Detector ID:{$}, nPreviewHeight:{$}", nDetectorID, m_nPreviewImageHeight);
- break;
- }
- case EVT_CONF_MODULE_TYPE:
- {
- //m_strModuleType = pszMsg;
- FINFO("Detector ID:{$}, ModuleType {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_IP:
- {
- //m_strModuleIP = pszMsg;
- FINFO("Detector ID:{$}, ModuleIP {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_MODULE_SN:
- {
- //m_strModuleSN = pszMsg;
- FINFO("Detector ID:{$}, ModuleSN {$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_FIRWARE_UPDATE:
- {
- m_stDeviceConfig.nFirmwareStatus = nParam1;
- FINFO("Detector ID:{$}, FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus);
- break;
- }
- case EVT_CONF_PART_NUMBER:
- {
- m_stDeviceConfig.strPartNumber = pszMsg;
- FINFO("Detector ID:{$}, PartNumber:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_BATTERY_SN:
- {
- //m_strBatterySN = pszMsg;
- FINFO("Detector ID:{$}, Battery SN:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_WIFI_SSID:
- {
- m_stDeviceConfig.strWifiSSID = pszMsg;
- FINFO("Detector ID:{$}, WifiSSID:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_IFBOARD:
- {
- m_stDeviceConfig.strInterfaceBoard = pszMsg;
- FINFO("Detector ID:{$}, InterfaceBoard:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_DATECODE:
- {
- m_stDeviceConfig.strDateCode = pszMsg;
- FINFO("Detector ID:{$}, DateCode:{$}", nDetectorID, pszMsg);
- break;
- }
- case EVT_CONF_LIFETIME:
- {
- int nLifeTime = nParam1;
- if ((nLifeTime != m_stDeviceConfig.nLifeTime))
- {
- FINFO("LifeTime:{$}", nLifeTime);
- m_stDeviceConfig.nLifeTime = nLifeTime;
- }
- break;
- }
- default:
- break;
- }
- }
- void nsFPD::FPDDeviceKonica::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this info({$})", nEventID);
- }
- void nsFPD::FPDDeviceKonica::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_STATUS_INIT:
- {
- FINFO("EVT_STATUS_INIT nParam1:{$}", nParam1);
- break;
- }
- case EVT_STATUS_PANEL:
- {
- PanelStatus m_ePanelStatus = (PanelStatus)nParam1;
- if (PANEL_CLOSE == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
- m_bDeviceConnect = false;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
- }
- else if (PANEL_CONNECT == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
- m_bDeviceConnect = true;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- }
- else if (PANEL_STANDBY == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_STANDBY");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PANEL_STANDBY
- m_bEnterAcqStatus = true;
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- 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_stSystemTime = { 0 };
- GetLocalTime(&m_stSystemTime);
- FINFO("XWindowOn at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}",
- m_stSystemTime.wYear, m_stSystemTime.wMonth, m_stSystemTime.wDay,
- m_stSystemTime.wHour, m_stSystemTime.wMinute, m_stSystemTime.wSecond, m_stSystemTime.wMilliseconds);
-
- m_SyncUnit->XWindowOnNotify();//Xwindow On
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- m_stSystemTime = { 0 };
- GetLocalTime(&m_stSystemTime);
- FINFO("XWindowOff at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}",
- m_stSystemTime.wYear, m_stSystemTime.wMonth, m_stSystemTime.wDay,
- m_stSystemTime.wHour, m_stSystemTime.wMinute, m_stSystemTime.wSecond, m_stSystemTime.wMilliseconds);
-
- m_SyncUnit->XWindowOffNotify();
- }
- else if (PANEL_START_ACQ == nParam1)
- {
- 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)
- {
- FINFO("EVT_STATUS_PANEL PANEL_XRAY_ON");
- m_SyncUnit->XrayOnNotify();
- }
- else if (PANEL_XRAY_OFF == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_XRAY_OFF");
- m_SyncUnit->XrayOffNotify();
- }
- break;
- }
- case EVT_STATUS_CALIBRATIOIN:
- {
- 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));//EVT_STATUS_CALIBRATIOIN PANEL_EVENT_END_OK
- 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:
- {
- FINFO("EVT_STATUS_SAVECALIB");
- PanelEventState eStatus = (PanelEventState)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_START:
- {
- FINFO("save calib file start");
- break;
- }
- case PANEL_EVENT_END:
- {
- FINFO("save calib file end");
- break;
- }
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_SINGLEEXP:
- {
- FINFO("EVT_STATUS_PANEL EVT_STATUS_SINGLEEXP");
- if (DOSE_ACCEPT == nParam1)
- {
- FINFO("Calibration Result is acceptable");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//EVT_STATUS_SINGLEEXP DOSE_ACCEPT
- m_CalibUnit->PauseCalibration();
- }
- else
- {
- FERROR("Not support this param({$})", nParam1);
- }
- break;
- }
- case EVT_STATUS_TEMPERATURE:
- {
- 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:
- {
- 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:
- {
- 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:
- FERROR("Not support this event({$})", nEventID);
- break;
- }
- }
- string nsFPD::FPDDeviceKonica::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::FPDDeviceKonica::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_DATA_RAW_IMAGE:
- {
- FINFO("EVT_DATA_RAW_IMAGE");
- if (nullptr != m_pFullImgBuffer)
- {
- delete[]m_pFullImgBuffer;
- m_pFullImgBuffer = nullptr;
- }
- m_pFullImgBuffer = new WORD[m_nFullImageWidth * m_nFullImageHeight];
- m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing);
- 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);
- }
- memcpy(m_pFullImgBuffer, pParam, (size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight * sizeof(WORD));
- string strImageHeader = MakeImageHead(IMAGE_FULL);
- 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);
- FINFO("Add image over");
- break;
- }
- case EVT_DATA_PREVIEW_IMAGE:
- {
- FINFO("EVT_DATA_PREVIEW_IMAGE");
- if (m_nPreviewEnable)
- {
- m_AcqUnit->SetPrevImageInfo(true, m_nPreviewImageHeight, m_nPreviewImageWidth, 0);
- if (nullptr != m_pPreviewImgBuffer)
- {
- delete[] m_pPreviewImgBuffer;
- m_pPreviewImgBuffer = nullptr;
- }
- m_pPreviewImgBuffer = new WORD[m_nPreviewImageWidth * m_nPreviewImageHeight];
- memcpy(m_pPreviewImgBuffer, pParam, (size_t)m_nPreviewImageWidth * (size_t)m_nPreviewImageHeight * sizeof(WORD));
- string strImageHeader = MakeImageHead(IMAGE_PREVIEW);
- 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;
- FINFO("EVT_DATA_DOSEPARAM m_nTargetCalibExi:{$}", m_nTargetCalibExi);
- break;
- }
- default:
- FERROR("Not support this data({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceKonica::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:
- FERROR("Not support this error({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceKonica::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this warn({$})", nEventID);
- }
- RET_STATUS nsFPD::FPDDeviceKonica::ActiveSyncMode(int nSyncMode)
- {
- FINFO("--Func-- ActiveSyncMode nSyncMode:{$}", nSyncMode);
- m_eSyncMode = (SYNC_MODE)nSyncMode;
- if (g_pDetector->ActiveSyncMode(nSyncMode))
- {
- return RET_SUCCEED;
- }
- else
- {
- FERROR("ActiveSyncMode fail!");
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDeviceKonica::ActiveDetector(bool bActive)
- {
- FINFO("--Func-- ActiveDetector bActive:{$}", bActive);
- if (g_pDetector->ActiveDetector(this, bActive))
- {
- if (bActive)
- {
- FINFO("ActiveDetector success!");
- }
- else
- {
- FINFO("InActiveDetector success!");
- }
- return RET_SUCCEED;
- }
- else
- {
- if (bActive)
- {
- FERROR("ActiveDetector fail!");
- }
- else
- {
- FERROR("InActiveDetector fail!");
- }
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDeviceKonica::UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode)
- {
- FINFO("--Func-- UpdateCalibMode eCalibMode:{$}", (int)eCalibMode);
- m_stDeviceConfig.nCalibMode = (int)eCalibMode;
- if (g_pDetector->UpdateCalibMode(eCalibMode))
- {
- FINFO("UpdateCalibMode success!");
- return RET_SUCCEED;
- }
- else
- {
- FERROR("UpdateCalibMode fail!");
- return RET_FAILED;
- }
- }
- RET_STATUS nsFPD::FPDDeviceKonica::UpdateNotifyStatusTimePeriod(int nTime)
- {
- FINFO("--Func-- UpdateNotifyStatusTimePeriod nTime:{$}", nTime);
- m_stDeviceConfig.nNotifyStatusTimePeriod = nTime;
- g_pDetector->SetNotifyStatusTimePeriod(nTime);
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceKonica::UpdateReconnectTimePeriod(int nTime)
- {
- FINFO("--Func-- UpdateReconnectTimePeriod nTime:{$}", nTime);
- m_stDeviceConfig.nReconnectTimePeriod = nTime;
- g_pDetector->SetReconnectTimePeriod(nTime);
- return RET_SUCCEED;
- }
|