image thumbnail

XPC_COMMAND_CENTER

by

 

28 Nov 2004 (Updated )

xpc_command_center is a GUI to easily communicate to the xPC Target Application.

xpc_command_center.m
function varargout = xpc_command_center(varargin)
% XPC_COMMAND_CENTER xPC Target beginners introduction help gui
% 
%  The XPC_COMMAND_CENTER is for xPC Target beginners a GUI which should
%  help to get familiar with the commands as well the functionality. The
%  Buttons where possitioned in execution order as the commands should be 
%  executed. They have the corresponding xPC Commands shown as Tooltip for
%  having an overview of them.
%
%  XPC_COMMAND_CENTER_DIAG does read the File xpc_cmd_diag.mat which has the
%  Diagnostics information about the XPC_COMMAND_CENTER GUI if some
%  problems where found during execution. The MAT-File will be saved in the
%  TEMPDIR of MATLAB current Session.
%  Provide the MAT-File for furthermore support of functioanlity to 
%  Frank Gonzlez-Morphy ... frank.gonzalez-morphy@mathworks.de
%
%
%  Needed Files:      * xpc_command_center.m
%                     * TMW_Logo.jpg
%                     * xPC_LOGO_by_Frank_Gonzalez.bmp
%
%  Additional Files:  * xpc_command_center_diag.m
%
%  SYNTAX: >> xpc_command_center
% 
%  See also: XPC_COMMAND_CENTER_DIAG XPC_DISPLAY_LOGGED_DATA XPC_QUICK_REFERENCE

%% AUTHOR    : Frank Gonzalez-Morphy 
%% $DATE     : 25-June-2004 09:36:02 $ 
%% $Revision : 1.4.7 $ 
%% DEVELOPED : 7.0.0.19920 (R14) 
%% FILENAME  : xpc_command_center.m

% Last Modified by GUIDE v2.5 28-Jul-2004 10:05:39


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


% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @xpc_command_center_OpeningFcn, ...
                   'gui_OutputFcn',  @xpc_command_center_OutputFcn, ...
                   'gui_LayoutFcn',  @xpc_command_center_LayoutFcn, ...
                   'gui_Callback',   []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before xpc_command_center is made visible.
function xpc_command_center_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to xpc_command_center (see VARARGIN)

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

movegui('northwest');   % moves the window to left upper corner

% Setting Initialization Status of Buttons
set(handles.tag_btn_pci, 'Enable', 'off')
set(handles.tag_btn_tg_info, 'Enable', 'off')
set(handles.tag_btn_signals_on_off, 'Enable', 'off')
set(handles.tag_btn_show_parameter_on_off, 'Enable', 'off')
set(handles.tag_btn_start, 'Enable', 'off')
set(handles.tag_btn_stop, 'Enable', 'off')
set(handles.tag_btn_close_connection, 'Enable', 'off')
set(handles.tag_btn_spy, 'Enable', 'off')
set(handles.tag_btn_rctool, 'Enable', 'off')
set(handles.tag_btn_hscope, 'Enable', 'off')
set(handles.tag_btn_tscope, 'Enable', 'off')

% Putting The MathWorks Logo into Header
if exist('TMW_Logo.jpg') == 2
    [X,map] = imread('TMW_Logo.jpg');
    image('CData',X,'Parent',handles.tag_axes_logo);
    set(handles.tag_axes_logo, 'YDir' ,'reverse');
end

% Putting the xPC Logo by Frank Gonzlez-Morphy into Header
if exist('xPC_LOGO_by_Frank_Gonzalez.bmp') == 2
    [X,map] = imread('xPC_LOGO_by_Frank_Gonzalez.bmp');
    image('CData',X,'Parent',handles.tag_axes_xpclogo);
    set(handles.tag_axes_xpclogo, 'YDir' ,'reverse');
end

% Diagnostics Information about MATALB and xPC Target used Versions
handles.xpc_cmd_gui.ini = 'OK';
mlv = version;
handles.xpc_cmd_gui.mlversion = mlv;
xpcver = ver('xpc');
xpcv = [xpcver.Name ' ' xpcver.Version ' ' xpcver.Release];
handles.xpc_cmd_gui.xpcversion = xpcv;

% Update handles structure
guidata(hObject, handles);

% Set common TootipStrings of Buttons
set_tooltip_strings(handles)


% --- Outputs from this function are returned to the command line.
function varargout = xpc_command_center_OutputFcn(hObject, eventdata, handles)

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


% --- Executes on button press in tag_btn_close.
function tag_btn_close_Callback(hObject, eventdata, handles)

handles.xpc_cmd_gui.end = 'OK';
xpc_cmd_data.logged = handles.xpc_cmd_gui;
% Where Diagnostics Information will be saved:
fn = [tempdir 'xpc_cmd_diag'];
save(fn, 'xpc_cmd_data')

closereq;


% --- Executes on button press in tag_btn_rctool.
function tag_btn_rctool_Callback(hObject, eventdata, handles)

xpcrctool    % Opens the xPC Target Remote Control Tool

handles.xpc_cmd_gui.rctool = 'Called';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_tscope.
function tag_btn_tscope_Callback(hObject, eventdata, handles)

xpctgscope   % Opens the xPC Target Scope Manager

