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.

rheodyneobjgui(varargin)
function varargout = rheodyneobjgui(varargin)
% RHEODYNEOBJGUI M-file for rheodyneobjgui.fig
%      RHEODYNEOBJGUI, by itself, creates a new RHEODYNEOBJGUI or raises the existing
%      singleton*.
%
%      H = RHEODYNEOBJGUI returns the handle to a new RHEODYNEOBJGUI or the handle to
%      the existing singleton*.
%
%      RHEODYNEOBJGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in RHEODYNEOBJGUI.M with the given input arguments.
%
%      RHEODYNEOBJGUI('Property','Value',...) creates a new RHEODYNEOBJGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before rheodyneobjgui_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to rheodyneobjgui_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 rheodyneobjgui

% Last Modified by GUIDE v2.5 14-Jul-2009 14:46:20

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @rheodyneobjgui_OpeningFcn, ...
                   'gui_OutputFcn',  @rheodyneobjgui_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 rheodyneobjgui is made visible.
function rheodyneobjgui_OpeningFcn(hObject, eventdata, handles, mainGuiHandle, timerObject)
% 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 rheodyneobjgui (see VARARGIN)

% checks the number of arguments
error(nargchk(5, 5, nargin))

% stashes away the main gui handle
handles.mainGuiHandle = mainGuiHandle;

% stashes the serial object away for later use
handles.timerObject = timerObject;

% Update handles structure
guidata(hObject, handles)

% gets the user data
userData = timerObject.UserData;

% fills the boxes if the respective fields exist
if isfield(userData, 'nominalLoopSize')
    % fills the box
    set(handles.nominalLoopSize, 'String', num2str(userData.nominalLoopSize))
end

% same with measured loop size
if isfield(userData, 'measuredLoopSize')
    % fills the box
    set(handles.measuredLoopSize, 'String', num2str(userData.measuredLoopSize))
end


% --- Outputs from this function are returned to the command line.
function rheodyneobjgui_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 nominalLoopSize_Callback(hObject, eventdata, handles)
% hObject    handle to nominalLoopSize (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 nominalLoopSize as text
%        str2double(get(hObject,'String')) returns contents of nominalLoopSize as a double

% gets the new value
newValue = str2double(get(hObject, 'String'));

% checks its OK
if ~isnumber(newValue) && newValue <= 0
    % brings up an error dialog
    warntooltip(hObject, 'Nominal loop size must be a real number greater than 0.')
    
else
    % gets the user data (have to do it like this for timer objects - can't
    % use dot parens notation with structures and timer objects - although
    % bizarrely this is OK with serial objects and structures
    userData = get(handles.timerObject, 'UserData');
    
    % updates the timer object user data
    userData.nominalLoopSize = newValue;
    
    % saves it
    set(handles.timerObject, 'UserData', userData)
end


% --- Executes during object creation, after setting all properties.
function nominalLoopSize_CreateFcn(hObject, eventdata, handles)
% hObject    handle to nominalLoopSize (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 measuredLoopSize_Callback(hObject, eventdata, handles)
% hObject    handle to measuredLoopSize (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 measuredLoopSize as text
%        str2double(get(hObject,'String')) returns contents of measuredLoopSize as a double

% gets the new value
newValue = str2double(get(hObject, 'String'));

% checks its OK
if ~isnumber(newValue) && newValue <= 0
    % brings up an error dialog
    warntooltip(hObject, 'Measured loop size must be a real number greater than 0.')
    
else
    % gets the user data (have to do it like this for timer objects - can't
    % use dot parens notation with structures and timer objects - although
    % bizarrely this is OK with serial objects and structures
    userData = get(handles.timerObject, 'UserData');
    
    % updates the timer object user data
    userData.measuredLoopSize = newValue;
    
    % saves it
    set(handles.timerObject, 'UserData', userData)
end


% --- Executes during object creation, after setting all properties.
function measuredLoopSize_CreateFcn(hObject, eventdata, handles)
% hObject    handle to measuredLoopSize (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