PageRenderTime 63ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/matlab/FlyDetectionMM.m~

http://github.com/Yniold/liftsrc
Unknown | 2099 lines | 1798 code | 301 blank | 0 comment | 0 complexity | ad792bf17e1118268931834da944cd7c MD5 | raw file
  1. function varargout = FlyDetection(varargin)
  2. % DETECTION M-file for FlyDetection.fig
  3. % DETECTION, by itself, creates a new DETECTION or raises the existing
  4. % singleton*.
  5. %
  6. % H = DETECTION returns the handle to a new DETECTION or the handle to
  7. % the existing singleton*.
  8. %
  9. % DETECTION('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in DETECTION.M with the given input arguments.
  11. %
  12. % DETECTION('Property','Value',...) creates a new DETECTION or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before FlyDetection_OpeningFunction gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to FlyDetection_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Copyright 2002-2003 The MathWorks, Inc.
  23. % Edit the above text to modify the response to help FlyDetection
  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name', mfilename, ...
  27. 'gui_Singleton', gui_Singleton, ...
  28. 'gui_OpeningFcn', @FlyDetection_OpeningFcn, ...
  29. 'gui_OutputFcn', @FlyDetection_OutputFcn, ...
  30. 'gui_LayoutFcn', [] , ...
  31. 'gui_Callback', []);
  32. if nargin && ischar(varargin{1})
  33. gui_State.gui_Callback = str2func(varargin{1});
  34. end
  35. if nargout
  36. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38. gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT
  41. % --- Executes just before FlyDetection is made visible.
  42. function FlyDetection_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject handle to figure
  45. % eventdata reserved - to be defined in a future version of MATLAB
  46. % handles structure with handles and user data (see GUIDATA)
  47. % varargin command line arguments to FlyDetection (see VARARGIN)
  48. % Choose default command line output for FlyDetection
  49. handles.output = hObject;
  50. % get horus handle
  51. if length(varargin)==2 & varargin{1}=='handle'
  52. handles.parenthandle=str2double(varargin{2});
  53. end
  54. % choose Text size
  55. set(double(get(handles.figure1,'Children')),'FontSize',8)
  56. %setup Timer function
  57. handles.Timer = timer('ExecutionMode','fixedDelay',...
  58. 'Period',0.7,...
  59. 'BusyMode','drop',...
  60. 'TimerFcn', {@FlyDetRefresh,handles});
  61. data.Timer=handles.Timer;
  62. data.calstatus=0; %needed for in-flight calibration
  63. data.PitotTime=0; %needed for in-flight calibration
  64. data.tglPitot=handles.tglPitot;
  65. % Update handles structure
  66. guidata(hObject, handles);
  67. setappdata(handles.output, 'Detdata', data);
  68. start(handles.Timer);
  69. function FlyDetRefresh(arg1,arg2,handles)
  70. data = getappdata(handles.output, 'Detdata');
  71. horusdata = getappdata(handles.parenthandle, 'horusdata');
  72. statusData=horusdata.statusData;
  73. AvgData=horusdata.AvgData;
  74. col=horusdata.col;
  75. fcts2val=horusdata.fcts2val;
  76. statustime=horusdata.statustime;
  77. maxLen=horusdata.maxLen;
  78. lastrow=horusdata.lastrow;
  79. indexZeit=horusdata.indexZeit;
  80. horustxtBlower=horusdata.txtBlower;
  81. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1])
  82. tcpBlower=horusdata.tcpBlower;
  83. end
  84. PlotWidth=maxLen;
  85. stopPlot=maxLen;
  86. startPlot=1;
  87. iZeit=indexZeit(startPlot:stopPlot);
  88. minTime=statustime(iZeit(1));
  89. maxTime=statustime(iZeit(size(iZeit,1)));
  90. xlim1=str2double(get(handles.editxlim1,'String'));
  91. xlim2=str2double(get(handles.editxlim2,'String'));
  92. limTime1=maxTime-xlim1./86400.0;
  93. limTime2=maxTime-xlim2./86400.0;
  94. if limTime2==limTime1
  95. limTime2=limTime1+1/86400.0;
  96. end
  97. % display system time
  98. disptime=statustime(lastrow)-double(statusData(lastrow,6))/86400000.0;
  99. set(handles.txtTimer,'String',strcat(datestr(disptime,13),'.',num2str(statusData(lastrow,6)/100)));
  100. if statusData(lastrow,col.ValidSlaveDataFlag) % only if Arm is on
  101. % start pitot zero after lamp was switched on or off
  102. if data.calstatus==1 & bitget(statusData(lastrow,col.Valve1armAxis),12)==0 % lamp just switched and pitot zero is not already on
  103. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),12); %switch on pitot zero
  104. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch
  105. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  106. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to hold solenoids
  107. data.PitotTime=statustime;
  108. data.calstatus=0;
  109. end
  110. % stop pitot zero after 10 s
  111. if data.PitotTime~=0 %zeroing process active ?
  112. if (statustime-data.PitotTime)*86400>10 % for more than 10 s already ?
  113. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),12,0); %switch off pitot zero
  114. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch
  115. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  116. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to hold solenoids
  117. data.PitotTime=0;
  118. end
  119. end
  120. end
  121. % calculate parameters from ADC counts
  122. x=double(statusData(:,col.DiodeUV)); eval(['DiodeUV=',fcts2val.DiodeUV,';']);
  123. x=double(statusData(:,col.TDet));
  124. if x>10000
  125. eval(['TDet=',fcts2val.TDet,';']);
  126. else
  127. TDet=statustime; TDet(:)=NaN;
  128. end
  129. %TDet=double(statusData(:,col.TDet));
  130. x=double(statusData(:,col.P20)); eval(['P20=',fcts2val.P20,';']);
  131. %x=double(statusData(:,col.P1000)); eval(['P1000=',fcts2val.P1000,';']);
  132. x=double(statusData(:,col.DiodeWZ1out)); eval(['DiodeWZ1out=',fcts2val.DiodeWZ1out,';']);
  133. x=double(statusData(:,col.DiodeWZ2out)); eval(['DiodeWZ2out=',fcts2val.DiodeWZ2out,';']);
  134. x=double(statusData(:,col.DiodeWZ1in)); eval(['DiodeWZ1in=',fcts2val.DiodeWZ1in,';']);
  135. x=double(statusData(:,col.DiodeWZ2in)); eval(['DiodeWZ2in=',fcts2val.DiodeWZ2in,';']);
  136. x=double(statusData(:,col.PNO)); eval(['PNO=',fcts2val.PNO,';']);
  137. x=double(statusData(:,col.MFCFlow)); eval(['MFCFlow=',fcts2val.MFCFlow,';']);
  138. if ~isnan(col.TempDetFunnel)
  139. x=double(statusData(:,col.TempDetFunnel)); eval(['TempDetFunnel=',fcts2val.TempDetFunnel,';']);
  140. else
  141. TempDetFunnel=statustime; TempDetFunnel(:)=NaN;
  142. end
  143. if ~isnan(col.TempPenray)
  144. x=double(statusData(:,col.TempPenray)); eval(['TempPenray=',fcts2val.TempPenray,';']);
  145. else
  146. TempPenray=statustime; TempPenray(:)=NaN;
  147. end
  148. x=double(statusData(:,col.PitotAbs)); eval(['PitotAbs=',fcts2val.PitotAbs,';']);
  149. x=double(statusData(:,col.PitotDiff)); eval(['PitotDiff=',fcts2val.PitotDiff,';']);
  150. x=double(statusData(:,col.MFCC3F6Flow)); eval(['MFCC3F6Flow=',fcts2val.MFCC3F6Flow,';']);
  151. x=double(statusData(:,col.MFCPropFlow)); eval(['MFCPropFlow=',fcts2val.MFCPropFlow,';']);
  152. x=double(statusData(:,col.MFCShowerFlow)); eval(['MFCShowerFlow=',fcts2val.MFCShowerFlow,';']);
  153. set(handles.txtDiodeUV,'String',[num2str(DiodeUV(lastrow),3),' mW']);
  154. set(handles.txtWZ1in,'String',[num2str(DiodeWZ1in(lastrow),3),' mW']);
  155. set(handles.txtWZ1out,'String',[num2str(DiodeWZ1out(lastrow),3),' mW']);
  156. set(handles.txtWZ2in,'String',[num2str(DiodeWZ2in(lastrow),3),' mW']);
  157. set(handles.txtWZ2out,'String',[num2str(DiodeWZ2out(lastrow),3),' mW']);
  158. set(handles.txtP1000,'String',statusData(lastrow,col.P1000));
  159. set(handles.txtP20,'String',[num2str(P20(lastrow),3),' mbar']);
  160. set(handles.txtPNO,'String',[num2str(PNO(lastrow),4),' mbar']);
  161. set(handles.txtVHV,'String',statusData(lastrow,col.VHV));
  162. set(handles.txtTDet,'String',[num2str(TDet(lastrow),3),' C']);
  163. set(handles.txtTDetFunnel,'String',[num2str(TempDetFunnel(lastrow),3),' C']);
  164. set(handles.txtTLamp,'String',[num2str(TempPenray(lastrow),3),' C']);
  165. set(handles.txtMFCC3F6,'String',[num2str(MFCC3F6Flow(lastrow),3),' bar']);
  166. set(handles.txtPabs,'String',[num2str(PitotAbs(lastrow),4),' mbar']);
  167. set(handles.txtPdiff,'String',[num2str(PitotDiff(lastrow),3),' mbar']);
  168. set(handles.txtMFCProp,'String',[num2str(MFCPropFlow(lastrow),3),' sccm']);
  169. set(handles.txtMFCShower,'String',[num2str(MFCShowerFlow(lastrow),4),' sccm']);
  170. set(handles.txtMFCNO,'String',[num2str(MFCFlow(lastrow),3),' sccm']);
  171. % warn for ADC signals out of allowed range for measurements
  172. if P20(lastrow)<1 | P20(lastrow)>10
  173. set(handles.txtP20,'BackgroundColor','r');
  174. else
  175. set(handles.txtP20,'BackgroundColor',[0.7 0.7 0.7]);
  176. end
  177. if DiodeWZ1in(lastrow)<2
  178. set(handles.txtWZ1in,'BackgroundColor','r');
  179. else
  180. set(handles.txtWZ1in,'BackgroundColor',[0.7 0.7 0.7]);
  181. end
  182. if DiodeWZ1out(lastrow)<0.6*DiodeWZ1in
  183. set(handles.txtWZ1out,'BackgroundColor','y');
  184. else
  185. set(handles.txtWZ1out,'BackgroundColor',[0.7 0.7 0.7]);
  186. end
  187. if DiodeWZ2in(lastrow)<0.4
  188. set(handles.txtWZ2in,'BackgroundColor','r');
  189. else
  190. set(handles.txtWZ2in,'BackgroundColor',[0.7 0.7 0.7]);
  191. end
  192. if DiodeWZ2out(lastrow)<0.6*DiodeWZ2in
  193. set(handles.txtWZ2out,'BackgroundColor','y');
  194. else
  195. set(handles.txtWZ2out,'BackgroundColor',[0.7 0.7 0.7]);
  196. end
  197. if MFCFlow(lastrow)<4 | MFCFlow(lastrow)>9
  198. set(handles.txtMFCNO,'BackgroundColor','r');
  199. else
  200. set(handles.txtMFCNO,'BackgroundColor',[0.7 0.7 0.7]);
  201. end
  202. if statusData(lastrow,col.VHV)<12400
  203. set(handles.txtVHV,'BackgroundColor','y');
  204. else
  205. set(handles.txtVHV,'BackgroundColor',[0.7 0.7 0.7]);
  206. end
  207. %if PCuvette(lastrow)>2
  208. % if (bitget(statusData(lastrow,col.Valve1armAxis),13)==1 | bitget(statusData(lastrow,col.Valve1armAxis),13)==1)
  209. % Valveword=bitset(statusData(lastrow,col.Valve1armAxis),13,0);
  210. % Valveword=bitset(Valveword,14,0);
  211. % system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  212. % system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  213. % system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  214. % end
  215. %end
  216. %if statusData(lastrow,col.PhototubeLamp1)>10010;
  217. % set(handles.txtMFCProp,'BackgroundColor','r');
  218. %else
  219. % set(handles.txtMFCProp,'BackgroundColor',[0.7 0.7 0.7]);
  220. %end
  221. %if statusData(lastrow,col.PhototubeLamp2)>10010;
  222. % set(handles.txtMFCShower,'BackgroundColor','r');
  223. %else
  224. % set(handles.txtMFCShower,'BackgroundColor',[0.7 0.7 0.7]);
  225. %end
  226. % plot checked parameters vs. time
  227. hold(handles.axes1,'off');
  228. if get(handles.chkDiodeUV,'Value')
  229. plot(handles.axes1,statustime(iZeit),DiodeUV(iZeit),'b');
  230. hold(handles.axes1,'on');
  231. end
  232. if get(handles.chkWZ1in,'Value')
  233. plot(handles.axes1,statustime(iZeit),DiodeWZ1in(iZeit),'b');
  234. hold(handles.axes1,'on');
  235. end
  236. if get(handles.chkWZ1out,'Value')
  237. plot(handles.axes1,statustime(iZeit),DiodeWZ1out(iZeit),'b');
  238. hold(handles.axes1,'on');
  239. end
  240. if get(handles.chkWZ2in,'Value')
  241. plot(handles.axes1,statustime(iZeit),DiodeWZ2in(iZeit),'g');
  242. hold(handles.axes1,'on');
  243. end
  244. if get(handles.chkWZ2out,'Value')
  245. plot(handles.axes1,statustime(iZeit),DiodeWZ2out(iZeit),'g');
  246. hold(handles.axes1,'on');
  247. end
  248. if get(handles.chkP1000,'Value')
  249. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.P1000),'r');
  250. hold(handles.axes1,'on');
  251. end
  252. if get(handles.chkP20,'Value')
  253. plot(handles.axes1,statustime(iZeit),P20(iZeit),'r');
  254. hold(handles.axes1,'on');
  255. end
  256. if get(handles.chkPNO,'Value')
  257. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.PNO),'g');
  258. hold(handles.axes1,'on');
  259. end
  260. if get(handles.chkVHV,'Value')
  261. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.VHV),'r');
  262. hold(handles.axes1,'on');
  263. end
  264. if get(handles.chkTDet,'Value')
  265. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.TDet),'r');
  266. hold(handles.axes1,'on');
  267. end
  268. if get(handles.chkMFCNO,'Value')
  269. plot(handles.axes1,statustime(iZeit),MFCFlow(iZeit),'r');
  270. hold(handles.axes1,'on');
  271. end
  272. if get(handles.chkPabs,'Value')
  273. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.PitotAbs),'r');
  274. hold(handles.axes1,'on');
  275. end
  276. if get(handles.chkPdiff,'Value')
  277. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.PitotDiff),'r');
  278. hold(handles.axes1,'on');
  279. end
  280. if get(handles.chkTDetFunnel,'Value')
  281. if ~isnan(col.TempDetFunnel)
  282. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.TempDetFunnel),'r');
  283. hold(handles.axes1,'on');
  284. end
  285. end
  286. if get(handles.chkTLamp,'Value')
  287. if ~isnan(col.TempPenray)
  288. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.TempPenray),'r');
  289. hold(handles.axes1,'on');
  290. end
  291. end
  292. if get(handles.chkMFCC3F6,'Value')
  293. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.MFCC3F6Flow),'r');
  294. hold(handles.axes1,'on');
  295. end
  296. if get(handles.chkMFCProp,'Value')
  297. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.PhototubeLamp1),'r');
  298. hold(handles.axes1,'on');
  299. end
  300. if get(handles.chkMFCShower,'Value')
  301. plot(handles.axes1,statustime(iZeit),statusData(iZeit,col.PhototubeLamp2),'r');
  302. hold(handles.axes1,'on');
  303. end
  304. xlim(handles.axes1,[limTime1 limTime2]);
  305. grid(handles.axes1);
  306. %plot PMT and MCP signals
  307. PMTBase=col.ccData0;
  308. MCP1Base=col.ccData1;
  309. MCP2Base=col.ccData2;
  310. PMTMaskBase=col.ccMask0;
  311. MCP1MaskBase=col.ccMask1;
  312. MCP2MaskBase=col.ccMask2;
  313. % PMT: Has the counter mask changed ? Then read in new mask.
  314. if ~isfield(data,'PMTMask')| ...
  315. ~isequal(statusData(lastrow,PMTMaskBase:PMTMaskBase+9),statusData(lastrow-5,PMTMaskBase:PMTMaskBase+9))
  316. data.PMTMask=ones(1,160);
  317. for a = 0:9,
  318. data.PMTMask((a*16+1):(a*16+16))=bitget(statusData(lastrow,PMTMaskBase+a),1:16);
  319. end
  320. end
  321. PMTSumCounts=statusData(:,col.ccCounts0);
  322. % MCP1: Has the counter mask changed ? Then read in new mask.
  323. if ~isfield(data,'MCP1Mask')| ...
  324. ~isequal(statusData(lastrow,MCP1MaskBase:MCP1MaskBase+9),statusData(lastrow-5,MCP1MaskBase:MCP1MaskBase+9))
  325. data.MCP1Mask=ones(1,160);
  326. for a=0:9
  327. data.MCP1Mask((a*16+1):(a*16+16))=bitget(statusData(lastrow,MCP1MaskBase+a),1:16);
  328. end
  329. end
  330. MCP1SumCounts=statusData(:,col.ccCounts1);
  331. % MCP2: Has the counter mask changed ? Then read in new mask.
  332. if ~isfield(data,'MCP2Mask')| ...
  333. ~isequal(statusData(lastrow,MCP2MaskBase:MCP2MaskBase+9),statusData(lastrow-5,MCP2MaskBase:MCP2MaskBase+9))
  334. data.MCP2Mask=ones(1,160);
  335. for a=0:9
  336. data.MCP2Mask((a*16+1):(a*16+16))=bitget(statusData(lastrow,MCP2MaskBase+a),1:16);
  337. end
  338. end
  339. MCP2SumCounts=statusData(:,col.ccCounts2);
  340. % display counts and pulses
  341. set(handles.txtPMTCounts,'String',num2str(statusData(lastrow,col.ccCounts0),3));
  342. set(handles.txtMCP1Counts,'String',num2str(statusData(lastrow,col.ccCounts1),2));
  343. set(handles.txtMCP2Counts,'String',num2str(statusData(lastrow,col.ccCounts2),2));
  344. set(handles.txtPMTPulses,'String',num2str(statusData(lastrow,col.ccPulses0),4));
  345. set(handles.txtMCP1Pulses,'String',num2str(statusData(lastrow,col.ccPulses1),4));
  346. set(handles.txtMCP2Pulses,'String',num2str(statusData(lastrow,col.ccPulses2),4));
  347. % calculate running averages for online and both offlines
  348. PMTOnlineAvg=AvgData(:,1);
  349. PMTOfflineLeftAvg=AvgData(:,2);
  350. PMTOfflineRightAvg=AvgData(:,3);
  351. PMTOfflineAvg(1:size(statusData,1))=NaN;
  352. PMTOfflineAvg=PMTOfflineAvg';
  353. PMTOfflineAvg(statusData(:,col.RAvgOnOffFlag)==1)=PMTOfflineRightAvg(statusData(:,col.RAvgOnOffFlag)==1);
  354. PMTOfflineAvg(statusData(:,col.RAvgOnOffFlag)==2)=PMTOfflineLeftAvg(statusData(:,col.RAvgOnOffFlag)==2);
  355. PMTAvg(statusData(:,col.RAvgOnOffFlag)==3)=PMTOnlineAvg(statusData(:,col.RAvgOnOffFlag)==3);
  356. PMTAvg(statusData(:,col.RAvgOnOffFlag)==2)=PMTOfflineLeftAvg(statusData(:,col.RAvgOnOffFlag)==2);
  357. PMTAvg(statusData(:,col.RAvgOnOffFlag)==1)=PMTOfflineRightAvg(statusData(:,col.RAvgOnOffFlag)==1);
  358. PMTAvg(statusData(:,col.RAvgOnOffFlag)==0)=NaN;
  359. MCP1OnlineAvg=AvgData(:,4);
  360. MCP1OfflineLeftAvg=AvgData(:,5);
  361. MCP1OfflineRightAvg=AvgData(:,6);
  362. MCP1OfflineAvg(1:size(statusData,1))=NaN;
  363. MCP1OfflineAvg=MCP1OfflineAvg';
  364. MCP1OfflineAvg(statusData(:,col.RAvgOnOffFlag)==1)=MCP1OfflineRightAvg(statusData(:,col.RAvgOnOffFlag)==1);
  365. MCP1OfflineAvg(statusData(:,col.RAvgOnOffFlag)==2)=MCP1OfflineLeftAvg(statusData(:,col.RAvgOnOffFlag)==2);
  366. MCP1Avg(statusData(:,col.RAvgOnOffFlag)==3)=MCP1OnlineAvg(statusData(:,col.RAvgOnOffFlag)==3);
  367. MCP1Avg(statusData(:,col.RAvgOnOffFlag)==2)=MCP1OfflineLeftAvg(statusData(:,col.RAvgOnOffFlag)==2);
  368. MCP1Avg(statusData(:,col.RAvgOnOffFlag)==1)=MCP1OfflineRightAvg(statusData(:,col.RAvgOnOffFlag)==1);
  369. MCP1Avg(statusData(:,col.RAvgOnOffFlag)==0)=NaN;
  370. MCP2OnlineAvg=AvgData(:,7);
  371. MCP2OfflineLeftAvg=AvgData(:,8);
  372. MCP2OfflineRightAvg=AvgData(:,9);
  373. MCP2OfflineAvg(1:size(statusData,1))=NaN;
  374. MCP2OfflineAvg=MCP2OfflineAvg';
  375. MCP2OfflineAvg(statusData(:,col.RAvgOnOffFlag)==1)=MCP2OfflineRightAvg(statusData(:,col.RAvgOnOffFlag)==1);
  376. MCP2OfflineAvg(statusData(:,col.RAvgOnOffFlag)==2)=MCP2OfflineLeftAvg(statusData(:,col.RAvgOnOffFlag)==2);
  377. MCP2Avg(statusData(:,col.RAvgOnOffFlag)==3)=MCP2OnlineAvg(statusData(:,col.RAvgOnOffFlag)==3);
  378. MCP2Avg(statusData(:,col.RAvgOnOffFlag)==2)=MCP2OfflineLeftAvg(statusData(:,col.RAvgOnOffFlag)==2);
  379. MCP2Avg(statusData(:,col.RAvgOnOffFlag)==1)=MCP2OfflineRightAvg(statusData(:,col.RAvgOnOffFlag)==1);
  380. MCP2Avg(statusData(:,col.RAvgOnOffFlag)==0)=NaN;
  381. % display offline and online averages
  382. set(handles.txtPMTOffline,'String',num2str(PMTOfflineAvg(lastrow),3));
  383. set(handles.txtMCP1Offline,'String',num2str(MCP1OfflineAvg(lastrow),2));
  384. set(handles.txtMCP2Offline,'String',num2str(MCP2OfflineAvg(lastrow),2));
  385. set(handles.txtPMTOnline,'String',num2str(PMTOnlineAvg(lastrow),4));
  386. set(handles.txtMCP1Online,'String',num2str(MCP1OnlineAvg(lastrow),4));
  387. set(handles.txtMCP2Online,'String',num2str(MCP2OnlineAvg(lastrow),4));
  388. % warn if Offline Signals are zero, possible problem with MCPs
  389. if MCP1OnlineAvg(lastrow)==0
  390. set(handles.txtMCP1Online,'BackgroundColor','r');
  391. else
  392. set(handles.txtMCP1Online,'BackgroundColor',[0.7 0.7 0.7]);
  393. end
  394. if MCP2OnlineAvg(lastrow)==0
  395. set(handles.txtMCP2Online,'BackgroundColor','r');
  396. else
  397. set(handles.txtMCP2Online,'BackgroundColor',[0.7 0.7 0.7]);
  398. end
  399. % warn if PMTOnline is too low for valid online Signal
  400. if PMTOnlineAvg(lastrow)<2*PMTOfflineAvg
  401. set(handles.txtPMTOnline,'BackgroundColor','r');
  402. else
  403. set(handles.txtPMTOnline,'BackgroundColor',[0.7 0.7 0.7]);
  404. end
  405. %calculate OH and HO2 mixing ratios
  406. if statusData(lastrow,col.ValidSlaveDataFlag)
  407. radlife=1.45e6; % Radiative lifetime (Hz) from D. Heard data
  408. % THESE PARAMETERS NEED TO BE CONSIDERED WHEN RUNNING THE INSTRUMENT IN A
  409. % DIFFERENT SETUP
  410. gate1=136e-9; % Approximate gate setting for rising edge (sec)
  411. gate2=596e-9; % ...for falling edge (sec)
  412. Tcal=299; % Cell Temperature during lab calibration (K)
  413. Pcal=3.7;
  414. PowCal=10; %OHUVPower during lab calibration (mW)
  415. PowCalb=1.75; %HO2UVPower during lab calibration (mW)
  416. wmrcal=8E-3; % Calibration reference water concentration
  417. k_qcal=getq(Tcal,wmrcal);
  418. GAMMAcal= k_qcal*Pcal + radlife;
  419. densCal=(6.022E+23/22400)*273/Tcal*Pcal/1013;
  420. bc=boltzcorr(Tcal,TDet(lastrow)+273);
  421. k_q=getq(TDet(lastrow)+273,str2double(get(handles.editH2O,'String')));
  422. GAMMA = k_q*P20(lastrow) + radlife;
  423. quen = (1/GAMMA).*((exp(-gate1*GAMMA)-exp(-gate2*GAMMA)));
  424. quencal = (1/GAMMAcal).*((exp(-gate1*GAMMAcal)-exp(-gate2*GAMMAcal)));
  425. Dens=6.023E23/22400*273./(TDet(lastrow)+273)*P20(lastrow)/1013; %Converting to density
  426. COH=quen.*bc.*(str2double(get(handles.editC,'String'))/quencal/densCal)*Dens;
  427. COH=COH.*(DiodeWZ1in(lastrow)+DiodeWZ1out(lastrow))/2;
  428. CHO2b=quen.*bc.*(str2double(get(handles.editC,'String'))/quencal/densCal)*Dens;
  429. CHO2b=CHO2b.*(DiodeWZ2in(lastrow)+DiodeWZ2out(lastrow))/2;
  430. if ~isnan(COH)
  431. if rank(COH)~=0
  432. XOH = (MCP1OnlineAvg-MCP1OfflineAvg).*5./COH';
  433. end
  434. else
  435. XOH = MCP1OnlineAvg; XOH(:)=NaN;
  436. end
  437. if ~isnan(COH)
  438. if rank(CHO2b)~=0
  439. XHOx = (MCP2OnlineAvg-MCP2OfflineAvg).*5./CHO2b';
  440. end
  441. else
  442. XHOx = MCP1OnlineAvg; XHOx(:)=NaN;
  443. end
  444. else
  445. XOH = MCP1OnlineAvg; XOH(:)=NaN;
  446. XHOx = MCP1OnlineAvg; XHOx(:)=NaN;
  447. end
  448. % make plots
  449. hold(handles.axeRay,'off');
  450. hold(handles.axeFluo,'off');
  451. hold(handles.axeCounts,'off');
  452. if get(handles.chkPMT,'Value')
  453. plot(handles.axeRay,statusData(lastrow,PMTBase+1:PMTBase+160),'r');
  454. hold(handles.axeRay,'on');
  455. z=find(data.PMTMask==0);
  456. PMTdata1=double(statusData(lastrow,PMTBase+1:PMTBase+160));
  457. PMTdata1(z)=NaN;
  458. plot(handles.axeRay,PMTdata1);
  459. xlim(handles.axeRay,[1,160]);
  460. xaxis=[40:160];
  461. plot(handles.axeFluo,xaxis,statusData(lastrow,PMTBase+40:PMTBase+160),'r');
  462. hold(handles.axeFluo,'on');
  463. y=data.PMTMask(40:160);
  464. z=find(y==0);
  465. PMTdata2=double(statusData(lastrow,PMTBase+40:PMTBase+160));
  466. PMTdata2(z)=NaN;
  467. plot(handles.axeFluo,xaxis,PMTdata2);
  468. xlim(handles.axeFluo,[40,160]);
  469. WhichPlot=get(handles.popPMTPlot,'Value');
  470. switch WhichPlot
  471. case 1
  472. plot(handles.axeCounts,statustime(iZeit),PMTSumCounts(iZeit)); %statusData(iZeit,PMTBase+204));
  473. xlim1=str2double(get(handles.editxlim1,'String'));
  474. xlim2=str2double(get(handles.editxlim2,'String'));
  475. limTime1=maxTime-xlim1./86400.0;
  476. limTime2=maxTime-xlim2./86400.0;
  477. xlim(handles.axes1,[limTime1 limTime2]);
  478. hold(handles.axeCounts,'on');
  479. case 2
  480. plot(handles.axeCounts,statustime(30:end),PMTAvg(30:end),'b');
  481. hold(handles.axeCounts,'on');
  482. end
  483. hold(handles.axeCounts,'on');
  484. end
  485. if get(handles.chkMCP1,'Value')
  486. plot(handles.axeRay,statusData(lastrow,MCP1Base+1:MCP1Base+160),'r');
  487. hold(handles.axeRay,'on');
  488. z=find(data.MCP1Mask==0);
  489. MCP1data1=double(statusData(lastrow,MCP1Base+1:MCP1Base+160));
  490. MCP1data1(z)=NaN;
  491. plot(handles.axeRay,MCP1data1);
  492. xlim(handles.axeRay,[1,160]);
  493. xaxis=[40:160];
  494. plot(handles.axeFluo,xaxis, statusData(lastrow,MCP1Base+40:MCP1Base+160),'r');
  495. hold(handles.axeFluo,'on');
  496. y=data.MCP1Mask(40:160);
  497. z=find(y==0);
  498. MCP1data2=double(statusData(lastrow,MCP1Base+40:MCP1Base+160));
  499. MCP1data2(z)=NaN;
  500. plot(handles.axeFluo,xaxis,MCP1data2);
  501. xlim(handles.axeFluo,[40,160]);
  502. WhichPlot=get(handles.popMCP1Plot,'Value');
  503. switch WhichPlot
  504. case 1
  505. plot(handles.axeCounts,statustime(iZeit),MCP1SumCounts(iZeit)); %statusData(iZeit,MCP1Base+204));
  506. hold(handles.axeCounts,'on');
  507. case 2
  508. plot(handles.axeCounts,statustime(30:end),MCP1Avg(30:end),'b');
  509. hold(handles.axeCounts,'on');
  510. case 3
  511. plot(handles.axeCounts,statustime(30:end),XOH(30:end),'b');
  512. hold(handles.axeCounts,'on');
  513. end
  514. hold(handles.axeCounts,'on');
  515. end
  516. if get(handles.chkMCP2,'Value')
  517. plot(handles.axeRay,statusData(lastrow,MCP2Base+1:MCP2Base+160),'r');
  518. hold(handles.axeRay,'on');
  519. z=find(data.MCP2Mask==0);
  520. MCP2data1=double(statusData(lastrow,MCP2Base+1:MCP2Base+160));
  521. MCP2data1(z)=NaN;
  522. plot(handles.axeRay,MCP2data1);
  523. xlim(handles.axeRay,[1,160]);
  524. xaxis=[40:160];
  525. plot(handles.axeFluo,xaxis,statusData(lastrow,MCP2Base+40:MCP2Base+160),'r');
  526. hold(handles.axeFluo,'on');
  527. y=data.MCP2Mask(40:160);
  528. z=find(y==0);
  529. MCP2data2=double(statusData(lastrow,MCP2Base+40:MCP2Base+160));
  530. MCP2data2(z)=NaN;
  531. plot(handles.axeFluo,xaxis,MCP2data2);
  532. xlim(handles.axeFluo,[40,160]);
  533. WhichPlot=get(handles.popMCP2Plot,'Value');
  534. switch WhichPlot
  535. case 1
  536. plot(handles.axeCounts,statustime(iZeit),MCP2SumCounts(iZeit),'r'); %statusData(iZeit,MCP2Base+204));
  537. hold(handles.axeCounts,'on');
  538. case 2
  539. plot(handles.axeCounts,statustime(30:end),MCP2Avg(30:end),'r');
  540. hold(handles.axeCounts,'on');
  541. case 3
  542. plot(handles.axeCounts,statustime(30:end),XHOx(30:end),'r');
  543. hold(handles.axeCounts,'on');
  544. end
  545. hold(handles.axeCounts,'on');
  546. end
  547. xlim(handles.axeCounts,[limTime1 limTime2]);
  548. grid(handles.axeCounts);
  549. % check HV
  550. if bitget(statusData(lastrow,col.Valve2armAxis),8)==0
  551. % set(handles.togHV,'Value',0)
  552. set(handles.togHV,'BackgroundColor','c','String','HV OFF');
  553. else
  554. if bitget(statusData(lastrow,col.ccGateDelay1),16)==0 ...
  555. | bitget(statusData(lastrow,col.ccGateDelay2),16)==0
  556. set(handles.togHV,'BackgroundColor','y','String','HV ON');
  557. else
  558. % set(handles.togHV,'Value',1)
  559. set(handles.togHV,'BackgroundColor','g','String','HV ON');
  560. end
  561. end
  562. % check Pump, Bit 10 is Leybold, Bit 7 is Scroll Pump
  563. if ~isequal(get(handles.togPump,'BackgroundColor'),[1 1 0]) % if Pump is not just being switched
  564. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % Blower connected via tcp (ground configuration)
  565. % no actual check is done, to recheck push button in horus has to be used
  566. BlowerStatus=get(horustxtBlower,'String');
  567. if (strcmp(BlowerStatus,'Pump ON') | strcmp(BlowerStatus,'Blower ON'))
  568. set(handles.togPump,'BackgroundColor','g','String','Pump ON');
  569. else
  570. set(handles.togPump,'BackgroundColor','c','String','Pump OFF');
  571. end
  572. else % Blower connected directly to ARMaxis (air configuration)
  573. if (bitget(statusData(lastrow,col.Valve2armAxis),10) & bitget(statusData(lastrow,col.Valve2armAxis),7))
  574. set(handles.togPump,'BackgroundColor','g','String','Pump ON');
  575. else
  576. set(handles.togPump,'BackgroundColor','c','String','Pump OFF');
  577. end
  578. end
  579. end
  580. % check Blower
  581. if ~isequal(get(handles.togBlower,'BackgroundColor'),[1 1 0]) % if Blower is not just being switched
  582. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % Blower connected via tcp (ground configuration)
  583. % no actual check is done, to recheck push button in horus has to be used
  584. BlowerStatus=get(horustxtBlower,'String');
  585. if strcmp(BlowerStatus,'Blower ON')
  586. set(handles.togBlower,'BackgroundColor','g','String','Blower ON');
  587. else
  588. set(handles.togBlower,'BackgroundColor','c','String','Blower OFF');
  589. end
  590. else % Blower connected directly to ARMaxis (air configuration)
  591. if ((bitget(statusData(lastrow,col.Valve2armAxis),9) & ...
  592. bitget(statusData(lastrow,col.Valve2armAxis),1)))
  593. set(handles.togBlower,'BackgroundColor','g','String','Blower ON');
  594. else
  595. set(handles.togBlower,'BackgroundColor','c','String','Blower OFF');
  596. end
  597. end
  598. end
  599. % check Butterfly
  600. % Butterfly with relay
  601. if bitget(statusData(lastrow,col.Valve2armAxis),2)==1
  602. set(handles.togButterfly,'BackgroundColor','c','String','Butterfly CLOSED');
  603. else
  604. set(handles.togButterfly,'BackgroundColor','g','String','Butterfly OPEN');
  605. end
  606. % end Butterfly with relay
  607. % Butterfly with stepper motor
  608. %if statusData(lastrow,col.ButterflyPositionValid)==0
  609. % set(handles.togButterfly,'BackgroundColor','r','String','Butterfly INIT');
  610. %else
  611. % if statusData(lastrow,col.ButterflyCurrentPosition)==42
  612. % set(handles.togButterfly,'BackgroundColor','c','String','Butterfly CLOSED');
  613. % elseif statusData(lastrow,col.ButterflyCurrentPosition)==(625+42)
  614. % set(handles.togButterfly,'BackgroundColor','g','String','Butterfly OPEN');
  615. % else
  616. % set(handles.togButterfly,'BackgroundColor','r','String','MOVING');
  617. % end
  618. %end
  619. % end Butterfly with stepper motor
  620. % check Lamp
  621. if bitget(statusData(lastrow,col.Valve2armAxis),11)
  622. set(handles.tglLamp,'BackgroundColor','r','String','Lamp ON');
  623. else
  624. set(handles.tglLamp,'BackgroundColor','c','String','Lamp OFF');
  625. end
  626. % check Pitot Zeroing Valve
  627. if bitget(statusData(lastrow,col.Valve1armAxis),12)
  628. set(handles.tglPitot,'BackgroundColor','y','String','Pitot 0 ON');
  629. else
  630. set(handles.tglPitot,'BackgroundColor','c','String','Pitot 0 OFF');
  631. end
  632. % check Heaters
  633. % Heater Lamp
  634. if bitget(statusData(lastrow,col.Valve2armAxis),3)
  635. set(handles.tglHeatLamp,'BackgroundColor','g');
  636. else
  637. set(handles.tglHeatLamp,'BackgroundColor','y');
  638. end
  639. % Heater Prallplatte
  640. if bitget(statusData(lastrow,col.Valve2armAxis),4)
  641. set(handles.tglHeatPrall,'BackgroundColor','g');
  642. else
  643. set(handles.tglHeatPrall,'BackgroundColor','y');
  644. end
  645. % Heater Phototube 2
  646. if bitget(statusData(lastrow,col.Valve2armAxis),5)
  647. set(handles.tglHeatPhoto2,'BackgroundColor','g');
  648. else
  649. set(handles.tglHeatPhoto2,'BackgroundColor','y');
  650. end
  651. % check solenoids
  652. if bitget(statusData(lastrow,col.Valve1armAxis),4)==0
  653. set(handles.toggleC3F6,'BackgroundColor','c');
  654. else
  655. set(handles.toggleC3F6,'BackgroundColor','r');
  656. end
  657. if bitget(statusData(lastrow,col.Valve1armAxis),3)==0
  658. set(handles.toggleN2,'BackgroundColor','c');
  659. else
  660. set(handles.toggleN2,'BackgroundColor','r');
  661. end
  662. if bitget(statusData(lastrow,col.Valve1armAxis),2)==0
  663. set(handles.toggleHO2Inj,'BackgroundColor','c');
  664. else
  665. set(handles.toggleHO2Inj,'BackgroundColor','g');
  666. end
  667. if bitget(statusData(lastrow,col.Valve1armAxis),1)==0
  668. set(handles.toggleOHInj,'BackgroundColor','c');
  669. else
  670. set(handles.toggleOHInj,'BackgroundColor','r');
  671. end
  672. if bitget(statusData(lastrow,col.Valve1armAxis),7)==0
  673. set(handles.toggleNO1,'BackgroundColor','c');
  674. else
  675. set(handles.toggleNO1,'BackgroundColor','g');
  676. end
  677. if bitget(statusData(lastrow,col.Valve1armAxis),6)==0
  678. set(handles.toggleNO2,'BackgroundColor','c');
  679. else
  680. set(handles.toggleNO2,'BackgroundColor','g');
  681. end
  682. if bitget(statusData(lastrow,col.Valve1armAxis),5)==0
  683. set(handles.toggleNOPurge,'BackgroundColor','c');
  684. else
  685. set(handles.toggleNOPurge,'BackgroundColor','g');
  686. end
  687. if bitget(statusData(lastrow,col.Valve1armAxis),14)==0
  688. set(handles.tglN2O,'BackgroundColor','c');
  689. else
  690. set(handles.tglN2O,'BackgroundColor','g');
  691. end
  692. if bitget(statusData(lastrow,col.Valve1armAxis),13)==0
  693. set(handles.tglVac,'BackgroundColor','c');
  694. else
  695. set(handles.tglVac,'BackgroundColor','g');
  696. end
  697. %if bitget(statusData(lastrow,col.Valve2armAxis),12)==0
  698. % set(handles.tglKuv,'BackgroundColor','c');
  699. %else
  700. % set(handles.tglKuv,'BackgroundColor','g');
  701. %end
  702. if bitget(statusData(lastrow,col.Valve1armAxis),4)==0
  703. set(handles.tglVent,'BackgroundColor','c');
  704. else
  705. set(handles.tglVent,'BackgroundColor','r');
  706. end
  707. data.lastrow=lastrow;
  708. setappdata(handles.output, 'Detdata', data);
  709. % --- Outputs from this function are returned to the command line.
  710. function varargout = FlyDetection_OutputFcn(hObject, eventdata, handles)
  711. % varargout cell array for returning output args (see VARARGOUT);
  712. % hObject handle to figure
  713. % eventdata reserved - to be defined in a future version of MATLAB
  714. % handles structure with handles and user data (see GUIDATA)
  715. % Get default command line output from handles structure
  716. varargout{1} = handles.output;
  717. % --- Executes on button press in chkPMT.
  718. function chkPMT_Callback(hObject, eventdata, handles)
  719. % hObject handle to chkPMT (see GCBO)
  720. % eventdata reserved - to be defined in a future version of MATLAB
  721. % handles structure with handles and user data (see GUIDATA)
  722. % Hint: get(hObject,'Value') returns toggle state of chkPMT
  723. % --- Executes on button press in chkMCP2.
  724. function chkMCP2_Callback(hObject, eventdata, handles)
  725. % hObject handle to chkMCP2 (see GCBO)
  726. % eventdata reserved - to be defined in a future version of MATLAB
  727. % handles structure with handles and user data (see GUIDATA)
  728. % Hint: get(hObject,'Value') returns toggle state of chkMCP2
  729. % --- Executes on button press in chkMCP1.
  730. function chkMCP1_Callback(hObject, eventdata, handles)
  731. % hObject handle to chkMCP1 (see GCBO)
  732. % eventdata reserved - to be defined in a future version of MATLAB
  733. % handles structure with handles and user data (see GUIDATA)
  734. % Hint: get(hObject,'Value') returns toggle state of chkMCP1
  735. % --- Executes on button press in pshExit.
  736. function pshExit_Callback(hObject, eventdata, handles)
  737. % hObject handle to pshExit (see GCBO)
  738. % eventdata reserved - to be defined in a future version of MATLAB
  739. % handles structure with handles and user data (see GUIDATA)
  740. % Hint: get(hObject,'Value') returns toggle state of pshExit
  741. horusdata = getappdata(handles.parenthandle, 'horusdata');
  742. statusData=horusdata.statusData;
  743. data = getappdata(handles.output, 'Detdata');
  744. lastrow=data.lastrow;
  745. col=horusdata.col;
  746. %close N2 valves to detection tubes
  747. if statusData(lastrow,col.ValidSlaveDataFlag)
  748. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),13,0);
  749. Valveword=bitset(Valveword,14,0);
  750. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  751. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  752. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  753. end
  754. stop(handles.Timer);
  755. delete(handles.Timer);
  756. close(handles.figure1);
  757. % --- Executes on selection change in popPMTPlot.
  758. function popPMTPlot_Callback(hObject, eventdata, handles)
  759. % hObject handle to popPMTPlot (see GCBO)
  760. % eventdata reserved - to be defined in a future version of MATLAB
  761. % handles structure with handles and user data (see GUIDATA)
  762. % Hints: contents = get(hObject,'String') returns popPMTPlot contents as cell array
  763. % contents{get(hObject,'Value')} returns selected item from popPMTPlot
  764. % --- Executes during object creation, after setting all properties.
  765. function popPMTPlot_CreateFcn(hObject, eventdata, handles)
  766. % hObject handle to popPMTPlot (see GCBO)
  767. % eventdata reserved - to be defined in a future version of MATLAB
  768. % handles empty - handles not created until after all CreateFcns called
  769. % Hint: popupmenu controls usually have a white background on Windows.
  770. % See ISPC and COMPUTER.
  771. if ispc
  772. set(hObject,'BackgroundColor','white');
  773. else
  774. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  775. end
  776. % --- Executes on selection change in popMCP1Plot.
  777. function popMCP1Plot_Callback(hObject, eventdata, handles)
  778. % hObject handle to popMCP1Plot (see GCBO)
  779. % eventdata reserved - to be defined in a future version of MATLAB
  780. % handles structure with handles and user data (see GUIDATA)
  781. % Hints: contents = get(hObject,'String') returns popMCP1Plot contents as cell array
  782. % contents{get(hObject,'Value')} returns selected item from popMCP1Plot
  783. % --- Executes during object creation, after setting all properties.
  784. function popMCP1Plot_CreateFcn(hObject, eventdata, handles)
  785. % hObject handle to popMCP1Plot (see GCBO)
  786. % eventdata reserved - to be defined in a future version of MATLAB
  787. % handles empty - handles not created until after all CreateFcns called
  788. % Hint: popupmenu controls usually have a white background on Windows.
  789. % See ISPC and COMPUTER.
  790. if ispc
  791. set(hObject,'BackgroundColor','white');
  792. else
  793. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  794. end
  795. % --- Executes on selection change in popMCP2Plot.
  796. function popMCP2Plot_Callback(hObject, eventdata, handles)
  797. % hObject handle to popMCP2Plot (see GCBO)
  798. % eventdata reserved - to be defined in a future version of MATLAB
  799. % handles structure with handles and user data (see GUIDATA)
  800. % Hints: contents = get(hObject,'String') returns popMCP2Plot contents as cell array
  801. % contents{get(hObject,'Value')} returns selected item from popMCP2Plot
  802. % --- Executes during object creation, after setting all properties.
  803. function popMCP2Plot_CreateFcn(hObject, eventdata, handles)
  804. % hObject handle to popMCP2Plot (see GCBO)
  805. % eventdata reserved - to be defined in a future version of MATLAB
  806. % handles empty - handles not created until after all CreateFcns called
  807. % Hint: popupmenu controls usually have a white background on Windows.
  808. % See ISPC and COMPUTER.
  809. if ispc
  810. set(hObject,'BackgroundColor','white');
  811. else
  812. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  813. end
  814. % --- Executes on button press in chkWZ1out.
  815. function chkWZ1out_Callback(hObject, eventdata, handles)
  816. % hObject handle to chkWZ1out (see GCBO)
  817. % eventdata reserved - to be defined in a future version of MATLAB
  818. % handles structure with handles and user data (see GUIDATA)
  819. % Hint: get(hObject,'Value') returns toggle state of chkWZ1out
  820. % --- Executes on button press in chkWZ1in.
  821. function chkWZ1in_Callback(hObject, eventdata, handles)
  822. % hObject handle to chkWZ1in (see GCBO)
  823. % eventdata reserved - to be defined in a future version of MATLAB
  824. % handles structure with handles and user data (see GUIDATA)
  825. % Hint: get(hObject,'Value') returns toggle state of chkWZ1in
  826. % --- Executes on button press in chkPNO.
  827. function chkPNO_Callback(hObject, eventdata, handles)
  828. % hObject handle to chkPNO (see GCBO)
  829. % eventdata reserved - to be defined in a future version of MATLAB
  830. % handles structure with handles and user data (see GUIDATA)
  831. % Hint: get(hObject,'Value') returns toggle state of chkPNO
  832. % --- Executes on button press in chkP20.
  833. function chkP20_Callback(hObject, eventdata, handles)
  834. % hObject handle to chkP20 (see GCBO)
  835. % eventdata reserved - to be defined in a future version of MATLAB
  836. % handles structure with handles and user data (see GUIDATA)
  837. % Hint: get(hObject,'Value') returns toggle state of chkP20
  838. % --- Executes on button press in chkP1000.
  839. function chkP1000_Callback(hObject, eventdata, handles)
  840. % hObject handle to chkP1000 (see GCBO)
  841. % eventdata reserved - to be defined in a future version of MATLAB
  842. % handles structure with handles and user data (see GUIDATA)
  843. % Hint: get(hObject,'Value') returns toggle state of chkP1000
  844. % --- Executes on button press in togglebutton3.
  845. function togBlower_Callback(hObject, eventdata, handles)
  846. % hObject handle to togglebutton3 (see GCBO)
  847. % eventdata reserved - to be defined in a future version of MATLAB
  848. % handles structure with handles and user data (see GUIDATA)
  849. % Hint: get(hObject,'Value') returns toggle state of togglebutton3
  850. horusdata = getappdata(handles.parenthandle, 'horusdata');
  851. statusData=horusdata.statusData;
  852. data = getappdata(handles.output, 'Detdata');
  853. lastrow=data.lastrow;
  854. col=horusdata.col;
  855. horustxtBlower=horusdata.txtBlower;
  856. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % blower connected via tcpip (ground configuration)
  857. set(hObject,'BackgroundColor','y');
  858. tcpBlower=horusdata.tcpBlower;
  859. % check Blower and Pump status
  860. fprintf(tcpBlower,'status');
  861. pause(0.5);
  862. BlowerStatus=tcpBlower.UserData;
  863. tcpBlower.UserData=[];
  864. if BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='f'
  865. PumpSwitch=0;
  866. elseif BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='n'
  867. PumpSwitch=1;
  868. else PumpSwitch=-1;
  869. end
  870. if BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='f'
  871. InverterSwitch=0;
  872. elseif BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='n'
  873. InverterSwitch=1;
  874. else InverterSwitch=-1;
  875. end
  876. if BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='f'
  877. RampSwitch=0;
  878. elseif BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='n'
  879. RampSwitch=1;
  880. else RampSwitch=-1;
  881. end
  882. end
  883. if statusData(lastrow,col.ValidSlaveDataFlag) % only if armaxis is active
  884. if get(hObject,'Value') % switch on
  885. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % Blower connected via tcp (ground configuration)
  886. set(hObject,'BackgroundColor','y','String','switching Blower ON');
  887. % switch on Blower only when pump is on and cell pressure P1000
  888. % is low enough and Butterfly has been initialized
  889. % if (PumpSwitch==0 | statusData(lastrow,col.P1000)>10300 | statusData(lastrow,col.ButterflyPositionValid)==0)
  890. % set(handles.txtP1000,'BackgroundColor','r');
  891. % disp('Pressure too high or Butterfly not initialized');
  892. % set(hObject,'BackgroundColor','c','String','Blower OFF');
  893. % else
  894. set(handles.txtP1000,'BackgroundColor',[0.7 0.7 0.7]);
  895. fprintf(tcpBlower,'inverter on');
  896. pause(0.5)
  897. tcpBlower.UserData=[];
  898. fprintf(tcpBlower,'ramp on');
  899. pause(0.5)
  900. tcpBlower.UserData=[];
  901. % end
  902. else % Blower connected directly to armaxis (air configuration)
  903. if isequal(get(hObject,'BackgroundColor'),[0 1 1])
  904. set(hObject,'BackgroundColor','y','String','switching Blower ON');
  905. % switch on Blower only when pump is on and cell pressure
  906. % P1000
  907. % is low enough and Butterfly has been initialized
  908. % Butterfly with stepper motor
  909. % if ( (bitget(statusData(lastrow,col.Valve2armAxis),10)==0 | bitget(statusData(lastrow,col.Valve2armAxis),7)==0) ...
  910. % | statusData(lastrow,col.P1000)>10300 | statusData(lastrow,col.ButterflyPositionValid)==0)
  911. % end Butterfly with stepper motor
  912. % Butterfly with relay
  913. if ( (bitget(statusData(lastrow,col.Valve2armAxis),10)==0 | bitget(statusData(lastrow,col.Valve2armAxis),7)==0) ...
  914. | statusData(lastrow,col.P1000)>10300)
  915. % end Butterfly with relay
  916. set(handles.txtP1000,'BackgroundColor','r');
  917. disp('Pressure too high or Butterfly not initialized');
  918. set(hObject,'BackgroundColor','c','String','Blower OFF');
  919. else
  920. set(handles.txtP1000,'BackgroundColor',[0.7 0.7 0.7]);
  921. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),10); % make sure Leybold pump is not switched off
  922. Valveword=bitset(Valveword,7); % make sure Scroll pump is not switched off
  923. Valveword=bitset(Valveword,9); % switch on blower
  924. Valveword=bitset(Valveword,1); % ramp blower up
  925. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  926. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  927. set(hObject,'BackgroundColor','g','String','Blower ON');
  928. end
  929. end
  930. end
  931. else % switch off
  932. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % Blower connected via tcp (ground configuration)
  933. set(hObject,'BackgroundColor','y','String','switching Blower OFF');
  934. % Butterfly with stepper motor
  935. system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(42)]); % close Butterfly
  936. % end Butterfly with stepper motor
  937. % Butterfly with relay
  938. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),2,1); % close Butterfly
  939. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  940. % end Butterfly with relay
  941. set(handles.togButterfly,'BackgroundColor','r','String','MOVING');
  942. fprintf(tcpBlower,'ramp off'); % ramp blower down
  943. pause(0.5);
  944. tcpBlower.UserData=[];
  945. pause(10);
  946. fprintf(tcpBlower,'inverter off'); % switch off blower
  947. tcpBlower.UserData=[];
  948. else % Blower connected directly to armaxis (air configuration)
  949. if isequal(get(hObject,'BackgroundColor'),[0 1 0]) | isequal(get(hObject,'BackgroundColor'),[1 0 0])
  950. set(hObject,'BackgroundColor','y','String','switching Blower OFF');
  951. % Butterfly with stepper motor
  952. system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(42)]); % close Butterfly
  953. % end Butterfly with stepper motor
  954. % Butterfly with relay
  955. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),2,1); % close Butterfly
  956. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  957. % end Butterfly with relay
  958. set(handles.togButterfly,'BackgroundColor','r','String','MOVING');
  959. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),1,0); % ramp blower down
  960. % Valveword=bitset(Valveword,13); % ventilate Pump
  961. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  962. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  963. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to other valves working
  964. % set(handles.tglVent,'BackgroundColor','r');
  965. pause(5);
  966. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),1,0); % make sure ramp down switch is set
  967. % Valveword=bitset(Valveword,13); % ventilate Pump
  968. Valveword=bitset(Valveword,9,0); % switch off blower
  969. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  970. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  971. set(hObject,'BackgroundColor','c','String','Blower OFF');
  972. end
  973. end
  974. end
  975. end
  976. %for ground configuration, recheck pump status
  977. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1])
  978. fprintf(tcpBlower,'status');
  979. pause(0.5);
  980. BlowerStatus=tcpBlower.UserData;
  981. tcpBlower.UserData=[];
  982. if BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='f'
  983. PumpSwitch=0;
  984. elseif BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='n'
  985. PumpSwitch=1;
  986. else PumpSwitch=-1;
  987. end
  988. if BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='f'
  989. InverterSwitch=0;
  990. elseif BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='n'
  991. InverterSwitch=1;
  992. else InverterSwitch=-1;
  993. end
  994. if BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='f'
  995. RampSwitch=0;
  996. elseif BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='n'
  997. RampSwitch=1;
  998. else RampSwitch=-1;
  999. end
  1000. if PumpSwitch==0
  1001. set(horustxtBlower,'String','Pump OFF');
  1002. else
  1003. set(horustxtBlower,'String','Pump ON');
  1004. end
  1005. if (RampSwitch==0 | InverterSwitch==0)
  1006. set(hObject,'BackgroundColor','c','String','Blower OFF');
  1007. else
  1008. set(horustxtBlower,'String','Blower ON','BackgroundColor','g');
  1009. set(hObject,'BackgroundColor','g','String','Blower ON');
  1010. end
  1011. if (PumpSwitch==-1 | RampSwitch==-1 | InverterSwitch==-1)
  1012. set(hObject,'BackgroundColor','r','String','Blower ERR');
  1013. set(horustxtBlower,'String','Blower ERROR','BackgroundColor','r');
  1014. end
  1015. end
  1016. % --- Executes on button press in togHV.
  1017. function togHV_Callback(hObject, eventdata, handles)
  1018. % switches HV and Gain
  1019. % hObject handle to togHV (see GCBO)
  1020. % eventdata reserved - to be defined in a future version of MATLAB
  1021. % handles structure with handles and user data (see GUIDATA)
  1022. % Hint: get(hObject,'Value') returns toggle state of togHV
  1023. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1024. statusData=horusdata.statusData;
  1025. data = getappdata(handles.output, 'Detdata');
  1026. lastrow=data.lastrow;
  1027. col=horusdata.col;
  1028. if statusData(lastrow,col.ValidSlaveDataFlag)
  1029. if get(hObject,'Value')
  1030. if isequal(get(hObject,'BackgroundColor'),[0 1 1]) | isequal(get(hObject,'BackgroundColor'),[1 1 0])
  1031. set(hObject,'BackgroundColor','g','String','HV ON');
  1032. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),8); % switch HV on
  1033. % switch gain on for MCP1
  1034. word1=bitset(statusData(lastrow,col.ccGateDelay1),16);
  1035. % switch gain on for MCP2
  1036. word2=bitset(statusData(lastrow,col.ccGateDelay2),16);
  1037. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch HV
  1038. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1039. system(['/lift/bin/eCmd @armAxis w 0xa318 ',num2str(word1)]);
  1040. system(['/lift/bin/eCmd @armAxis w 0xa31c ',num2str(word2)]);
  1041. end
  1042. else
  1043. if isequal(get(hObject,'BackgroundColor'),[0 1 0]) | isequal(get(hObject,'BackgroundColor'),[1 1 0])
  1044. set(hObject,'BackgroundColor','c','String','HV OFF');
  1045. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),8,0); % switch HV off
  1046. % switch gain off for MCP1
  1047. word1=bitset(statusData(lastrow,col.ccGateDelay1),16,0);
  1048. % switch gain off for MCP2
  1049. word2=bitset(statusData(lastrow,col.ccGateDelay2),16,0);
  1050. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch HV
  1051. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1052. system(['/lift/bin/eCmd @armAxis w 0xa318 ',num2str(word1)]);
  1053. system(['/lift/bin/eCmd @armAxis w 0xa31c ',num2str(word2)]);
  1054. end
  1055. end
  1056. end
  1057. % --- Executes on button press in togglebutton5.
  1058. function tglLamp_Callback(hObject, eventdata, handles)
  1059. % hObject handle to togglebutton5 (see GCBO)
  1060. % eventdata reserved - to be defined in a future version of MATLAB
  1061. % handles structure with handles and user data (see GUIDATA)
  1062. % Hint: get(hObject,'Value') returns toggle state of togglebutton5
  1063. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1064. statusData=horusdata.statusData;
  1065. data = getappdata(handles.output, 'Detdata');
  1066. lastrow=data.lastrow;
  1067. col=horusdata.col;
  1068. if statusData(lastrow,col.ValidSlaveDataFlag)
  1069. if get(hObject,'Value')
  1070. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),11);
  1071. set(hObject,'BackgroundColor','r','String','Lamp ON');
  1072. else
  1073. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),11,0);
  1074. set(hObject,'BackgroundColor','c','String','Lamp OFF');
  1075. end
  1076. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  1077. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1078. data.calstatus=1;
  1079. setappdata(handles.output, 'Detdata', data);
  1080. end
  1081. % --- Executes on button press in chkTDet.
  1082. function chkTDet_Callback(hObject, eventdata, handles)
  1083. % hObject handle to chkTDet (see GCBO)
  1084. % eventdata reserved - to be defined in a future version of MATLAB
  1085. % handles structure with handles and user data (see GUIDATA)
  1086. % Hint: get(hObject,'Value') returns toggle state of chkTDet
  1087. % --- Executes on button press in chkVHV.
  1088. function chkVHV_Callback(hObject, eventdata, handles)
  1089. % hObject handle to chkVHV (see GCBO)
  1090. % eventdata reserved - to be defined in a future version of MATLAB
  1091. % handles structure with handles and user data (see GUIDATA)
  1092. % Hint: get(hObject,'Value') returns toggle state of chkVHV
  1093. % --- Executes on button press in toggleOHInj.
  1094. function toggleOHInj_Callback(hObject, eventdata, handles)
  1095. % hObject handle to toggleOHInj (see GCBO)
  1096. % eventdata reserved - to be defined in a future version of MATLAB
  1097. % handles structure with handles and user data (see GUIDATA)
  1098. % Hint: get(hObject,'Value') returns toggle state of toggleOHInj
  1099. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1100. statusData=horusdata.statusData;
  1101. col=horusdata.col;
  1102. data = getappdata(handles.output, 'Detdata');
  1103. lastrow=data.lastrow;
  1104. if statusData(lastrow,col.ValidSlaveDataFlag)
  1105. if get(hObject,'Value')
  1106. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),1);
  1107. set(hObject,'BackgroundColor','r');
  1108. else
  1109. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),1,0);
  1110. set(hObject,'BackgroundColor','c');
  1111. end
  1112. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1113. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1114. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1115. end
  1116. % --- Executes on button press in toggleHO2Inj.
  1117. function toggleHO2Inj_Callback(hObject, eventdata, handles)
  1118. % hObject handle to toggleHO2Inj (see GCBO)
  1119. % eventdata reserved - to be defined in a future version of MATLAB
  1120. % handles structure with handles and user data (see GUIDATA)
  1121. % Hint: get(hObject,'Value') returns toggle state of toggleHO2Inj
  1122. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1123. statusData=horusdata.statusData;
  1124. col=horusdata.col;
  1125. data = getappdata(handles.output, 'Detdata');
  1126. lastrow=data.lastrow;
  1127. if statusData(lastrow,col.ValidSlaveDataFlag)
  1128. if get(hObject,'Value')
  1129. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),2);
  1130. set(hObject,'BackgroundColor','g');
  1131. else
  1132. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),2,0);
  1133. set(hObject,'BackgroundColor','c');
  1134. end
  1135. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1136. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1137. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1138. end
  1139. % --- Executes on button press in toggleN2.
  1140. function toggleN2_Callback(hObject, eventdata, handles)
  1141. % hObject handle to toggleN2 (see GCBO)
  1142. % eventdata reserved - to be defined in a future version of MATLAB
  1143. % handles structure with handles and user data (see GUIDATA)
  1144. % Hint: get(hObject,'Value') returns toggle state of toggleN2
  1145. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1146. statusData=horusdata.statusData;
  1147. col=horusdata.col;
  1148. data = getappdata(handles.output, 'Detdata');
  1149. lastrow=data.lastrow;
  1150. if statusData(lastrow,col.ValidSlaveDataFlag)
  1151. if get(hObject,'Value')
  1152. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),3);
  1153. set(hObject,'BackgroundColor','r');
  1154. else
  1155. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),3,0);
  1156. set(hObject,'BackgroundColor','c');
  1157. end
  1158. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1159. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1160. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1161. end
  1162. % --- Executes on button press in toggleC3F6.
  1163. function toggleC3F6_Callback(hObject, eventdata, handles)
  1164. % hObject handle to toggleC3F6 (see GCBO)
  1165. % eventdata reserved - to be defined in a future version of MATLAB
  1166. % handles structure with handles and user data (see GUIDATA)
  1167. % Hint: get(hObject,'Value') returns toggle state of toggleC3F6
  1168. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1169. statusData=horusdata.statusData;
  1170. col=horusdata.col;
  1171. data = getappdata(handles.output, 'Detdata');
  1172. lastrow=data.lastrow;
  1173. if statusData(lastrow,col.ValidSlaveDataFlag)
  1174. if get(hObject,'Value')
  1175. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),4);
  1176. set(hObject,'BackgroundColor','r');
  1177. else
  1178. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),4,0);
  1179. set(hObject,'BackgroundColor','c');
  1180. end
  1181. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1182. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1183. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1184. end
  1185. % --- Executes on button press in toggleNO1.
  1186. function toggleNO1_Callback(hObject, eventdata, handles)
  1187. % hObject handle to toggleNO1 (see GCBO)
  1188. % eventdata reserved - to be defined in a future version of MATLAB
  1189. % handles structure with handles and user data (see GUIDATA)
  1190. % Hint: get(hObject,'Value') returns toggle state of toggleNO1
  1191. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1192. statusData=horusdata.statusData;
  1193. col=horusdata.col;
  1194. data = getappdata(handles.output, 'Detdata');
  1195. lastrow=data.lastrow;
  1196. if statusData(lastrow,col.ValidSlaveDataFlag)
  1197. if get(hObject,'Value')
  1198. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),7);
  1199. set(hObject,'BackgroundColor','g');
  1200. else
  1201. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),7,0);
  1202. set(hObject,'BackgroundColor','c');
  1203. end
  1204. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1205. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1206. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1207. end
  1208. % --- Executes on button press in toggleNO2.
  1209. function toggleNO2_Callback(hObject, eventdata, handles)
  1210. % hObject handle to toggleNO2 (see GCBO)
  1211. % eventdata reserved - to be defined in a future version of MATLAB
  1212. % handles structure with handles and user data (see GUIDATA)
  1213. % Hint: get(hObject,'Value') returns toggle state of toggleNO2
  1214. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1215. statusData=horusdata.statusData;
  1216. col=horusdata.col;
  1217. data = getappdata(handles.output, 'Detdata');
  1218. lastrow=data.lastrow;
  1219. if statusData(lastrow,col.ValidSlaveDataFlag)
  1220. if get(hObject,'Value')
  1221. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),6);
  1222. set(hObject,'BackgroundColor','g');
  1223. else
  1224. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),6,0);
  1225. set(hObject,'BackgroundColor','c');
  1226. end
  1227. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1228. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1229. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1230. end
  1231. % --- Executes on button press in toggleNOPurge.
  1232. function toggleNOPurge_Callback(hObject, eventdata, handles)
  1233. % hObject handle to toggleNOPurge (see GCBO)
  1234. % eventdata reserved - to be defined in a future version of MATLAB
  1235. % handles structure with handles and user data (see GUIDATA)
  1236. % Hint: get(hObject,'Value') returns toggle state of toggleNOPurge
  1237. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1238. statusData=horusdata.statusData;
  1239. col=horusdata.col;
  1240. data = getappdata(handles.output, 'Detdata');
  1241. lastrow=data.lastrow;
  1242. if statusData(lastrow,col.ValidSlaveDataFlag)
  1243. if get(hObject,'Value')
  1244. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),5);
  1245. set(hObject,'BackgroundColor','g');
  1246. else
  1247. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),5,0);
  1248. set(hObject,'BackgroundColor','c');
  1249. end
  1250. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1251. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1252. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1253. end
  1254. function editxlim1_Callback(hObject, eventdata, handles)
  1255. % hObject handle to editxlimit1 (see GCBO)
  1256. % eventdata reserved - to be defined in a future version of MATLAB
  1257. % handles structure with handles and user data (see GUIDATA)
  1258. % Hints: get(hObject,'String') returns contents of editxlimit1 as text
  1259. % str2double(get(hObject,'String')) returns contents of editxlimit1 as a double
  1260. xlim1=uint16(str2double(get(hObject,'String')));
  1261. if (xlim1>600) set(hObject,'String','600');
  1262. else set(hObject,'String',num2str(xlim1));
  1263. end
  1264. function editxlim2_Callback(hObject, eventdata, handles)
  1265. % hObject handle to editxlim2 (see GCBO)
  1266. % eventdata reserved - to be defined in a future version of MATLAB
  1267. % handles structure with handles and user data (see GUIDATA)
  1268. % Hints: get(hObject,'String') returns contents of editxlim2 as text
  1269. % str2double(get(hObject,'String')) returns contents of editxlim2 as a double
  1270. xlim2=uint16(str2double(get(hObject,'String')));
  1271. if xlim2>600 set(hObject,'String','600');
  1272. else set(hObject,'String',num2str(xlim2));
  1273. end
  1274. % --- Executes on button press in chkWZ2out.
  1275. function chkWZ2out_Callback(hObject, eventdata, handles)
  1276. % hObject handle to chkWZ2out (see GCBO)
  1277. % eventdata reserved - to be defined in a future version of MATLAB
  1278. % handles structure with handles and user data (see GUIDATA)
  1279. % Hint: get(hObject,'Value') returns toggle state of chkWZ2out
  1280. % --- Executes on button press in chkWZ2in.
  1281. function chkWZ2in_Callback(hObject, eventdata, handles)
  1282. % hObject handle to chkWZ2in (see GCBO)
  1283. % eventdata reserved - to be defined in a future version of MATLAB
  1284. % handles structure with handles and user data (see GUIDATA)
  1285. % Hint: get(hObject,'Value') returns toggle state of chkWZ2in
  1286. function editH2O_Callback(hObject, eventdata, handles)
  1287. % hObject handle to editH2O (see GCBO)
  1288. % eventdata reserved - to be defined in a future version of MATLAB
  1289. % handles structure with handles and user data (see GUIDATA)
  1290. % Hints: get(hObject,'String') returns contents of editH2O as text
  1291. % str2double(get(hObject,'String')) returns contents of editH2O as a double
  1292. function editC_Callback(hObject, eventdata, handles)
  1293. % hObject handle to editC (see GCBO)
  1294. % eventdata reserved - to be defined in a future version of MATLAB
  1295. % handles structure with handles and user data (see GUIDATA)
  1296. % Hints: get(hObject,'String') returns contents of editC as text
  1297. % str2double(get(hObject,'String')) returns contents of editC as a double
  1298. function editMFC_Callback(hObject, eventdata, handles)
  1299. % hObject handle to editMFC (see GCBO)
  1300. % eventdata reserved - to be defined in a future version of MATLAB
  1301. % handles structure with handles and user data (see GUIDATA)
  1302. % Hints: get(hObject,'String') returns contents of editMFC as text
  1303. % str2double(get(hObject,'String')) returns contents of editMFC as a double
  1304. MaxFlow=20;
  1305. setMFC=str2double(get(hObject,'String'));
  1306. if setMFC<0 | isnan(setMFC) setMFC=0; end
  1307. if setMFC>MaxFlow setMFC=MaxFlow; end
  1308. set(hObject,'String',num2str(setMFC));
  1309. Value=setMFC/MaxFlow*255;
  1310. %system(['/lift/bin/eCmd @armAxis w 0xa404 0xFF']); % initialise
  1311. system(['/lift/bin/eCmd @armAxis w 0xa440 ', num2str(uint16(Value))]);
  1312. % --- Executes on button press in chkMFCNO.
  1313. function chkMFCNO_Callback(hObject, eventdata, handles)
  1314. % hObject handle to chkMFCNO (see GCBO)
  1315. % eventdata reserved - to be defined in a future version of MATLAB
  1316. % handles structure with handles and user data (see GUIDATA)
  1317. % Hint: get(hObject,'Value') returns toggle state of chkMFCNO
  1318. % --- Executes on button press in chkDiodeUV.
  1319. function chkDiodeUV_Callback(hObject, eventdata, handles)
  1320. % hObject handle to chkDiodeUV (see GCBO)
  1321. % eventdata reserved - to be defined in a future version of MATLAB
  1322. % handles structure with handles and user data (see GUIDATA)
  1323. % Hint: get(hObject,'Value') returns toggle state of chkDiodeUV
  1324. % --- Executes on button press in chkTDetFunnel.
  1325. function chkTDetFunnel_Callback(hObject, eventdata, handles)
  1326. % hObject handle to chkTDetFunnel (see GCBO)
  1327. % eventdata reserved - to be defined in a future version of MATLAB
  1328. % handles structure with handles and user data (see GUIDATA)
  1329. % Hint: get(hObject,'Value') returns toggle state of chkTDetFunnel
  1330. % --- Executes on button press in chkPabs.
  1331. function chkPabs_Callback(hObject, eventdata, handles)
  1332. % hObject handle to chkPabs (see GCBO)
  1333. % eventdata reserved - to be defined in a future version of MATLAB
  1334. % handles structure with handles and user data (see GUIDATA)
  1335. % Hint: get(hObject,'Value') returns toggle state of chkPabs
  1336. % --- Executes on button press in tglN2O.
  1337. function tglN2O_Callback(hObject, eventdata, handles)
  1338. % hObject handle to tglN2O (see GCBO)
  1339. % eventdata reserved - to be defined in a future version of MATLAB
  1340. % handles structure with handles and user data (see GUIDATA)
  1341. % Hint: get(hObject,'Value') returns toggle state of tglN2O
  1342. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1343. statusData=horusdata.statusData;
  1344. col=horusdata.col;
  1345. data = getappdata(handles.output, 'Detdata');
  1346. lastrow=data.lastrow;
  1347. if statusData(lastrow,col.ValidSlaveDataFlag)
  1348. if get(hObject,'Value')
  1349. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),14);
  1350. set(hObject,'BackgroundColor','g');
  1351. else
  1352. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),14,0);
  1353. set(hObject,'BackgroundColor','c');
  1354. end
  1355. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1356. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1357. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1358. end
  1359. % --- Executes on button press in tglVac.
  1360. function tglVac_Callback(hObject, eventdata, handles)
  1361. % hObject handle to tglVac (see GCBO)
  1362. % eventdata reserved - to be defined in a future version of MATLAB
  1363. % handles structure with handles and user data (see GUIDATA)
  1364. % Hint: get(hObject,'Value') returns toggle state of tglVac
  1365. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1366. statusData=horusdata.statusData;
  1367. col=horusdata.col;
  1368. data = getappdata(handles.output, 'Detdata');
  1369. lastrow=data.lastrow;
  1370. if statusData(lastrow,col.ValidSlaveDataFlag)
  1371. if get(hObject,'Value')
  1372. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),13);
  1373. set(hObject,'BackgroundColor','g');
  1374. else
  1375. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),13,0);
  1376. set(hObject,'BackgroundColor','c');
  1377. end
  1378. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1379. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1380. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1381. end
  1382. % --- Executes on button press in tglKuv.
  1383. %function tglKuv_Callback(hObject, eventdata, handles)
  1384. % hObject handle to tglKuv (see GCBO)
  1385. % eventdata reserved - to be defined in a future version of MATLAB
  1386. % handles structure with handles and user data (see GUIDATA)
  1387. % Hint: get(hObject,'Value') returns toggle state of tglKuv
  1388. %horusdata = getappdata(handles.parenthandle, 'horusdata');
  1389. %statusData=horusdata.statusData;
  1390. %col=horusdata.col;
  1391. %data = getappdata(handles.output, 'Detdata');
  1392. %lastrow=data.lastrow;
  1393. %if statusData(lastrow,col.ValidSlaveDataFlag)
  1394. % if get(hObject,'Value')
  1395. % Valveword=bitset(statusData(lastrow,col.Valve2armAxis),12);
  1396. % set(hObject,'BackgroundColor','g');
  1397. % else
  1398. % Valveword=bitset(statusData(lastrow,col.Valve2armAxis),12,0);
  1399. % set(hObject,'BackgroundColor','c');
  1400. % end
  1401. % system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1402. % system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1403. % system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to other valves working
  1404. %end
  1405. % --- Executes on button press in tglKuvN2.
  1406. %function tglKuvN2_Callback(hObject, eventdata, handles)
  1407. % hObject handle to tglKuv (see GCBO)
  1408. % eventdata reserved - to be defined in a future version of MATLAB
  1409. % handles structure with handles and user data (see GUIDATA)
  1410. % Hint: get(hObject,'Value') returns toggle state of tglKuv
  1411. %if statusData(lastrow,col.ValidSlaveDataFlag)
  1412. % if get(hObject,'Value')
  1413. % Valveword=bitset(statusData(lastrow,col.Valve2armAxis),13);
  1414. % set(hObject,'BackgroundColor','g');
  1415. % else
  1416. % Valveword=bitset(statusData(lastrow,col.Valve2armAxis),13,0);
  1417. % set(hObject,'BackgroundColor','c');
  1418. % end
  1419. % system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1420. % system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1421. % system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18 needed to keep other valves working%
  1422. %end
  1423. % --- Executes on button press in chkMFCProp.
  1424. function chkMFCProp_Callback(hObject, eventdata, handles)
  1425. % hObject handle to chkMFCProp (see GCBO)
  1426. % eventdata reserved - to be defined in a future version of MATLAB
  1427. % handles structure with handles and user data (see GUIDATA)
  1428. % Hint: get(hObject,'Value') returns toggle state of chkMFCProp
  1429. % --- Executes on button press in chkMFCShower.
  1430. function chkMFCShower_Callback(hObject, eventdata, handles)
  1431. % hObject handle to chkMFCShower (see GCBO)
  1432. % eventdata reserved - to be defined in a future version of MATLAB
  1433. % handles structure with handles and user data (see GUIDATA)
  1434. % Hint: get(hObject,'Value') returns toggle state of chkMFCShower
  1435. % --- Executes on button press in tglPitot.
  1436. function tglPitot_Callback(hObject, eventdata, handles)
  1437. % hObject handle to tglPitot (see GCBO)
  1438. % eventdata reserved - to be defined in a future version of MATLAB
  1439. % handles structure with handles and user data (see GUIDATA)
  1440. % Hint: get(hObject,'Value') returns toggle state of tglPitot
  1441. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1442. statusData=horusdata.statusData;
  1443. data = getappdata(handles.output, 'Detdata');
  1444. lastrow=data.lastrow;
  1445. col=horusdata.col;
  1446. if statusData(lastrow,col.ValidSlaveDataFlag)
  1447. if get(hObject,'Value')
  1448. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),12);
  1449. set(hObject,'BackgroundColor','y','String','Pitot 0 ON');
  1450. else
  1451. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),12,0);
  1452. set(hObject,'BackgroundColor','c','String','Pitot 0 OFF');
  1453. end
  1454. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch
  1455. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1456. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to hold solenoids
  1457. end
  1458. % --- Executes on button press in tglHeatLamp.
  1459. function tglHeatLamp_Callback(hObject, eventdata, handles)
  1460. % hObject handle to tglHeatLamp (see GCBO)
  1461. % eventdata reserved - to be defined in a future version of MATLAB
  1462. % handles structure with handles and user data (see GUIDATA)
  1463. % Hint: get(hObject,'Value') returns toggle state of tglHeatLamp
  1464. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1465. statusData=horusdata.statusData;
  1466. data = getappdata(handles.output, 'Detdata');
  1467. lastrow=data.lastrow;
  1468. col=horusdata.col;
  1469. if statusData(lastrow,col.ValidSlaveDataFlag)
  1470. if get(hObject,'Value')
  1471. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),3);
  1472. else
  1473. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),3,0);
  1474. end
  1475. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  1476. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1477. end
  1478. % --- Executes on button press in chkTLamp.
  1479. function chkTLamp_Callback(hObject, eventdata, handles)
  1480. % hObject handle to chkTLamp (see GCBO)
  1481. % eventdata reserved - to be defined in a future version of MATLAB
  1482. % handles structure with handles and user data (see GUIDATA)
  1483. % Hint: get(hObject,'Value') returns toggle state of chkTLamp
  1484. % --- Executes on button press in chkMFCC3F6.
  1485. function chkMFCC3F6_Callback(hObject, eventdata, handles)
  1486. % hObject handle to chkMFCC3F6 (see GCBO)
  1487. % eventdata reserved - to be defined in a future version of MATLAB
  1488. % handles structure with handles and user data (see GUIDATA)
  1489. % Hint: get(hObject,'Value') returns toggle state of chkMFCC3F6
  1490. % --- Executes on button press in tglHeatPrall.
  1491. function tglHeatPrall_Callback(hObject, eventdata, handles)
  1492. % hObject handle to tglHeatPrall (see GCBO)
  1493. % eventdata reserved - to be defined in a future version of MATLAB
  1494. % handles structure with handles and user data (see GUIDATA)
  1495. % Hint: get(hObject,'Value') returns toggle state of tglHeatPrall
  1496. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1497. statusData=horusdata.statusData;
  1498. data = getappdata(handles.output, 'Detdata');
  1499. lastrow=data.lastrow;
  1500. col=horusdata.col;
  1501. if statusData(lastrow,col.ValidSlaveDataFlag)
  1502. if get(hObject,'Value')
  1503. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),4);
  1504. else
  1505. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),4,0);
  1506. end
  1507. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  1508. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1509. end
  1510. % --- Executes on button press in tglHeatPhoto2.
  1511. function tglHeatPhoto2_Callback(hObject, eventdata, handles)
  1512. % hObject handle to tglHeatPhoto2 (see GCBO)
  1513. % eventdata reserved - to be defined in a future version of MATLAB
  1514. % handles structure with handles and user data (see GUIDATA)
  1515. % Hint: get(hObject,'Value') returns toggle state of tglHeatPhoto2
  1516. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1517. statusData=horusdata.statusData;
  1518. data = getappdata(handles.output, 'Detdata');
  1519. lastrow=data.lastrow;
  1520. col=horusdata.col;
  1521. if statusData(lastrow,col.ValidSlaveDataFlag)
  1522. if get(hObject,'Value')
  1523. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),5);
  1524. else
  1525. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),5,0);
  1526. end
  1527. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  1528. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1529. end
  1530. % --- Executes on button press in tglVent.
  1531. function tglVent_Callback(hObject, eventdata, handles)
  1532. % hObject handle to tglVent (see GCBO)
  1533. % eventdata reserved - to be defined in a future version of MATLAB
  1534. % handles structure with handles and user data (see GUIDATA)
  1535. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1536. statusData=horusdata.statusData;
  1537. col=horusdata.col;
  1538. data = getappdata(handles.output, 'Detdata');
  1539. lastrow=data.lastrow;
  1540. if statusData(lastrow,col.ValidSlaveDataFlag)
  1541. if get(hObject,'Value')
  1542. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),4);
  1543. set(hObject,'BackgroundColor','r');
  1544. else
  1545. Valveword=bitset(statusData(lastrow,col.Valve1armAxis),4,0);
  1546. set(hObject,'BackgroundColor','c');
  1547. end
  1548. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1549. system(['/lift/bin/eCmd @armAxis w 0xa408 ', num2str(Valveword)]);
  1550. system(['/lift/bin/eCmd @armAxis w 0xa460 ', num2str(uint16(15*140))]); % 15V needed to keep Pitot Zero open
  1551. end
  1552. % --- Executes on button press in togButterfly.
  1553. function togButterfly_Callback(hObject, eventdata, handles)
  1554. % hObject handle to togButterfly (see GCBO)
  1555. % eventdata reserved - to be defined in a future version of MATLAB
  1556. % handles structure with handles and user data (see GUIDATA)
  1557. % Hint: get(hObject,'Value') returns toggle state of togButterfly
  1558. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1559. statusData=horusdata.statusData;
  1560. data = getappdata(handles.output, 'Detdata');
  1561. lastrow=data.lastrow;
  1562. col=horusdata.col;
  1563. % Butterfly with stepper motor
  1564. %if statusData(lastrow,col.ButterflyPositionValid)==0
  1565. % system('/lift/bin/eCmd @armAxis s butterflyposition 2500'); % move to find index position
  1566. % set(hObject,'BackgroundColor','r','String','MOVING');
  1567. % pause(2);
  1568. % system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(625+42)]); % open Butterfly
  1569. % set(hObject,'Value',1);
  1570. %else
  1571. % if get(hObject,'Value')
  1572. % system('/lift/bin/eCmd @armAxis s butterflyposition 2500'); % move to find index position
  1573. % set(hObject,'BackgroundColor','r','String','MOVING');
  1574. % pause(2);
  1575. % system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(625+42)]); % open Butterfly
  1576. % else
  1577. % system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(42)]); % close Butterfly
  1578. % set(hObject,'BackgroundColor','r','String','MOVING');
  1579. % end
  1580. %end
  1581. % end Butterfly with stepper motor
  1582. % Butterfly with relay
  1583. if get(hObject,'Value')
  1584. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),2,0); % open Butterfly
  1585. set(hObject,'BackgroundColor','r','String','MOVING');
  1586. else
  1587. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),2,1); % close Butterfly
  1588. set(hObject,'BackgroundColor','r','String','MOVING');
  1589. end
  1590. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1591. % end Butterfly with relay
  1592. % --- Executes on button press in togPump.
  1593. function togPump_Callback(hObject, eventdata, handles)
  1594. % hObject handle to togPump (see GCBO)
  1595. % eventdata reserved - to be defined in a future version of MATLAB
  1596. % handles structure with handles and user data (see GUIDATA)
  1597. % Hint: get(hObject,'Value') returns toggle state of togPump
  1598. horusdata = getappdata(handles.parenthandle, 'horusdata');
  1599. statusData=horusdata.statusData;
  1600. data = getappdata(handles.output, 'Detdata');
  1601. lastrow=data.lastrow;
  1602. col=horusdata.col;
  1603. horustxtBlower=horusdata.txtBlower;
  1604. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1])
  1605. set(hObject,'BackgroundColor','y');
  1606. tcpBlower=horusdata.tcpBlower;
  1607. % check if Blower and/or pump are on or off
  1608. fprintf(tcpBlower,'status');
  1609. pause(0.5);
  1610. BlowerStatus=tcpBlower.UserData;
  1611. tcpBlower.UserData=[];
  1612. if BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='f'
  1613. PumpSwitch=0;
  1614. elseif BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='n'
  1615. PumpSwitch=1;
  1616. else PumpSwitch=-1;
  1617. end
  1618. if BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='f'
  1619. InverterSwitch=0;
  1620. elseif BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='n'
  1621. InverterSwitch=1;
  1622. else InverterSwitch=-1;
  1623. end
  1624. if BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='f'
  1625. RampSwitch=0;
  1626. elseif BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='n'
  1627. RampSwitch=1;
  1628. else RampSwitch=-1;
  1629. end
  1630. end
  1631. if get(hObject,'Value') % switch on
  1632. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % Blower connected via tcp (ground configuration)
  1633. fprintf(tcpBlower,'pump on'); % switch pump on
  1634. pause(0.5);
  1635. tcpBlower.UserData=[];
  1636. else % Blower connected directly to armaxis (air configuration)
  1637. if statusData(lastrow,col.ValidSlaveDataFlag) % only if armaxis is active
  1638. if isequal(get(hObject,'BackgroundColor'),[0 1 1])
  1639. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),10); % switch Leybold pump on
  1640. Valveword=bitset(Valveword,7); % switch Scroll pump on
  1641. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to switch
  1642. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1643. set(hObject,'BackgroundColor','g','String','Pump ON');
  1644. end
  1645. end
  1646. end
  1647. else % switch off
  1648. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1]) % Blower connected via tcp (ground configuration)
  1649. if InverterSwitch==0 % make sure blower is ramped down
  1650. fprintf(tcpBlower,'pump off'); % switch pump off
  1651. pause(0.5);
  1652. tcpBlower.UserData=[];
  1653. % Butterfly with stepper motor
  1654. system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(42)]); % close Butterfly
  1655. % end Butterfly with stepper motor
  1656. % Butterfly with relay
  1657. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),2,1); % close Butterfly
  1658. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1659. % end Butterfly with relay
  1660. set(handles.togButterfly,'BackgroundColor','r','String','MOVING');
  1661. end
  1662. else % Blower connected directly to armaxis (air configuration)
  1663. if statusData(lastrow,col.ValidSlaveDataFlag) % only if armaxis is active
  1664. if isequal(get(hObject,'BackgroundColor'),[0 1 0]) | isequal(get(hObject,'BackgroundColor'),[1 0 0])
  1665. % set(handles.tglVent,'BackgroundColor','r');
  1666. if bitget(statusData(lastrow,col.Valve2armAxis),1)==0 % make sure blower is ramped down
  1667. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),9,0); % switch off blower
  1668. Valveword=bitset(Valveword,10,0); % switch off Leybold Pump
  1669. Valveword=bitset(Valveword,7,0); % switch off Scroll Pump
  1670. % Valveword=bitset(Valveword,13); % ventilate Pump
  1671. % Butterfly with stepper motor
  1672. system(['/lift/bin/eCmd @armAxis s butterflyposition ',num2str(42)]); % close Butterfly
  1673. % end Butterfly with stepper motor
  1674. % Butterfly with relay
  1675. Valveword=bitset(statusData(lastrow,col.Valve2armAxis),2,1); % close Butterfly
  1676. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1677. % end Butterfly with relay
  1678. set(handles.togButterfly,'BackgroundColor','r','String','MOVING');
  1679. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(24*140))]); % 24V needed to switch solenoids on
  1680. system(['/lift/bin/eCmd @armAxis w 0xa40a ', num2str(Valveword)]);
  1681. system(['/lift/bin/eCmd @armAxis w 0xa462 ', num2str(uint16(18*140))]); % 18V needed to other valves working
  1682. set(hObject,'BackgroundColor','c','String','Pump OFF');
  1683. % set(handles.tglVent,'BackgroundColor','r');
  1684. end
  1685. end
  1686. end
  1687. end
  1688. end
  1689. %for ground configuration, recheck pump status
  1690. if ~isequal(get(horustxtBlower,'BackgroundColor'),[0 1 1])
  1691. fprintf(tcpBlower,'status');
  1692. pause(0.5);
  1693. BlowerStatus=tcpBlower.UserData;
  1694. tcpBlower.UserData=[];
  1695. if BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='f'
  1696. PumpSwitch=0;
  1697. elseif BlowerStatus(strfind(BlowerStatus,'Pump')+7)=='n'
  1698. PumpSwitch=1;
  1699. else PumpSwitch=-1;
  1700. end
  1701. if BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='f'
  1702. InverterSwitch=0;
  1703. elseif BlowerStatus(strfind(BlowerStatus,'Inverter')+11)=='n'
  1704. InverterSwitch=1;
  1705. else InverterSwitch=-1;
  1706. end
  1707. if BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='f'
  1708. RampSwitch=0;
  1709. elseif BlowerStatus(strfind(BlowerStatus,'Ramp')+7)=='n'
  1710. RampSwitch=1;
  1711. else RampSwitch=-1;
  1712. end
  1713. if PumpSwitch==0
  1714. set(hObject,'BackgroundColor','c','String','Pump OFF');
  1715. set(horustxtBlower,'String','Pump OFF');
  1716. elseif (RampSwitch==0 | InverterSwitch==0)
  1717. set(hObject,'BackgroundColor','g','String','Pump ON');
  1718. set(horustxtBlower,'String','Pump ON');
  1719. else
  1720. set(horustxtBlower,'String','Blower ON','BackgroundColor','g');
  1721. end
  1722. if (PumpSwitch==-1 | RampSwitch==-1 | InverterSwitch==-1)
  1723. set(hObject,'BackgroundColor','r','String','Pump ERR');
  1724. set(horustxtBlower,'String','Blower ERROR','BackgroundColor','r');
  1725. end
  1726. end
  1727. function editMFCShower_Callback(hObject, eventdata, handles)
  1728. % hObject handle to editMFCShower (see GCBO)
  1729. % eventdata reserved - to be defined in a future version of MATLAB
  1730. % handles structure with handles and user data (see GUIDATA)
  1731. % Hints: get(hObject,'String') returns contents of editMFCShower as text
  1732. % str2double(get(hObject,'String')) returns contents of editMFCShower as a double
  1733. MaxFlow=5000;
  1734. setMFC=str2double(get(hObject,'String'));
  1735. if setMFC<0 | isnan(setMFC) setMFC=0; end
  1736. if setMFC>MaxFlow setMFC=MaxFlow; end
  1737. set(hObject,'String',num2str(setMFC));
  1738. Value=setMFC/MaxFlow*255;
  1739. %system(['/lift/bin/eCmd @armAxis w 0xa404 0xFF']); % initialise
  1740. system(['/lift/bin/eCmd @armAxis w 0xa446 ', num2str(uint16(Value))]);
  1741. % --- Executes during object creation, after setting all properties.
  1742. function editMFCShower_CreateFcn(hObject, eventdata, handles)
  1743. % hObject handle to editMFCShower (see GCBO)
  1744. % eventdata reserved - to be defined in a future version of MATLAB
  1745. % handles empty - handles not created until after all CreateFcns called
  1746. % Hint: edit controls usually have a white background on Windows.
  1747. % See ISPC and COMPUTER.
  1748. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1749. set(hObject,'BackgroundColor','white');
  1750. end
  1751. function editMFCProp_Callback(hObject, eventdata, handles)
  1752. % hObject handle to editMFCProp (see GCBO)
  1753. % eventdata reserved - to be defined in a future version of MATLAB
  1754. % handles structure with handles and user data (see GUIDATA)
  1755. % Hints: get(hObject,'String') returns contents of editMFCProp as text
  1756. % str2double(get(hObject,'String')) returns contents of editMFCProp as a double
  1757. MaxFlow=200;
  1758. setMFC=str2double(get(hObject,'String'));
  1759. if setMFC<0 | isnan(setMFC) setMFC=0; end
  1760. if setMFC>MaxFlow setMFC=MaxFlow; end
  1761. set(hObject,'String',num2str(setMFC));
  1762. Value=setMFC/MaxFlow*255;
  1763. %system(['/lift/bin/eCmd @armAxis w 0xa404 0xFF']); % initialise
  1764. system(['/lift/bin/eCmd @armAxis w 0xa442 ', num2str(uint16(Value))]);
  1765. % --- Executes during object creation, after setting all properties.
  1766. function editMFCProp_CreateFcn(hObject, eventdata, handles)
  1767. % hObject handle to editMFCProp (see GCBO)
  1768. % eventdata reserved - to be defined in a future version of MATLAB
  1769. % handles empty - handles not created until after all CreateFcns called
  1770. % Hint: edit controls usually have a white background on Windows.
  1771. % See ISPC and COMPUTER.
  1772. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1773. set(hObject,'BackgroundColor','white');
  1774. end
  1775. function editMFCC3F6_Callback(hObject, eventdata, handles)
  1776. % hObject handle to editMFCC3F6 (see GCBO)
  1777. % eventdata reserved - to be defined in a future version of MATLAB
  1778. % handles structure with handles and user data (see GUIDATA)
  1779. % Hints: get(hObject,'String') returns contents of editMFCC3F6 as text
  1780. % str2double(get(hObject,'String')) returns contents of editMFCC3F6 as a double
  1781. MaxFlow=500;
  1782. setMFC=str2double(get(hObject,'String'));
  1783. if setMFC<0 | isnan(setMFC) setMFC=0; end
  1784. if setMFC>MaxFlow setMFC=MaxFlow; end
  1785. set(hObject,'String',num2str(setMFC));
  1786. Value=setMFC/MaxFlow*255;
  1787. %system(['/lift/bin/eCmd @armAxis w 0xa404 0xFF']); % initialise
  1788. system(['/lift/bin/eCmd @armAxis w 0xa444 ', num2str(uint16(Value))]);
  1789. % --- Executes during object creation, after setting all properties.
  1790. function editMFCC3F6_CreateFcn(hObject, eventdata, handles)
  1791. % hObject handle to editMFCC3F6 (see GCBO)
  1792. % eventdata reserved - to be defined in a future version of MATLAB
  1793. % handles empty - handles not created until after all CreateFcns called
  1794. % Hint: edit controls usually have a white background on Windows.
  1795. % See ISPC and COMPUTER.
  1796. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  1797. set(hObject,'BackgroundColor','white');
  1798. end