handles.xpc_cmd_gui.tgscope = 'Opened';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_hscope.
function tag_btn_hscope_Callback(hObject, eventdata, handles)

xpcscope;    % Opens the Host Scope Manager of xPC Target

handles.xpc_cmd_gui.hscope = 'Opened';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_pci.
function tag_btn_pci_Callback(hObject, eventdata, handles)

pcidevs = getxpcpci('all');  % Get a List of Installed PCI Boards on Target
if ~isempty(pcidevs)
    disp(' ')
    disp('  :: Installed PCI I/O-Boards on Target System:')
    disp('  ---------------------------------------------')
    % Header of Output
    fprintf(1,'%-5s%-5s%-5s%-30s%-20s%-30s%-10s%-10s\n\n',...
        'Bus','Slot','IRQ','Vendor Name','Device Name','Device Type','VendorID','DeviceID');
    % Sequence of founded Data
    for i=1:length(pcidevs)
        fprintf(1,'%-5s%-5s%-5s%-30s%-20s%-30s%-10s%-10s\n',...
            num2str(pcidevs(i).Bus),...
            num2str(pcidevs(i).Slot),...
            num2str(pcidevs(i).Interrupt),...
            pcidevs(i).VendorName,...
            pcidevs(i).DeviceName,...
            pcidevs(i).DeviceType,...
            pcidevs(i).VendorID,...
            pcidevs(i).DeviceID);
    end
    % pcidevs =
    % 1x5 struct array with fields:
    %     Bus
    %     Slot
    %     VendorID
    %     DeviceID
    %     BaseClass
    %     SubClass
    %     Interrupt
    %     BaseAddresses
    %     VendorName
    %     DeviceName
    %     DeviceType
    disp('  ---------------------------------------------')
    handles.xpc_cmd_gui.pcidevicesinstalled = pcidevs;
else
    disp(' ')
    disp(' Target doesn''t have any PCI Installed !')
    disp(' ')
    handles.xpc_cmd_gui.pcidevicesinstalled = 'None';
end

guidata(hObject, handles)

    
% --- Executes on button press in tag_btn_spy.
function tag_btn_spy_Callback(hObject, eventdata, handles)

xpctargetspy   % Opens the Window having a Screenshot of Target Display

handles.xpc_cmd_gui.spy = 'Tg Spyed';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_tgping.
function tag_btn_tgping_Callback(hObject, eventdata, handles)

Tping = xpctargetping;   % CMD: Check if MATLAB can communicate with Target
if (strcmp(Tping, 'failed'))  % ... not connected or wrong IP-Adr on PC
    set(handles.tag_btn_02_status_ping, ...
        'BackgroundColor', 'red', 'String', '', ...
        'TooltipString', [' Status: ' Tping])
    set(handles.tag_btn_01_status_xpcobj, ...
        'BackgroundColor', 'red', ...
        'TooltipString', ' Connected ?: None!')
    set(handles.tag_btn_create_xpc, 'Enable', 'off') % makes the Button unavailable
    m = msgbox([' ...', Tping],'Pinging Target System','error');
    movegui(m, 'center');
    set(handles.tag_btn_spy, 'Enable', 'off')
    set(handles.tag_btn_rctool, 'Enable', 'off')
    set(handles.tag_btn_hscope, 'Enable', 'off')
    set(handles.tag_btn_tscope, 'Enable', 'off')
    set(handles.tag_btn_pci, 'Enable', 'off')
    handles.xpc_cmd_gui.pinged = 'Failed';
