www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcfoundation/@DCTManager/guiSchedulerChooser.m
function OK = guiSchedulerChooser(manager) %GUISCHEDULERCHOOSER Display a dialog for choosing the scheduler % % OK = GUISCHEDULERCHOOSER(OBJ) displays a dialog that allows the user to % set the scheduler to be used when running a DCT job. % Copyright 2006-2014 The MathWorks, Inc. hFig = xregdialog('Name', 'Parallel Computing Toolbox Scheduler'); xregcenterfigure(hFig, [400 300]); sc = xregGui.SystemColorsDbl; % Get a list of the available configurations confs = parallel.clusterProfiles(); % OK Button hOK = uicontrol('Parent', hFig, ... 'String', 'OK', ... 'Style', 'pushbutton', ... 'Callback', @(src, evt) set(hFig, 'Tag', 'ok', 'Visible', 'off')); % Cancel Button hCancel = uicontrol('Parent', hFig, ... 'String', 'Cancel', ... 'Style', 'pushbutton', ... 'Callback', @(src, evt) set(hFig, 'Visible', 'off')); % List of available configurations info = ['Select the Parallel Computing Toolbox configuration to ' ... 'use to find a scheduler:']; hLabel = uicontrol('Parent', hFig, ... 'Style', 'text', ... 'String', info, ... 'HorizontalAlignment', 'left'); hList = uicontrol('Parent', hFig, ... 'Style', 'listbox', ... 'String', confs, ... 'BackgroundColor', sc.WINDOW_BG); % Button to perform a test on the selected configuration hTest = uicontrol('Parent', hFig, ... 'String', 'Test', ... 'Style', 'pushbutton', ... 'Callback', {@i_TestConf, hList}); L = xreggridbaglayout(hFig, ... 'packstatus', 'off', ... 'dimension', [5 4], ... 'rowsizes', [30, 2, -1, 7, 25],... 'colsizes', [65, -1, 65, 65], ... 'gapx', 7, ... 'border', [7 7 7 7], ... 'mergeblock', {[1,1], [1,4]}, ... 'mergeblock', {[3,3], [1,4]}, ... 'elements', {hLabel, [], hList, [], hTest, ... [], [], [], [], [], ... [], [], [], [], hOK, ... [], [], [], [], hCancel}); hFig.LayoutManager = L; set(L, 'packstatus', 'on'); if ~isempty(manager.Configuration) % If the DCTManager already has a configuration search for it in the list ind = find( strcmp( manager.Configuration,confs ) ); if ~isempty(ind) && isscalar(ind) % If we find the matching configuration, then select it set(hList, 'Value', ind); end end hFig.showDialog(hOK); OK = strcmpi(get(hFig, 'Tag'), 'ok'); if OK items = get(hList, 'String'); ind = get(hList, 'Value'); if ~isempty(ind) && ~strcmp(manager.Configuration, items{ind}) manager.Configuration = items{ind}; end end hFig.delete; function i_TestConf(~, ~, list) confs = get(list, 'String'); ind = get(list, 'Value'); manager = mbcfoundation.DCTManager(confs{ind}); hFig = get(list, 'Parent'); set(hFig, 'Pointer', 'watch'); ok = connect(manager, true); set(hFig, 'Pointer', 'arrow'); if ok manager.guiDisplayScheduler('Scheduler Test Result', ... 'The following scheduler was found:'); end