function varargout = addmmlmenu(h, Command)
%  ADDMENUAO - Menu to tune AO parameters
%
%  INPUTS
%  1. h - handles to the parent figure
%  2. Command - Build {Default} builds menu
%               Action used for callback (edition, ...)
%               NoAction
%  3. LabelString - if Build command
%  4. ParentLabelString - if Build command
%
%  OUPUTS
%  1. hmenu - handles to admenu
%
%  See Also addmenuao, addmenuad

%
% Written by Laurent S. Nadolski

% TODO: this is just for testing

if nargin < 1
    h = gcf;
end
if nargin < 2
    Command = 'Build';
end

switch lower(Command)
    case 'build'

        if nargin < 3
            LabelString = 'Middle Layer Family Setup';
        end
        if nargin < 4
            ParentLabelString = 'MiddleLayer';
        end

        if strcmpi(get(h,'Type'), 'figure')
            h_childen = get(gcf,'children');
            EditMenuFlag = 0;
            for i = 1:length(h_childen)
                if ~strcmpi(get(h_childen(i),'Type'),'uicontrol') && ...
                        strcmpi(get(h_childen(i),'label'), ParentLabelString)
                    EditMenuFlag = 1;
                    h = h_childen(i);
                    break;
                end
            end
            if ~EditMenuFlag
                % Make an edit menu
                h = uimenu(h, 'Label', ParentLabelString, 'Callback','');
            end
            hmenu = uimenu(h, 'Label', LabelString, 'Callback','');
        elseif strcmpi(get(h,'Type'), 'uimenu')
            if isempty(findstr(get(h, 'Label'), 'Middle Layer'))
                hmenu = uimenu(h, 'Label', LabelString, 'Callback','');
            else
                hmenu = h;
            end
        else
            hmenu = h;
        end

        varargout{1} = hmenu;

        %% Build tree
        appdata = [];
        h146 = uimenu(...
            'Parent',h,...
            'Label','Lattice',...
            'Separator','on',...
            'Tag','LatticeMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'THESEMENUSRUN';

        h147 = uimenu(...
            'Parent',h146,...
            'Label','THESE MENUS RUN IN THE MATLAB WINDOW',...
            'Tag','THESEMENUSRUN',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'Initialization';

        hmenu = uimenu( ...
            'Parent',h146,...
            'Label','Initialization',...
            'Separator','on',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'Tag','Initialization');
        h148= hmenu;
%         h148 = uimenu(...
%             'Parent',h146,...
%             'Label','Initialization',...
%             'Separator','on',...
%             'Tag','Initialization',...
%             'Behavior',get(0,'defaultuimenuBehavior'),...
%             'CreateFcn', {@local_CreateFcn, '', appdata} );

  
%         appdata = [];
%         appdata.lastValidTag = 'InitializetheMiddleLayer';

        hmenu = uimenu( ...
            'Parent',h148,...
            'Label','Initialize the Middle Layer (Default) - aoinit',...
            'Tag','InitializetheMiddleLayer');
        set(hmenu,'Callback', 'addmmlmenu(gcbo,''Action'')');

%         h149 = uimenu(...
%             'Parent',h148,...
%             'Callback','set(gcbf,''HandleVisibility'',''off''); try; aoinit; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred initializing the middle layer''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
%             'Label','Initialize the Middle Layer (Default) - aoinit',...
%             'Tag','InitializetheMiddleLayer',...
%             'Behavior',get(0,'defaultuimenuBehavior'),...
%             'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'InitializetheMiddleLayerfromFile';

        h150 = uimenu(...
            'Parent',h148,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setao(''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred initializing the middle layer''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Initialize the Middle Layer from File - setao('''')',...
            'Tag','InitializetheMiddleLayerfromFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SetOperationMode';

        h151 = uimenu(...
            'Parent',h148,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setoperationalmode; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred initializing the middle layer'');end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Set the Operation Mode - setoperationalmode',...
            'Tag','SetOperationMode',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'InitializeControlSystem';

        h152 = uimenu(...
            'Parent',h148,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; srinit(''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred initializing control system parameters''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Initialize Control System Parameters - srinit',...
            'Separator','on',...
            'Tag','InitializeControlSystem',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SwitchtoHardwareUnits';

        h153 = uimenu(...
            'Parent',h148,...
            'Callback','switch2hw;',...
            'Label','Switch to Hardware Units - switch2hw',...
            'Separator','on',...
            'Tag','SwitchtoHardwareUnits',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SwitchtoPhysicsUnits';

        h154 = uimenu(...
            'Parent',h148,...
            'Callback','switch2physics;',...
            'Label','Switch to Physics Units - switch2physics',...
            'Tag','SwitchtoPhysicsUnits',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SwitchtoOnlineMode';

        h155 = uimenu(...
            'Parent',h148,...
            'Callback','switch2online;',...
            'Label','Switch to Online Mode - switch2online',...
            'Separator','on',...
            'Tag','SwitchtoOnlineMode',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SwitchtoSimulateMode';

        h156 = uimenu(...
            'Parent',h148,...
            'Callback','switch2sim;',...
            'Label','Switch to Simulate Mode - switch2sim',...
            'Tag','SwitchtoSimulateMode',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'EditMiddleLayerAO';

        h157 = uimenu(...
            'Parent',h148,...
            'Label','Middle Layer Family Setup',...
            'Separator','on',...
            'Tag','EditMiddleLayerAO',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'EditMiddleLayerAD';

        h158 = uimenu(...
            'Parent',h148,...
            'Label','Middle Layer Parameter Setup',...
            'Tag','EditMiddleLayerAD',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'LatticeConfiguration';

        h159 = uimenu(...
            'Parent',h146,...
            'Label','Lattice Configuration',...
            'Separator','on',...
            'Tag','LatticeConfiguration',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'StandardizetoPresentLattice';

        h160 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; srcycle(''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred standardizing the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Standardize to Present Lattice - srcycle',...
            'Tag','StandardizetoPresentLattice',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'StandardizetoGoldenLattice';

        h161 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; srcycle(''Golden'',''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred standardizing the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Standardize to Golden Lattice - srcycle(''Golden'')',...
            'Tag','StandardizetoGoldenLattice',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'StandardizetoUserSelectableLatticeFile';

        h162 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; srcycle('''',''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred standardizing the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Standardize to User Selectable Lattice File - srcycle('''')',...
            'Tag','StandardizetoUserSelectableLatticeFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'LoadtheGoldenLattice';

        h163 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setmachineconfig(''Golden'',''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while loading the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Load the Golden Lattice and Set to Machine - setmachineconfig(''Golden'')',...
            'Separator','on',...
            'Tag','LoadtheGoldenLattice',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'LoadtheInjectionLattice';

        h164 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setmachineconfig(''Injection'',''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while loading the injection lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Load the Injection Lattice and Set to Machine - setmachineconfig(''Injection'')',...
            'Tag','LoadtheInjectionLattice',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'LoadaLatticefromFile';

        h165 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setmachineconfig(''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while loading the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Load a Lattice from File and Set to Machine - setmachineconfig',...
            'Tag','LoadaLatticefromFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SaveLatticetotheGoldenFile';

        h166 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; getmachineconfig(''Golden''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while saving the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Save Lattice to the Golden File - getmachineconfig(''Golden'')',...
            'Separator','on',...
            'Tag','SaveLatticetotheGoldenFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SaveLatticetotheInjectionFile';

        h167 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; getmachineconfig(''Injection''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while saving the injection lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Save Lattice to the Injection File - getmachineconfig(''Injection'')',...
            'Tag','SaveLatticetotheInjectionFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SaveLatticetoFile';

        h168 = uimenu(...
            'Parent',h159,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; getmachineconfig(''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while saving the lattice''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Save Lattice to File - getmachineconfig(''Archive'','''')',...
            'Tag','SaveLatticetoFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'CorrecttheOrbit';

        h169 = uimenu(...
            'Parent',h146,...
            'Label','Correct the Orbit ',...
            'Separator','on',...
            'Tag','CorrecttheOrbit',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OCBothPlanes';

        h170 = uimenu(...
            'Parent',h169,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setorbitdefault(''Display''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while correcting the orbit''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Both Planes - setorbitdefault',...
            'Tag','OCBothPlanes',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OCBothPlanesIncludeRF';

        h171 = uimenu(...
            'Parent',h169,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setorbitdefault(''Display'',''FitRF''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while correcting the orbit (including RF)''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Both Planes, Included RF - setorbitdefault(''FitRF'')',...
            'Tag','OCBothPlanesIncludeRF',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OCHorizontalPlane';

        h172 = uimenu(...
            'Parent',h169,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setorbitdefault(''Display'',''Horizontal''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while correcting the orbit''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Horizontal Planes - setorbitdefault(''Horizontal'')',...
            'Separator','on',...
            'Tag','OCHorizontalPlane',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OCHorizontalPlaneIncludeRF';

        h173 = uimenu(...
            'Parent',h169,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setorbitdefault(''Display'',''Horizontal'',''FitRF''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while correcting the orbit (including RF)''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Horizontal Planes, Included RF - setorbitdefault(''Horizontal'',''FitRF'')',...
            'Tag','OCHorizontalPlaneIncludeRF',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OCVerticalPlane';

        h174 = uimenu(...
            'Parent',h169,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setorbitdefault(''Display'',''Vertical''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while correcting the orbit''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Vertical Planes - setorbitdefault(''Vertical'')',...
            'Separator','on',...
            'Tag','OCVerticalPlane',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'CorrecttheTune';

        h175 = uimenu(...
            'Parent',h146,...
            'Label','Correct the Tune',...
            'Separator','on',...
            'Tag','CorrecttheTune',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SteptheTune';

        h176 = uimenu(...
            'Parent',h175,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; steptune; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while stepping the tune''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Step the Tune - steptune',...
            'Tag','SteptheTune',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SettheTune';

        h177 = uimenu(...
            'Parent',h175,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; settune; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while setting the tune''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Set the Tune - settune',...
            'Separator','on',...
            'Tag','SettheTune',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'CorrecttheChromaticity';

        h178 = uimenu(...
            'Parent',h146,...
            'Label','Correct the Chromaticity',...
            'Separator','on',...
            'Tag','CorrecttheChromaticity',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SteptheChromaticityHW';

        h179 = uimenu(...
            'Parent',h178,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; stepchro; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while stepping the chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Step the Chromaticity (Hardware Units) - stepchro',...
            'Tag','SteptheChromaticityHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SteptheChromaticity';

        h180 = uimenu(...
            'Parent',h178,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; stepchro(''Physics''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while stepping the chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Step the Chromaticity (Physics Units) - stepchro(''Physics'')',...
            'Tag','SteptheChromaticity',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SettheChromaticityHW';

        h181 = uimenu(...
            'Parent',h178,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setchro; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while setting the chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Set the Chromaticity (Hardware Units) - setchro',...
            'Separator','on',...
            'Tag','SettheChromaticityHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'SetptheChromaticity';

        h182 = uimenu(...
            'Parent',h178,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; setchro(''Physics''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while setting the chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Set the Chromaticity (Physics Units) - stepchro(''Physics'')',...
            'Tag','SetptheChromaticity',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'MeasureMenu';

        h183 = uimenu(...
            'Parent',h146,...
            'Label','Measure',...
            'Separator','on',...
            'Tag','MeasureMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'DispersionHW';

        h184 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measdisp(''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring dispersion''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion (Hardware Units) - measdisp(''Archive'','''')',...
            'Tag','DispersionHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'Dispersion';

        h185 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measdisp(''Physics'',''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring dispersion''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion (Physics Units) - measdisp(''Physics'',''Archive'','''')',...
            'Tag','Dispersion',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityHW';

        h186 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measchro(''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Chromaticity (Hardware Units) - measchro(''Archive'','''')',...
            'Separator','on',...
            'Tag','ChromaticityHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'Chromaticity';

        h187 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measchro(''Physics'',''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Chromaticity (Physics Units) - measchro(''Physics'',''Archive'','''')',...
            'Tag','Chromaticity',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h188 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measbpmresp; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Orbit Response Matrix - measbpmresp',...
            'Separator','on',...
            'Tag','OrbitResponseMatrix ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h189 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; meastuneresp; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring the tune response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Tune Response Matrix - meastuneresp',...
            'Tag','TuneResponseMatrix ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h190 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measchroresp; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring the chromaticity response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Chromaticity Response Matrix - measchroresp',...
            'Tag','ChromaticityResponseMatrix ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h191 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measdispresp; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring the dispersion response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion Response Matrix - measdispresp',...
            'Tag','DispersionResponseMatrix ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'LOCOInputData';

        h192 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; measlocodata; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring the LOCO data''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','LOCO Input Data - measlocodata',...
            'Separator','on',...
            'Tag','LOCOInputData',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h193 = uimenu(...
            'Parent',h183,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; quadcenter; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while measuring a quadrupole center''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Quadrupole Center - quadcenter',...
            'Separator','on',...
            'Tag','QuadrupoleCenter ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'MonitorMenu';

        h194 = uimenu(...
            'Parent',h146,...
            'Label','Monitor',...
            'Separator','on',...
            'Tag','MonitorMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OrbitSnapshot';

        h195 = uimenu(...
            'Parent',h194,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; getbpm(''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while saving the orbit''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Orbit (Snapshot) - getbpm(''Archive'','''')',...
            'Tag','OrbitSnapshot',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'Orbit3Minutes';

        h196 = uimenu(...
            'Parent',h194,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; monbpm(''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while monitoring the orbit''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Orbit (3 minutes) - monbpm(''Archive'','''')',...
            'Tag','Orbit3Minutes',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'MagnetPowerSupplyData';

        h197 = uimenu(...
            'Parent',h194,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; monmags(''Archive'',''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while monitoring the orbit''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Magnet Power Supply Data - monmags(''Archive'','''')',...
            'Separator','on',...
            'Tag','MagnetPowerSupplyData',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'PlottingandAnalysis';

        h198 = uimenu(...
            'Parent',h146,...
            'Label','Plotting and Analysis',...
            'Separator','on',...
            'Tag','PlottingandAnalysis',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OrbitwrtGoldenOrbit';

        h199 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotorbit(''Golden''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Orbit w.r.t. Golden Orbit - plotorbit(''Golden'')',...
            'Tag','OrbitwrtGoldenOrbit',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OrbitwrtOffsetOrbit';

        h200 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotorbit(''Offset''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Orbit w.r.t. Offset Orbit - plotorbit(''Offset'')',...
            'Tag','OrbitwrtOffsetOrbit',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'GoldenOrbit';

        h201 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotgoldenorbit; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Golden Orbit - plotgoldenorbit',...
            'Separator','on',...
            'Tag','GoldenOrbit',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h202 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotoffsetorbit; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Offset Orbit - plotoffsetorbit',...
            'Tag','OffsetOrbit ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotcm';

        h203 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotcm; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Correctors - plotcm',...
            'Separator','on',...
            'Tag','plotcm',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h204 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotlattice(''Golden''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Golden Magnet Lattice - plotlattice(''Golden'');',...
            'Separator','on',...
            'Tag','GoldenLattice ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'BPMSigmaDefault';

        h205 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotorbitdata([getfamilydata(''Directory'',''OpsData''), getfamilydata(''OpsData'',''BPMSigmaFile'')]); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting BPM sigma data''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Sigma (Default)',...
            'Separator','on',...
            'Tag','BPMSigmaDefault',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'BPMSigmaFromFile';

        h206 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotorbitdata([getfamilydata(''Directory'',''DataRoot''),''BPM'',filesep]); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting BPM sigma data''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Sigma (From File)',...
            'Tag','BPMSigmaFromFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotbpmresp';

        h207 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotbpmresp; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Response Matrix (Default) - plotbpmresp;',...
            'Separator','on',...
            'Tag','plotbpmresp',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotbpmrespFile';

        h208 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotbpmresp(''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Response Matrix (From File) - plotbpmresp('''');',...
            'Tag','plotbpmrespFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotbpmrespSym';

        h209 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotbpmrespsym; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Response Matrix Symmetry (Default) - plotbpmrespsym;',...
            'Separator','on',...
            'Tag','plotbpmrespSym',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotbpmrespSymFile';

        h210 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotbpmrespsym(''''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Response Matrix Symmetry (From File) - plotbpmrespsym('''');',...
            'Tag','plotbpmrespSymFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotbpmrespError';

        h211 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotbpmresp(''Error''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Response Matrix Error (Default) - plotbpmresp(''Error'')',...
            'Separator','on',...
            'Tag','plotbpmrespError',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotbpmrespErrorFile';

        h212 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotbpmresp('''',''Error''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the BPM response matrix''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','BPM Response Matrix Error (From File) - plotbpmresp('''',''Error'');',...
            'Tag','plotbpmrespErrorFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'DispersionHW';

        h213 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotdisp(''Hardware''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the dispersion''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion (Default, Hardware Units) - plotdisp(''Hardware'')',...
            'Separator','on',...
            'Tag','DispersionHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'DispersionPhysics';

        h214 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotdisp(''Physics''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the dispersion''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion (Default, Physics Units) - plotdisp(''Physics'')',...
            'Tag','DispersionPhysics',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'DispersionHWFile';

        h215 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotdisp('''',''Hardware''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the dispersion''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion (From File, Hardware Units) - plotdisp('''',''Hardware'')',...
            'Tag','DispersionHWFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'DispersionPhysicsFile';

        h216 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotdisp('''',''Physics''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the dispersion''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Dispersion (From File, Physics Units) - plotdisp('''',''Physics'')',...
            'Tag','DispersionPhysicsFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityHWFile';

        h217 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotchro(''Hardware''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Chromaticity (From File, Hardware Units) - plotchro(''Hardware'')',...
            'Separator','on',...
            'Tag','ChromaticityHWFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityPhysicsFile';

        h218 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotchro(''Physics''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the chromaticity''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Chromaticity (From File, Physics Units) - plotchro(''Physics'')',...
            'Tag','ChromaticityPhysicsFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'QuadrupoleCenterPlot';

        h219 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; quadplot; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting the quadrupole center data''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Quadrupole Center',...
            'Separator','on',...
            'Tag','QuadrupoleCenterPlot',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'monmagplot';

        h220 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; monmags(1); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting BPM magnet data''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Magnet Noise - monmags(1)',...
            'Separator','on',...
            'Tag','monmagplot',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'plotorbitdata';

        h221 = uimenu(...
            'Parent',h198,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; plotorbitdata; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while plotting data''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','General Plotting Program (Orbit, Dispersion, Response, etc) - plotorbitdata',...
            'Separator','on',...
            'Tag','plotorbitdata',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'BuildLOCOInput';

        h222 = uimenu(...
            'Parent',h198,...
            'Callback','buildlocoinput',...
            'Label','Build LOCO Input File - buildlocoinput',...
            'Separator','on',...
            'Tag','BuildLOCOInput',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ModelFunctionMenu';

        h223 = uimenu(...
            'Parent',h146,...
            'Label','Model Functions',...
            'Separator','on',...
            'Tag','ModelFunctionMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h224 = uimenu(...
            'Parent',h223,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; modeltwiss(''Beta''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Plot the Model Beta Function - modeltwiss(''Beta'') or modelbeta',...
            'Tag','ModelBetaFunction ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ModelPhaseAdvance';

        h225 = uimenu(...
            'Parent',h223,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; modeltwiss(''Phase''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Plot the Model Phase Advance - modeltwiss(''Phase'')',...
            'Tag','ModelPhaseAdvance',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ModelDispersion';

        h226 = uimenu(...
            'Parent',h223,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; modeltwiss(''Eta''); catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','Plot the Model Dispersion - modeltwiss(''Eta'')',...
            'Tag','ModelDispersion',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'UpdateOnlineAccelerator';

        h227 = uimenu(...
            'Parent',h223,...
            'Callback','plotfamily_export(''Sim2Machine_Callback'',gcbo,[],guidata(gcbo));',...
            'Label','Update the Online Accelerator with the Model - sim2machine',...
            'Separator','on',...
            'Tag','UpdateOnlineAccelerator',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'UpdatetheModel';

        h228 = uimenu(...
            'Parent',h223,...
            'Callback','plotfamily_export(''Machine2Sim_Callback'',gcbo,[],guidata(gcbo));',...
            'Label','Update the Model/Simulator - machine2sim',...
            'Tag','UpdatetheModel',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'UpdatetheModelWithGoldenLattice';

        h229 = uimenu(...
            'Parent',h223,...
            'Callback','golden2sim;',...
            'Label','Update the Model/Simulator with the Golden Lattice - golden2sim',...
            'Tag','UpdatetheModelWithGoldenLattice',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ExporttoWorkspace';

        h230 = uimenu(...
            'Parent',h146,...
            'Label','Export to Workspace',...
            'Separator','on',...
            'Tag','ExporttoWorkspace',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'MachineConfigurationStructure';

        h231 = uimenu(...
            'Parent',h230,...
            'Callback','[SP, AM] = getmachineconfig; SP',...
            'Label','Machine Configuration Structure:  [SP, AM] = getmachineconfig',...
            'Tag','MachineConfigurationStructure',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'OrbitExportMenu';

        h232 = uimenu(...
            'Parent',h230,...
            'Label','Orbit',...
            'Separator','on',...
            'Tag','OrbitExportMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'getx';

        h233 = uimenu(...
            'Parent',h232,...
            'Callback','x = getx;',...
            'Label','x = getx;',...
            'Tag','getx',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'gety';

        h234 = uimenu(...
            'Parent',h232,...
            'Callback','y = gety;',...
            'Label','y = gety;',...
            'Tag','gety',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'CorrectorExportMenu';

        h235 = uimenu(...
            'Parent',h230,...
            'Label','Correctors',...
            'Separator','on',...
            'Tag','CorrectorExportMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'HCMam';

        h236 = uimenu(...
            'Parent',h235,...
            'Callback','HCMam = getam(''HCM'');',...
            'Label','HCMam = getam(''HCM'');',...
            'Tag','HCMam',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'HCMsp';

        h237 = uimenu(...
            'Parent',h235,...
            'Callback','HCMsp = getsp(''HCM'');',...
            'Label','HCMsp = getsp(''HCM'');',...
            'Tag','HCMsp',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'VCMam';

        h238 = uimenu(...
            'Parent',h235,...
            'Callback','VCMam = getam(''VCM'');',...
            'Label','VCMam = getam(''VCM'');',...
            'Separator','on',...
            'Tag','VCMam',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'VCMsp';

        h239 = uimenu(...
            'Parent',h235,...
            'Callback','VCMsp = getsp(''VCM'');',...
            'Label','VCMsp = getsp(''VCM'');',...
            'Tag','VCMsp',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'TuneExportMenu';

        h240 = uimenu(...
            'Parent',h230,...
            'Label','Tune',...
            'Separator','on',...
            'Tag','TuneExportMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'TuneGolden';

        h241 = uimenu(...
            'Parent',h240,...
            'Callback','TuneGolden = getgolden(''TUNE'',[1 1;1 2])',...
            'Label','Tunes (Golden):  TuneGolden = getgolden(''TUNE'',[1 1;1 2])',...
            'Tag','TuneGolden',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'TuneModel';

        h242 = uimenu(...
            'Parent',h240,...
            'Callback','TuneModel = gettune(''Model'')',...
            'Label','Tunes (Model):  TuneModel = gettune(''Model'')',...
            'Tag','TuneModel',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChroExportMenu';

        h243 = uimenu(...
            'Parent',h230,...
            'Label','Chromaticity',...
            'Separator','on',...
            'Tag','ChroExportMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityGoldenHW';

        h244 = uimenu(...
            'Parent',h243,...
            'Callback','ChroGoldenHardware = -getgolden(''Chromaticity'') / getrf / getmcf',...
            'Label','Chromaticity (Golden, Hardware Units):  ChroGoldenHardware = -getgolden(''Chromaticity'') / getrf / getmcf',...
            'Tag','ChromaticityGoldenHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityGolden';

        h245 = uimenu(...
            'Parent',h243,...
            'Callback','ChroGoldenPhysics = getgolden(''Chromaticity'')',...
            'Label','Chromaticity (Golden, Physics Units):  ChroGoldenPhysics = getgolden(''Chromaticity'')',...
            'Tag','ChromaticityGolden',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityModelHW';

        h246 = uimenu(...
            'Parent',h243,...
            'Callback','ChroModelHardware = measchro(''Model'',''Hardware'')',...
            'Label','Chromaticity (Model, Hardware Units):  ChroModelHardware = measchro(''Model'',''Hardware'')',...
            'Separator','on',...
            'Tag','ChromaticityModelHW',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityModel';

        h247 = uimenu(...
            'Parent',h243,...
            'Callback','ChroModelPhysics = measchro(''Model'',''Physics'')',...
            'Label','Chromaticity (Model, Physics Units):  ChroModelPhysics = measchro(''Model'',''Physics'')',...
            'Tag','ChromaticityModel',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityFile';

        h248 = uimenu(...
            'Parent',h243,...
            'Callback','C = getchro',...
            'Label','Get Chromaticity from a File (Vector):  C = getchro',...
            'Separator','on',...
            'Tag','ChromaticityFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityFileStructure';

        h249 = uimenu(...
            'Parent',h243,...
            'Callback','C = getchro(''Struct'')',...
            'Label','Get Chromaticity from a File (Stucture):  C = getchro(''Struct'') or getdata(''Chromaticity'',''Struct'')',...
            'Tag','ChromaticityFileStructure',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ResponseMatrixExportMenu';

        h250 = uimenu(...
            'Parent',h230,...
            'Label','Resonse Matrices',...
            'Separator','on',...
            'Tag','ResponseMatrixExportMenu',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'BPMResponseMatrixExport';

        h251 = uimenu(...
            'Parent',h250,...
            'Callback','BPMRespMatDefault = getbpmresp;',...
            'Label','BPM Response Matrix (Default):  BPMRespMatDefault = getbpmresp;',...
            'Tag','BPMResponseMatrixExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'BPMResponseMatrixExportFile';

        h252 = uimenu(...
            'Parent',h250,...
            'Callback','BPMRespMat =getbpmresp('''');',...
            'Label','BPM Response Matrix (From File):  BPMRespMat = getbpmresp('''');',...
            'Tag','BPMResponseMatrixExportFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'BPMResponseMatrixModelExport';

        h253 = uimenu(...
            'Parent',h250,...
            'Callback','BPMRespMatModel = measbpmresp(''Model'');',...
            'Label','BPM Response Matrix (Model):  BPMRespMatModel = measbpmresp(''Model'');',...
            'Tag','BPMResponseMatrixModelExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'TuneResponseMatrixExport';

        h254 = uimenu(...
            'Parent',h250,...
            'Callback','TuneRespMatDefault = gettuneresp',...
            'Label','Tune Response Matrix (Default):  TuneRespMatDefault = gettuneresp',...
            'Separator','on',...
            'Tag','TuneResponseMatrixExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'TuneResponseMatrixExportFile';

        h255 = uimenu(...
            'Parent',h250,...
            'Callback','TuneRespMat = gettuneresp('''')',...
            'Label','Tune Response Matrix (From File):  TuneRespMat = gettuneresp('''')',...
            'Tag','TuneResponseMatrixExportFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'TuneResponseMatrixTuneExport';

        h256 = uimenu(...
            'Parent',h250,...
            'Callback','TuneRespMatModel = meastuneresp(''Model'',''Matrix'')',...
            'Label','Tune Response Matrix (Model):  TuneRespMatModel = meastuneresp(''Model'',''Matrix'')',...
            'Tag','TuneResponseMatrixTuneExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityResponseMatrixHWExport';

        h257 = uimenu(...
            'Parent',h250,...
            'Callback','ChroRespMatDefaultHardware = getchroresp(''Hardware'')',...
            'Label','Chromaticity Response Matrix (Default, Hardware Units):  ChroRespMatDefaultHardware = getchroresp(''Hardware'')',...
            'Separator','on',...
            'Tag','ChromaticityResponseMatrixHWExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityResponseMatrixExport';

        h258 = uimenu(...
            'Parent',h250,...
            'Callback','ChroRespMatDefaultPhysics = getchroresp(''Physics'')',...
            'Label','Chromaticity Response Matrix (Default, Physics Units):  ChroRespMatDefaultPhysics = getchroresp(''Physics'')',...
            'Tag','ChromaticityResponseMatrixExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityResponseMatrixHWExportFile';

        h259 = uimenu(...
            'Parent',h250,...
            'Callback','ChroRespMatHardware = getchroresp('''',''Hardware'')',...
            'Label','Chromaticity Response Matrix (From File, Hardware Units):  ChroRespMatHardware = getchroresp('''',''Hardware'')',...
            'Separator','on',...
            'Tag','ChromaticityResponseMatrixHWExportFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityResponseMatrixExportFile';

        h260 = uimenu(...
            'Parent',h250,...
            'Callback','ChroRespMatPhysics = getchroresp('''',''Physics'')',...
            'Label','Chromaticity Response Matrix (From File, Physics Units):  ChroRespMatPhysics = getchroresp('''',''Physics'')',...
            'Tag','ChromaticityResponseMatrixExportFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityResponseMatrixModelHWExport';

        h261 = uimenu(...
            'Parent',h250,...
            'Callback','ChroRespMatModelHardware = measchroresp(''Model'',''Hardware'',''Matrix'')',...
            'Label','Chromaticity Response Matrix (Model, Hardware Units):  ChroRespMatModelHardware = measchroresp(''Model'',''Hardware'',''Matrix'')',...
            'Separator','on',...
            'Tag','ChromaticityResponseMatrixModelHWExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'ChromaticityResponseMatrixModelExport';

        h262 = uimenu(...
            'Parent',h250,...
            'Callback','ChroRespMatModelPhysics = measchroresp(''Model'',''Physics'',''Matrix'')',...
            'Label','Chromaticity Response Matrix (Model, Physics Units):  ChroRespMatModelHardware = measchroresp(''Model'',''Physics'',''Matrix'')',...
            'Tag','ChromaticityResponseMatrixModelExport',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewOperationalFiles';

        h263 = uimenu(...
            'Parent',h146,...
            'Label','New Operational Files',...
            'Separator','on',...
            'Tag','NewOperationalFiles',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'InfoTag';

        h264 = uimenu(...
            'Parent',h263,...
            'Label','THERE ARE 7 DATA FILES NEEDED IN THE MIDDLE LAYER',...
            'Tag','InfoTag',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewLatticeConfigurationFile';

        h265 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copymachineconfigfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','1. Copy New Lattice Configuration File to the Golden File - copymachineconfigfile',...
            'Separator','on',...
            'Tag','NewLatticeConfigurationFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewInjectionConfigurationFile';

        h266 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copyinjectionconfigfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','2. Copy New Injection Configuration File to the Golden File - copyinjectionconfigfile',...
            'Separator','on',...
            'Tag','NewInjectionConfigurationFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = '';

        h267 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copybpmsigmafile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','3. Copy New BPM Sigma File to the Golden File - copybpmsigmafile',...
            'Separator','on',...
            'Tag','NewBPMSigmaFile ',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewBPMResponseFile';

        h268 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copybpmrespfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','4. Copy New BPM Response File to the Golden File - copybpmrespfile',...
            'Separator','on',...
            'Tag','NewBPMResponseFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewTuneResponseFile';

        h269 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copytunerespfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','5. Copy New Tune Response File to the Golden File - copytunerespfile',...
            'Separator','on',...
            'Tag','NewTuneResponseFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewChromaticityResponseFile';

        h270 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copychrorespfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','6. Copy New Chromaticity Response File to the Golden File - copychrorespfile',...
            'Separator','on',...
            'Tag','NewChromaticityResponseFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewDispResponseFile';

        h271 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copydisprespfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','7. Copy New Dispersion Response File to the Golden File - copydisprespfile',...
            'Separator','on',...
            'Tag','NewDispResponseFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );

        appdata = [];
        appdata.lastValidTag = 'NewDispFile';

        h272 = uimenu(...
            'Parent',h263,...
            'Callback','set(gcbf,''HandleVisibility'',''off''); try; copydispersionfile; catch; fprintf(''%s\n'',lasterr); set(gcbf,''HandleVisibility'',''Callback''); disp(''   An error occurred while coping file''); end; set(gcbf,''HandleVisibility'',''Callback'');',...
            'Label','8. Copy New Dispersion File to the Golden File - copydispersionfile',...
            'Separator','on',...
            'Tag','NewDispFile',...
            'Behavior',get(0,'defaultuimenuBehavior'),...
            'CreateFcn', {@local_CreateFcn, '', appdata} );
    case 'action'
        
        Data = get(h, 'UserData');

        TagName = get(h,'Tag');
        switch TagName
            case 'InitializetheMiddleLayer'
                set(gcbf,'HandleVisibility','off'); 
                try; 
                    aoinit; 
                catch; 
                    fprintf('%s\n',lasterr); 
                    set(gcbf,'HandleVisibility','Callback'); 
                    disp('   An error occurred initializing the middle layer'); 
                end; 
                set(gcbf,'HandleVisibility','Callback');
            otherwise
        end
end