else  % ... Connection successful
    set(handles.tag_btn_02_status_ping, ...
        'BackgroundColor', 'green', 'String', 'OK', ...
        'TooltipString', [' Status: ' Tping])
    m = msgbox(Tping,'Pinging Target System','help');
    movegui(m, 'center');
    set(handles.tag_btn_create_xpc', 'Enable', 'on')
    set(handles.tag_btn_spy, 'Enable', 'on')
    set(handles.tag_btn_rctool, 'Enable', 'on')
    set(handles.tag_btn_hscope, 'Enable', 'on')
    set(handles.tag_btn_tscope, 'Enable', 'on')
    handles.xpc_cmd_gui.pinged = 'Successfull';
end    

guidata(hObject, handles)


% --- Executes on button press in tag_btn_create_xpc.
function tag_btn_create_xpc_Callback(hObject, eventdata, handles)

tg = xpc;                     % Create a xPC Target Object
% if (strcmp(tg.Connected,'No'))
%     set(handles.tag_btn_01_status_xpcobj, 'BackgroundColor', 'red', ...
%         'TooltipString', [' Status: ' tg.Connected])
%     set(hObject, 'Enable', 'off') % makes the Button unavailable
% else  % Yes ... Target is Connected
if (strcmp(tg.Connected,'Yes'))
    set(handles.tag_btn_create_xpc, 'Enable', 'off')
    set(handles.tag_btn_01_status_xpcobj, ...
        'BackgroundColor', 'green', 'String', 'OK', ...
        'TooltipString', [' Status:  Successfull'])
    set(handles.tag_btn_02_status_ping, ...
        'BackgroundColor', 'green', 'String', 'OK', ...
        'TooltipString', [' Status: ' tg.Connected])
    set(handles.tag_btn_pci, 'Enable', 'on')
    set(handles.tag_btn_tg_info, 'Enable', 'on')
    set(handles.tag_btn_signals_on_off, 'Enable', 'on')
    set(handles.tag_btn_show_parameter_on_off, 'Enable', 'on')
    set(handles.tag_btn_spy, 'Enable', 'on')
    set(handles.tag_btn_rctool, 'Enable', 'on')
    set(handles.tag_btn_hscope, 'Enable', 'on')
    set(handles.tag_btn_tscope, 'Enable', 'on')
    set(handles.tag_btn_close_connection, 'Enable', 'on')
    set(handles.tag_btn_close, 'Enable', 'off')
    if strcmp(tg.Status, 'running')
        set(handles.tag_btn_start, 'Enable', 'Off')
        set(handles.tag_btn_stop, 'Enable', 'On')
        handles.xpc_cmd_gui.tgob = tg;   % save information on handle
        guidata(hObject, handles)        % save information of structure in GUI
        % watch if Target is Running
        looking_target_running(tg, hObject, eventdata, handles)  
    else
        if strcmp(tg.Application, 'loader')
            msg = ['Download Target Appl. to be able to Start or Stop.', ...
                    'Close Connection, Download and Create xPC Object again!', ...
                    'You can use the Remote Contro Tool for Downloading Application.'];
            m = msgbox(msg,'Target Running Status','error');
            movegui(m, 'center');
            return
        else           
            set(handles.tag_btn_start, 'Enable', 'On')
            set(handles.tag_btn_stop, 'Enable', 'Off')
        end
    end

end
handles.xpc_cmd_gui.tgob = tg;   % save information on handle
handles.xpc_cmd_gui.tg = 'Created';
guidata(hObject, handles)        % save information of structure in GUI


% --- Executes on button press in tag_btn_setup.
function tag_btn_setup_Callback(hObject, eventdata, handles)

xpcsetup    % Opens the xPC Target Setup Window

handles.xpc_cmd_gui.setup = 'Called';
guidata(hObject, handles)

% --- Executes on button press in tag_btn_01_status_xpcobj.
function tag_btn_01_status_xpcobj_Callback(hObject, eventdata, handles)
% Helper Buttons, none functionality

% --- Executes on button press in tag_btn_02_status_ping.
function tag_btn_02_status_ping_Callback(hObject, eventdata, handles)
% Helper Buttons, none functionality

% --- Executes on button press in tag_btn_getenv.
function tag_btn_getenv_Callback(hObject, eventdata, handles)

v = handles.xpc_cmd_gui.mlversion;
if v(1) == '7'
    commandwindow  % brings the MATLAB Command Window to front, only in R14
end
getxpcenv   % CMD: Shows in the MATLAB Command Window the current xPC Settings

figure(handles.tag_xpc_command_center) % Bring the GUI again to front

handles.xpc_cmd_gui.getxpcenv = 'YES';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_bookdisc.
function tag_btn_bookdisc_Callback(hObject, eventdata, handles)

xpcbootdisk    % CMD: Command Line oriented xPC Bootdisk creation

handles.xpc_cmd_gui.bootdisk = 'Called';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_close_connection.
function tag_btn_close_connection_Callback(hObject, eventdata, handles)

tg = handles.xpc_cmd_gui.tgob;
close(xpc);   % CMD: Close and gives free the MATLAB Target Communication
% st = close(xpc);  
st = 'Close';
disp(['  :: Connection Status: ' st]); disp(' ')

set(handles.tag_btn_create_xpc, 'Enable', 'on') 
set(handles.tag_btn_01_status_xpcobj, ...
    'BackgroundColor', [0.639 0.639 0.639], 'String', '', ...
    'TooltipString', [' Status:  Closed! '])
set(handles.tag_btn_02_status_ping, ...
    'BackgroundColor', [0.639 0.639 0.639], 'String', '', ...
    'TooltipString', [' Status: Closed!'])
set(handles.tag_btn_pci, 'Enable', 'off')
set(handles.tag_btn_tg_info, 'Enable', 'off')
set(handles.tag_btn_start, 'Enable', 'Off')
set(handles.tag_btn_stop, 'Enable', 'Off')
set(handles.tag_btn_signals_on_off, 'Enable', 'off')
set(handles.tag_btn_show_parameter_on_off, 'Enable', 'off')
set(handles.tag_btn_close_connection, 'Enable', 'off')
set(handles.tag_btn_close, 'Enable', 'On')

handles.xpc_cmd_gui.tgob = 'tgob Closed & Deleted';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_tg_info.
function tag_btn_tg_info_Callback(hObject, eventdata, handles)

tg = handles.xpc_cmd_gui.tgob  % CMD: Only tg brings actual information up

handles.xpc_cmd_gui.tginfo = 'Called';
guidata(hObject, handles)


% --- Executes on button press in tag_btn_signals_on_off.
function tag_btn_signals_on_off_Callback(hObject, eventdata, handles)

tg = handles.xpc_cmd_gui.tgob;
v = handles.xpc_cmd_gui.mlversion;
if v(1) == '7'
    commandwindow  % brings the MATLAB Command Window to front, only in R14
end
SigSt = tg.ShowS;  % Which is the Signal Show Status ?
if strcmp(lower(SigSt), 'on')
    tg.ShowS = 'Off';         % Switch Off the Signals display
else
    tg.ShowS = 'On';          % ... or ON.
end

tg                            % Show actual Signals

figure(handles.tag_xpc_command_center) % Bring the GUI again to front

handles.xpc_cmd_gui.ShowS = tg.ShowS; % Diagnostic Information
handles.xpc_cmd_gui.tgob = tg; % Update Target Information
guidata(hObject, handles)


% --- Executes on button press in tag_btn_show_parameter_on_off.
function tag_btn_show_parameter_on_off_Callback(hObject, eventdata, handles)

tg = handles.xpc_cmd_gui.tgob;
v = handles.xpc_cmd_gui.mlversion;
if v(1) == '7'
    commandwindow  % brings the MATLAB Command Window to front, only in R14
end
ParSt = tg.ShowP;  % Which is the Parameter Status ?
if strcmp(lower(ParSt), 'on')
    tg.ShowP = 'Off';         % Switch OFF the Parameter Display
else
    tg.ShowP = 'On';          % ... ON
end

tg                            % Show actual Parameters

figure(handles.tag_xpc_command_center) % Bring the GUI again to front

handles.xpc_cmd_gui.ShowP = tg.ShowP;  % Diagnostic Information
handles.xpc_cmd_gui.tgob = tg;         % Update Target Information
guidata(hObject, handles)


% --- Executes on button press in tag_btn_stop.
function tag_btn_stop_Callback(hObject, eventdata, handles)

tg = handles.xpc_cmd_gui.tgob;
stop(tg);   % = -tg;  % = tg.stop;   % CMD: Stop the running Target
set(handles.tag_btn_stop, 'Enable', 'off')
set(handles.tag_btn_start, 'Enable', 'on')

handles.xpc_cmd_gui.tgst = 'Stopped';
guidata(hObject, handles)

% --- Executes on button press in tag_btn_start.
function tag_btn_start_Callback(hObject, eventdata, handles)

tg = handles.xpc_cmd_gui.tgob;
start(tg);  % = +tg;  % = tg.start;  % CMD: Start the stopped Target
set(handles.tag_btn_start, 'Enable', 'off')
set(handles.tag_btn_stop, 'Enable', 'on')

looking_target_running(tg, hObject, eventdata, handles)  % watch if Target is Running

handles.xpc_cmd_gui.tgst = 'Started';
guidata(hObject, handles)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%  LOOKING_TARGET_RUNNING %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function looking_target_running(tg, hObject, eventdata, handles)
% looks if Target does Running, first when stop Disable Stop and Enable
% Start Button.
cl = get(handles.tag_btn_close_connection, 'Enable');     % Button Status
while (strcmp(tg.Status,'running') & strcmp(cl, 'on'))
    set(handles.tag_btn_stop, 'String' , '\'); pause(0.1)
    set(handles.tag_btn_stop, 'String' , '|'); pause(0.1)
    set(handles.tag_btn_stop, 'String' , '/'); pause(0.1)
    set(handles.tag_btn_stop, 'String' , '-'); pause(0.1)
    cl = get(handles.tag_btn_close_connection, 'Enable');  % update status
end
if strcmp(cl, 'on') % Only when Button Enabled, call action
    tag_btn_stop_Callback(hObject, eventdata, handles)
end

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

w = which('xpc_command_center');         % get who is these Appl saved
[pathstr,name,ext,versn] = fileparts(w); % get only the path ...
web([pathstr,'/html/xpc_command_center_help.html']) % call HTML Help in MATLAB Browser

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%   SET_TOOLTIP_STRINGS   %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function set_tooltip_strings(handles)
% Set all uicontrol ToolTipStrings, which are also Multiline Tooltips.
TP = 'TooltipString';

txt = sprintf(['Show on the MATLAB Command Window the \n', ...
    'current xPC Environment Settings \n(CMD: >> getxpcenv)']);
set(handles.tag_btn_getenv, TP, txt)

txt = sprintf(['Opens the Dialog to \n', ...
    'setup up Target Comunication \n(CMD: >> xpcsetup)']);
set(handles.tag_btn_setup, TP, txt)

txt = sprintf(['Creates an xPCTarget Bootdisk. \n', ...
    'Insert a Disquette on Floppydisk \n(CMD: >> xpcbootdisk)']);
set(handles.tag_btn_bookdisc, TP, txt)

txt = sprintf(['Does check if Target is \n', ...
    'connected and able to talk \n(CMD: >> xpctargetping)']);
set(handles.tag_btn_tgping, TP, txt)

txt = sprintf(['Creates an xPC Object to be able \n', ...
    'to talk with Target \n(CMD: >> tg = xpc)']);
set(handles.tag_btn_create_xpc, TP, txt)

txt = sprintf(['Gets a list of installed \n', ...
    'PCI I/O Boards on the Target \n(CMD: >> getxpcpci)']);
set(handles.tag_btn_pci, TP, txt)

txt = sprintf(['Display on the MATLAB Command Window \n', ...
    'the actual Target Application Information \n(CMD: >> tg)']);
set(handles.tag_btn_tg_info, TP, txt)

txt = sprintf(['Signals: Toggle between On and Off \n', ...
    '(CMD: >> tg.ShowS = ''On'' or ''Off'' )']);
set(handles.tag_btn_signals_on_off, TP, txt)

txt = sprintf(['Parameters: Toggle between On and Off \n', ...
    '(CMD: >> tg.ShowP = ''On'' or ''Off'' )']);
set(handles.tag_btn_show_parameter_on_off, TP, txt)

txt = sprintf(['Gives the MATLAB Access \n', ...
    'to the Target free \n(CMD: >> close(xpc) )']);
set(handles.tag_btn_close_connection, TP, txt)

txt = sprintf(['Open an Target Spy which creates a \n', ...
    'Target Screenshot \n(CMD: >> xpctargetspy)']);
set(handles.tag_btn_spy, TP, txt)

txt = sprintf(['Opens the xPC Target \n', ...
    'Remote Control Tool \n(CMD: >> xpcrctool)']);
set(handles.tag_btn_rctool, TP, txt)

txt = sprintf(['Opens the Host Scope Manager to \n', ...
    'view Data on the Host \n(CMD: >> xpcscope)']);
set(handles.tag_btn_hscope, TP, txt)

txt = sprintf(['Opens the Target Scope Manager to \n', ...
    'control the Scopes on Target \n(CMD: >> xpctgscope)']);
set(handles.tag_btn_tscope, TP, txt)

txt = sprintf(['Opens the HTML Help of the Application \n', ...
    'using the MATLAB own Browser GUI']);
set(handles.tag_btn_help, TP, txt)


% OVERVIEW of ALL Handle Names of used UIcontrols
% ===============================================
% handles = 
%            tag_xpc_command_center: 185.0057
%            tag_btn_02_status_ping: 199.0062
%          tag_btn_01_status_xpcobj: 198.0057
%                     tag_axes_logo: 193.0065
%                   tag_btn_tg_info: 192.0068
%                        tag_txt_fg: 191.0063
%                       tag_btn_tmw: 190.0056
%                 tag_txt_cmdcenter: 189.0057
%                 tag_txt_title_xpc: 188.0057
%                    tag_btn_tscope: 187.0057
%                    tag_btn_hscope: 40.0096
%                    tag_btn_rctool: 39.0096
%                       tag_btn_spy: 38.0096
%          tag_btn_close_connection: 37.0096
%     tag_btn_show_parameter_on_off: 36.0096
%            tag_btn_signals_on_off: 35.0096
%                      tag_btn_stop: 34.0096
%                     tag_btn_start: 33.0096
%                tag_btn_create_xpc: 32.0096
%                    tag_btn_tgping: 31.0122
%                       tag_btn_pci: 23.0037
%                  tag_btn_bookdisc: 22.0037
%                     tag_btn_setup: 21.0037
%                    tag_btn_getenv: 20.0037
%                     tag_btn_close: 19.0038
%                    tag_frame_btns: 186.0057
%                            output: 185.0057
% =========================================
                      
% By GUIDE created Graphical Structure ...


% --- Creates and returns a handle to the GUI figure. 
function h1 = xpc_command_center_LayoutFcn(policy)
% policy - create a new figure or use a singleton. 'new' or 'reuse'.

persistent hsingleton;
if strcmpi(policy, 'reuse') & ishandle(hsingleton)
    h1 = hsingleton;
    return;
end

appdata = [];
appdata.GUIDEOptions = struct(...
    'active_h', 190.002319335938, ...
    'taginfo', struct(...
    'figure', 2, ...
    'frame', 2, ...
    'pushbutton', 21, ...
    'text', 5, ...
    'axes', 4), ...
    'override', 0, ...
    'release', 13, ...
    'resize', 'none', ...
    'accessibility', 'callback', ...
    'mfile', 1, ...
    'callbacks', 1, ...
    'singleton', 1, ...
    'syscolorfig', 1, ...
    'blocking', 0, ...
    'lastSavedFile', 'D:\eigen\ml_sl_files\Vorlagen\xpc_command_center.m');
appdata.lastValidTag = 'tag_xpc_command_center';
appdata.GUIDELayoutEditor = [];

h1 = figure(...
'Units','characters',...
'PaperUnits',get(0,'defaultfigurePaperUnits'),...
'Color',[0.831372549019608 0.815686274509804 0.784313725490196],...
'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],...
'IntegerHandle','off',...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'MenuBar','none',...
'Name','  :: xPC Command Center ::  - v1.6',...
'NumberTitle','off',...
'PaperPosition',get(0,'defaultfigurePaperPosition'),...
'PaperSize',[20.98404194812 29.67743169791],...
'PaperType',get(0,'defaultfigurePaperType'),...
'Position',[103.8 15.5384615384616 53 50],...
'Renderer',get(0,'defaultfigureRenderer'),...
'RendererMode','manual',...
'Resize','off',...
'HandleVisibility','callback',...
'Tag','tag_xpc_command_center',...
'UserData',[],...
...'Behavior',get(0,'defaultfigureBehavior'),...
'Visible','on',...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h2 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'BackgroundColor',[0.63921568627451 0.63921568627451 0.63921568627451],...
'ListboxTop',0,...
'Position',[4.8 5.30769230769231 42.6 34.8461538461538],...
'String',{  '' },...
'Style','frame',...
'Tag','tag_frame_btns',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h3 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_close_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[34 0.615384615384615 13.2 1.76923076923077],...
'String','Close',...
'TooltipString','Closes the xPC Target Command Center',...
'Tag','tag_btn_close',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h4 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_getenv_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 37.3846153846154 24 1.84615384615385],...
'String','Show xPC settings',...
'Tag','tag_btn_getenv',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h5 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_setup_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 35.4615384615385 24 1.84615384615385],...
'String','Set xPC Environment',...
'Tag','tag_btn_setup',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h6 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_bookdisc_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 33.5384615384615 24 1.84615384615385],...
'String','Create BootDisk',...
'Tag','tag_btn_bookdisc',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h7 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_pci_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14.2 25.7692307692308 24 1.84615384615385],...
'String','Target PCI Info',...
'Tag','tag_btn_pci',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h8 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_tgping_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[13.8 30.3846153846154 24 1.84615384615385],...
'String','Target Ping',...
'Tag','tag_btn_tgping',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h9 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_create_xpc_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[13.8 28.3846153846154 24 1.84615384615385],...
'String','Create xPC Object',...
'Tag','tag_btn_create_xpc',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h10 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_start_Callback'',gcbo,[],guidata(gcbo))',...
'FontSize',13,...
'ListboxTop',0,...
'Position',[39.8 21.2307692307692 4 1.53846153846154],...
'String','+',...
'TooltipString','Starts the Target',...
'Tag','tag_btn_start',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h11 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_stop_Callback'',gcbo,[],guidata(gcbo))',...
'FontSize',13,...
'ListboxTop',0,...
'Position',[39.8 19.3846153846154 4 1.53846153846154],...
'String','-',...
'TooltipString','Stops the Target',...
'Tag','tag_btn_stop',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h12 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_signals_on_off_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 21.1538461538462 24 1.84615384615385],...
'String','Signals (On/Off)',...
'Tag','tag_btn_signals_on_off',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h13 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_show_parameter_on_off_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 19.2307692307692 24 1.84615384615385],...
'String','Parameter (On/Off)',...
'Tag','tag_btn_show_parameter_on_off',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h14 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_close_connection_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 16.7692307692308 24 1.84615384615385],...
'String','Close Connection',...
'Tag','tag_btn_close_connection',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h15 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_spy_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 12.7692307692308 24 1.84615384615385],...
'String','Spy Target',...
'Tag','tag_btn_spy',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h16 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_rctool_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 10.8461538461538 24 1.84615384615385],...
'String','Remote Control Tool',...
'Tag','tag_btn_rctool',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h17 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_hscope_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 8.15384615384616 24 1.84615384615385],...
'String','Host Scope Manager',...
'Tag','tag_btn_hscope',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h18 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_tscope_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 6.23076923076923 24 1.84615384615385],...
'String','Target Scope Manager',...
'Tag','tag_btn_tscope',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h19 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',16,...
'FontWeight','bold',...
'ListboxTop',0,...
'Position',[6.2 43.3076923076923 40.6 2],...
'String','xPC Target',...
'Style','text',...
'Tag','tag_txt_title_xpc',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h20 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontSize',16,...
'FontWeight','bold',...
'ListboxTop',0,...
'Position',[6.2 41.2307692307692 40.6 1.76923076923077],...
'String','Command Center',...
'Style','text',...
'Tag','tag_txt_cmdcenter',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h21 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontAngle','italic',...
'ListboxTop',0,...
'Position',[15 1.84615384615385 17 2.15384615384615],...
'String',{  'A Courtesy of '; 'The MathWorks' },...
'Style','text',...
'TooltipString','www.mathworks.com :: R14 GUI',...
'Tag','tag_btn_tmw',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h22 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'FontAngle','italic',...
'ListboxTop',0,...
'Position',[4.2 0.461538461538462 28 1.15384615384615],...
'String','by Frank Gonzlez-Morphy',...
'Style','text',...
'TooltipString','eMail Me: frank.gonzalez-morphy@mathworks.de',...
'Tag','tag_txt_fg',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h23 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_tg_info_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[14 23.0769230769231 24 1.84615384615385],...
'String','Show Target Info',...
'Tag','tag_btn_tg_info',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h24 = axes(...
'Parent',h1,...
'Units','characters',...
'Position',[6.6 45.7692307692308 39 3],...
'CameraPosition',[0.5 0.5 9.16025403784439],...
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),...
'Color',get(0,'defaultaxesColor'),...
'ColorOrder',get(0,'defaultaxesColorOrder'),...
...'LooseInset',[6.89 5.5 5.035 3.75],...
'XColor',get(0,'defaultaxesXColor'),...
'YColor',get(0,'defaultaxesYColor'),...
'ZColor',get(0,'defaultaxesZColor'),...
'Tag','tag_axes_logo',...
...'Behavior',get(0,'defaultaxesBehavior'),...
'Visible','off',...
'CreateFcn', {@local_CreateFcn, '', appdata} );

