forked from GiovanniSena/LiSM_Hardware_Control
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAIN.m
87 lines (75 loc) · 3.28 KB
/
MAIN.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
function MAIN( )
%% MAIN Main code for the LaserDAQ
% This is the main file to run the Laser Sheet Fluorescence Microscopy
% (LSFM) user interface.
% Please ensure that all the necessary hardware is connected and switched
% on and that their ports are correctly configured in the file ".\CFG\myConfig.ini"
% Refer to the LSFM user manual for further details.
% Initial code by Paolo Baesso
% Further modifications by members of the "Lab of plant morphogenesys"
% Imperial College London
diary('D:\myMATLAB\LaserDAQ\Logs\log.txt');
disp('========================================');
disp(date);
% Start diary
% Check that myConfig.ini file exists. If so, start GUI.
fileName = 'D:\myMATLAB\LaserDAQ\CFG\myConfig.ini';
if(exist(fileName)==2)
% Create the GUI
mainFig= mainGUI(fileName);
set(mainFig, 'Visible','on');
% Temporaly disable all buttons until the hardware is ready
InterfaceObj=findobj(mainFig,'Enable','on'); %Search for all active buttons ...
InterfaceObj2= findobj(mainFig, 'Enable', 'Inactive'); % ... and for the Inactive ones
set(InterfaceObj,'Enable','off'); %... set them to be disabled
set(InterfaceObj2, 'Enable', 'off'); %...while we do the initial stuff
% Retrieve configuration parameters
confPar=getappdata(mainFig, 'confPar');
% Initialize LABJACK
[ledobj, ledhandl]=LED_initialize;
setappdata(mainFig, 'ledobj', ledobj);
setappdata(mainFig, 'ledhandl', ledhandl);
% Initialize CAMERA
[vidobj, videosrc]= camera_initialize('qimaging');
setappdata(mainFig, 'vidobj', vidobj);
setappdata(mainFig, 'videosrc', videosrc);
% Initialize FILTER WHEEL
fwPort= confPar.filterwh.port;
FWSerial = FW_initialize(fwPort);
setappdata(mainFig, 'FWSerial', FWSerial);
% Initialize WEBCAM
% A USB camera can be used to monitor the setup remotely.
% If the camera is used, uncomment the following two lines.
%webcam = web_initialize();
%setappdata(mainFig, 'webcam', webcam);
% Initialize PUMP
pumpPort= confPar.pump.port;
myPump = pump_initialize(pumpPort);
setappdata(mainFig, 'myPump' , myPump);
% Initialize TEMPERATURE HARDWARE and create TIMERS
tempPort= confPar.temperature.port;
myTemp = tempHW_initialize(tempPort);
setappdata(mainFig, 'myTemp' , myTemp);
timer_createGUITemp(mainFig);
timer_createPeltierThermostat(mainFig);
temperatureGUITimer=getappdata(mainFig, 'temperatureGUITimer');
start(temperatureGUITimer);
% Initialize MOTORS
try
HW_SN(mainFig);
HW_initialize(mainFig);
%HW_home( mainFig );
catch
msg = ['Error while opening motors'];
errordlg(msg);
end
% Enable the user interface
set(InterfaceObj,'Enable','on');
set(InterfaceObj2, 'Enable', 'Inactive');
else
errorstring = 'I could not locate file "myConfig.ini". Execution will now stop';
h = errordlg(errorstring);
end
% Close diary
diary off;
end