This repository has been archived by the owner on Oct 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AndorControl.m
186 lines (157 loc) · 6.12 KB
/
AndorControl.m
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
classdef AndorControl < handle
%AndorControl control the Andor Camera
properties (Access = private)
handle; % handle to camera
end
properties (Transient)
AOI;
end
properties (Dependent)
SensorCooling;
SensorTemperatureStatus;
SensorTemperature;
ExposureTime;
TriggerMode;
CycleMode;
SimplePreAmpGainControl;
PixelEncoding;
FrameCount;
ImageSizeBytes;
end
methods
%% Constructor
function obj = AndorControl()
[rc] = AT_InitialiseLibrary();
AT_CheckError(rc);
[rc,obj.handle] = AT_Open(0);
AT_CheckError(rc);
obj.AOI = AOI.init(obj.handle);
end
%% Destructor
function delete (obj)
[rc] = AT_Flush(obj.handle);
AT_CheckWarning(rc);
[rc] = AT_Close(obj.handle);
AT_CheckWarning(rc);
[rc] = AT_FinaliseLibrary();
AT_CheckWarning(rc);
end
%% Enable and disable sensor cooling, get status
function set.SensorCooling (obj,Cooling)
[rc] = AT_SetBool(obj.handle,'SensorCooling',Cooling);
AT_CheckWarning(rc);
end
function Cooling = get.SensorCooling(obj)
[rc,Cooling] = AT_GetBool(obj.handle,'SensorCooling');
AT_CheckWarning(rc);
end
function status = get.SensorTemperatureStatus(obj)
status = obj.GetEnumString('TemperatureStatus');
end
function temp = get.SensorTemperature(obj)
[rc,temp] = AT_GetFloat(obj.handle,'SensorTemperature');
AT_CheckWarning(rc);
end
%% Set and get acquisition parameters
function string = GetEnumString (obj, featurename)
[rc,index] = AT_GetEnumIndex(obj.handle,featurename);
AT_CheckWarning(rc);
[rc,string]=AT_GetEnumStringByIndex(obj.handle,featurename,index,100);
AT_CheckWarning(rc);
end
%function sets the exposure time
function set.ExposureTime (obj,ExTime)
[rc] = AT_SetFloat(obj.handle,'ExposureTime',ExTime);
AT_CheckWarning(rc);
end
%function gets the exposure time
function ExTime = get.ExposureTime (obj)
[rc,ExTime] = AT_GetFloat(obj.handle,'ExposureTime');
AT_CheckWarning(rc);
end
%function sets the cycle mode
function set.CycleMode (obj,CycleMode)
[rc] = AT_SetEnumString(obj.handle,'CycleMode',CycleMode);
AT_CheckWarning(rc);
end
%function gets the cycle mode
function CycleMode = get.CycleMode (obj)
CycleMode = obj.GetEnumString('CycleMode');
end
%function sets the trigger mode
function set.TriggerMode (obj,TriggerMode)
[rc] = AT_SetEnumString(obj.handle,'TriggerMode',TriggerMode);
AT_CheckWarning(rc);
end
%function gets the trigger mode
function TriggerMode = get.TriggerMode (obj)
TriggerMode = obj.GetEnumString('TriggerMode');
end
%function sets the simple PreAmp gain control
function set.SimplePreAmpGainControl (obj,SimplePreAmpGainControl)
[rc] = AT_SetEnumString(obj.handle,'SimplePreAmpGainControl',SimplePreAmpGainControl);
AT_CheckWarning(rc);
end
%function gets the simple PreAmp gain control
function SimplePreAmpGainControl = get.SimplePreAmpGainControl (obj)
SimplePreAmpGainControl = obj.GetEnumString('SimplePreAmpGainControl');
end
%function sets the pixel encoding
function set.PixelEncoding (obj,PixelEncoding)
[rc] = AT_SetEnumString(obj.handle,'PixelEncoding',PixelEncoding);
AT_CheckWarning(rc);
end
%function gets the pixel encoding
function PixelEncoding = get.PixelEncoding (obj)
PixelEncoding = obj.GetEnumString('PixelEncoding');
end
%function sets the frame count
function set.FrameCount (obj,FrameCount)
[rc] = AT_SetInt(obj.handle,'FrameCount',FrameCount);
AT_CheckWarning(rc);
end
%function gets the frame count
function ExTime = get.FrameCount (obj)
[rc,ExTime] = AT_GetInt(obj.handle,'FrameCount');
AT_CheckWarning(rc);
end
%function gets the ImageSiyeBytes
function ImageSizeBytes = get.ImageSizeBytes(obj)
[rc,ImageSizeBytes] = AT_GetInt(obj.handle,'ImageSizeBytes');
AT_CheckWarning(rc);
end
%% Control acquisition
%function starts the acquisition
function startAcquisition(obj)
[rc] = AT_Command(obj.handle,'AcquisitionStart');
AT_CheckWarning(rc);
end
%function stops the acquisition
function stopAcquisition(obj)
[rc] = AT_Command(obj.handle,'AcquisitionStop');
AT_CheckWarning(rc);
end
%function triggers image acquisition
function trigger(obj)
[rc] = AT_Command(obj.handle,'SoftwareTrigger');
AT_CheckWarning(rc);
end
%% Handle image buffer
%function return the image buffer
function buf = getBuffer(obj)
[rc] = AT_QueueBuffer(obj.handle,obj.ImageSizeBytes);
AT_CheckWarning(rc);
if strcmp(obj.TriggerMode, 'Software')
obj.trigger();
end
% Set timeout dynamically (in milliseconds)
[rc, buf] = AT_WaitBuffer(obj.handle,obj.ExposureTime*1e3 + 1000);
AT_CheckWarning(rc);
end
%function converts image buffer to matrix
function image = ConvertBuffer(obj, buf)
[rc,image] = AT_ConvertMono16ToMatrix(buf,obj.AOI.height,obj.AOI.width,obj.AOI.stride);
AT_CheckWarning(rc);
end
end
end