h25 = get(h24,'title');

set(h25,...
'Parent',h24,...
'Color',[0 0 0],...
'HorizontalAlignment','center',...
'Position',[0.5 1.16666666666667 1.00005459937205],...
'VerticalAlignment','bottom',...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

h26 = get(h24,'xlabel');

set(h26,...
'Parent',h24,...
'Color',[0 0 0],...
'HorizontalAlignment','center',...
'Position',[0.494871794871795 -0.602564102564103 1.00005459937205],...
'VerticalAlignment','cap',...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

h27 = get(h24,'ylabel');

set(h27,...
'Parent',h24,...
'Color',[0 0 0],...
'HorizontalAlignment','center',...
'Position',[-0.146153846153846 0.474358974358974 1.00005459937205],...
'Rotation',90,...
'VerticalAlignment','bottom',...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

h28 = get(h24,'zlabel');

set(h28,...
'Parent',h24,...
'Color',[0 0 0],...
'HorizontalAlignment','right',...
'Position',[-0.171794871794872 1.37179487179487 1.00005459937205],...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

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

h29 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_01_status_xpcobj_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[40.2 28.6153846153846 4 1.53846153846154],...
'String','',...
'TooltipString','Show Status of Command execution',...
'Tag','tag_btn_01_status_xpcobj',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h30 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_02_status_ping_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[40.2 30.4615384615385 4 1.53846153846154],...
'String','',...
'TooltipString','Shows Status of Command execution',...
'Tag','tag_btn_02_status_ping',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );

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

h31 = axes(...
'Parent',h1,...
'Units','characters',...
'Position',[4.8 1.15384615384615 9.4 3.76923076923077],...
'CameraPosition',[0.5 0.5 9.16025403784439],...
'CameraPositionMode',get(0,'defaultaxesCameraPositionMode'),...
'Color',get(0,'defaultaxesColor'),...
'ColorOrder',get(0,'defaultaxesColorOrder'),...
...'LooseInset',[6.89 5.5 5.035 3.75],...
'XColor',get(0,'defaultaxesXColor'),...
'YColor',get(0,'defaultaxesYColor'),...
'ZColor',get(0,'defaultaxesZColor'),...
'Tag','tag_axes_xpclogo',...
...'Behavior',get(0,'defaultaxesBehavior'),...
'Visible','off',...
'CreateFcn', {@local_CreateFcn, '', appdata} );

h32 = get(h31,'title');

set(h32,...
'Parent',h31,...
'Color',[0 0 0],...
'HorizontalAlignment','center',...
'Position',[0.5 1.13265306122449 1.00005459937205],...
'VerticalAlignment','bottom',...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

h33 = get(h31,'xlabel');

set(h33,...
'Parent',h31,...
'Color',[0 0 0],...
'HorizontalAlignment','center',...
'Position',[0.478723404255319 -0.47959183673469 1.00005459937205],...
'VerticalAlignment','cap',...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

h34 = get(h31,'ylabel');

set(h34,...
'Parent',h31,...
'Color',[0 0 0],...
'HorizontalAlignment','center',...
'Position',[-0.606382978723404 0.479591836734697 1.00005459937205],...
'Rotation',90,...
'VerticalAlignment','bottom',...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

h35 = get(h31,'zlabel');

set(h35,...
'Parent',h31,...
'Color',[0 0 0],...
'HorizontalAlignment','right',...
'Position',[-0.521276595744681 12.9285714285714 1.00005459937205],...
'HandleVisibility','off',...
...'Behavior',struct(),...
'Visible','off');

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

h36 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','xpc_command_center(''tag_btn_help_Callback'',gcbo,[],guidata(gcbo))',...
'ListboxTop',0,...
'Position',[37.2 2.76923076923077 7 1.76923076923077],...
'String','Help',...
'Tag','tag_btn_help',...
...'Behavior',get(0,'defaultuicontrolBehavior'),...
'CreateFcn', {@local_CreateFcn, '', appdata} );


hsingleton = h1;


% --- Set application data first then calling the CreateFcn. 
function local_CreateFcn(hObject, eventdata, createfcn, appdata)

if ~isempty(appdata)
   names = fieldnames(appdata);
   for i=1:length(names)
       name = char(names(i));
       setappdata(hObject, name, getfield(appdata,name));
   end
end

if ~isempty(createfcn)
   eval(createfcn);
end


% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin)


%   GUI_MAINFCN provides these command line APIs for dealing with GUIs
%
%      XPC_COMMAND_CENTER, by itself, creates a new XPC_COMMAND_CENTER or raises the existing
%      singleton*.
%
%      H = XPC_COMMAND_CENTER returns the handle to a new XPC_COMMAND_CENTER or the handle to
%      the existing singleton*.
%
%      XPC_COMMAND_CENTER('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in XPC_COMMAND_CENTER.M with the given input arguments.
%
%      XPC_COMMAND_CENTER('Property','Value',...) creates a new XPC_COMMAND_CENTER or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before untitled_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to untitled_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".

%   Copyright 1984-2004 The MathWorks, Inc.
%   $Revision: 1.4.6.8 $ $Date: 2004/04/15 00:06:57 $

gui_StateFields =  {'gui_Name'
                    'gui_Singleton'
                    'gui_OpeningFcn'
                    'gui_OutputFcn'
                    'gui_LayoutFcn'
                    'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
    if ~isfield(gui_State, gui_StateFields{i})
        error('Could not find field %s in the gui_State struct in GUI M-file %s', gui_StateFields{i}, gui_Mfile);        
    elseif isequal(gui_StateFields{i}, 'gui_Name')
        gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
    end
end

numargin = length(varargin);

if numargin == 0
    % XPC_COMMAND_CENTER
    % create the GUI
    gui_Create = 1;
elseif isequal(ishandle(varargin{1}), 1) && ispc && iscom(varargin{1}) && isequal(varargin{1},gcbo)
    % XPC_COMMAND_CENTER(ACTIVEX,...)    
    vin{1} = gui_State.gui_Name;
    vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
    vin{3} = varargin{1};
    vin{4} = varargin{end-1};
    vin{5} = guidata(varargin{1}.Peer);
    feval(vin{:});
    return;
elseif ischar(varargin{1}) && numargin>1 && isequal(ishandle(varargin{2}), 1)
    % XPC_COMMAND_CENTER('CALLBACK',hObject,eventData,handles,...)
    gui_Create = 0;
else
    % XPC_COMMAND_CENTER(...)
    % create the GUI and hand varargin to the openingfcn
    gui_Create = 1;
end

if gui_Create == 0
    varargin{1} = gui_State.gui_Callback;
    if nargout
        [varargout{1:nargout}] = feval(varargin{:});
    else
        feval(varargin{:});
    end
else
    if gui_State.gui_Singleton
        gui_SingletonOpt = 'reuse';
    else
        gui_SingletonOpt = 'new';
    end
    
    % Open fig file with stored settings.  Note: This executes all component
    % specific CreateFunctions with an empty HANDLES structure.
    
    % Do feval on layout code in m-file if it exists
    if ~isempty(gui_State.gui_LayoutFcn)
        gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);
        % openfig (called by local_openfig below) does this for guis without
        % the LayoutFcn. Be sure to do it here so guis show up on screen.
        movegui(gui_hFigure,'onscreen')
    else
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);            
        % If the figure has InGUIInitialization it was not completely created
        % on the last pass.  Delete this handle and try again.
        if isappdata(gui_hFigure, 'InGUIInitialization')
            delete(gui_hFigure);
            gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);            
        end
    end
    
    % Set flag to indicate starting GUI initialization
    setappdata(gui_hFigure,'InGUIInitialization',1);

    % Fetch GUIDE Application options
    gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
    
    if ~isappdata(gui_hFigure,'GUIOnScreen')
        % Adjust background color
        if gui_Options.syscolorfig 
            set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor'));
        end

        % Generate HANDLES structure and store with GUIDATA
        guidata(gui_hFigure, guihandles(gui_hFigure));
    end
    
    % If user specified 'Visible','off' in p/v pairs, don't make the figure
    % visible.
    gui_MakeVisible = 1;
    for ind=1:2:length(varargin)
        if length(varargin) == ind
            break;
        end
        len1 = min(length('visible'),length(varargin{ind}));
        len2 = min(length('off'),length(varargin{ind+1}));
        if ischar(varargin{ind}) && ischar(varargin{ind+1}) && ...
                strncmpi(varargin{ind},'visible',len1) && len2 > 1
            if strncmpi(varargin{ind+1},'off',len2)
                gui_MakeVisible = 0;
            elseif strncmpi(varargin{ind+1},'on',len2)
                gui_MakeVisible = 1;
            end
        end
    end
    
    % Check for figure param value pairs
    for index=1:2:length(varargin)
        if length(varargin) == index
            break;
        end
        try set(gui_hFigure, varargin{index}, varargin{index+1}), catch break, end
    end

    % If handle visibility is set to 'callback', turn it on until finished
    % with OpeningFcn
    gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
    if strcmp(gui_HandleVisibility, 'callback')
        set(gui_hFigure,'HandleVisibility', 'on');
    end
    
    feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
    
    if ishandle(gui_hFigure)
        % Update handle visibility
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
        
        % Make figure visible
        if gui_MakeVisible
            set(gui_hFigure, 'Visible', 'on')
            if gui_Options.singleton 
                setappdata(gui_hFigure,'GUIOnScreen', 1);
            end
        end

        % Done with GUI initialization
        rmappdata(gui_hFigure,'InGUIInitialization');
    end
    
    % If handle visibility is set to 'callback', turn it on until finished with
    % OutputFcn
    if ishandle(gui_hFigure)
        gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
        if strcmp(gui_HandleVisibility, 'callback')
            set(gui_hFigure,'HandleVisibility', 'on');
        end
        gui_Handles = guidata(gui_hFigure);
    else
        gui_Handles = [];
    end
    
    if nargout
        [varargout{1:nargout}] = feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    else
        feval(gui_State.gui_OutputFcn, gui_hFigure, [], gui_Handles);
    end
    
    if ishandle(gui_hFigure)
        set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
    end
end    

function gui_hFigure = local_openfig(name, singleton)

% openfig with three arguments was new from R13. Try to call that first, if
% failed, try the old openfig.
try 
    gui_hFigure = openfig(name, singleton, 'auto');
catch
    % OPENFIG did not accept 3rd input argument until R13,
    % toggle default figure visible to prevent the figure
    % from showing up too soon.
    gui_OldDefaultVisible = get(0,'defaultFigureVisible');
    set(0,'defaultFigureVisible','off');
    gui_hFigure = openfig(name, singleton);
    set(0,'defaultFigureVisible',gui_OldDefaultVisible);
end

% === EOF === [xpc_command_center.m] ==============================

Contact us