2 properties(GetAccess=
private,SetAccess=
private,Hidden)
10 function obj=
unit_view(nextNodes,destInputs,label)
12 obj.nextNodes = nextNodes;
13 obj.destInputs = destInputs;
16 % Create GUI and populate
23 methods (Access=public)
24 function select(obj,~,~,ui)
25 list = ui.listbox.Value;
28 fprintf('\n%s:\n',[obj.label ' --> ' obj.nextNodes{i}.label
'[' num2str(obj.destInputs(i))
']']);
29 disp(obj.nextNodes{list(i)}.inputBuffer{obj.destInputs(list(i))});
32 function copy2Cell(obj,~,~,ui)
33 list = ui.listbox.Value;
37 sig{i}=obj.nextNodes{list(i)}.inputBuffer{obj.destInputs(list(i))};
39 assignin(
'base',
'sig',sig)
40 fprintf(
'Saved chosen signals to workspace as cell (1,%g).\n',N)
42 function plotTime(obj,~,~,ui)
43 list = ui.listbox.Value;
45 sig = zeros(obj.nextNodes{1}.inputBuffer{list(1)}.L,N);
47 sig(:,i)=
get(obj.nextNodes{list(i)}.inputBuffer{list(i)});
49 t = 0:obj.nextNodes{list(1)}.inputBuffer{list(1)}.Ts:(obj.nextNodes{list(1)}.inputBuffer{list(1)}.L-1)*obj.nextNodes{list(1)}.inputBuffer{list(1)}.Ts;
56 function plotFreq(obj,~,~,ui)
57 list = ui.listbox.Value;
59 sig = zeros(obj.nextNodes{1}.inputBuffer{list(1)}.L,N);
61 sig(:,i)=
get(obj.nextNodes{list(i)}.inputBuffer{list(i)});
63 f = linspace(-1/obj.nextNodes{list(1)}.inputBuffer{list(1)}.Ts/2,1/obj.nextNodes{list(1)}.inputBuffer{list(1)}.Ts/2,obj.nextNodes{list(1)}.inputBuffer{list(1)}.L);
64 SIG = abs(fftshift(fft(sig))).^2;
72 methods (Access=
private)
73 function ui = createUI(obj)
74 % Create and then hide the UI as it is being constructed.
75 f = figure(
'Visible',
'off',...
77 'NumberTitle',
'off',...
82 scrsz =
get(0,
'ScreenSize');
83 set(gcf,
'OuterPosition',[1 scrsz(4)*(1-ratioH) scrsz(3)*ratioW scrsz(4)*ratioH ])
84 pos =
get(gcf,
'Position');
88 N=numel(obj.nextNodes);
89 popupmenu_data = cell(1,N);
91 popupmenu_data{i} = [obj.label
' --> ' obj.nextNodes{i}.label
'[' num2str(obj.destInputs(i))
']'];
93 if(isempty(popupmenu_data) || (~ispref(
'robochameleon',
'debugMode') || ~getpref(
'robochameleon',
'debugMode')))
94 fprintf(
'This is a sink unit or debugMode is turned off.\n')
99 ui.listbox = uicontrol(
'Style',
'listbox',...
100 'String',popupmenu_data,...
103 'Position',[0 h-285 200 285]);
104 ui.showbtn = uicontrol(
'Style',
'pushbutton',...
105 'String',
'disp()',...
106 'Position', [210 h-25 160 25],...
107 'Enable',enablebtn,...
108 'Callback', @(hObject,callbackdata) obj.select(hObject,callbackdata,ui));
109 % ui.timebtn = uicontrol(
'Style',
'pushbutton',...
110 %
'String',
'plot(t,sig) (TODO)',...
111 %
'Position', [210 3*28 160 25],...
113 %
'Callback', @(hObject,callbackdata) obj.plotTime(hObject,callbackdata,ui));
114 % ui.freqbtn = uicontrol(
'Style',
'pushbutton',...
115 %
'String',
'plot(f,fft(sig)) (TODO)',...
116 %
'Position', [210 2*28 160 25],...
118 %
'Callback', @(hObject,callbackdata) obj.plotFreq(hObject,callbackdata,ui));
119 % ui.workspacebtn1 = uicontrol(
'Style',
'pushbutton',...
120 %
'String',
'Copy to workspace as matrix',...
121 %
'Position', [210 28 160 25],...
122 %
'Enable',enablebtn,...
123 %
'Callback', @(hObject,callbackdata) obj.copy2Mat(hObject,callbackdata,ui));
124 ui.workspacebtn2 = uicontrol(
'Style',
'pushbutton',...
125 'String',
'Copy to workspace as cell',...
126 'Position', [210 h-25-1*28 160 25],...
127 'Enable',enablebtn,...
128 'Callback', @(hObject,callbackdata) obj.copy2Cell(hObject,callbackdata,ui));
129 % Make the UI visible.
Superclass: graphical interface for units.