Newer
Older
function TTdiag(varargin)
orig_gcbh = gcbh;
Action = varargin{1};
if 1 ~= nargin
DAStudio.warning('improper function use')
end
switch Mode,
case 'Simulink'
LocalOpenBlockFcn(blockHandleTTTopMask,1);
case 'Matlab'
LocalOpenBlockFcn([],0);
end
case 'Close',
blockHandleTTTopMask = orig_gcbh;
LocalCloseBlockFcn(blockHandleTTTopMask);
case 'Copy',
blockHandleTTTopMask = orig_gcbh;
LocalCopyBlockFcn(blockHandleTTTopMask);
otherwise,
DAStudio.error('Simulink:dialog:UnknownAction',Action);
end
end
function LocalCopyBlockFcn(blockHandleTTTopMask)
Colin Eles
committed
if(~isempty(data))
data_new = data.clone(blockHandleTTTopMask);
set_param(blockHandleTTTopMask,'UserData',data_new)
if (mode == 1)
modelHandle = bdroot(blockHandleTTTopMask);
% check if the user is trying to open the block from the library
if strcmp(get_param(modelHandle,'Lock'), 'on') || ...
strcmp(get_param(blockHandleTTTopMask,'LinkStatus'),'implicit')
Colin Eles
committed
errordlg(...
DAStudio.message('can not open Model Locked, Add to new model to use'),...
'Error', 'modal')
return
end
Colin Eles
committed
Colin Eles
committed
if isempty(data)
data = Data();
data.init();
Colin Eles
committed
else
if ~data.valid
errordlg(...
DAStudio.message('Block Data has been corputed'),...
'Error', 'modal')
return
end
if data.open
if ishghandle(data.fig)
figure(data.fig)
end
return
end
Colin Eles
committed
end
if mode == 1
gui = GUI(blockHandleTTTopMask,1);
elseif mode == 0
gui = GUI([],0);
end
Colin Eles
committed
gui.setData(data)
gui.init();
if(mode == 1)
set_param(blockHandleTTTopMask,'UserData',data);
set_param(blockHandleTTTopMask, 'UserDataPersistent', 'on');
end
Colin Eles
committed
end
function LocalCloseRequestBlockFcn(blockHandleTTTopMask)
data = get_param(blockHandleTTTopMask,'UserData');
Colin Eles
committed
if ~isempty(data)
if data.open
delete(data.fig)
end
end
%set_param(gui.fig,'Visible','off')