Jelajahi Sumber

1.为探测器Demo和mould增加日志
2.修改TiRay的图像裁剪逻辑!

lwk 2 minggu lalu
induk
melakukan
cdd90d18a2

+ 19 - 16
Detector/CCOS.Dev.FPD.Demo/CCOS.Dev.FPD.Demo.cpp

@@ -1,12 +1,14 @@
 // CCOS.Dev.FPD.Demo.cpp : 定义 DLL 应用程序的导出函数。
 //
 
+#include <pthread.h> 
 #include "FileVersion.hpp"
 #include "CCOS.Dev.FPD.Demo.h"
 #include "common_api.h"
 #include "DICOMImageHeadKey.h"
 #include "dcm.hpp"
-#include <pthread.h> 
+#include "LogLocalHelper.h"       
+#include "Log4CPP.h"
 
 
 namespace nsFPD = CCOS::Dev::Detail::Detector;
@@ -48,23 +50,24 @@ nsFPD::FPDDemoDriver::~FPDDemoDriver()
 		delete dev;
 		dev = nullptr;
 	}
-	Close();
-	//Log4CPP::ThreadContext::Map::Clear();
-	gLogger = nullptr;
 }
 
 void nsFPD::FPDDemoDriver::Prepare()
 {
-	//string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
-	//auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
-	gLogger = Log4CPP::LogManager::GetLogger("Module");
-
-	FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
-#ifdef _WIN64
-	FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
-#else
-	FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
-#endif
+	std::string strLogPath = GetProcessDirectory() + R"(/Conf/log_config.xml)";
+	std::string LogHost = "DemoFPD"; // 确保这是正确的值
+	std::string moduleName = "DemoFPD";
+	bool ret = initLogModule(
+		LogHost,       // 主机名(用于日志路径中的{host}占位符)
+		moduleName,        // 唯一模块名
+		strLogPath,  // 配置文件路径
+		true           // 是否输出到控制台(可选)
+	);
+	if (!ret) {
+		std::cerr << "Log init failed!" << std::endl;
+		return;
+	}
+	FPDDemoSetLocalModuleName(moduleName);
 }
 
 bool nsFPD::FPDDemoDriver::Connect()
@@ -314,7 +317,7 @@ std::string nsFPD::FPDDemoDriver::GetResource()
 	ResDataObject r_config, temp;
 	if (!temp.loadFile(m_ConfigFileName.c_str()))
 	{
-		Debug("GetResource load File failed! file name:{$}", m_ConfigFileName);
+		FDEBUG("GetResource load File failed! file name:{$}", m_ConfigFileName);
 		return "";
 	}
 
@@ -1583,7 +1586,7 @@ bool nsFPD::FPDDemoDevice::LoadDCMDemo(const char* pPath)
 			memcpy(pRaw, objDcm.ppData[i], sizeof(unsigned short) * nWidth * nHeight);
 			m_pSeqList->PushMemImage(pRaw, nWidth, nHeight, i);
 			FINFO("Load dcm success(width: {$} height: {$} bits: {$} frame: {$})",
-				//nWidth, nHeight, nBits, i);
+				nWidth, nHeight, nBits, i);
 		}
 	}
 

+ 3 - 0
Detector/CCOS.Dev.FPD.Demo/CCOS.Dev.FPD.Demo.h

@@ -188,6 +188,9 @@ namespace CCOS::Dev::Detail::Detector
 		RET_STATUS SetDemoImage(string& strPath1, string& strPath2, string& strPath3);
 		RET_STATUS ResetError();
 		RET_STATUS ActiveSyncMode(int nSyncMode);
+		std::string getLogHostName() const override {
+			return "DemoFPD"; // ×ÓÀàµÄ¾ßÌåÖµ
+		}
 
 		void SendInfoLog(string strLogKey, float fValue);
 		void SendInfoLog(string strLogKey, int nValue);

+ 2 - 0
Detector/CCOS.Dev.FPD.Demo/CMakeLists.txt

