No BSD License  

Highlights from
INCA Matlab Auto Calibration Wizard

image thumbnail

INCA Matlab Auto Calibration Wizard

by

 

27 Sep 2007 (Updated )

This is a Matlab application which accesses the INCA API and guides users through the process of aut

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

% Last Modified by GUIDE v2.5 08-Mar-2006 10:34:37

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @configure_OpeningFcn, ...
                   'gui_OutputFcn',  @configure_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


function configure_OpeningFcn(hObject, eventdata, handles, varargin)
%%***********************************************************************
%%	Method: configure_OpeningFcn
%%	Purpose: Initializes variables to be used by configure.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      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 optimization (see VARARGIN)
%%	Returns: none
%%***********************************************************************
    % Choose default command line output for configure
    handles.output = hObject;
    
    %Initialize the global variable.
    handles.meas_vars=[];
    
    %Read in data from the autocal application.
    handles.meas_time = getappdata(0,'meas_time');
    handles.meas_delay = getappdata(0,'meas_delay');
    handles.savedata=getappdata(0,'savedata');
    handles.savepath=getappdata(0,'savepath');
    handles.variables=getappdata(0,'variables');
    handles.value_trigger = getappdata(0,'value_trigger');
    set(handles.return_to_best,'Value',getappdata(0,'return_to_best'))
    set(handles.enable_value,'Value',getappdata(0,'value_trigger_flag'))
    set(handles.enable_time,'Value',getappdata(0,'time_trigger_flag'))
    set(handles.report_value,'Value',getappdata(0,'report_value'))
    set(handles.report_time,'Value',getappdata(0,'report_time'))
    
    %If the value-based trigger is enabled, show the panel.
    if get(handles.enable_value,'Value') == 1.0
        set(handles.value_panel,'Visible','on')
    else
        set(handles.value_panel,'Visible','off')
    end

    %Update the GUI
    set(handles.meas_time_entry,'String',handles.meas_time);
    set(handles.meas_delay_entry,'String',handles.meas_delay);
    
    %If the recording option is enabled, update the GUI.
    if handles.savedata == true
        set(handles.save_data,'Value',1);
        set(handles.text3,'String',strcat([handles.savepath]));
        set(handles.text6,'Visible','on');
        set(handles.text3,'Visible','on');
    end

    %Convert the list of variables to a form to be used in the selection
    %list, and update the GUI.
    for counter=1:length(handles.variables(:,1))
        handles.meas_vars=[handles.meas_vars;{char(handles.variables{counter,1})}];
    end
    set(handles.value_var,'String',handles.meas_vars);

    %If a value-based trigger exists, update the GUI with it.
    if length(handles.value_trigger)>0
        set(handles.value_op,'Value',handles.value_trigger{1,5});
        set(handles.value_value,'String',num2str(handles.value_trigger{1,6}));
        location = 1;
        currentlisting = get(handles.value_var,'String');
        %Find the variable used for the trigger, and set the selection list
        %to it.
        for counter=1:length(currentlisting)
            if strcmp(strtrim(strcat(handles.value_trigger{1,1})),currentlisting{counter})
                location = counter;
            end
        end
        set(handles.value_var,'Value',location);
    end
    
    %Save globals.
    guidata(hObject, handles);


function varargout = configure_OutputFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: configure_OutputFcn
%%	Purpose: Directs the output for the GUI.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns:
%%      varargout:  cell array for returning output args (see VARARGOUT)
%%***********************************************************************
    % Get default command line output from handles structure
    varargout{1} = handles.output;


function meas_time_entry_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: meas_time_entry_Callback
%%	Purpose: Allows the user to save the length of the test to a global
%%      variable when meas_time_entry is changed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Store the contents of meas_time_entry to a global variable.
    handles.meas_time = get(hObject,'String');
    
    %Save globals.
    guidata(hObject, handles);


function meas_time_entry_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: meas_time_entry_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    guidata(hObject, handles);


function meas_delay_entry_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: meas_delay_entry_Callback
%%	Purpose: Allows the user to save the measurement delay to a global
%%      variable when meas_delay_entry is changed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Store the value of meas_delay_entry to a global variable.
    handles.meas_delay = get(hObject,'String');
    
    %Save globals.
    guidata(hObject, handles);


function meas_delay_entry_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: meas_delay_entry_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end
    guidata(hObject, handles);


function save_data_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: save_data_Callback
%%	Purpose: Allows the user to toggle data recording mode when the
%%      save_data checkbox is pressed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if get(hObject,'Value')==1
        %If the checkbox is "on"...
        %Prompt the user for a path to save the data.
        handles.savepath = uigetdir(pwd,'Select a Directory for Run Data');
        if (length(handles.savepath)>0)
            %As long as the user provided a path, set the save data flag to
            %true, and indicate where the data will be saved to the GUI.
            handles.savedata=true;
            set(handles.text3,'String',strcat([handles.savepath]));
            set(handles.text6,'Visible','on');
            set(handles.text3,'Visible','on');
        end
    else
        %If the checkbox is "off"...
        %Set the flag to false, clear the save location, and turn off
        %notifications of where data will be saved.
        handles.savedata=false;
        handles.savepath='';
        set(handles.text6,'Visible','off');
        set(handles.text3,'Visible','off');
    end
    
    %Save globals.
    guidata(hObject, handles);


function ok_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: ok_Callback
%%	Purpose: Allows the user to close the application when the OK button is
%%      pressed, saving changes.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if (get(handles.enable_time,'Value')==1 || get(handles.enable_value,'Value')==1)
        %As long as at least one trigger is enabled, continue.
        
        %Send application data back to the autocal application.
        setappdata(0,'action','ok');
        setappdata(0,'savedata',handles.savedata);
        setappdata(0,'savepath',handles.savepath);
        setappdata(0,'meas_time',str2num(get(handles.meas_time_entry,'String')));
        setappdata(0,'meas_delay',str2num(get(handles.meas_delay_entry,'String')));
        setappdata(0,'time_trigger_flag',get(handles.enable_time,'Value'));
        setappdata(0,'value_trigger_flag',get(handles.enable_value,'Value'));
        setappdata(0,'report_time',get(handles.report_time,'Value'));
        setappdata(0,'report_value',get(handles.report_value,'Value'));
        setappdata(0,'return_to_best',get(handles.return_to_best,'Value'));
        
        %Determine which variable is selected, and send that data back to
        %the autocal application.
        location = get(handles.value_var,'Value');
        handles.value_trigger=[{handles.variables{location,1},handles.variables{location,3},handles.variables{location,4},handles.variables{location,5},get(handles.value_op,'Value'),str2num(get(handles.value_value,'String'))}];
        setappdata(0,'value_trigger',handles.value_trigger);
        
        %Save globals.
        guidata(hObject, handles);
        
        %Close the application.
        close;
    else
        %Report that at least one trigger must be selected.
        errordlg('Error: At least one type of trigger must be enabled to run the experiment.  Please enable at least one type of trigger.','Trigger Error');
    end


function cancel_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: cancel_Callback
%%	Purpose: Allows the user to close the application when the Cancel
%%      button is pressed, ignoring changes.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %Send application data back to the autocal application.
    setappdata(0,'action','cancel');
    
    %Close the application.
    close;


function value_var_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: value_var_Callback
%%	Purpose: Executes on selection change in value_var.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.


function value_var_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: value_var_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end

 
function value_op_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: value_op_Callback
%%	Purpose: Executes on selection change in value_op.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.


function value_op_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: value_op_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end


function value_value_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: value_value_Callback
%%	Purpose: Executes when value_value is changed.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.


function value_value_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: value_value_CreateFcn
%%	Purpose: Executes during object creation, after setting all properties.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
        set(hObject,'BackgroundColor','white');
    end


function enable_value_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: enable_value_Callback
%%	Purpose: Allows the user to show or hide the value-based trigger panel
%%      and control the use of the value-based trigger.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if get(hObject,'Value') == 1.0
        %If enable_value is checked, show the panel.
        set(handles.value_panel,'Visible','on')
    else
        %Otherwise, hide the panel.
        set(handles.value_panel,'Visible','off')
    end
    
    %Save globals.
    guidata(hObject, handles);


function enable_time_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: enable_time_Callback
%%	Purpose: Allows the user to show or hide the time-based trigger panel
%%      and control the use of the time-based trigger.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    if get(hObject,'Value') == 1.0
        %If enable_time is checked, show the panel.
        set(handles.time_panel,'Visible','on')
    else
        %Otherwise, hide the panel.
        set(handles.time_panel,'Visible','off')
    end
    
    %Save globals.
    guidata(hObject, handles);


function report_value_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: report_value_Callback
%%	Purpose: Executes on button press in report_value.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.

 
function report_time_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: report_time_Callback
%%	Purpose: Executes on button press in report_time.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.


function return_to_best_Callback(hObject, eventdata, handles)
%%***********************************************************************
%%	Method: return_to_best_Callback
%%	Purpose: Executes on button press in return_to_best.
%%	Parameters:
%%      hObject: handle to quit (see GCBO)
%%      eventdata: reserved - to be defined in a future version of MATLAB
%%      handles: structure with handles and user data (see GUIDATA)
%%	Returns: none
%%***********************************************************************
    %This function does nothing.

Contact us