00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#ifndef __DETECUSE_H
00013
#define __DETECUSE_H
00014
00015
#if defined ( Build_Counters )
00016
#define _COUNTERCLASS __declspec(dllexport)
00017
#elif defined( Use_Counters )
00018
#define _COUNTERCLASS __declspec(dllimport)
00019
#else
00020 #define _COUNTERCLASS
00021
#endif
00022
00023
#include "utils\u_utils.h"
00024
#include "detecuse\range.h"
00025
#include "motrstrg\motrstrg.h"
00026
#include "difrkmty\d_extern.h"
00027
00028
00029
00030 enum EDetectorType
00031 {
00032
CounterDetector= 1,
PsdDetector,
GenericDetector,
CCDDetector
00033 };
00034
00035 enum EHowReadOutPsd
00036 {
00037
FinalRead= 1,
FirstRead,
AccumulationRead,
IntermediateRead
00038 };
00039
00040 enum EPsdDataType
00041 {
00042
PsdEnergyData= 3000,
PsdPositionData,
PsdRestoreLast= 99,
PsdUnknown= 0
00043 };
00044
00045
00046 #define R_MeasOk 206
00047
00053 class _COUNTERCLASS TExposureSettings
00054 {
00055
public:
00056 TExposureSettings(
float exposureTime= 0, DWORD exposureCounts= 0);
00057
00058 float GetExposureTime()
const
00059
{
00060
return fExposureTime;
00061 };
00062 DWORD GetExposureCounts()
const
00063
{
00064
return dwExposureCounts;
00065 };
00066
00067
void SetExposureTime(
float exposureTime);
00068
void SetExposureCounts( DWORD exposureCounts );
00069
00070
#pragma warning( push )
00071
#pragma warning( disable : 4251 )
00072 TRange<DWORD> CountBounds;
00073 TRange<float> TimeBounds;
00074
#pragma warning( pop )
00075
00076
private:
00077
float fExposureTime;
00078 DWORD dwExposureCounts;
00079 };
00080
00081
00082
00083 struct _COUNTERCLASS TDSettings
00084 {
00085 TExposureSettings exposure;
00086 int nAddedChannels;
00087 };
00088
00089
00090
class TDetector;
00091
00092
00093
00099 class _COUNTERCLASS TDetectorManager
00100 {
00101
00102
00103
00104
public:
00105
00109
virtual ~TDetectorManager();
00110
00111
00112
00113
00114
public:
00115
00117
static TDetectorManager& DetectorManager();
00118
00120
TDetector* GetDetector(
void )
const;
00121
00123
TDetector* GetDetector(
int n,
int nFilterDimension= -1 )
const;
00124
00127 BOOL SetDetector(
int n,
int nFilterDimension= -1 );
00128
00132 BOOL SetDetector(
const TDetector* );
00133
00134
00135
00136
00137
public:
00138
00140
void FillDetectorComboBox( HWND comboBox,
int nFilterDimension= -1 )
const;
00141
00144 BOOL DimAvailable(
int dimension)
const;
00145
00148
int GetIdByDescription( LPCSTR detectorname )
const;
00149
00152 BOOL IsValidId(
int n)
const;
00153
00154
00155
00156
00157
private:
00158
00160 TDetectorManager();
00161
00162
00163
00164
00165
private:
00166
00167 TDetectorManager(
const TDetectorManager&);
00168 TDetectorManager& operator=(
const TDetectorManager&);
00169
00170
00171
00172
00173
private:
00174
00178
void CreateDetector(
const char* type,
int id);
00179
00180
00181
00182
00183
private:
00184
00186
TDetector* ActiveDetector;
00187 };
00188
00189
00190
00193 class _COUNTERCLASS TDetector
00194 {
00195
00196
00197
00198
00199
public:
00200
00201 TDetector(
int id);
00202
virtual ~TDetector(
void );
00203
00204
00205
00206
00207
public:
00208
00214 int GetId(
void )
const
00215
{
00216
return nId;
00217 };
00218
00221 BOOL IsActive(
void )
const
00222
{
00223
return bActive;
00224 };
00225
00227 float GetSigma(
void )
const
00228
{
00229
return fSigma;
00230 };
00231
00233 BOOL SetExposureSettings (
const TExposureSettings& newExposureSettings);
00234
00236 TExposureSettings& GetExposureSettings()
00237 {
00238
return exposure;
00239 };
00240
00242 const char*
const GetCharacteristic()
const
00243
{
00244
return szCharacteristic;
00245 };
00246
00248 BOOL IsDataValid()
const
00249
{
00250
return bDataValid;
00251 };
00252
00254 double GetRealTime()
const
00255
{
00256
return dRealTime;
00257 };
00258
00259
00260
00261
00262
public:
00263
00266
virtual BOOL Initialize(
void );
00267
00269
virtual int MeasureStart(
void )= 0;
00270
00272
virtual int MeasureStop(
void )= 0;
00273
00276 virtual int PollDetector(
void ) {
return R_Failure; };
00277
00279
virtual int GetIntegral(
float& )= 0;
00280
00285
virtual BOOL PushSettings(
void );
00286
00288
virtual BOOL PopSettings(
void );
00289
00291 BOOL SetParameters(
void );
00292
00293
00294
00295
00296
public:
00297
00299 HWND GetDisplayWnd(
void )
const
00300
{
00301
return hDisplayWnd;
00302 };
00303
00305 HWND GetControlWnd(
void )
const
00306
{
00307
return hControlWnd;
00308 };
00309
00312 void SetDisplayWnd( HWND hwnd )
00313 {
00314 hDisplayWnd= hwnd;
00315 };
00316
00320 void SetControlWnd( HWND hwnd )
00321 {
00322 hControlWnd= hwnd;
00323 };
00324
00327
00328
00329 virtual BOOL RunSpecificParametersDlg(
void )
00330 {
00331
return FALSE;
00332 };
00333
00336 virtual BOOL HasSpecificParametersDlg(
void )
const
00337
{
00338
return FALSE;
00339 };
00340
00344
void UpdateViews(BOOL bDisplayOnly= FALSE)
const;
00345
00346
00347
00348
00349
public:
00350
00353
virtual EDetectorType GetDetectorType() const= 0;
00354
00357 virtual
int GetDimension() const= 0;
00358
00359
00360
00361
00362 protected:
00363
00365 static
double MillisecondsToSeconds( DWORD milliseconds);
00366
00368 static
float CalculateSigma(
float intensity,
float factor= 1.0);
00369
00373 DWORD GetPrivateProfileString(
00374 LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString ) const;
00375
00379 DWORD WritePrivateProfileString( LPCSTR lpKeyName, LPCSTR lpString) const;
00380
00381
00382
00383
00384
00385 protected:
00386
00388 virtual BOOL _SetParameters(
void)
00389 {
00390
return TRUE;
00391 };
00392
00396
virtual void LoadDetectorSettings();
00397
00401
virtual void SaveDetectorSettings() const;
00402
00403
00404
00405
00406 protected:
00407
00410 double dRealTime;
00411
00414 BOOL bActive;
00415
00419 HWND hWndFrame;
00420
00422 BOOL bDebug;
00423
00426 float fIntensity;
00427
00429 float fSigma;
00430
00432 BOOL bDataValid;
00433
00435 UINT uAskTime;
00436
00438 DWORD dwStartTime;
00439
00443 TDSettings Settings;
00444
00447 char szCharacteristic[ MaxString ];
00448
00450 TExposureSettings exposure;
00451
00454 TDetector* EventDetector;
00455
00456
00457
00458
00459 private:
00460
00462 TDetector(const TDetector&);
00463
00465 TDetector& operator=(const TDetector&);
00466
00467
00468
00469
00470 private:
00471
00474
int nId;
00475
00478 HWND hDisplayWnd;
00479
00483 HWND hControlWnd;
00484 };
00485
00488 class _COUNTERCLASS
TZeroDimDetector : public TDetector
00489 {
00490
00491
00492
00493
00494
public:
00495
00496
TZeroDimDetector(
int id);
00497
virtual ~
TZeroDimDetector();
00498
00499
00500
00501
00502
public:
00503
00506
void SetSound(BOOL);
00507
00510 BOOL GetSound(
void)
const
00511
{
00512
return bSound;
00513 };
00514
00515
00516
00517
00518
public:
00519
00520
int MeasureStart(
void );
00521
int MeasureStop(
void );
00522
virtual int GetIntegral(
float& );
00523
00524
00525
00526
00527
public:
00528
00531
static CALLBACK EventHandler( UINT, UINT, DWORD, DWORD, DWORD );
00532
00534
virtual BOOL InitializeEvent( HWND,
int );
00535
00537
virtual BOOL GetEventIntensity(
float& );
00538
00541
void SetEventHost(HWND);
00542
00544
void KillEvent(
void );
00545
00546
00547
00548
00549
public:
00550
00551 EDetectorType GetDetectorType()
const
00552
{
00553
return CounterDetector;
00554 };
00555
00558 int GetDimension()
const
00559
{
00560
return 0;
00561 };
00562
00563 BOOL Initialize(
void );
00564
virtual int PollDetector(
void )= 0;
00565
00566
private:
00567
void LoadDetectorSettings();
00568
void SaveDetectorSettings() const;
00569
00572 BOOL bSound;
00573 };
00574
00575
00576 class
TCurve;
00577
00580 class _COUNTERCLASS
TOneDimDetector : public TDetector
00581 {
00582
00583
00584
00585
00586
public:
00587
00588
TOneDimDetector(
int id);
00589
virtual ~
TOneDimDetector(
void );
00590
00591
00592
00593
00594
public:
00595
00597 virtual BOOL SetEnergyRange( UINT, UINT )
00598 {
00599
return TRUE;
00600 };
00601
00603 virtual void GetEnergyRange( UINT& low, UINT& high )
const
00604
{
00605 high= 1;
00606 low= 0;
00607 };
00608
00611
void SetAddedChannels(
int ach );
00612
00615 int GetAddedChannels(
void )
const
00616
{
00617
return nAddedChannels;
00618 };
00619
00621
void SetChannelRange(
int first,
int last);
00622
00624 int GetFirstChannel()
const
00625
{
00626
return nFirstChannel;
00627 };
00628
00630 int GetLastChannel()
const
00631
{
00632
return nLastChannel;
00633 };
00634
00636 BOOL GetHVControl()
const
00637
{
00638
return bHVControl;
00639 };
00640
00642 void SetHVControl(BOOL param)
00643 {
00644 bHVControl= param;
00645 };
00646
00649 BOOL GetReadLeftFirst()
const
00650
{
00651
return bReadLeftFirst;
00652 };
00653
00656 void SetReadLeftFirst(BOOL param)
00657 {
00658 bReadLeftFirst= param;
00659 };
00660
00661
00662
void SetAngleRange(
float );
00663
00665 void SetSignalGrowUp( BOOL gup )
00666 {
00667 bSignalGrowUp= gup;
00668 };
00669
00670 void SetAngleStep(
float stp )
00671 {
00672 fAngleStep= stp;
00673 };
00674 float GetAngleStep(
void )
const
00675
{
00676
return fAngleStep;
00677 };
00678
00680 BOOL IsSoftOverflow(
void )
const
00681
{
00682
return bSoftOverflow;
00683 };
00684
00688 BOOL IsHardOverflow(
void )
const
00689
{
00690
return bHardOverflow;
00691 };
00692
00694
float GetWidth( EUnitType ) const;
00695 float GetWidth()
const
00696
{
00697
return GetWidth(eUnit);
00698 };
00699
00701
float GetAngleRange(EUnitType) const;
00702 float GetAngleRange()
const
00703
{
00704
return GetAngleRange(eUnit);
00705 };
00706
00708 void SetDataType( EPsdDataType typeParam )
00709 {
00710 eDataType= typeParam;
00711 };
00712
00714
virtual int FillInCurve( TCurve& );
00715
00717
virtual int GetIntegral(
float& );
00718
00719
int MeasureStart(
void );
00720
int MeasureStop(
void );
00721
int PollDetector(
void );
00722 BOOL Initialize(
void );
00723 BOOL PushSettings(
void );
00724 BOOL PopSettings(
void );
00725
00726 BOOL RunSpecificParametersDlg(
void );
00727 BOOL HasSpecificParametersDlg(
void )
const
00728
{
00729
return TRUE;
00730 };
00731
00734 UINT GetMaximumChannel(
void ) const;
00735
00738 float GetMaximumIntensity(
void )
const
00739
{
00740
return (
float)( dwMaxCounts / dRealTime );
00741 };
00742
00744 virtual int PsdInit(
void )
00745 {
00746
return R_OK;
00747 };
00748
00750 virtual int GetBufferSize(
void )
const
00751
{
00752
return GetChannelNumber();
00753 };
00754
00756 virtual int GetChannelNumber(
void )
const
00757
{
00758
return nLastChannel - nFirstChannel + 1;
00759 };
00760
00761
00762 EAxisType GetAxis()
const
00763
{
00764
return m_Axis;
00765 };
00766
00767
00768
00769
00770
public:
00771
00772 EDetectorType GetDetectorType()
const
00773
{
00774
return PsdDetector;
00775 };
00776
00779 int GetDimension()
const
00780
{
00781
return 1;
00782 };
00783
00784
protected:
00785
00787
void CheckMaxChannel(UINT channel, DWORD counts);
00788
00791 EUnitType eUnit;
00792
00793
00794 HGLOBAL hCountBuf;
00795
00796
00797 int nCountBufItems;
00798
00800 DWORD dwMaxCounts;
00801
00804 DWORD dwIntegratedCounts;
00805
00807 UINT uMaximumChannel;
00808
00811 BOOL bHardOverflow;
00812
00814 BOOL bReadLeftFirst;
00815
00817 BOOL bSignalGrowUp;
00818
00819
00820 EPsdDataType eDataType;
00821
00824 BOOL bFirstReadOut;
00825
00827
00828 DWORD dwElapsedTime;
00829
00830
private:
00831
00832
void LoadDetectorSettings();
00833
void SaveDetectorSettings() const;
00834
float CalculateValueInSeconds(EUnitType eUnitTypeParam,
float fValParam) const;
00835
00836
00837
float fAngleStep;
00838
00840
int nAddedChannels;
00841
00843 virtual
int PsdStart(
void )
00844 {
00845
return R_OK;
00846 };
00847
00849
virtual int PsdStop(
void )
00850 {
00851
return R_OK;
00852 };
00853
00855
virtual int PsdReadOut( EHowReadOutPsd )= 0;
00856
00857
00858
virtual int PsdRead(
int, LPWORD )
00859 {
00860
return R_OK;
00861 };
00862
00866 BOOL bSoftOverflow;
00867
00871
float OverflowIntensity;
00872
00874
int nFirstChannel;
00875
00877
int nLastChannel;
00878
00880
int nMaxChannel;
00881
00883 BOOL bHVControl;
00884
00886
EAxisType m_Axis;
00887 };
00888
00892 class _COUNTERCLASS TDetectorGUI
00893 {
00894
public:
00896
static void RunCommonDevParamDialog(HWND);
00897
00899
static void RunPsdCalibrateDialog(
TCurve &, HWND);
00900 };
00901
00902
#ifdef __cplusplus
00903
extern "C"
00904 {
00905
#endif
00906
LPCSTR
__declspec(dllexport) WINAPI dlGetVersion(
void );
00907 HINSTANCE __declspec(dllexport) WINAPI dlGetInstance(
void );
00908 #ifdef __cplusplus
00909 }
00910
00911 #endif
00912
00913 #endif
00914