-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMMALHub.h
187 lines (156 loc) · 5.37 KB
/
MMMALHub.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
* MMMalHub.h
*
* Created on: Jul 12, 2013
* Author: Ji-Yu
*/
#ifndef MMMALHUB_H_
#define MMMALHUB_H_
#include <windows.h>
#include <iostream>
#include "MalMicroscope.h"
#include "MMDevice.h"
#include "MMDeviceConstants.h"
#include "DeviceBase.h"
namespace MMMAL {
class MMMALFocus;
class MMMALAutofocus;
class MMMALMirrorUnit;
class MMMALLightPath;
class MMMALNosepiece;
class MMMALShutter;
class MMMALLamp;
class MMMALHub : public HubBase<MMMALHub>
{
public:
static const char * const DeviceName_;
static const char * const Description_;
static const char * const Keyword_Frame_Version_;
static const char * const Keyword_Focus_Version_;
static const char * const Keyword_UCB_Version_;
static const char * const Keyword_Config_Path;
static const char * const Keyword_ZDC_Config_Path;
MMMALHub();
~MMMALHub();
// MM::Device
bool Busy() {return false; }
int Initialize();
int Shutdown();
void GetName(char *pszName) const;
// MM:hub
MM::DeviceDetectionStatus DetectDevice(void);
int DetectInstalledDevices();
void * GetMALObject() const;
void SetMirrorUnitDevice(MMMALMirrorUnit* dev);
void SetNosepieceDevice(MMMALNosepiece* dev);
void SetLightPathDevice(MMMALLightPath* dev);
void SetShutterDevice(MMMALShutter* dev);
void SetLampDevice(MMMALLamp* dev);
void SetFocusDevice(MMMALFocus* dev);
void SetAutofocusDevice(MMMALAutofocus* dev);
//Shutter functions
int UpdateShutterState();
int SetShutterState(MAL_IOTARGET channel, bool bOpen);
bool IsShutterOpen(MAL_IOTARGET channel) const;
bool IsShutterBusy(MAL_IOTARGET channel);
// mirro unit
long GetMirrorUnitNPositions() const;
int UpdateMirrorUnitState();
int GetMirrorUnitPosition() const;
int SetMirrorUnitPosition(int pos, bool updateNow = false);
bool IsMirrorUnitBusy() const;
//nosepiece
long GetNosepieceNPositions() const;
int UpdateNosepieceState();
int GetNosepiecePosition() const;
bool IsNosepieceBusy() const;
int SetNosepiecePosition(int pos, bool updateNow = false);
//lightpath
long GetLightPathNPositions() const;
int UpdateLightPathState();
int GetLightPathState() const;
bool IsLightPathBusy() const;
int SetLightPathState(int state, bool updateNow = false);
bool HasBottomPort() const;
//Lamp
ULONG GetLampVoltage() const;
int UpdateLampState();
int SetLampVoltage(ULONG voltage, bool updateNow = false);
bool IsLampBusy() const;
int GetLampVoltageRange(ULONG* min, ULONG* max);
int SwitchLampOnOff();
//focus
bool HasZDC() const;
bool HasZDC2() const;
int InitializeFocus();
LONGLONG GetFocusPosition();
int UpdateFocusPosition();
int SetFocusPosition(LONGLONG pos, bool updateNow = false);
bool IsFocusBusy() const;
int GetFocusLimits(LONGLONG* nearLimit, LONGLONG *farLimit);
int SetFocusLimits(LONGLONG nearLimit, LONGLONG farLimit);
int GetFocusStepSize(long* stepSize);
int SetFocusStepSize(long stepSize);
bool IsAFBusy() const;
MAL_MS_AFSTATUS GetAFStatus() const;
int SetAFStatus(MAL_MS_AFSTATUS status);
int GetAFOffset(long *offset) const;
int UpdateAFStatus();
int SetAFOffset(long offset);
int GetAFSearchRange(LONGLONG* range)const;
int SetAFSearchRange(LONGLONG range);
int SwitchAF();
protected:
bool fineJogStep_;
int CreateMALObject();
int InitMALObject();
int ExitMALObject();
int ReleaseMALObject();
int DetectDeviceStatus();
int RegisterButtonNotices(MAL_STATUS status);
int EscapeNosepiece();
static MALRESULT MALAPI PreMALCallback(MAL_MS_MESSAGE msg, long wParam, long lParam, void* pv, void* pCaller, void* pOwner);
MALRESULT MALCallback(MAL_MS_MESSAGE msg, long wParam, long lParam, void* pv, void* pCaller);
int TranslateMalError(MALRESULT malResult) const;
private:
void LogError(std::string src, long errorcode, void* pv) const;
int GetConfigFilePath(char* path, size_t len = MM::MaxStrLength);
void * pMAL_;
bool initialized_;
long configuration_[12];
//subdevices
MMMALAutofocus* autofocusDev_;
MMMALFocus* focusDev_;
MMMALLightPath* lightPathDev_;
MMMALMirrorUnit* mirrorUnitDev_;
MMMALNosepiece* nosepieceDev_;
MMMALShutter* epiShutterDev_;
MMMALShutter* diaShutterDev_;
MMMALLamp* lampDev_;
//shutter
MAL_STATUS epiShutterState_;
MAL_STATUS diaShutterState_;
// bool epiShutterBusy_;
// bool diaShutterBusy_;
//Lamp
ULONG lampVoltage_;
bool lampBusy_;
//MU
int cubePosition_;
bool cubeBusy_;
//nosepiece
int nosepiecePosition_;
bool nosepieceBusy_;
//lightpath
int lightPathState_;
bool prismBusy_;
bool bottomPortBusy_;
//focus
LONGLONG focusPos_;
bool focusBusy_;
MAL_MS_AFSTATUS afStatus_;
bool afBusy_;
long afOffset_;
};
}
#endif /* MMMALHUB_H_ */