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.

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

% Last Modified by GUIDE v2.5 12-Nov-2009 17:29:38

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

%get the handles structure from the optimise GUI
handles.optimiseGUIHandles = varargin{3};

%get the object config information from the mainGUI
objectConfig = getappdata(handles.optimiseGUIHandles.MainGUI,'objectConfig');
objectTypes = getappdata(handles.optimiseGUIHandles.MainGUI,'objectTypes');

%run through each object
for m = 1:9
    %name boxes
    name = objectConfig(m).name; %get the object name
    namebox = sprintf('name%d',m); %generate handle to the textbox for the name of this object
    set(handles.(namebox),'String',name) %set the text box to this name
    
    %type boxes
    type = objectConfig(m).type; %get the number type for this object
    typeName = objectTypes(type).name; %get the name for this type number
    typebox = sprintf('type%d',m); %generate handle to the textbox for the type of this object
    set(handles.(typebox),'String',typeName); %set the text box to this type
    
    %deviation & noise boxes
    devHandle = sprintf('dev%d',m); %generate handles to the boxes in this GUI and file names in the optimiseGUI appdata
    noiseHandle = sprintf('noise%d',m);
    defHandle = sprintf('def%d',m);
    
    devValue = getappdata(handles.optimiseGUIHandles.optimisegui,devHandle); %get the current value for deviation and noise
    noiseValue = getappdata(handles.optimiseGUIHandles.optimisegui,noiseHandle);
    if isempty(devValue) %check if any value has been set yet, if not then assume it is zero
        devValue = 0;
    end
    if isempty(noiseValue)
        noiseValue = 0;
    end
    
    enable = get(handles.optimiseGUIHandles.(sprintf('checkbox%d',m)), 'Value'); %check if this object is enabled
    if enable && ~(type == 1) %set enable to On or Off (Rheo can never be enabled for this feature)
        enable = 'On';
    else
        enable = 'Off';
    end
    
    set(handles.(devHandle),'Enable',enable,'String',devValue); %set the box to on/off and put in value for deviation
    set(handles.(noiseHandle),'Enable',enable,'String',noiseValue);
    set(handles.(defHandle),'Enable',enable);
end

setappdata(handles.optimiseGUIHandles.MainGUI,'noisesettingHandle',handles.noisesetting); %pass handle to the mainGUI
setappdata(handles.optimiseGUIHandles.optimisegui,'noisesettingHandle',handles.noisesetting); %pass handle to optimisegui
   

% Choose default command line output for noisesetting
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes noisesetting wait for user response (see UIRESUME)
% uiwait(handles.noisesetting);


% --- Outputs from this function are returned to the command line.
function varargout = noisesetting_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)

% Get default command line output from handles structure
varargout{1} = handles.output;



