1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480 |
- #include "stdafx.h"
- #include "CCOS.Dev.FPD.TeledyneDalsa.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "Detector_TeledyneDalsa.h"
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- static nsFPD::TeledyneDalsaDriver gIODriver;
- Log4CPP::Logger* gLogger = nullptr;
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- return new nsFPD::TeledyneDalsaDriver();
- }
- nsFPD::TeledyneDalsaDriver::TeledyneDalsaDriver()
- {
- pObjDev = nullptr;
- m_bConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::TeledyneDalsaDriver::~TeledyneDalsaDriver()
- {
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- void nsFPD::TeledyneDalsaDriver::Prepare()
- {
- printf("TeledyneDalsa 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.TeledyneDalsa");
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("FPD.TeledyneDalsa");
- Info("--Func-- driver prepare");
- }
- bool nsFPD::TeledyneDalsaDriver::Connect()
- {
- printf("--Func-- driver connect \r\n");
- Info("--Func-- driver connect \n");
-
- pObjDev = new FPDDeviceTeledyneDalsa(EventCenter, m_ConfigFileName);
- m_bConnect = true; //connect执行完毕,置为true
- printf("TeledyneDalsa driver module: Connect over\r\n");
- return true;
- }
- void nsFPD::TeledyneDalsaDriver::Disconnect()
- {
- printf("--Func-- driver disconnect \r\n");
- Info("--Func-- driver disconnect \n");
- m_bConnect = false; //disconnect置为false
- }
- bool nsFPD::TeledyneDalsaDriver::isConnected() const
- {
- return m_bConnect;
- }
- auto nsFPD::TeledyneDalsaDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("--Func-- driver createdevice \r\n");
- Info("--Func-- driver createdevice \n");
- auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
- pObjDev->CreateDevice();
- pObjDev->Register();
- return Device;
- }
- std::string nsFPD::TeledyneDalsaDriver::DriverProbe()
- {
- printf("--Func-- driver DriverProbe \r\n");
- Info("--Func-- driver DriverProbe \n");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "RF");
- HardwareInfo.add("VendorID", "TeledyneDalsa");
- HardwareInfo.add("ProductID", "TeledyneDalsa");
- HardwareInfo.add("SerialID", "Driver");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /***
- ** 获取ID和配置
- ***/
- std::string nsFPD::TeledyneDalsaDriver::GetResource()
- {
- printf("--Func-- driver GetResource \r\n");
- Info("--Func-- driver GetResource");
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- Error("load file error! file name:{$}",m_ConfigFileName.c_str());
- return "";
- }
- m_ConfigAll = temp;
- r_config = temp["CONFIGURATION"];
- m_Configurations = r_config;
- ResDataObject DescriptionTemp;
- ResDataObject ListTemp;
- string strTemp = ""; //用于读取字符串配置信息
- string strIndex = ""; //用于读取配置信息中的List项
- int nTemp = -1; //用于读取整型配置信息
- char sstream[10] = { 0 }; //用于转换值
- string strValue = ""; //用于存储配置的值
- string strType = ""; //用于存储配置的类型 int/float/string...
- /***
- * 1. 通过循环,将所有配置项写到pDeviceConfig
- * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
- ***/
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- //Info(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());
- //Info(g_pFPDCtrlLog, "--> {$}: {$}", AttributeType, strTemp.c_str());
- strType = strTemp; //记录配置项的类型
- //AttributeKey
- //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
- GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
- //2. 赋值
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if ("int" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
- //Info(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- //Info(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- //Info(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
- //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMax, strTemp.c_str());
- }
- //AttributeList
- nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
- if (nTemp > 0) //ListNum不大于0时说明不需要list配置
- {
- for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
- //sprintf_s(sstream, "{$}", nListIndex);
- auto temKey = std::to_string(nListIndex);
- ListTemp.add(temKey.c_str(), strTemp.c_str());
- //Info(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (exception e)
- {
- Error("Get config error: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
- m_DeviceConfig = DescriptionTempEx;
- string res = DescriptionTempEx.encode();
- printf("TeledyneDalsa driver module: get resource over \r\n");
- //Info("get resource over {$}", res.c_str());//此处在调试读取配置的时候再放开,不然打印很长查日志不方便
- Info("get resource over!");
- return res;
- }
- std::string nsFPD::TeledyneDalsaDriver::DeviceProbe()
- {
- printf("--Func-- driver DeviceProbe \r\n");
- Info("--Func-- driver DeviceProbe \n");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", "TeledyneDalsa");
- HardwareInfo.add("ProductID", "TeledyneDalsa");
- HardwareInfo.add("SerialID", "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- bool nsFPD::TeledyneDalsaDriver::GetDeviceConfig(std::string& Cfg)
- {
- printf("--Func-- driver GetDeviceConfig \r\n");
- Info("--Func-- driver GetDeviceConfig \n");
- Cfg = m_DeviceConfig.encode();
- Info("GetDeviceConfig over");
- return true;
- }
- bool nsFPD::TeledyneDalsaDriver::SetDeviceConfig(std::string Cfg)
- {
- printf("--Func-- driver SetDeviceConfig \r\n");
- Info("--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];
- Info("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- Info("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- Info("ConfigInfo Count: {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- Info("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- Error("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- bool nsFPD::TeledyneDalsaDriver::SaveConfigFile(bool bSendNotify)
- {
- printf("--Func-- driver SaveConfigFile \r\n");
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- std::cout << " Write Config to xml " << m_ConfigFileName << " Content: " << m_Configurations.encode() << endl;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- Info("SaveConfigFile over");
- return true;
- }
- bool nsFPD::TeledyneDalsaDriver::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 || RawImgWidth == strTemp || RawImgHeight == strTemp)
- {
- strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
- }
- else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- TempUpperLimit == strTemp || TempLowerLimit == strTemp || "TempMinLimit" == strTemp ||
- BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- ShowTemperature == strTemp || ShowWifi == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || "Attached" == strTemp)
- {
- strValue = (string)config[pInnerKey];
- }
- else
- {
- strValue = "";
- Warn("Error Configuration item: {$}", pInnerKey);
- }
- }
- return true;
- }
- bool nsFPD::TeledyneDalsaDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- string strTemp = pInnerKey;
- Trace("Begin to change {$} item value to {$}", pInnerKey, szValue);
- if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
- {
- if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
- {
- config["connections"][pInnerKey] = szValue;
- }
- else if (DetectorVender == strTemp || DetectorModel == strTemp ||
- DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else if (SyncType == strTemp || FPDWorkStation == strTemp ||
- ImageWidth == strTemp || ImageHeight == strTemp)
- {
- config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
- }
- else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
- BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- ShowTemperature == strTemp || ShowWifi == strTemp ||
- ShowBattery == strTemp || ShowBluetooth == strTemp ||
- FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp)
- {
- config[pInnerKey] = szValue;
- }
- else
- {
- Warn("Error Configuration item: {$}", pInnerKey);
- return false;
- }
- }
- return true;
- }
- //-----------------------------------------------------------------------------
- // FPDDeviceTeledyneDalsa
- //-----------------------------------------------------------------------------
- extern Detector_TeledyneDalsa* g_pDetector;
- nsFPD::FPDDeviceTeledyneDalsa::FPDDeviceTeledyneDalsa(std::shared_ptr<IOEventCenter> center,std::string strConfigPath)
- {
- m_bConnect = false;
- m_pDetector = nullptr;
- m_nImageHeight = 0;
- m_nImageWidth = 0;
- /*m_nCropLeft = 0;
- m_nCropRight = 0;
- m_nCropTop = 0;
- m_nCropBottom = 0;
- m_nRawImgHeight = 0;
- m_nRawImgWidth = 0;*/
- m_pImgBuffer = nullptr;
- m_nImgBits = 0;
- m_nAngle = 0;
- m_nPixelSpacing = 0;
- m_nSensitivity = 0;
- 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_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_STANDBY);
- m_CalibUnit->SetCalibrationStatus(CCOS_CALIBRATION_STATUS_STANDBY);
- EventCenter = center;
- }
- nsFPD::FPDDeviceTeledyneDalsa::~FPDDeviceTeledyneDalsa()
- {
- if (nullptr != m_pDetector)
- {
- delete m_pDetector;
- m_pDetector = nullptr;
- }
- if (nullptr != m_pImgBuffer)
- {
- delete m_pImgBuffer;
- m_pImgBuffer = nullptr;
- }
- }
- std::string nsFPD::FPDDeviceTeledyneDalsa::GetGUID() const
- {
- return DetectorUnitType;
- }
- bool nsFPD::FPDDeviceTeledyneDalsa::Prepare()
- {
- printf("--Func-- device Prepare \r\n");
- Info("--Func-- device prepare \n");
- EventCenter->OnMaxBlockSize("RfQue",
- m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgHeight * 2,
- 20, 1500 * 1500 * 2, 1);
- //printf(("%d %d \r\n", m_stDeviceConfig.nMaxImgWidth, m_stDeviceConfig.nMaxImgHeight);
- Connect();
- return true;
- }
- bool nsFPD::FPDDeviceTeledyneDalsa::CreateDevice()
- {
- printf("--Func-- device CreateDevice \r\n");
- Info("--Func-- device CreateDevice \n");
- if (!LoadConfig())
- {
- return false;
- }
- //bool bRet = false;
- if (nullptr == g_pDetector)
- {
- if (nullptr == m_pDetector)
- {
- m_pDetector = new Detector_TeledyneDalsa();
- g_pDetector = (Detector_TeledyneDalsa*)m_pDetector;
- }
- }
- else
- {
- m_pDetector = g_pDetector;
- }
- ((Detector_TeledyneDalsa*)m_pDetector)->DriverEntry(this, m_DetectorConfiguration->m_Configurations);
- return true;
- }
- bool nsFPD::FPDDeviceTeledyneDalsa::LoadConfig()
- {
- printf("--Func-- device LoadConfig \r\n");
- Info("--Func-- device LoadConfig \n");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
- {
- Error("Load configuration file failed!!! \n");
- return false;
- }
- //printf("m_ACQMODElist:\n {$}\n", m_ACQMODElist.encode()); //暂时用不到
- //不同采集模式可能会有不同的值,后面在考虑 --ys
- char szFDinfo[MAX_STRING] = { 0 };
- string strFPDinfo;
- sprintf_s(szFDinfo, "%d", m_nSensitivity);
- strFPDinfo = szFDinfo;
- m_DetectorCtrlUnit->SetFPDSensitivity(strFPDinfo);
- m_DetectorCtrlUnit->SetPixelData("");
- m_DetectorCtrlUnit->SetTargetEXI("5000");
- ResDataObject CalibDoseList;
- string strCalibDose = m_strWorkPath + R"(\OEMDrivers\Detector\TeledyneDalsaDetector\CalibrationDose_TeledyneDalsa.xml)";
- Info("start load calibDose file: {$}", strCalibDose.c_str());
- try {
- CalibDoseList.loadFile(strCalibDose.c_str());
- m_CalibDoseList = CalibDoseList["List"];
- Info("m_CalibDoseList: {$} ", m_CalibDoseList.encode());
- for (int i = 0; i < m_CalibDoseList.size(); i++)
- {
- ResDataObject temp = m_CalibDoseList[i];
- Info("temp : {$} ", temp.encode());
- }
- }
- catch (exception e)
- {
- Error("Get calibDose error: {$}", e.what());
- }
- return true;
- }
- void nsFPD::FPDDeviceTeledyneDalsa::Register()
- {
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::Connect()
- {
- printf("--Func-- device Connect \r\n");
- Info("--Func-- device Connect \n");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if(((Detector_TeledyneDalsa*)m_pDetector)->Connect(this, m_strWorkPath.c_str()))
- {
- m_bConnect = true;
- ret = RET_STATUS::RET_SUCCEED;
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::EnterExam(int nExamMode)
- {
- Info("--Func-- EnterExam {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- Info("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS_WORK_END:
- Info("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- Info("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS_DETSHAR_END:
- m_eAppStatus = APP_STATUS_IDLE;
- Info("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS_CAL_BEGIN:
- Info("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS_CAL_END:
- Info("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_END;
- break;
- case APP_STATUS_WORK_IN_SENSITIVITY:
- Info("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::FPDDeviceTeledyneDalsa::SetAcqMode(int nMode)
- {
- printf("TeledyneDalsa device module: SetAcqMode(%d) \r\n", nMode);
- Info("--Func-- SetAcqMode({$})", nMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接,不执行
- try
- {
- if (nullptr != m_pImgBuffer)
- {
- delete m_pImgBuffer;
- m_pImgBuffer = nullptr;
- }
- ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
- int nModeCount = (int)objModeConfig["ModeTable"].GetKeyCount("DetectorMode");
- for (int i = 0; i < nModeCount; i++)
- {
- int nAppModeID = (int)objModeConfig["ModeTable"][i]["LogicMode"];
- if (nAppModeID == nMode)
- {
- m_nImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"];
- m_nImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"];
- /*m_nCropLeft = (int)objModeConfig["ModeTable"][i]["DeadLineLeft"];
- m_nCropRight = (int)objModeConfig["ModeTable"][i]["DeadLineRight"];
- m_nCropTop = (int)objModeConfig["ModeTable"][i]["DeadLineTop"];
- m_nCropBottom = (int)objModeConfig["ModeTable"][i]["DeadLineBottom"];
- m_nRawImgHeight = (int)objModeConfig["ModeTable"][i]["RawImgSizeY"];
- m_nRawImgWidth = (int)objModeConfig["ModeTable"][i]["RawImgSizeX"];*/
- m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
- m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
- m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"];
- m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
- string strDose = (string)objModeConfig["ModeTable"][i]["CalibConfig"]["Dose"];
- m_fDose = stof(strDose.c_str());
- m_pImgBuffer = new WORD[(size_t)m_nImageWidth * (size_t)m_nImageHeight];
- if (m_nAngle == 90 || m_nAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(m_nImageWidth, m_nImageHeight, m_nImgBits, false);
- }
- else
- {
- m_AcqUnit->SetFulImageInfo(m_nImageHeight, m_nImageWidth, m_nImgBits, false);
- }
-
- m_AcqUnit->SetPrevImageInfo(false, 0, 0, false);
- break;
- }
- }
- Info("Ratate angle: {$}", m_nAngle);
- if (nullptr == m_pImgBuffer)
- {
- Error("Illegal mode!");
- }
- else
- {
- if (g_pDetector->SetAcqMode(nMode))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- Error("Read configuration failed, Error code: {$}", e.what());
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::PrepareAcquisition()
- {
- printf("--Func-- PrepareAcquisition \r\n");
- Info("--Func-- PrepareAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- //printf(("PrepareAcquisition failed. Detector at Calibration status.\n");
- Error("PrepareAcquisition failed. Detector at Calibration status");
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //printf(("Detector already at Acq status.\n");
- Warn("Detector already at Acq status");
- ret = RET_STATUS::RET_SUCCEED;
- }
- }
- else
- {
- m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_SyncUnit->FPDReadyNotify(true); //prepare succeed
- }
- }
- m_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_STANDBY);
- Info("PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::StartAcquisition()
- {
- printf("--Func-- StartAcquisition \r\n");
- Info("--Func-- StartAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- //printf(("PrepareAcquisition failed. Detector at Calibration status.\n");
- Error("PrepareAcquisition failed. Detector at Calibration status.");
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //printf(("Detector already at Acq status.\n");
- Error("Detector already at Acq status.");
- }
- }
- else
- {
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_ACQ);
- }
- else
- {
- m_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_STANDBY);
- }
- }
- Info("StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::StopAcquisition()
- {
- printf("--Func-- StopAcquisition \r\n");
- Info("--Func-- StopAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //printf(("Detector already at stanby status.\n");
- Info("Detector already at stanby status.");
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_STANDBY);
- }
- }
- Info("StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::SetXrayOnNum()
- {
- Info("--Func-- SetXrayOnNum");
- if (g_pDetector->SetXrayOnNum())
- {
- return RET_STATUS::RET_SUCCEED;
- }
- return RET_STATUS::RET_FAILED;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::SetExposureTimes(int nTimes)
- {
- Info("--Func-- SetExposureTimes({$})", nTimes);
- if (g_pDetector->SetExposureTimes(nTimes))
- {
- return RET_STATUS::RET_SUCCEED;
- }
- return RET_STATUS::RET_FAILED;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- printf("--Func-- ActiveCalibration eType:%d \r\n", eType);
- Info("--Func-- ActiveCalibration {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("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())
- {
- //printf(("ActiveCalibration failed. Detector at Acq status\r\n");
- Error("ActiveCalibration failed. Detector at Acq status");
- }
- return RET_STATUS::RET_FAILED;
- }
- if (g_pDetector->ActiveCalibration(this, eType))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_CalibUnit->SetCalibrationStatus(CCOS_CALIBRATION_STATUS_ACTIVE);
- m_CalibUnit->SetCalibrationProgress(0);
- }
- else
- {
- Error("Active calibration failed");
- }
- Info("ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration \r\n");
- Info("--Func-- PrepareCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("Detector not connected, return");
- return ret;
- }
- m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值
- if (g_pDetector->PrepareCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_SyncUnit->FPDReadyNotify(true); //prepare succeed
- }
- else
- {
- Error("Prepare calibration failed");
- }
- Info("PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::GetRequestedDose(std::string& strDose)
- {
- printf("--Func-- GetRequestedDose \r\n");
- Info("--Func-- GetRequestedDose");
- RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
- bool bGetDoseInfo = false;
- ResDataObject out;
- CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
- if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
- {
- out.add("Dose", 0.0f);
- out.add("kV", 0.0f);
- out.add("mA", 0.0f);
- out.add("ms", 0.0f);
- out.add("mAs", 0.0f);
- bGetDoseInfo = true;
- }
- else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
- {
- for (int i = 0; i < m_CalibDoseList.size(); i++)
- {
- ResDataObject temp = m_CalibDoseList[i];
- int nDose = temp["Dose"];
- int nDoseParem = (int)(m_fDose * 1000);
- if (nDoseParem == nDose)
- {
- out.add("Dose", nDoseParem);
- out.add("kV", temp["kV"]);
- out.add("mA", temp["mA"]);
- out.add("ms", temp["ms"]);
- out.add("mAs", temp["mAs"]);
- bGetDoseInfo = true;
- break;
- }
- }
- }
- else
- {
- Ret = RET_STATUS::RET_FAILED;
- }
- if (bGetDoseInfo)
- {
- strDose = out.encode();
- Info("GetRequestedDose {$} over", strDose.c_str());
- }
- else
- {
- Error("GetRequestedDose failed");
- }
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::StartCalibration()
- {
- printf("--Func-- StartCalibration \r\n");
- Info("--Func-- StartCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("Detector not connected, return");
- return ret;
- }
- if ((m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PAUSE) && (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- //printf(("CCOS_CALIBRATION_STATUS = %d\r\n", (int)m_CalibUnit->GetCalibrationStatus());
- Error("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())
- {
- //printf(("Start calibration failed. Detector at Acq status.\r\n");
- Error("Start calibration failed. Detector at Acq status");
- }
- return ret;
- }
- if (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING)
- {
- //printf(("Detector already at calib status.\n");
- Error("Detector already at calib status");
- return ret;
- }
- if (g_pDetector->StartCalibration(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_ACQ);
- m_CalibUnit->SetCalibrationStatus(CCOS_CALIBRATION_STATUS_RUNNING);
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- Error("Start calibration failed");
- }
- Info("StartCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceTeledyneDalsa::StopCalibration()
- {
- printf("--Func-- StopCalibration \r\n");
- Info("--Func-- StopCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- Error("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->StopCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_CalibUnit->SetCalibrationStatus(CCOS_CALIBRATION_STATUS_STANDBY);
- m_CalibUnit->SetCalibrationProgress(100);
- }
- else
- {
- Error("Start calibration failed");
- }
- Info("StopCalibration over");
- return ret;
- }
- bool nsFPD::FPDDeviceTeledyneDalsa::Support_DarkCalib()
- {
- return true;
- }
- bool nsFPD::FPDDeviceTeledyneDalsa::Support_XrayCalib()
- {
- return true;
- }
- void nsFPD::FPDDeviceTeledyneDalsa::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- //Dispatch->Get.Push(ActionKey::GetDetectorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
- Dispatch->Action.Push("ActiveDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
- //Dispatch->Action.Push("RESET", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET);
- Dispatch->Action.Push("EnterExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
- Dispatch->Action.Push("ExitExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
- //Dispatch->Action.Push("AttachConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect);
- //Dispatch->Action.Push("CancelAttach", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach);
- //Dispatch->Action.Push("RecoverImage", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage);
- //Dispatch->Action.Push("ResetConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect);
- //Dispatch->Action.Push("DisConnectFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD);
- //Dispatch->Action.Push("UpdateFirmware", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware);
- //Dispatch->Action.Push("SaveSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity);
- Dispatch->Get.Push(CcosDetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
- //Dispatch->Get.Push(CcosDetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus);
- //Dispatch->Get.Push(CcosDetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);
- //Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- //Dispatch->Get.Push(CcosDetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);
- //Dispatch->Get.Push(CcosDetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus);
- //Dispatch->Get.Push("FPDShockSensorInfo", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo);
- //Dispatch->Get.Push("FieldofViewShape", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape);
- //Dispatch->Get.Push("FieldofViewDimension", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension);
- Dispatch->Get.Push("DetectorType", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
- Dispatch->Get.Push("Description", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
- Dispatch->Get.Push("DetectorID", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
- //Dispatch->Get.Push("DateofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration);
- //Dispatch->Get.Push("TimeofLastDetectorCalibration", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration);
- //Dispatch->Get.Push("DetectorConditionsNominalFlag", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag);
- Dispatch->Get.Push("FPDSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
- Dispatch->Get.Push("PixelData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
- Dispatch->Get.Push("TargetEXI", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
- Dispatch->Action.Push("SetXrayOnNum", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum);
- Dispatch->Action.Push("SetExposureTimes", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
- }
- void nsFPD::FPDDeviceTeledyneDalsa::RegisterAcq(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("SetAcqMode", m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
- Dispatch->Get.Push(CcosZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
- Dispatch->Get.Push("NoNeedWaitImage", m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
- Dispatch->Get.Push("ImgDataInfo", m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
- }
- void nsFPD::FPDDeviceTeledyneDalsa::RegisterSync(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push("SetSyncMode", m_SyncUnit.get(), &SyncUnit::JSSetSyncMode);
- Dispatch->Action.Push("SetXwindowSize", m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize);
- Dispatch->Action.Push("PrepareAcquisition", m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
- Dispatch->Action.Push("StartAcquisition", m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
- Dispatch->Action.Push("StopAcquisition", m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
- Dispatch->Get.Push(CcosFPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
- Dispatch->Get.Push(CcosXwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
- Dispatch->Get.Push(CcosImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
- }
- void nsFPD::FPDDeviceTeledyneDalsa::RegisterCalib(nsDetail::Dispatch* Dispatch)
- {
- //Dispatch->Action.Push("UploadCalibrationFiles", m_CalibUnit.get(), &CalibUnit::JSUploadCalibrationFiles);
- //Dispatch->Action.Push("SetSID", m_CalibUnit.get(), &CalibUnit::JSSetSID);
- Dispatch->Action.Push("ActiveCalibration", m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
- Dispatch->Action.Push("GetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
- Dispatch->Action.Push("PrepareCalibration", m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
- Dispatch->Action.Push("StartCalibration", m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
- Dispatch->Action.Push("StopCalibration", m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
- Dispatch->Action.Push("SetCorrectionType", m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
- Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
- Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
- Dispatch->Get.Push("UploadCalibrationFilesResult", m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
- Dispatch->Get.Push("SupportCalibrationType", m_CalibUnit.get(), &CalibUnit::JSGetSupportCalibrationType);
- }
- void nsFPD::FPDDeviceTeledyneDalsa::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::FPDDeviceTeledyneDalsa::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- Warn("Not support this conf({$})", nEventID);
- }
- void nsFPD::FPDDeviceTeledyneDalsa::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- Warn("Not support this info({$})", nEventID);
- }
- void nsFPD::FPDDeviceTeledyneDalsa::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 ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
- if (PANEL_END_ACQ == nParam1)
- {
- Info("Panel Status: End acq");
- if (g_pDetector->StopAcquisition(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(DETECTOR_STATUS_STANDBY);
- }
- }
- /*else if (PANEL_READY_EXP == nParam1)
- {
- Info("Panel Status:READY");
- ((OemSync*)m_pSync)->FPDReadyNotify();
- }*/
- else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
- {
- Info("XWindowOnNotify");
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- Info("XWindowOffNotify");
- m_SyncUnit->XWindowOffNotify();
- }
- }
- 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(DETECTOR_STATUS_STANDBY);
- m_CalibUnit->SetCalibrationStatus(CCOS_CALIBRATION_STATUS_STANDBY);
- m_CalibUnit->SetCalibrationProgress(100);//make progress
- break;
- case PANEL_EVENT_TIMEOUT:
- break;
- default:
- break;
- }
- }
- break;
- //case EVT_STATUS_SINGLEEXP:
- //{
- // if (DOSE_ACCEPT == nParam1)
- // {
- // Info("Calibration Result is acceptable");
- // SetEvent(m_hPauseCaliEvt);
- // }
- // else
- // {
- // Warn("Not support this param(%d)", nParam1);
- // }
- //}
- //break;
- //case 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:
- //{
- // 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:
- //{
- // 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:
- Warn("Not support this status({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceTeledyneDalsa::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:
- {
- //m_SyncUnit->XWindowOnNotify(); //add20220111 模拟发送窗口消息,使状态机可以跳转状态
- Info("Image Arrived");
- memcpy(m_pImgBuffer, pParam, (size_t)m_nImageWidth * (size_t)m_nImageHeight * sizeof(WORD));
- //暂时先用假值,有需要再改
- SYSTEMTIME stImgCreateTime = { 0 };
- GetLocalTime(&stImgCreateTime);
- 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, stImgCreateTime.wYear);
- objTemp.add(SM_IMAGE_MONTH, stImgCreateTime.wMonth);
- objTemp.add(SM_IMAGE_DAY, stImgCreateTime.wDay);
- objTemp.add(SM_IMAGE_HOUR, stImgCreateTime.wHour);
- objTemp.add(SM_IMAGE_MINUTE, stImgCreateTime.wMinute);
- objTemp.add(SM_IMAGE_SEC, stImgCreateTime.wSecond);
- objTemp.add(SM_IMAGE_MILLSEC, stImgCreateTime.wMilliseconds);
- objTemp.add(SM_IMAGE_LSB, "5000");
- objTemp.add(SM_IMAGE_DOSE, m_nSensitivity);
- objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
- objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
- objTemp.add(SM_IMAGE_FLIP, "No");
- objTemp.add(SM_IMAGE_ORIGINX, "0");
- objTemp.add(SM_IMAGE_ORIGINY, "0");
- m_AcqUnit->RotateImage(m_pImgBuffer, m_nImageHeight, m_nImageWidth, m_nAngle);
- if (90 == m_nAngle || 270 == m_nAngle)
- {
- objTemp.add(SM_IMAGE_WIDTH, m_nImageHeight);
- objTemp.add(SM_IMAGE_HEIGHT, m_nImageWidth);
- objTemp.add(SM_IMAGE_ROTATION, "Yes");
- }
- else
- {
- objTemp.add(SM_IMAGE_WIDTH, m_nImageWidth);
- objTemp.add(SM_IMAGE_HEIGHT, m_nImageHeight);
- objTemp.add(SM_IMAGE_ROTATION, "No");
- }
- objImageHead.add(SM_IMAGE_HEAD, objTemp);
- Trace("Full image head: {$}", objImageHead.encode());
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pImgBuffer, m_nImageWidth * m_nImageHeight);
- Info("Add image over");
- //printf(("Add image over, %d \n", ret);
- m_SyncUnit->XWindowOffNotify(); //add20220111 模拟发送窗口消息,使状态机可以跳转状态
- }
- break;
- default:
- Warn("Not support this data({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceTeledyneDalsa::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:
- Warn("Not support this error({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceTeledyneDalsa::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- Warn("Not support this warn({$})", nEventID);
- }
|