|
|
@@ -105,7 +105,10 @@ Detector_TiRayDR::Detector_TiRayDR()
|
|
|
m_bAEDWorkFlag(false),
|
|
|
m_bExitRadAcqStatus(false),
|
|
|
m_bMonitorFlag(false),
|
|
|
- m_bIsMultiFrame(false)
|
|
|
+ m_bIsMultiFrame(false),
|
|
|
+ m_bIpInitialized(false),
|
|
|
+ m_bFirstConnect(true),
|
|
|
+ m_nXWindow(0)
|
|
|
{
|
|
|
m_pDPC2PanelID = new map<FPDDeviceTiRay*, int>();
|
|
|
m_pPanelID2DPC = new map<int, FPDDeviceTiRay*>();
|
|
|
@@ -336,6 +339,32 @@ void Detector_TiRayDR::EnterExamMode(int nExamMode)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+bool Detector_TiRayDR::SetExposureTimes(int nTimes)
|
|
|
+{
|
|
|
+ FINFO("--TiRayDR Func-- SetExposureTimes Start");
|
|
|
+ FINFO("SetExposureTimes: {$}", nTimes);
|
|
|
+
|
|
|
+ // 参数验证
|
|
|
+ if (nTimes <= 0)
|
|
|
+ {
|
|
|
+ FERROR("Invalid exposure times: {$}, must be greater than 0", nTimes);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查探测器连接状态
|
|
|
+ if (!m_pStPanelStatus[m_nCurrentPanelID]->bConnectState)
|
|
|
+ {
|
|
|
+ FERROR("Detector not connected, cannot set exposure times");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存曝光次数参数
|
|
|
+ m_nXWindow = nTimes;
|
|
|
+ FINFO("Exposure times set to: {$}", m_nXWindow);
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
/***
|
|
|
** 根据采集模式申请图像buffer
|
|
|
***/
|
|
|
@@ -404,7 +433,20 @@ bool Detector_TiRayDR::SetAcqMode(int nMode)
|
|
|
workMode = WorkMode_SyncIn;
|
|
|
m_bIsMultiFrame = true; // 多帧图
|
|
|
modeName = "PF";
|
|
|
- nXWindow = 800;
|
|
|
+
|
|
|
+ // PF模式下,优先使用SetExposureTimes设置的值,若未设置则使用配置值
|
|
|
+ if (m_nXWindow > 0)
|
|
|
+ {
|
|
|
+ nXWindow = m_nXWindow;
|
|
|
+ FINFO("PF mode: Using custom exposure times from SetExposureTimes: {$}", nXWindow);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FWARN("PF mode: m_nXWindow not set, using config value: {$}", nXWindow);
|
|
|
+ }
|
|
|
+ //auto err = write_attribute(Attr_PhotoNumber, 8);
|
|
|
+ //if (err != Err_Success)
|
|
|
+ //FERROR("[Detector_TiRayDR::OpenDetector] Failed to write Attr_PhotoNumber. Error code: {$}", err);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -424,12 +466,15 @@ bool Detector_TiRayDR::SetAcqMode(int nMode)
|
|
|
|
|
|
FINFO("Work mode set successfully");
|
|
|
|
|
|
+ // 设置曝光间隔到硬件
|
|
|
+ FINFO("Setting Attr_PhotoInterval to: {$}", nXWindow);
|
|
|
err = write_attribute(Attr_PhotoInterval, nXWindow);
|
|
|
if (err != Err_Success)
|
|
|
{
|
|
|
FERROR("Failed to write Attr_PhotoInterval, error code: {$}", err);
|
|
|
return false;
|
|
|
}
|
|
|
+ FINFO("Attr_PhotoInterval set successfully");
|
|
|
|
|
|
StatusFeedback(EVT_STATUS_PANEL, PANEL_SLEEP);
|
|
|
FINFO("TiRayDR SetAcqMode Over");
|
|
|
@@ -570,7 +615,7 @@ bool Detector_TiRayDR::StartAcquisition(FPDDeviceTiRay* pDrvDPC)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (m_nSyncMode == SYNC_MODE::SYNC_SOFTWARE)
|
|
|
+ //if (m_nSyncMode == SYNC_MODE::SYNC_SOFTWARE)
|
|
|
{
|
|
|
//SetSyncMode(1);
|
|
|
|
|
|
@@ -581,10 +626,10 @@ bool Detector_TiRayDR::StartAcquisition(FPDDeviceTiRay* pDrvDPC)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- StatusFeedback(EVT_STATUS_PANEL, PANEL_START_ACQ);
|
|
|
+ //StatusFeedback(EVT_STATUS_PANEL, PANEL_START_ACQ);
|
|
|
m_bAEDWorkFlag = true;
|
|
|
|
|
|
- StatusFeedback(EVT_STATUS_PANEL, PANEL_XWINDOW_ON);
|
|
|
+ //StatusFeedback(EVT_STATUS_PANEL, PANEL_XWINDOW_ON);
|
|
|
|
|
|
std::cout << "TiRayDR StartAcquisition Over" << std::endl;
|
|
|
FINFO("TiRayDR StartAcquisition Over");
|
|
|
@@ -608,6 +653,7 @@ bool Detector_TiRayDR::StopAcquisition(FPDDeviceTiRay* pDrvDPC)
|
|
|
FINFO("## Stop Acquisition ##");
|
|
|
|
|
|
StatusFeedback(EVT_STATUS_PANEL, PANEL_STANDBY);
|
|
|
+ StatusFeedback(EVT_STATUS_PANEL, PANEL_XRAY_OFF);
|
|
|
SetTiRayDPCStatus(eDetStatus::DetStatus_Standby); //停止采集
|
|
|
FINFO("TiRayDR StopAcquisition Over");
|
|
|
|
|
|
@@ -1227,15 +1273,21 @@ bool Detector_TiRayDR::OpenDetector()
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
- FINFO("Start setting the IP address...");
|
|
|
- err = SetIp_Ptr(target_res.sn.c_str(), m_strLocalIP.c_str(), m_strWiredIP.c_str(), nullptr);
|
|
|
- if (err != TiRayError::Err_Success)
|
|
|
- {
|
|
|
- FINFO("The IP setting failed, error code:{$} (will continue to execute)", err);
|
|
|
- return false;
|
|
|
+ if (!m_bIpInitialized) {
|
|
|
+ FINFO("First connection, setting IP address...");
|
|
|
+ auto err = SetIp_Ptr(target_res.sn.c_str(), m_strLocalIP.c_str(), m_strWiredIP.c_str(), nullptr);
|
|
|
+
|
|
|
+ if (err == TiRayError::Err_Success) {
|
|
|
+ FINFO("IP setting successful");
|
|
|
+ m_bIpInitialized = true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ FINFO("IP setting failed, error:{$}", err);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
- FINFO("IP setting was successful");
|
|
|
+ FINFO("IP already initialized, skip SetIp_Ptr");
|
|
|
}
|
|
|
|
|
|
while (!m_bConnected)
|
|
|
@@ -1269,17 +1321,23 @@ bool Detector_TiRayDR::OpenDetector()
|
|
|
}
|
|
|
|
|
|
// 加载校准文件
|
|
|
- cout << "[Detector_TiRayDR::OpenDetector] Start loading the calibration file..." << endl;
|
|
|
- //if (m_nCalibrationMode) //TiRayCalibration
|
|
|
SetSyncMode(3);
|
|
|
|
|
|
-
|
|
|
+ // 从配置读取敏感度和曝光间隔参数
|
|
|
int nSensitivity = (int)m_ModeConfig["ModeTable"][0]["Sensitivity"];
|
|
|
- int nXWindow = (int)m_ModeConfig["ModeTable"][0]["XWindow"];
|
|
|
+ int nXWindow = m_nXWindow = (int)m_ModeConfig["ModeTable"][0]["XWindow"];
|
|
|
+ FINFO("Initialize XWindow from config: {$}", m_nXWindow);
|
|
|
|
|
|
+ // 设置曝光间隔到硬件
|
|
|
err = write_attribute(Attr_PhotoInterval, nXWindow);
|
|
|
if (err != Err_Success)
|
|
|
- FINFO("[Detector_TiRayDR::OpenDetector] Failed to write Attr_PhotoInterval. Error code: {$}", err);
|
|
|
+ {
|
|
|
+ FERROR("Failed to write Attr_PhotoInterval. Error code: {$}", err);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FINFO("Successfully set Attr_PhotoInterval to: {$}", nXWindow);
|
|
|
+ }
|
|
|
|
|
|
err = write_attribute(Attr_PhotoNumber, 1);
|
|
|
if (err != Err_Success)
|
|
|
@@ -2109,9 +2167,18 @@ std::string Detector_TiRayDR::saveProcessedImage(Detector_TiRayDR& detector, uns
|
|
|
|
|
|
FINFO("Saved processed image: {$}", filePath);
|
|
|
|
|
|
- // 使用完整的 baseTimestamp 作为会话标识(格式:YYYYMMDD_HHMMSS_mmm)
|
|
|
- // 清理旧文件,但保护当前会话的文件
|
|
|
- cleanOldFiles(dirPath, FILE_PREFIX, MAX_PROC_FILE_COUNT, isTmpfs, baseTimestamp);
|
|
|
+ // 从 baseTimestamp 中提取会话时间戳(去掉 _frameNNN 部分)
|
|
|
+ // baseTimestamp 格式: YYYYMMDD_HHMMSS_mmm_frameNNN
|
|
|
+ // sessionTimestamp 格式: YYYYMMDD_HHMMSS_mmm
|
|
|
+ std::string sessionTimestamp = baseTimestamp;
|
|
|
+ size_t framePos = baseTimestamp.find("_frame");
|
|
|
+ if (framePos != std::string::npos)
|
|
|
+ {
|
|
|
+ sessionTimestamp = baseTimestamp.substr(0, framePos);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清理旧文件,但保护当前会话的所有文件
|
|
|
+ cleanOldFiles(dirPath, FILE_PREFIX, MAX_PROC_FILE_COUNT, isTmpfs, sessionTimestamp);
|
|
|
return true;
|
|
|
}
|
|
|
catch (const std::filesystem::filesystem_error& e)
|
|
|
@@ -2195,9 +2262,18 @@ void Detector_TiRayDR::saveRawImage(Detector_TiRayDR& detector, unsigned short*
|
|
|
|
|
|
FINFO("Saved raw image: {$}", filePath);
|
|
|
|
|
|
- // 使用完整的 baseTimestamp 作为会话标识(格式:YYYYMMDD_HHMMSS_mmm)
|
|
|
- // 清理旧的原始图,但保护当前会话
|
|
|
- cleanOldFiles(dirPath, FILE_PREFIX, MAX_RAW_FILE_COUNT, false, baseTimestamp);
|
|
|
+ // 从 baseTimestamp 中提取会话时间戳(去掉 _frameNNN 部分)
|
|
|
+ // baseTimestamp 格式: YYYYMMDD_HHMMSS_mmm_frameNNN
|
|
|
+ // sessionTimestamp 格式: YYYYMMDD_HHMMSS_mmm
|
|
|
+ std::string sessionTimestamp = baseTimestamp;
|
|
|
+ size_t framePos = baseTimestamp.find("_frame");
|
|
|
+ if (framePos != std::string::npos)
|
|
|
+ {
|
|
|
+ sessionTimestamp = baseTimestamp.substr(0, framePos);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清理旧的原始图,但保护当前会话的所有文件
|
|
|
+ cleanOldFiles(dirPath, FILE_PREFIX, MAX_RAW_FILE_COUNT, false, sessionTimestamp);
|
|
|
return true;
|
|
|
}
|
|
|
catch (const std::filesystem::filesystem_error& e)
|
|
|
@@ -2855,6 +2931,11 @@ void Detector_TiRayDR::on_event_callback(int detectorId, TiRayEvent eventType, T
|
|
|
}
|
|
|
case TiRayEvent::Evt_DetectorDisconnect:
|
|
|
{
|
|
|
+ //if (detector.m_bFirstConnect) {
|
|
|
+ // FINFO("Ignore first disconnect event after IP setting");
|
|
|
+ // detector.m_bFirstConnect = false; // 标记第一次连接已完成
|
|
|
+ // break;
|
|
|
+ //}
|
|
|
detector.m_nDetectorID = INT_MAX;
|
|
|
detector.m_bConnected = false;
|
|
|
detector.m_pStPanelStatus[detector.m_nCurrentPanelID]->bConnectState = false;
|