function dev1_Callback(hObject, eventdata, handles)
% hObject    handle to dev1 (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 dev1 as text
%        str2double(get(hObject,'String')) returns contents of dev1 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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

checkInputCallback(hObject, eventdata, handles) %run the standard check callback


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


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


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


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


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


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


checkInputCallback(hObject, eventdata, handles) %run the standard check callback

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


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


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


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


checkInputCallback(hObject, eventdata, handles) %run the standard check callback

% --- Executes during object creation, after setting all properties.
function noise9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to noise9 (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 on button press in Change.
function Change_Callback(hObject, eventdata, handles)
% hObject    handle to Change (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in Cancel.
function Cancel_Callback(hObject, eventdata, handles)
% hObject    handle to Cancel (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in change.
function change_Callback(hObject, eventdata, handles)
% hObject    handle to change (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

for object = 1:9 %cycle through each object
    devHandle = sprintf('dev%d',object); %generate handles 
    noiseHandle = sprintf('noise%d',object); 
    
    dev = get(handles.(devHandle),'String'); %get string from text box
    dev = str2num(dev); %convert to number
    noise = get(handles.(noiseHandle),'String'); %get string from text box
    noise = str2num(noise); %convert to number
    
    setappdata(handles.optimiseGUIHandles.optimisegui,devHandle,dev); %store new value in optimiseGUI
    setappdata(handles.optimiseGUIHandles.optimisegui,noiseHandle,noise);
        
end


% --- Executes on button press in load.
function load_Callback(hObject, eventdata, handles)
% hObject    handle to load (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

objectConfig = getappdata(handles.optimiseGUIHandles.MainGUI,'objectConfig');
objectTypes = getappdata(handles.optimiseGUIHandles.MainGUI,'objectTypes');

for object = 1:9 %cycle through each object
    objectType = objectConfig(object).type; %get which type of object this object is (number)
    noise = objectTypes(objectType).allowedNoise; %get the noise and deviation for that type of object from MainGUI
    dev = objectTypes(objectType).allowedDeviation;
    if isempty(noise) %if nothing has been entered for noise or deviation yet then set to zero
        noise = 0;
    end
    if isempty(dev)
        dev = 0;
    end
    devHandle = sprintf('dev%d',object); %generate handle to the deviation text box for this object
    noiseHandle = sprintf('noise%d',object); %generate handle to the noise text box for this object
    set(handles.(devHandle),'String',dev);
    set(handles.(noiseHandle),'String',noise);    
end


% --- Executes on button press in def1.
function def1_Callback(hObject, eventdata, handles)
% hObject    handle to def1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback


% --- Executes on button press in def2.
function def2_Callback(hObject, eventdata, handles)
% hObject    handle to def2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback


% --- Executes on button press in def3.
function def3_Callback(hObject, eventdata, handles)
% hObject    handle to def3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback


% --- Executes on button press in def4.
function def4_Callback(hObject, eventdata, handles)
% hObject    handle to def4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback


% --- Executes on button press in de.
function de_Callback(hObject, eventdata, handles)
% hObject    handle to de (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% --- Designed to be run by all of the initial edit boxes to prevent text entry
function checkInputCallback(callingObject, eventdata, handles)
% callingObject handle to the calling object
% eventdata     reserved - to be defined in a future version of MATLAB
% handles       structure with handles and user data (see GUIDATA)

% fetches the tag of the handle (the actual handle is a horribly unreadable
% number like 27.0023)
callingHandleString = get(callingObject, 'Tag');

% extracts out the last numeric part (the column) from the 'Tag' (cell
% array)
number = textscan(callingHandleString, '%*s%d', 'delimiter', '_');

% extracts that out as a number (weird textscan behaviour)
number = number{1};

% parses contents
newNumber = str2double(get(callingObject, 'String'));

% checks contents to see if they are numeric, finite, real, greater than
% or equal to 0
if isnan(newNumber) || ~isfinite(newNumber) || ~isreal(newNumber) || newNumber < 0
    errordlg('Must enter a finite real number greater than 0.')
    set(callingObject, 'String', '')
end

% Update handles structure
guidata(callingObject, handles);


function dev5_Callback(hObject, eventdata, handles)
% hObject    handle to dev5 (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 dev5 as text
%        str2double(get(hObject,'String')) returns contents of dev5 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback







function dev6_Callback(hObject, eventdata, handles)
% hObject    handle to dev6 (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 dev6 as text
%        str2double(get(hObject,'String')) returns contents of dev6 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback







function dev7_Callback(hObject, eventdata, handles)
% hObject    handle to dev7 (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 dev7 as text
%        str2double(get(hObject,'String')) returns contents of dev7 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback







function dev8_Callback(hObject, eventdata, handles)
% hObject    handle to dev8 (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 dev8 as text
%        str2double(get(hObject,'String')) returns contents of dev8 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback







function dev9_Callback(hObject, eventdata, handles)
% hObject    handle to dev9 (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 dev9 as text
%        str2double(get(hObject,'String')) returns contents of dev9 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback







function noise5_Callback(hObject, eventdata, handles)
% hObject    handle to noise5 (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 noise5 as text
%        str2double(get(hObject,'String')) returns contents of noise5 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback





function noise6_Callback(hObject, eventdata, handles)
% hObject    handle to noise6 (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 noise6 as text
%        str2double(get(hObject,'String')) returns contents of noise6 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback





function noise8_Callback(hObject, eventdata, handles)
% hObject    handle to noise8 (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 noise8 as text
%        str2double(get(hObject,'String')) returns contents of noise8 as a double

checkInputCallback(hObject, eventdata, handles) %run the standard check callback




% --- Executes on button press in def5.
function def5_Callback(hObject, eventdata, handles)
% hObject    handle to def5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback





% --- Executes on button press in def6.
function def6_Callback(hObject, eventdata, handles)
% hObject    handle to def6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback


% --- Executes on button press in def7.
function def7_Callback(hObject, eventdata, handles)
% hObject    handle to def7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback



% --- Executes on button press in def8.
function def8_Callback(hObject, eventdata, handles)
% hObject    handle to def8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback


% --- Executes on button press in def9.
function def9_Callback(hObject, eventdata, handles)
% hObject    handle to def9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

setNewDefaultCallback(hObject, eventdata, handles) %run the standard new default callback

%designed to be run every time the user clicks on one of the set a new
%default button
function setNewDefaultCallback(callingObject, eventdata, handles)
% callingObject handle to the calling object
% eventdata     reserved - to be defined in a future version of MATLAB
% handles       structure with handles and user data (see GUIDATA)

% fetches the tag of the handle (the actual handle is a horribly unreadable
% number like 27.0023)
callingHandleString = get(callingObject, 'Tag');

% extracts out the last numeric part (the column) from the 'Tag' (cell
% array)

objectNumber = str2double(callingHandleString(isstrprop(callingHandleString,'digit')));
%convert the number part of the tag into the object number

%get the object config information from the mainGUI
objectConfig = getappdata(handles.optimiseGUIHandles.MainGUI,'objectConfig');
objectType = objectConfig(objectNumber).type; %get which type of object this object is
objectTypes = getappdata(handles.optimiseGUIHandles.MainGUI,'objectTypes');
objectTypeName = objectTypes(objectType).name;

%generate question box which asks user if they are sure they want to change
%the default for this object type
question = sprintf('Are You Sure You Want To Change The Default Setting for a %s',objectTypeName);
title = sprintf('Change The Default for a %s ?',objectTypeName);
button = questdlg(question,title,'Yes','Cancel','Cancel');

if strcmp(button,'Yes') %if user selects yes
    devHandle = sprintf('dev%d',objectNumber); %generate handle to the deviation text box for this object
    noiseHandle = sprintf('noise%d',objectNumber); %generate handle to the noise text box for this object
    newDev = get(handles.(devHandle),'String'); %get string from text box
    newDev = str2num(newDev); %convert to number
    newNoise = get(handles.(noiseHandle),'String'); %get string from text box
    newNoise = str2num(newNoise); %convert to number
        
    objectTypes(objectType).allowedDeviation = newDev; %update the objectTypes structure
    objectTypes(objectType).allowedNoise= newNoise;
    
    setappdata(handles.optimiseGUIHandles.MainGUI,'objectTypes',objectTypes) %store in the appdata
end
%if user selects anything else then nothing happens


% Update handles structure
guidata(callingObject, handles);

Contact us