#ifndef _ANALYZESPECTURMEXPORT_H_ #define _ANALYZESPECTURMEXPORT_H_ #ifdef ANALYZESPECTURM_EXPORTS #define ANALYZESPECTURM_API(type) __declspec(dllexport) type __stdcall #else #define ANALYZESPECTURM_API(type) __declspec(dllimport) type __stdcall #endif #include "NuclideLibraryDefine.h" #include "PeakInfoDefine.h" #define MSS_SPECTURMDATA_MAXSIZE 65536 #pragma pack(push,1) //s - Peak fails shape tests. //D - Peak area deconvoluted. //M - Peak is close to a library peak. enum ePeakUseFlag { ePUF_PEAK_FAILED_SHAPE_TEST, ePUF_PEAK_DECONVOLUTED, ePUF_PEAK_FIT_NUCLIDE, ePUF_PEAK_SMALL_POS, eNF_ACTIVITY_AVG_CALC = 16, eNF_PEAK_TOO_WIDE, eNF_PEAK_MULT_AREA_NEG, eNF_PEAK_TOO_NARROW, eNF_PEAK_FWH25M_WIDE, eNF_PEAK_FAILED_SENS_TEST, eNF_PEAK_IDTY_FIRST_PEAK_FIALED, eNF_LARGE_INCALC_ACTIVITY, eNF_SMALL_INCALC_ACTIVITY, eNF_PEAK_OUTSIDE_ANS_ENERGY_RANGE, eNF_PEAK_CENTROID_IS_NOT_CLOSE_TO_LIB, eNF_PEAK_BACKGROUND_COR, }; #define IS_POS_CHECKED(flag,pos) ( (flag & (1 << pos)) == (1 << pos) ) #define SET_SHAPE_CHECK_FAILED(flag) (flag |= (1 << ePUF_PEAK_FAILED_SHAPE_TEST)) #define SET_SHAPE_CHECK_SUCCESS(flag) (flag &= ~(1 << ePUF_PEAK_FAILED_SHAPE_TEST)) #define SET_PEAK_DECONVOLUTED(flag) (flag |= (1 << ePUF_PEAK_DECONVOLUTED)) #define RESET_PEAK_DECONVOLUTED(flag) (flag &=~(1 << ePUF_PEAK_DECONVOLUTED)) #define SET_PEAK_FIT_NUCLIDE(flag) (flag |= (1 << ePUF_PEAK_FIT_NUCLIDE)) #define RESET_PEAK_FIT_NUCLIDE(flag) (flag &=~(1 << ePUF_PEAK_FIT_NUCLIDE)) #define IS_PEAK_FIT_NUCLIDE(flag) IS_POS_CHECKED( flag,ePUF_PEAK_FIT_NUCLIDE) #define SET_PEAK_SMALL(flag) (flag |= (1 << ePUF_PEAK_SMALL_POS)) #define RESET_PEAK_SMALL(flag) (flag &=~(1 << ePUF_PEAK_SMALL_POS)) #define IS_PEAK_SMALL(flag) IS_POS_CHECKED( flag,ePUF_PEAK_SMALL_POS) #define IS_NI_FLAG_CHECKED(flag,v) ( (flag &( 1 << v)) == (1 << v)) #define SET_NI_FLAG(flag,v) (flag |= (1 << v)) #define RESET_NI_FLAG(flag,v) (flag &= ~(1 << v)) #define IS_NI_KEY_LINE(flag) IS_NI_FLAG_CHECKED(flag,eNI_K) #define IS_NI_NOT_IN_AVG(flag) IS_NI_FLAG_CHECKED(flag,eNI_A) #define SET_ACTIVITY_AVG_CALC(flag) SET_NI_FLAG(flag,eNF_ACTIVITY_AVG_CALC) #define IS_ACTIVITY_AVG_CALC_SET(flag) IS_NI_FLAG_CHECKED(flag,eNF_ACTIVITY_AVG_CALC) #define SET_LARGE_INCALC_ACTIVITY(flag) SET_NI_FLAG(flag,eNF_LARGE_INCALC_ACTIVITY) #define SET_SMALL_INCALC_ACTIVITY(flag) SET_NI_FLAG(flag,eNF_SMALL_INCALC_ACTIVITY) #define SET_PEAK_FAILED_SENS_TEST(flag) SET_NI_FLAG(flag,eNF_PEAK_FAILED_SENS_TEST) enum eLinearFitType { eLFTNone, // 线性插值 eInterpolative, // 一次函数,2个未知数 eLine2, // 二次函数,3个未知数 eLine3, // 多次函数 eEFTPloy, // 一次函数,2个未知数,有权重拟合 eLine2WithW, // 二次函数,3个未知数,有权重拟合 eLine3WithW, eLine4,// 三次函数拟合 }; typedef struct sLinearFitResult { eLinearFitType type; double a; double b; double c; double d; double e; double f; double sa; double sb; double sc; double sd; double se; double sf; double chisq; }sLinearFitResult; class NuclideLibrary; struct sDataInfo { int *pOrgData; int Orglen; double dRealTime; double dLiveTime; int iPeakBeginCh; // 峰开始道址 NuclideLibrary *pNuclideLibaray; }; typedef struct sSmoothConfig { int bUseGaussSmoothNum; int bUseGaussSmoothTimes; }sSmoothConfig; typedef struct sPeakSearchConfig { double dSerachSensity; int iChNumOnEachSide; double dSfwhmRadioFwhmMaxValue; double dSheightRadioHeightValue; }sPeakSearchConfig; typedef struct sResolvePeakConfig { double dnofwhmofpeak; double dnofwhmofSideBaseLine; }sResolvePeakConfig; typedef struct sMatchPeaksConfig { double toler; double dprob; }sMatchPeaksConfig; typedef struct sPeakInfoConfig { BOOL isroi; int leftch; int righch; int n; int cursorpeak; }sPeakInfoConfig; typedef struct sCursorOnePeakInfo { double dChannel; // 峰所在道址 double dEnergy; // 峰所在的能量 int iNIChannel; double dNIEnergy; int iLeftChannel; int iRightChannel; char cNName[32]; double fwhm; double fwh5m; double dGrossArea; double dGrossAreaCountRate; double dNetArea; double dNetAreaCountRate; double dNetAreaUncertain; double dcA; // counting activity, }sCursorOnePeakInfo; typedef struct sPeakInfoResult { double* pSmoothData; int iSmoothDataLen; double* pSecDiffData; int iSecDiffDataLen; sCursorOnePeakInfo peakinfo; }sPeakInfoResult; typedef struct sConfigInfo { sSmoothConfig smoothconfig; sPeakSearchConfig peaksearchconfig; sResolvePeakConfig resolvepeakconfig; sLinearFitResult energycal; // 能量刻度 sMatchPeaksConfig matchpeakconfig; sPeakInfoConfig peakInfoConfig; }sConfigInfo; typedef struct OneValue { double v; double sv; }OneValue; typedef struct sOneBaseLineInfo { eLinearFitType type; int leftch; int rightch; OneValue a; OneValue b; OneValue c; OneValue d; double chisq; double leftsmoothpoint; double rightsmoothpoint; double leftvalue; double rightvalue; double peakpos; double grossarea; double bdarea; OneValue netarea; double directfitnetarea; }sOneBaseLineInfo; typedef struct sOnePeakInfo { OneValue height; OneValue centor; OneValue width; // 半高宽,道址 OneValue fwhm; ////y = a*exp(-b*(x-c)^2)); fwhmwidth = b double fwhmwidth; // 半高宽,道址 OneValue fittedfwhm; // //y = a*exp(-b*(x-c)^2)); fittedwidth = b OneValue fittedwidth; OneValue area; OneValue bdarea; double leftch; double rightch; double energy; int flag; double leftsmoothpoint; double rightsmoothpoint; double leftvalue; double rightvalue; // 活度 校正到开始测量时的活度 OneValue activity; // MDA OneValue mda; sOneNuclideInfo oni; sOneEnergyLine onl; sOneBaseLineInfo obli; }sOnePeakInfo; typedef struct sMulPeakInfo { int MulPeakNum; sOnePeakInfo peakinfo; }sMulPeakInfo; typedef struct sBaseLineInfo { sOneBaseLineInfo leftbaseline; sOneBaseLineInfo rightbaseline; sOneBaseLineInfo peakbaseline; }sBaseLineInfo; class _sOneNuclideActivity; typedef struct sResultInfo { char measureDate[32]; double dRealTime; double dLiveTime; int sprtLen; double* pSmoothData; int iSmoothDataLen; double* pSecDiffData; int iSecDiffDataLen; double* pCandidatePeaks; int iCandidatePeakNum; int iFinalPeakNum; // 两个作用 inout 传入内存大小,字节单位,传出峰数量 int iNotEnoughMemery; sOnePeakInfo* pSearchPeakResult; sLinearFitResult linFitResult; int iBaseLineNum; // 两个作用 inout 传入内存大小,字节单位,传出数量 int iNotEnoughMemeryofBaseLine; sBaseLineInfo *pBaselineInfo; int iMulPeakNum; // 两个作用 inout 传入内存大小,字节单位,传出重叠峰和单峰的数量 int iNotEnoughMemeryofMulPeak; sMulPeakInfo *pMulPeakInfo; int iNucResultNum; // 两个作用 inout 传入内存大小,字节单位,传出核素的数量 int iNotEnoughMemeryofNucResult; _sOneNuclideActivity *pNucResultInfo; }sResultInfo; struct sFitData { eLinearFitType type; int size; double *px; double *py; double *pw; }; typedef struct ASDataInfo { int* pHandle; // 设备句柄 int bdidx; int chidx; double beginchannel; double endchannel; eDisplaSprtInfoType calcType; double energy; eCalcSprtSubInfoType sprtSubType; unsigned char reserve[20]; }ASDataInfo; enum eSearchPeakSensityLevel { eSPS_1, eSPS_2, eSPS_3, eSPS_4, eSPS_5 }; typedef struct OneDefaultConfig { BOOL enalbe; BOOL useInternal; char path[MAX_PATH]; }OneDefaultConfig; enum eBackgroundType { eBTAuto, eBTOne, eBTThree, eBTFive, }; typedef struct AnalysisSampleConfig { // 描述 char Description[128]; // 分析范围 double beginchannel; double endchannel; // 随机相加 double RandomSum; // 本底类型 eBackgroundType BGType; // 核素库 OneDefaultConfig NuclideLib; // 校正文件,能量刻度,效率刻度 OneDefaultConfig Clb; }AnalysisSampleConfig; enum eMDAType { eMDATP_1 }; enum eASUnit { eASUBq, eASUuCi, }; typedef struct AnalysisSystemConfig { // 实验室名 char LaboratoryName[128]; // 操作员名 char OperatorName[128]; // MDA类型 eMDAType mdaType; // 寻峰参数 eSearchPeakSensityLevel eSPSLevel; // 匹配配置 double dlibMatchWidth; // 分支比限制 100 double dlibFractionLimit; // 可疑核素库 OneDefaultConfig libSuspect; // 单位 eASUnit asuUit; double asuMultiplier; double asuDivisor; char asuActivity[32]; double asuSize; char asuSizeUnit[32]; double asuSizeUncertain; }AnalysisSystemConfig; typedef struct AnalysisDecayConfig { // 衰减校正 BOOL bDecayCorrection; // 衰减校正 yyyy-MM-dd HH:mm:ss char bDCDateTime[32]; // 谱线采集校正 BOOL bAcquisitionCorr; // 样品采集时间校正 BOOL bSampleCorrect; // 样品采集时间校正 yyyy-MM-dd HH:mm:ss char bSCStartDateTime[32]; // 样品采集时间校正yyyy-MM-dd HH:mm:ss char bSCStopDateTime[32]; }AnalysisDecayConfig; enum eUncertainReportUnitType { eUPUTPercent, eUPUTActivity }; enum eUncertainReportValueType { eUPVTCouting, eUPTVTotal }; enum eUncertainLevel { eULOne, eULTwo, eULThree, }; enum eOutputType { eOTPrinter, eFile, eProgram, }; typedef struct AnalysisReportConfig { // 报告峰信息 int dReportOption; // 不确定度报告单位 eUncertainReportUnitType URUTType; // 不确定度报告值类型 eUncertainReportUnitType URVTType; // 不确定度水平 eUncertainLevel UncertainLevel; // 输出类型 eOutputType OTType; // 显示解谱结果 BOOL bDisplayAnalysisResult; // 输出文件配置 char FileProgramInfo[260]; // 输出程序配置 char ProgramInfo[260]; // 报告器配置 char ReporterInfo[260]; }AnalysisReportConfig; typedef struct AnalysisMethodConfig { // 额外误差 % double dSystematic; // 随机误差 double dRandom; }AnalysisMethodConfig; typedef struct AnalysisCorrectionConfig { // 峰本底校正 OneDefaultConfig PBC; // 几何校正 OneDefaultConfig GeometryC; // 衰减校正 OneDefaultConfig AttenuationC; }AnalysisCorrectionConfig; typedef struct AnalysisDataDealConfig { int bUseGaussSmoothNum; int bUseGaussSmoothTimes; // 峰形测试 double dSfwhmRadioFwhmMaxValue; double dSheightRadioHeightValue; // 解谱 double dnofwhmofpeak; double dnofwhmofSideBaseLine; unsigned char reserve[128]; }AnalysisDataDealConfig; typedef struct AnalysisSpecturmConfig { AnalysisSampleConfig ascSample; AnalysisSystemConfig ascSystem; AnalysisDecayConfig ascDecay; AnalysisReportConfig ascReport; AnalysisMethodConfig ascMethod; AnalysisCorrectionConfig ascCorrection; AnalysisDataDealConfig ascDataDeal; unsigned char reserve[128]; }AnalysisSpecturmConfig; class _sOneNuclideActivity { public: sOneNuclideInfo info; OneValue activity; OneValue totalActivityUncertain; OneValue mda; }; typedef struct AnalyzeSpecturmConfigInfo { int head; int version; char CreateTime[32]; char LastModifyTime[32]; char Desc[128]; unsigned char reserve[256]; }AnalyzeSpecturmConfigInfo; #pragma pack(pop) #ifdef __cplusplus extern "C" { #endif ANALYZESPECTURM_API(int) NuclideIndentifaction(int*pInst, sDataInfo* pSpecturmData, sConfigInfo *pConfig, sResultInfo *pResultInfo, char *ErrorInfo); ANALYZESPECTURM_API(int) NuclideIndentifactionV2(int*pInst, ASDataInfo* pASDI, sConfigInfo *pConfig, sResultInfo *pResultInfo, char *ErrorInfo); ANALYZESPECTURM_API(int) NuclideIndentifactionV3(int*pInst, ASDataInfo* pASDI, sResultInfo *pResultInfo, char *ErrorInfo); ANALYZESPECTURM_API(int) FitLinear(int*pInst, sFitData* pSpecturmData, sLinearFitResult *pResultInfo, char *ErrorInfo); ANALYZESPECTURM_API(int*) GetInst(char *ErrorInfo); ANALYZESPECTURM_API(int) FreeInst(int*pInst); ANALYZESPECTURM_API(int) GetAnalyzeSpecturmConfig(AnalyzeSpecturmConfigInfo *pInfo, AnalysisSpecturmConfig *pconfig, char *ErrMsg); ANALYZESPECTURM_API(int) SetAnalyzeSpecturmConfig(AnalyzeSpecturmConfigInfo *pInfo, AnalysisSpecturmConfig *pconfig, char *ErrMsg); ANALYZESPECTURM_API(int) SaveAnalyzeSpecturmConfig(const char *path, char *ErrMsg); ANALYZESPECTURM_API(int) ReadAnalyzeSpecturmConfig(const char *path, char *ErrMsg); ANALYZESPECTURM_API(int) GetCusorNuclideInfo(int*pInst, ASDataInfo* pASDI, sResultInfo *pResultInfo, char *ErrorInfo); #ifdef __cplusplus } #endif #endif // _ANALYZESPECTURMEXPORT_H_