Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

statusgui(varargin)
function varargout = statusgui(varargin)
% STATUSGUI M-file for statusgui.fig
%      STATUSGUI, by itself, creates a new STATUSGUI or raises the existing
%      singleton*.
%
%      H = STATUSGUI returns the handle to a new STATUSGUI or the handle to
%      the existing singleton*.
%
%      STATUSGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in STATUSGUI.M with the given input arguments.
%
%      STATUSGUI('Property','Value',...) creates a new STATUSGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before statusgui_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to statusgui_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help statusgui

% Last Modified by GUIDE v2.5 18-Nov-2009 16:08:26

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @statusgui_OpeningFcn, ...
                   'gui_OutputFcn',  @statusgui_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before statusgui is made visible.
function statusgui_OpeningFcn(hObject, eventdata, handles, mainGuiHandle)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to statusgui (see VARARGIN)

% error checking
if nargin < 4
    % brings up an error dialog
    errdlg('Cannot open status window as the handle to the main window has not been supplied.')
    
    % deletes the figure
    delete(hObject)
end

% saves the mainGuiHandle to handles
handles.mainGuiHandle = mainGuiHandle;

% Update handles structure
guidata(hObject, handles);

% saves the status window handle into the main gui appdata
setappdata(mainGuiHandle, 'statusWindowHandle', hObject)
setappdata(mainGuiHandle, 'statusWindowHandles', handles)

% gets the start time serial
startTimeSerial = getappdata(mainGuiHandle, 'startTimeSerial');

% sets the starting time and date in the start time box
set(handles.startTime, 'String', datestr(startTimeSerial, 'HH:MM dd mmm'))

% calculates the current running time
runningTimeSerial = now - startTimeSerial;

% fills the upTime box
set(handles.upTime, 'String', sprintf('%d:%s', fix(runningTimeSerial * 24), datestr(runningTimeSerial, 'MM:SS')))

% fill all of the boxes from appdata
for m = 1:11
    % forms the status handle
    status = sprintf('status%d', m);
    
    % fills the box
    set(handles.(status), 'String', getappdata(mainGuiHandle, status))
end


% --- Outputs from this function are returned to the command line.
function statusgui_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function status1_Callback(hObject, eventdata, handles)
% hObject    handle to status1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status1 as text
%        str2double(get(hObject,'String')) returns contents of status1 as a double


% --- Executes during object creation, after setting all properties.
function status1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status2_Callback(hObject, eventdata, handles)
% hObject    handle to status2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status2 as text
%        str2double(get(hObject,'String')) returns contents of status2 as a double


% --- Executes during object creation, after setting all properties.
function status2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status3_Callback(hObject, eventdata, handles)
% hObject    handle to status3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status3 as text
%        str2double(get(hObject,'String')) returns contents of status3 as a double


% --- Executes during object creation, after setting all properties.
function status3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status4_Callback(hObject, eventdata, handles)
% hObject    handle to status4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status4 as text
%        str2double(get(hObject,'String')) returns contents of status4 as a double


% --- Executes during object creation, after setting all properties.
function status4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status5_Callback(hObject, eventdata, handles)
% hObject    handle to status5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status5 as text
%        str2double(get(hObject,'String')) returns contents of status5 as a double


% --- Executes during object creation, after setting all properties.
function status5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status6_Callback(hObject, eventdata, handles)
% hObject    handle to status6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status6 as text
%        str2double(get(hObject,'String')) returns contents of status6 as a double


% --- Executes during object creation, after setting all properties.
function status6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status7_Callback(hObject, eventdata, handles)
% hObject    handle to status7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status7 as text
%        str2double(get(hObject,'String')) returns contents of status7 as a double


% --- Executes during object creation, after setting all properties.
function status7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status8_Callback(hObject, eventdata, handles)
% hObject    handle to status8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status8 as text
%        str2double(get(hObject,'String')) returns contents of status8 as a double


% --- Executes during object creation, after setting all properties.
function status8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status9_Callback(hObject, eventdata, handles)
% hObject    handle to status9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status9 as text
%        str2double(get(hObject,'String')) returns contents of status9 as a double


% --- Executes during object creation, after setting all properties.
function status9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function status10_Callback(hObject, eventdata, handles)
% hObject    handle to status10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status10 as text
%        str2double(get(hObject,'String')) returns contents of status10 as a double


% --- Executes during object creation, after setting all properties.
function status10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function startTime_Callback(hObject, eventdata, handles)
% hObject    handle to startTime (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of startTime as text
%        str2double(get(hObject,'String')) returns contents of startTime as a double


% --- Executes during object creation, after setting all properties.
function startTime_CreateFcn(hObject, eventdata, handles)
% hObject    handle to startTime (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function upTime_Callback(hObject, eventdata, handles)
% hObject    handle to upTime (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of upTime as text
%        str2double(get(hObject,'String')) returns contents of upTime as a double


% --- Executes during object creation, after setting all properties.
function upTime_CreateFcn(hObject, eventdata, handles)
% hObject    handle to upTime (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end




% --- Executes when user attempts to close statusgui.
function statusgui_CloseRequestFcn(hObject, eventdata, handles)
% hObject    handle to statusgui (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% removes the handles from the main GUI appdata
try
    % deletes fields
    rmappdata(handles.mainGuiHandle, 'statusWindowHandle')
    rmappdata(handles.mainGuiHandle, 'statusWindowHandles')
    
catch
    % brings up an error dialog
    errordlg('Handle fields not removed from main GUI appdata.')
end

% deletes the figure
delete(hObject)



function status11_Callback(hObject, eventdata, handles)
% hObject    handle to status11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of status11 as text
%        str2double(get(hObject,'String')) returns contents of status11 as a double


% --- Executes during object creation, after setting all properties.
function status11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to status11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

Contact us