@@ -60,6 +60,8 @@ set(SRC_FILES
     OEM.Sync.cpp
     SeqImages.h
     SeqImages.cpp
+    LogLocalHelper.h
+    LogLocalHelper.cpp
 	${PhysicalDevice_DELIVER_INCLUDE_DIR}/CCOS.Dev.MSGMould.hpp
 	${PhysicalDevice_DELIVER_INCLUDE_DIR}/CCOS.Dev.MSGMould.cpp
 	${DELIVER_INCLUDE_DIR}/Base64.cpp

+ 2 - 0
Detector/CCOS.Dev.FPD.Demo/FPDErrorWarningProcess.cpp

@@ -1,4 +1,6 @@
 #include "FPDErrorWarningProcess.h"
+#include "LogLocalHelper.h"       
+#include "Log4CPP.h"
 
 //extern Log4CPP::Logger* mLog::gLogger;
 

+ 2 - 0
Detector/CCOS.Dev.FPD.Demo/OEM.Acq.cpp

@@ -1,5 +1,7 @@
 #include "OEM.Acq.h"
 #include "CCOS.Dev.FPD.Demo.h"
+#include "LogLocalHelper.h"       
+#include "Log4CPP.h"
 
 //extern Log4CPP::Logger* mLog::gLogger;
 

+ 2 - 0
Detector/CCOS.Dev.FPD.Demo/dcm.hpp

@@ -15,6 +15,8 @@ Example:
 #include <stdlib.h>
 #include <string>
 #include <sstream>	//使用stringstream需要引入这个头文件
+#include "LogLocalHelper.h"       
+#include "Log4CPP.h"
 
 using namespace std;
 

+ 1 - 0
Detector/CCOS.Dev.FPDDeviceMould/CCOS.Dev.FPD.AcqUnit.cpp

@@ -2,6 +2,7 @@
 //
 
 #include "CCOS.Dev.FPDDeviceMould.hpp"
+#include "LogLocalHelper.h"       
 #include "Log4CPP.h"
 
 using namespace CCOS::Dev;

+ 1 - 0
Detector/CCOS.Dev.FPDDeviceMould/CCOS.Dev.FPD.CalibUnit.cpp

@@ -2,6 +2,7 @@
 //
 
 #include "CCOS.Dev.FPDDeviceMould.hpp"
+#include "LogLocalHelper.h"       
 #include "Log4CPP.h"
 
 using namespace CCOS::Dev;

+ 1 - 0
Detector/CCOS.Dev.FPDDeviceMould/CCOS.Dev.FPD.CtrlUnit.cpp

@@ -2,6 +2,7 @@
 //
 
 #include "CCOS.Dev.FPDDeviceMould.hpp"
+#include "LogLocalHelper.h"       
 #include "Log4CPP.h"
 
 using namespace CCOS::Dev;

+ 1 - 0
Detector/CCOS.Dev.FPDDeviceMould/CCOS.Dev.FPD.SyncUnit.cpp

@@ -2,6 +2,7 @@
 //
 
 #include "CCOS.Dev.FPDDeviceMould.hpp"
+#include "LogLocalHelper.h"       
 #include "Log4CPP.h"
 
 using namespace CCOS::Dev;

+ 13 - 4
Detector/CCOS.Dev.FPDDeviceMould/CCOS.Dev.FPDDeviceMould.cpp

@@ -5,6 +5,7 @@
 #include "EasyJSONEncoder.hpp"
 #include "CCOS.Dev.FPDDeviceMould.hpp"
 #include "common_api.h"
+#include "LogLocalHelper.h"       
 #include "Log4CPP.h"
 
 using namespace CCOS::Dev::Detail::Detector;
@@ -26,12 +27,20 @@ FPDDeviceMould::FPDDeviceMould()
 {
 	m_strIODevicePath = "/Detector";
 
-	string strLogPath = GetProcessDirectory() + R"(\Conf\log_config.xml)";
+	string strLogPath = GetProcessDirectory() + R"(/Conf/log_config.xml)";
+	logHostName = getLogHostName();
 	// 初始化日志系统
-	if (!Log4CPP::init(logHostName, "FPD.Modle", strLogPath, true)) {
-		std::cerr << "Failed to initialize log system! Using default configuration." << std::endl;
-		// 即使配置文件加载失败,也可以继续使用默认配置
+	bool ret = initLogModule(
+		logHostName,       // 主机名(用于日志路径中的{host}占位符)
+		"FPD.Modle",        // 唯一模块名
+		strLogPath,  // 配置文件路径
+		true           // 是否输出到控制台(可选)
+	);
+	if (!ret) {
+		std::cerr << "Log init failed!" << std::endl;
+		return;
 	}
+	FPDSetLocalModuleName("FPD.Modle");
 //
 	FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
 }

+ 4 - 2
Detector/CCOS.Dev.FPDDeviceMould/CCOS.Dev.FPDDeviceMould.hpp

@@ -688,9 +688,11 @@ namespace CCOS::Dev::Detail::Detector
 	public:
 		FPDDeviceMould();
 		~FPDDeviceMould();
-		string logHostName = "FPDDeviceMould";
+		string logHostName;
 		//protected:
-
+		virtual std::string getLogHostName() const {
+			return "FPDDeviceMould"; // ĬÈÏÖµ
+		}
 		//	virtual void RegisterCtrl();
 		//	virtual void RegisterAcq();
 		//	virtual void RegisterSync();

+ 2 - 0
Detector/CCOS.Dev.FPDDeviceMould/CMakeLists.txt

@@ -45,6 +45,8 @@ set(SRC_FILES
     CCOS.Dev.FPD.CalibUnit.cpp
     CCOS.Dev.FPD.CtrlUnit.cpp
     CCOS.Dev.FPD.SyncUnit.cpp
+    LogLocalHelper.h
+    LogLocalHelper.cpp
 	${DELIVER_INCLUDE_DIR}/BatteryMould.hpp
 	${DELIVER_INCLUDE_DIR}/common_api.h
     ${DELIVER_INCLUDE_DIR}/TemperatureMould.hpp

+ 2 - 1
Detector/CMakeLists.txt

@@ -4,4 +4,5 @@ project(Detector)
 # 添加所有独立项目
 add_subdirectory(CCOS.Dev.FPDDeviceMould)
 add_subdirectory(CCOS.Dev.FPD.Demo)
-add_subdirectory(TiRay/CCOS.Dev.FPD.TiRayDR)
+add_subdirectory(TiRay/CCOS.Dev.FPD.TiRayDR)
+add_subdirectory(HaoBo/CCOS.Dev.FPD.HaoBo)

+ 1 - 1
Detector/TiRay/CCOS.Dev.FPD.TiRayDR/CCOS.Dev.FPD.TiRayDR.cpp

@@ -1668,7 +1668,7 @@ void nsFPD::FPDDeviceTiRay::OnEventProcessStatus(int nDetectorID, int nEventID,
 		{
 			m_stImgCreateTime = { 0 };
 			GetLocalTime(&m_stImgCreateTime);
-			FINFO("XWindowOn at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
+			FINFO("XWindowOn at {$}-{$}-{$} {$}:{$}:{$}:{$}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay,
 				m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds);
 			m_SyncUnit->XWindowOnNotify();
 			FINFO("m_SyncUnit XWindowOnNotify Finished!");

File diff ditekan karena terlalu besar
+ 153 - 141
Detector/TiRay/CCOS.Dev.FPD.TiRayDR/Detector_TiRayDR.cpp


+ 38 - 38
Detector/TiRay/CCOS.Dev.FPD.TiRayDR/Detector_TiRayDR.h

@@ -52,20 +52,20 @@ class Detector_TiRayDR
 		DetStatus_XrayCalibration,
 	};
 
-	//探测器信息
+	//鎺㈡祴鍣ㄤ俊鎭�
 	struct CPanelStatus
 	{
-		bool bInitOver; //是否初始化完成
-		bool bConnectState; //是否连接
-		SYNC_MODE eSyncMode; //同步模式
+		bool bInitOver; //鏄�惁鍒濆�鍖栧畬鎴�
+		bool bConnectState; //鏄�惁杩炴帴
+		SYNC_MODE eSyncMode; //鍚屾�妯″紡
 		int nSoftAcqState;
-		eDetStatus eFPDStatus; //探测器状态
+		eDetStatus eFPDStatus; //鎺㈡祴鍣ㄧ姸鎬�
 
 		CPanelStatus()
 		{
 			bInitOver = false;
 			bConnectState = false;
-			eSyncMode = SYNC_SOFTWARE; //暂时使用软同步作为缺省值
+			eSyncMode = SYNC_SOFTWARE; //鏆傛椂浣跨敤杞�悓姝ヤ綔涓虹己鐪佸€�
 			nSoftAcqState = 0;
 			eFPDStatus = eDetStatus::DetStatus_NotIni;
 		}
@@ -111,7 +111,7 @@ public:
 
 	void register_event_listener(const EventListener& fn);
 	void unregister_event_listener(const EventListener& fn);
-	static bool cropImage(unsigned short* srcData,
+	bool cropImage(unsigned short* srcData,
 		int srcWidth, int srcHeight,
 		unsigned short* destData,
 		int destWidth, int destHeight);
@@ -168,17 +168,17 @@ public:
 	//	param[0].Type = TiRayVariant::TiRayInt;
 	//	param[0].IntValue = attribute;
 
-	//	// 执行命令
+	//	// 鎵ц�鍛戒护
 	//	auto err = Execute(m_nDetectorID, Cmd_ReadAttribute, param, 1);
 	//	if (err != Err_Success) {
 	//		return { err, {} };
 	//	}
 
-	//	// 处理event_params类型(实际是std::vector<event_param>)
+	//	// 澶勭悊event_params绫诲瀷锛堝疄闄呮槸std::vector<event_param>锛�
 	//	if constexpr (std::is_same_v<T, event_params>) {
 	//		event_params result;
 
-	//		// 根据参数类型构造对应的event_param并添加到vector中
+	//		// 鏍规嵁鍙傛暟绫诲瀷鏋勯€犲�搴旂殑event_param骞舵坊鍔犲埌vector涓�
 	//		switch (param[0].Type) {
 	//		case TiRayVariant::TiRayInt:
 	//			result.emplace_back(param[0].IntValue);
@@ -200,7 +200,7 @@ public:
 	//		T result;
 	//		bool typeMismatch = false;
 
-	//		// 根据参数类型和目标类型进行转换
+	//		// 鏍规嵁鍙傛暟绫诲瀷鍜岀洰鏍囩被鍨嬭繘琛岃浆鎹�
 	//		if constexpr (std::is_integral_v<T> && sizeof(T) <= 4 || std::is_enum_v<T>) {
 	//			if (param[0].Type == TiRayVariant::TiRayInt) {
 	//				result = static_cast<T>(param[0].IntValue);
@@ -226,12 +226,12 @@ public:
 	//			}
 	//		}
 	//		else {
-	//			// 处理其他类型(如自定义类型)
+	//			// 澶勭悊鍏朵粬绫诲瀷锛堝�鑷�畾涔夌被鍨嬶級
 	//			typeMismatch = true;
 	//		}
 
 	//		if (typeMismatch) {
-	//			return { err, {} };  // 假设存在类型不匹配的错误码
+	//			return { err, {} };  // 鍋囪�瀛樺湪绫诲瀷涓嶅尮閰嶇殑閿欒�鐮�
 	//		}
 
 	//		return { Err_Success, result };
@@ -291,40 +291,40 @@ public:
 		return Err_Success;
 	}
 
-	std::vector<image_info> m_gainCalibImages;   // 存储Gain模式下的所有30张图像
-	std::vector<image_info> m_currentDoseImages; // 存储当前剂量组的6张图像
-	std::vector<image_info> m_gainV2MeanImages;  // 存储每个剂量组生成的均值图
-	int m_currentDoseIndex = 0;                  // 当前处理的剂量组索引(0-4,共5组)
+	std::vector<image_info> m_gainCalibImages;   // 瀛樺偍Gain妯″紡涓嬬殑鎵€鏈�30寮犲浘鍍�
+	std::vector<image_info> m_currentDoseImages; // 瀛樺偍褰撳墠鍓傞噺缁勭殑6寮犲浘鍍�
+	std::vector<image_info> m_gainV2MeanImages;  // 瀛樺偍姣忎釜鍓傞噺缁勭敓鎴愮殑鍧囧€煎浘
+	int m_currentDoseIndex = 0;                  // 褰撳墠澶勭悊鐨勫墏閲忕粍绱㈠紩锛�0-4锛屽叡5缁勶級
 private:
 	map<FPDDeviceTiRay*, int>* m_pDPC2PanelID;
 	map<int, FPDDeviceTiRay*>* m_pPanelID2DPC;
 	std::list<EventListener> m_listeners;
 
-	ResDataObject m_ModeConfig; //保存DPC模块下发的配置
+	ResDataObject m_ModeConfig; //淇濆瓨DPC妯″潡涓嬪彂鐨勯厤缃�
 	CPanelStatus* m_pStPanelStatus[2]; //
 	void* m_hTiRayDRModule;
-	APP_STATUS m_nAppStatus; //记录软件状态
-	CCOS_CALIBRATION_TYPE m_eCaliType; // 记录当前校正类型
-	CCOS_CALIBRATION_MODE m_nCalibrationMode;//校正模式 ecom校正/厂商校正
+	APP_STATUS m_nAppStatus; //璁板綍杞�欢鐘舵€�
+	CCOS_CALIBRATION_TYPE m_eCaliType; // 璁板綍褰撳墠鏍℃�绫诲瀷
+	CCOS_CALIBRATION_MODE m_nCalibrationMode;//鏍℃�妯″紡 ecom鏍℃�/鍘傚晢鏍℃�
 	CZSKKCalibrationCtrl* m_pZSKKCalib;
 
 	std::map<int32_t, std::promise<event_params>> notifiers_;
 	std::mutex notifiers_mutex_;
 
-	int m_nPanelCount; //探测器数量
+	int m_nPanelCount; //鎺㈡祴鍣ㄦ暟閲�
 	int m_nDetectorID;
 	int m_nCurrentPanelID;
-	int m_nSyncMode; //记录选择模式时使用的同步模式
+	int m_nSyncMode; //璁板綍閫夋嫨妯″紡鏃朵娇鐢ㄧ殑鍚屾�妯″紡
 	int m_nImageWidth;
 	int m_nImageHeight;
 	int m_nWidthOffset;
 	int m_nHeightOffset;
-	int m_nRawImgWidth; //SDK反馈的图像宽
-	int m_nRawImgHeight; //SDK反馈的图像高
-	int m_nCalibrationRounds;//校正轮数
-	int m_nCalibCurrentCalibrationRound;//当前校正轮数
-	int m_nCalibCurrentExposureIndex;//当前轮次曝光第几次
-	int m_nExposureNumCurrentRound;//当前轮次需要曝光的总次数
+	int m_nRawImgWidth; //SDK鍙嶉�鐨勫浘鍍忓�
+	int m_nRawImgHeight; //SDK鍙嶉�鐨勫浘鍍忛珮
+	int m_nCalibrationRounds;//鏍℃�杞�暟
+	int m_nCalibCurrentCalibrationRound;//褰撳墠鏍℃�杞�暟
+	int m_nCalibCurrentExposureIndex;//褰撳墠杞��鏇濆厜绗�嚑娆�
+	int m_nExposureNumCurrentRound;//褰撳墠杞��闇€瑕佹洕鍏夌殑鎬绘�鏁�
 	int m_nImageNum;
 	int m_nReconnectTimePeriod;
 	int m_nNotifyStatusTimePeriod;
@@ -338,27 +338,27 @@ private:
 	
 	bool m_bUseGainV2 = false;
 
-	std::string m_strWorkPath; //保存工作路径,用于加载SDK和配置
-	std::string m_strDetectorType; //探测器类型
+	std::string m_strWorkPath; //淇濆瓨宸ヤ綔璺�緞锛岀敤浜庡姞杞絊DK鍜岄厤缃�
+	std::string m_strDetectorType; //鎺㈡祴鍣ㄧ被鍨�
 	std::string m_strWiredIP;
 	std::string m_strWirelessIP;
 	std::string m_strLocalIP;
 	std::string m_strSerialNum;
 	
-	WORD* m_pRawImgBuffer; //原始图
-	WORD* m_pImgBuffer; //裁剪后图像
+	WORD* m_pRawImgBuffer; //鍘熷�鍥�
+	WORD* m_pImgBuffer; //瑁佸壀鍚庡浘鍍�
 
-	//辅助线程事件
+	//杈呭姪绾跨▼浜嬩欢
 	std::shared_ptr<LinuxEvent> m_hInitEvent;
-	std::shared_ptr<LinuxEvent> m_hExitEvent; //退出辅助线程事件
+	std::shared_ptr<LinuxEvent> m_hExitEvent; //閫€鍑鸿緟鍔╃嚎绋嬩簨浠�
 	std::shared_ptr<LinuxEvent> m_hReConnectEvent;
 	std::shared_ptr<LinuxEvent> m_hRadEvent;
 	std::vector<std::shared_ptr<LinuxEvent>> m_hArrayEvent;
 
 	pthread_t m_hReconnectThread = 0;
 	bool m_bReconnectThreadRunning = false;
-	std::shared_ptr<LinuxEvent> m_hToggleEvent; //辅助线程退出通知事件
-	pthread_t m_hFPDScanThread = 0; //辅助线程
+	std::shared_ptr<LinuxEvent> m_hToggleEvent; //杈呭姪绾跨▼閫€鍑洪€氱煡浜嬩欢
+	pthread_t m_hFPDScanThread = 0; //杈呭姪绾跨▼
 
 	pthread_t m_hRadAcquisitionThread = 0;
 
@@ -379,7 +379,7 @@ private:
 	bool CloseDetectorScan();
 	bool LoadCalibrationFiles(int nCalibrationMode);
 	bool TestError(TiRayError nErrorCode);
-	//辅助线程
+	//杈呭姪绾跨▼
 	static void* onFPDScanThread(PVOID pvoid);
 	void OnReconnectFPD();
 	void OnProcessInitFPD();

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini