function varargout = advancededit(varargin)
% ADVANCEDEDIT M-file for advancededit.fig
% ADVANCEDEDIT, by itself, creates a new ADVANCEDEDIT or raises the existing
% singleton*.
%
% H = ADVANCEDEDIT returns the handle to a new ADVANCEDEDIT or the handle to
% the existing singleton*.
%
% ADVANCEDEDIT('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ADVANCEDEDIT.M with the given input arguments.
%
% ADVANCEDEDIT('Property','Value',...) creates a new ADVANCEDEDIT or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before advancededit_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to advancededit_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 advancededit
% Last Modified by GUIDE v2.5 06-Mar-2006 12:58:20
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @advancededit_OpeningFcn, ...
'gui_OutputFcn', @advancededit_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 advancededit_OpeningFcn(hObject, eventdata, handles, varargin)
%%***********************************************************************
%% Method: advancededit_OpeningFcn
%% Purpose: Initializes variables to be used by advancededit.
%% 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 advancededit
handles.output = hObject;
%Read in data from the autocal application.
handles.setuptasks= getappdata(0,'setuptasks');
handles.pretasks= getappdata(0,'pretasks');
handles.posttasks= getappdata(0,'posttasks');
handles.finaltasks= getappdata(0,'finaltasks');
set(handles.setuplist,'String',getappdata(0,'setuplist'));
set(handles.prelist,'String',getappdata(0,'prelist'));
set(handles.postlist,'String',getappdata(0,'postlist'));
set(handles.finallist,'String',getappdata(0,'finallist'));
handles.variables = getappdata(0,'variables');
handles.measvariables = getappdata(0,'measvariables');
%If at least one task of each type exists, enable the Remove button.
if length(get(handles.setuplist,'String'))>0
set(handles.setupremove,'Enable','on');
end
if length(get(handles.prelist,'String'))>0
set(handles.preremove,'Enable','on');
end
if length(get(handles.postlist,'String'))>0
set(handles.postremove,'Enable','on');
end
if length(get(handles.finallist,'String'))>0
set(handles.finalremove,'Enable','on');
end
%Convert the listing of variables into a form usable in a selection
%list, and update the GUI.
currentlisting = handles.variables(:,2);
for count=1:length(currentlisting)
currentlisting{count} = strtrim(currentlisting{count});
end
set(handles.setvariables,'String',currentlisting);
set(handles.avail_cal,'String',currentlisting);
%Convert the listing of measurement variables into a form usable is a
%selection list, and update the GUI.
currentlisting = handles.measvariables(:,1);
for count=1:length(currentlisting)
currentlisting{count} = strtrim(currentlisting{count});
end
set(handles.avail_meas,'String',currentlisting);
%Save globals.
guidata(hObject, handles);
function varargout = advancededit_OutputFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: advancededit_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: none
%%***********************************************************************
% Get default command line output from handles structure
varargout{1} = handles.output;
function setuplist_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setuplist_Callback
%% Purpose: Manages the functionality of Move Up and Move Down buttons
%% when the selection of setuplist 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(hObject,'Value')==1
%If the first task is selected, turn off the Move Up button.
set(handles.setupup,'Enable','off');
else
%Otherwise, turn on the Move Up button.
set(handles.setupup,'Enable','on');
end
if get(hObject,'Value')==length(get(hObject,'String'))
%If the last task is selected, turn off the Move Down button.
set(handles.setupdown,'Enable','off');
else
%Otherwise, turn on the Move Down button.
set(handles.setupdown,'Enable','on');
end
function setuplist_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setuplist_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 prelist_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: prelist_Callback
%% Purpose: Manages the functionality of Move Up and Move Down buttons
%% when the selection of prelist 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(hObject,'Value')==1
%If the first task is selected, turn off the Move Up button.
set(handles.preup,'Enable','off');
else
%Otherwise, turn on the Move Up button.
set(handles.preup,'Enable','on');
end
if get(hObject,'Value')==length(get(hObject,'String'))
%If the last task is selected, turn off the Move Down button.
set(handles.predown,'Enable','off');
else
%Otherwise, turn on the Move Down button.
set(handles.predown,'Enable','on');
end
function prelist_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: prelist_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 postlist_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: postlist_Callback
%% Purpose: Manages the functionality of Move Up and Move Down buttons
%% when the selection of postlist 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(hObject,'Value')==1
%If the first task is selected, turn off the Move Up button.
set(handles.postup,'Enable','off');
else
%Otherwise, turn on the Move Up button.
set(handles.postup,'Enable','on');
end
if get(hObject,'Value')==length(get(hObject,'String'))
%If the last task is selected, turn off the Move Down button.
set(handles.postdown,'Enable','off');
else
%Otherwise, turn on the Move Down button.
set(handles.postdown,'Enable','on');
end
function postlist_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: postlist_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 finallist_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: finallist_Callback
%% Purpose: Manages the functionality of Move Up and Move Down buttons
%% when the selection of finallist 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(hObject,'Value')==1
%If the first task is selected, turn off the Move Up button.
set(handles.finalup,'Enable','off');
else
%Otherwise, turn on the Move Up button.
set(handles.finalup,'Enable','on');
end
if get(hObject,'Value')==length(get(hObject,'String'))
%If the last task is selected, turn off the Move Down button.
set(handles.finaldown,'Enable','off');
else
%Otherwise, turn on the Move Down button.
set(handles.finaldown,'Enable','on');
end
function finallist_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: finallist_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 waitsection_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: waitsection_Callback
%% Purpose: Executes on selection change in waitsection.
%% 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 waitsection_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: waitsection_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 waittime_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: waittime_Callback
%% Purpose: Executes on selection change in waittime.
%% 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 waittime_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: waittime_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 addwait_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: addwait_Callback
%% Purpose: Allows the user to add a wait task when the Add Task button 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
%%***********************************************************************
%As long as a time length has been supplied, proceed.
if (length(get(handles.waittime,'String'))>0)
%Constants defined for drop-down locations.
SETUP = 1;
PRE = 2;
POST = 3;
FINAL = 4;
%Based on which section is selected, define a different current GUI
%listing and database for storage.
switch(get(handles.waitsection,'Value'))
case SETUP
currentlisting = get(handles.setuplist,'String');
currentdb = handles.setuptasks;
case PRE
currentlisting = get(handles.prelist,'String');
currentdb = handles.pretasks;
case POST
currentlisting = get(handles.postlist,'String');
currentdb = handles.posttasks;
case FINAL
currentlisting = get(handles.finallist,'String');
currentdb = handles.finaltasks;
end
%Create a text line to be stored in the GUI, update the GUI, and
%add the task to the database.
displayline = strcat(['Pause for ',get(handles.waittime,'String'),' seconds']);
currentlisting = [currentlisting;{displayline}];
currentdb = [currentdb;{'wait' '' '' '' '' str2num(get(handles.waittime,'String')), ''}];
%Based on the section that is selected, update the GUI, enable
%buttons and store information into different variables.
switch(get(handles.waitsection,'Value'))
case SETUP
set(handles.setuplist,'String',currentlisting);
set(handles.setuplist,'Value',1);
set(handles.setupremove,'Enable','on');
handles.setuptasks = currentdb;
case PRE
set(handles.prelist,'String',currentlisting);
set(handles.prelist,'Value',1);
set(handles.preremove,'Enable','on');
handles.pretasks = currentdb;
case POST
set(handles.postlist,'String',currentlisting);
set(handles.postlist,'Value',1);
set(handles.postremove,'Enable','on');
handles.posttasks = currentdb;
case FINAL
set(handles.finallist,'String',currentlisting);
set(handles.finallist,'Value',1);
set(handles.finalremove,'Enable','on');
handles.finaltasks = currentdb;
end
%Save globals.
guidata(hObject, handles);
else
%Otherwise, notify the user of the error.
errordlg('Please provide an input in the "Time to Wait:" box.','Not Enough Information');
end
function setsection_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setsection_Callback
%% Purpose: Executes on selection change in setsection.
%% 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 setsection_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setsection_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 setvariables_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setvariables_Callback
%% Purpose: Executes on selection change in setvariables.
%% 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 setvariables_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setvariables_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 setvalue_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setvalue_Callback
%% Purpose: Executes on selection change in setvalue.
%% 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 setvalue_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setvalue_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 addset_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: addset_Callback
%% Purpose: Allows the user to add a set task when the Add Task button 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
%%***********************************************************************
%As long as a value is provided, proceed.
if (length(get(handles.setvalue,'String'))>0)
%Constants defined for the drop-down locations.
SETUP = 1;
PRE = 2;
POST = 3;
FINAL = 4;
%Based on which section is selected, define a different current GUI
%listing and database for storage.
switch(get(handles.setsection,'Value'))
case SETUP
currentlisting = get(handles.setuplist,'String');
currentdb = handles.setuptasks;
case PRE
currentlisting = get(handles.prelist,'String');
currentdb = handles.pretasks;
case POST
currentlisting = get(handles.postlist,'String');
currentdb = handles.posttasks;
case FINAL
currentlisting = get(handles.finallist,'String');
currentdb = handles.finaltasks;
end
%Determine which variable is selected, and retrieve its name.
listing = get(handles.setvariables,'String');
position = get(handles.setvariables,'Value');
%Create a new line of text for the task list box, and update the
%current listing.
displayline = strcat(['Set ',listing{position,:},' to ',get(handles.setvalue,'String')]);
currentlisting = [currentlisting;{displayline}];
%Trim the device and variable names for search purposes.
device=strcat(strtrim(handles.variables{position,1}));
varname=strcat(strtrim(handles.variables{position,2}));
%Determine which location in the cal will be calibrated, and what
%type of calibration will take place.
[positionx positiony type]=determinecal(device,varname);
%As long as an error was not returned from determinecal, proceed.
if positionx ~= -1
%Retrieve the set to value from the GUI, and add all task
%data to the database.
value=str2num(get(handles.setvalue,'String'));
currentdb = [currentdb;{'set' device varname positionx positiony value type}];
%Based on the section that is selected, update the GUI, enable
%buttons and store information into different variables.
switch(get(handles.setsection,'Value'))
case SETUP
set(handles.setuplist,'String',currentlisting);
set(handles.setuplist,'Value',1);
set(handles.setupremove,'Enable','on');
handles.setuptasks = currentdb;
case PRE
set(handles.prelist,'String',currentlisting);
set(handles.prelist,'Value',1);
set(handles.preremove,'Enable','on');
handles.pretasks = currentdb;
case POST
set(handles.postlist,'String',currentlisting);
set(handles.postlist,'Value',1);
set(handles.postremove,'Enable','on');
handles.posttasks = currentdb;
case FINAL
set(handles.finallist,'String',currentlisting);
set(handles.finallist,'Value',1);
set(handles.finalremove,'Enable','on');
handles.finaltasks = currentdb;
end
%Save globals.
guidata(hObject, handles);
end
else
%Otherwise, notify the user of the error.
errordlg('Please provide an input in the "To This Value:" box.','Not Enough Information');
end
function setupup_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setupup_Callback
%% Purpose: Allow the user to move a task up in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.setuplist,'Value');
currentlisting = get(handles.setuplist,'String');
%Move the selected task up one position.
currentlisting=[currentlisting(1:position-2);currentlisting(position);currentlisting(position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI
set(handles.setuplist,'Value',1);
set(handles.setuplist,'String',currentlisting);
%Move the selected task up one position in the database.
handles.setuptasks = [handles.setuptasks(1:position-2,:);handles.setuptasks(position,:);handles.setuptasks(position-1,:);handles.setuptasks(position+1:length(handles.setuptasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function setupdown_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setupdown_Callback
%% Purpose: Allow the user to move a task down in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.setuplist,'Value');
currentlisting = get(handles.setuplist,'String');
%Move the selected task down one position.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1);currentlisting(position);currentlisting(position+2:length(currentlisting))];
%Update the GUI
set(handles.setuplist,'Value',1);
set(handles.setuplist,'String',currentlisting);
%Move the selected task down one position in the database.
handles.setuptasks = [handles.setuptasks(1:position-1,:);handles.setuptasks(position+1,:);handles.setuptasks(position,:);handles.setuptasks(position+2:length(handles.setuptasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function setupremove_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: setupremove_Callback
%% Purpose: Allow the user to remove a task from the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.setuplist,'Value');
currentlisting = get(handles.setuplist,'String');
%Remove the selected task.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI
set(handles.setuplist,'Value',1);
set(handles.setuplist,'String',currentlisting);
%If there are no tasks in the listing, disable the remove, move up, and
%move down buttons.
if length(currentlisting)==0
set(hObject,'Enable','off')
set(handles.setupup,'Enable','off')
set(handles.setupdown,'Enable','off')
end
%Remove the selected task from the database.
handles.setuptasks = [handles.setuptasks(1:position-1,:);handles.setuptasks(position+1:length(handles.setuptasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function preup_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: preup_Callback
%% Purpose: Allow the user to move a task up in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.prelist,'Value');
currentlisting = get(handles.prelist,'String');
%Move the selected task up one position.
currentlisting=[currentlisting(1:position-2);currentlisting(position);currentlisting(position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI
set(handles.prelist,'Value',1);
set(handles.prelist,'String',currentlisting);
%Move the selected task up one position in the database.
handles.pretasks = [handles.pretasks(1:position-2,:);handles.pretasks(position,:);handles.pretasks(position-1,:);handles.pretasks(position+1:length(handles.pretasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function predown_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: predown_Callback
%% Purpose: Allow the user to move a task down in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.prelist,'Value');
currentlisting = get(handles.prelist,'String');
%Move the selected task down one position.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1);currentlisting(position);currentlisting(position+2:length(currentlisting))];
%Update the GUI
set(handles.prelist,'Value',1);
set(handles.prelist,'String',currentlisting);
%Move the selected task down one position in the database.
handles.pretasks = [handles.pretasks(1:position-1,:);handles.pretasks(position+1,:);handles.pretasks(position,:);handles.pretasks(position+2:length(handles.pretasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function preremove_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: preremove_Callback
%% Purpose: Allow the user to remove a task from the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.prelist,'Value');
currentlisting = get(handles.prelist,'String');
%Remove the selected task.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI
set(handles.prelist,'Value',1);
set(handles.prelist,'String',currentlisting);
%If there are no tasks in the listing, disable the remove, move up, and
%move down buttons.
if length(currentlisting)==0
set(hObject,'Enable','off')
set(handles.preup,'Enable','off')
set(handles.predown,'Enable','off')
end
%Remove the selected task from the database.
handles.pretasks = [handles.pretasks(1:position-1,:);handles.pretasks(position+1:length(handles.pretasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function postup_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: postup_Callback
%% Purpose: Allow the user to move a task up in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.postlist,'Value');
currentlisting = get(handles.postlist,'String');
%Move the selected task up one position.
currentlisting=[currentlisting(1:position-2);currentlisting(position);currentlisting(position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI
set(handles.postlist,'Value',1);
set(handles.postlist,'String',currentlisting);
%Move the selected task up one position in the database.
handles.posttasks = [handles.posttasks(1:position-2,:);handles.posttasks(position,:);handles.posttasks(position-1,:);handles.posttasks(position+1:length(handles.posttasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function postdown_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: postdown_Callback
%% Purpose: Allow the user to move a task down in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.postlist,'Value');
currentlisting = get(handles.postlist,'String');
%Move the selected task down one position.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1);currentlisting(position);currentlisting(position+2:length(currentlisting))];
%Update the GUI
set(handles.postlist,'Value',1);
set(handles.postlist,'String',currentlisting);
%Move the selected task down one position in the database.
handles.posttasks = [handles.posttasks(1:position-1,:);handles.posttasks(position+1,:);handles.posttasks(position,:);handles.posttasks(position+2:length(handles.posttasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function postremove_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: postremove_Callback
%% Purpose: Allow the user to remove a task from the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.postlist,'Value');
currentlisting = get(handles.postlist,'String');
%Remove the selected task.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI.
set(handles.postlist,'Value',1);
set(handles.postlist,'String',currentlisting);
%If there are no tasks in the listing, disable the remove, move up, and
%move down buttons.
if length(currentlisting)==0
set(hObject,'Enable','off')
set(handles.postup,'Enable','off')
set(handles.postdown,'Enable','off')
end
%Remove the selected task from the database.
handles.posttasks = [handles.posttasks(1:position-1,:);handles.posttasks(position+1:length(handles.posttasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function finalup_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: finalup_Callback
%% Purpose: Allow the user to move a task up in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.finallist,'Value');
currentlisting = get(handles.finallist,'String');
%Move the selected task up one position.
currentlisting=[currentlisting(1:position-2);currentlisting(position);currentlisting(position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI
set(handles.finallist,'Value',1);
set(handles.finallist,'String',currentlisting);
%Move the selected task up one position in the database.
handles.finaltasks = [handles.finaltasks(1:position-2,:);handles.finaltasks(position,:);handles.finaltasks(position-1,:);handles.finaltasks(position+1:length(handles.finaltasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function finaldown_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: finaldown_Callback
%% Purpose: Allow the user to move a task down in the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.finallist,'Value');
currentlisting = get(handles.finallist,'String');
%Move the selected task down one position.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1);currentlisting(position);currentlisting(position+2:length(currentlisting))];
%Update the GUI
set(handles.finallist,'Value',1);
set(handles.finallist,'String',currentlisting);
%Move the selected task down one position in the database.
handles.finaltasks = [handles.finaltasks(1:position-1,:);handles.finaltasks(position+1,:);handles.finaltasks(position,:);handles.finaltasks(position+2:length(handles.finaltasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function finalremove_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: finalremove_Callback
%% Purpose: Allow the user to remove a task from the task list.
%% 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
%%***********************************************************************
%Retrieve the location of the selected task, along with the selection
%list.
position = get(handles.finallist,'Value');
currentlisting = get(handles.finallist,'String');
%Remove the selected task.
currentlisting=[currentlisting(1:position-1);currentlisting(position+1:length(currentlisting))];
%Update the GUI.
set(handles.finallist,'Value',1);
set(handles.finallist,'String',currentlisting);
%If there are no tasks in the listing, disable the remove, move up, and
%move down buttons.
if length(currentlisting)==0
set(hObject,'Enable','off')
set(handles.finalup,'Enable','off')
set(handles.finaldown,'Enable','off')
end
%Remove the selected task from the database.
handles.finaltasks = [handles.finaltasks(1:position-1,:);handles.finaltasks(position+1:length(handles.finaltasks(:,1)),:)];
%Save globals.
guidata(hObject, handles);
function ok_button_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: ok_button_Callback
%% Purpose: Allow 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
%%***********************************************************************
%Send application data back to the autocal application.
setappdata(0,'setuptasks',handles.setuptasks);
setappdata(0,'pretasks',handles.pretasks);
setappdata(0,'posttasks',handles.posttasks);
setappdata(0,'finaltasks',handles.finaltasks);
setappdata(0,'setuplist',get(handles.setuplist,'String'));
setappdata(0,'prelist',get(handles.prelist,'String'));
setappdata(0,'postlist',get(handles.postlist,'String'));
setappdata(0,'finallist',get(handles.finallist,'String'));
setappdata(0,'status','ok');
%Close the application.
close;
function cancel_button_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: cancel_button_Callback
%% Purpose: Allow 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,'status','cancel');
%Close the application.
close;
function avail_meas_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: avail_meas_Callback
%% Purpose: Executes on selection change in avail_meas.
%% 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 avail_meas_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: avail_meas_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 avail_cal_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: avail_cal_Callback
%% Purpose: Executes on selection change in avail_cal.
%% 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 avail_cal_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: avail_cal_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 add_to_func_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: add_to_func_Callback
%% Purpose: Allow the user to add a variable to the end of the function
%% when the Add to End of Function button 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
%%***********************************************************************
%Determine which variable is selected, and retrieve the name of that
%variable.
position = get(handles.avail_meas,'Value');
available = get(handles.avail_meas,'String');
name = available{position};
%Retrieve the current function, add the variable to the end of the
%function, and update the GUI with the new function.
current_function = get(handles.calc_func,'String');
new_function = strcat([current_function,name]);
set(handles.calc_func,'String',new_function);
%Save globals.
guidata(hObject, handles);
function calc_func_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: calc_func_Callback
%% Purpose: Executes on change in calc_func.
%% 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 calc_func_CreateFcn(hObject, eventdata, handles)
%%***********************************************************************
%% Method: calc_func_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 add_calc_Callback(hObject, eventdata, handles)
%%***********************************************************************
%% Method: add_calc_Callback
%% Purpose: Allow the user to add a calculation Task when the Add Task
%% button 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
%%***********************************************************************
%Determine which calibration variable is selected, and retrieve the
%name of the variable along with the device it is located on.
location = get(handles.avail_cal,'Value');
varname = handles.variables{location,2};
device = handles.variables{location,1};
%Find out which position of the calibration variable will be
%calibrated, along with the type of calibration.
[positionx positiony type] = determinecal(device,varname);
if positionx ~= -1
%As long as the proper information is supplied, add the task to the
%database, and update the GUI with the new task.
handles.posttasks = [handles.posttasks;{'calc' device varname positionx positiony get(handles.calc_func,'String') type}];
taskname = strcat([strcat(strtrim(varname)),' = ',get(handles.calc_func,'String')]);
set(handles.postlist,'String',[get(handles.postlist,'String');{taskname}]);
set(handles.calc_func,'String','');
set(handles.postlist,'Value',1);
%Enable remove button for post-tasks area.
set(handles.postremove,'Enable','on');
end
%Save globals.
guidata(hObject, handles);
function [posx posy type]=determinecal(device,varname)
%%***********************************************************************
%% Method: determinecal
%% Purpose: Allows user to select INCA Database when Change Database
%% button is pressed.
%% Parameters:
%% device (String): Name of device
%% varname (String): Name of Variable
%% Returns:
%% posx (int): X-Position to be written to
%% posy (int): Y-Position to be written to
%% type (int): Type of calibration
%%***********************************************************************
%Initialize the position and type variables.
posx = 0;
posy = 0;
type='v';
%Retrieve the calibration variable, and determine the size of the
%variable.
a = IncaGetCalibrationValue(device,varname);
[columns,rows] = size(a);
if rows==1 && columns==1
%This is a scalar... no further action needed.
elseif rows>1 && columns>1
%This is a map. Now, prompt for data or breakpoints.
%Constants for the drop-down list locations.
XBREAKPOINT = 1;
YBREAKPOINT = 2;
DATA = 3;
%Prompt user to find out which type of data they would like to
%calibrate.
calibrationtype = listdlg('PromptString','Would you like to calibrate a breakpoint, or data?','Name','Calibration Type','ListString',{'X-Breakpoint','Y-Breakpoint','Data'},'SelectionMode','single','ListSize',[300 160]);
switch(calibrationtype)
case XBREAKPOINT %X-Breakpoint Calibration was chosen.
message = strcat(['You are calibrating an array of size 1 x ',num2str(columns),'. Please specify which column you would like to calibrate:']);
location = inputdlg(message,'Enter Write Location');
type=='x'
posx = str2num(location{1});
case YBREAKPOINT %Y-Breakpoint Calibration was chosen.
message = strcat(['You are calibrating an array of size ',num2str(rows),' x 1. Please specify which row you would like to calibrate:']);
location = inputdlg(message,'Enter Write Location');
type=='y'
posy = str2num(location{1});
case DATA %Data Calibration was chosen.
message = strcat(['You are mapping a map of size ',num2str(rows),' x ',num2str(columns),'. Please input the row number you would like to write to:']);
message2 = 'Please input the column number you would like to write to:';
answer = inputdlg({message,message2},'Enter Write Location');
row = answer{1};
posy = str2num(row);
column = answer{2};
posx = str2num(column);
type = 'v';
end
else
BREAKPOINT = 1;
DATA = 2;
%This is possibly a value block or curve. This should be determined.
try
a = IncaGetCalibrationValue(device,varname,'x');
%If this portion does not fail, the variable is a curve. Now,
%whether data or breakpoints should be set must be determined.
if rows==1
%Prompt user for the calibration type.
calibrationtype = listdlg('PromptString','Would you like to calibrate a breakpoint, or data?','Name','Calibration Type','ListString',{'X-Breakpoint','Data'},'SelectionMode','single','ListSize',[300 160]);
type = 'x';
target = 'column'
else
%Prompt user for the calibration type.
calibrationtype = listdlg('PromptString','Would you like to calibrate a breakpoint, or data?','Name','Calibration Type','ListString',{'Y-Breakpoint','Data'},'SelectionMode','single','ListSize',[300 160]);
type = 'y';
target = 'row';
end
%If the user has chosen to calibrate data, set the type
%variable appropriately.
if calibrationtype == DATA
type='v';
end
catch
%This variable is a value block where only data can be set.
type='v';
%Specify the write target appropriately depending on the size
%of the value block.
if rows==1
target='column';
else
target='row';
end
end
%Now, prompt the user for which cell should be calibrated.
message = strcat(['You are calibrating an array of size ',num2str(rows),' x ',num2str(columns),'. Please specify which ',target,' you would like to calibrate:']);
location = inputdlg(message,'Enter Write Location');
%Set the appropriate write location, depending on the size of the
%array.
if rows==1
posx = str2num(location{1})
else
posy = str2num(location{1})
end
if posx<=columns && posy<=rows
else
%If the user is tying to calibrate a location outside of the
%size of the variable, alert the user.
posx=-1;
errordlg('You have selected a position larger than the size of this variable. Please try again.','Location Error');
end
end