Aufgrund einer Wartung wird GitLab am 29.10. zwischen 9:00 und 10:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 29.10. between 9:00 and 10:00 am.

Aufgrund einer Konfigurationsänderung wird die GitLab Registry ab 10 Uhr nur Read Only zur Verfügung stehen. / Due to a configuration change, the GitLab Registry will be available for read-only access from 10am.

ita_aureliocontrol_gui_old.m 12.9 KB
Newer Older
1 2
function ita_aureliocontrol_gui(varargin)
% ITA_AURELIOCONTROL_GUI - gui for aurelio remote control
3 4 5 6 7 8

% <ITA-Toolbox>
% This file is part of the application RoboAurelioModulITAControl for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>

9
oldSettings = ita_aurelio_control('getSettings');
10 11 12 13 14 15 16
persistent hFigure

%% nice gui settings
gui_bg_color  = [0.8 0.8 0.8];

if nargin == 0
    width  = 440;
17
    height = 540;
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    
    mpos = get(0,'Monitor'); %try to position in the middle of the screen
    w_position = (mpos(1,length(mpos)-1)/2)-(width/2);
    h_position = (mpos(1,length(mpos))/2)-(height/2);
    MainPosition = [w_position h_position width height];
    
    %% Figure Handling
    if isempty(hFigure) || ~ishandle(hFigure)
        hFigure = figure( ...       % the main GUI figure
            'MenuBar', 'none', ...
            'Toolbar', 'none', ...
            'HandleVisibility', 'on', ...
            'Name', 'Aurelio Remote Control', ...
            'NumberTitle', 'off', ...
            'Position' , MainPosition, ...
            'Color', gui_bg_color);
    elseif ~strcmpi(get(hFigure,'Name'),'Aurelio Remote Control')
        hFigure = figure( ...       % the main GUI figure
            'MenuBar', 'none', ...
            'Toolbar', 'none', ...
            'HandleVisibility', 'on', ...
            'Name', 'ITA-Toolbox Preferences', ...
            'NumberTitle', 'off', ...
            'Position', MainPosition, ...
            'Color', gui_bg_color);
    else %we are in an ITA-Toolbox Preferences Window (pdi)
        clf(hFigure)
    end
    %% ITA toolbox logo
    a_im = importdata('ita_toolbox_logo.jpg');
    image(a_im);axis off
    set(gca,'Units','pixel', 'Position', [20 10 350 65]*0.6);
else %reset mode
    %     clf(hFigure) %clear old settings
end

%%
hor_start = 4;
ver_start = 5;
hor_space = 2;
ver_space = 0.5;

button_height = 1.5;
button_width = 20;

for ch_idx = 1:2
    %% FEED
    userdata.ch = ch_idx;
    
    nameStr = {'NONE','Pol','Pha','P+P','icp','all'};
    nButtons = length(nameStr);
69
    InputFeed{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
70 71 72 73 74 75 76 77 78 79 80 81 82 83
    InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
    InputFeed{ch_idx}.h = uibuttongroup(...
        'Parent',hFigure,...
        'Units','characters',...
        'FontSize',10,...
        'Title','Feed',...
        'Tag','Mode',...
        'BackgroundColor',gui_bg_color,...
        'Clipping','on',...
        'Position',InputFeed{ch_idx}.Position,...
        'SelectedObject',[],...
        'SelectionChangeFcn',@InputFeedCallback,...
        'OldSelectedObject',[]);
    
84
    position =  [0 0 button_width button_height];
85 86 87 88 89 90 91 92 93 94
    for button_idx = 1:nButtons
        InputFeed{ch_idx}.hButton(button_idx) = uicontrol(...
            'Parent',InputFeed{ch_idx}.h,...
            'Units','characters',...
            'FontSize',10,...
            'Position',[position],...
            'BackgroundColor',[1 0 0],...
            'String',nameStr{button_idx},...
            'Style','togglebutton',...
            'UserData',userdata,...
95
            'Value',strcmpi(nameStr{button_idx},oldSettings.ch(ch_idx).inputfeed),...
96
            'Tag','togglebuttonNorm');
97
        position = position + [0 button_height 0 0];
98 99 100 101 102
    end
    
    %% INPUT SELECT
    nameStr = {'Lemo','XLR','gnd','BNC'};
    nButtons = length(nameStr);
103
    InputSelect{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
104 105 106 107 108 109 110 111 112 113 114 115 116 117
    InputSelect{ch_idx}.Position = [InputFeed{ch_idx}.Position(1)  InputFeed{ch_idx}.Position(2)+ InputFeed{ch_idx}.Position(4)+ver_space InputSelect{ch_idx}.Size];
    InputSelect{ch_idx}.h = uibuttongroup(...
        'Parent',hFigure,...
        'Units','characters',...
        'FontSize',10,...
        'Title','Select',...
        'Tag','Mode',...
        'Clipping','on',...
        'BackgroundColor',gui_bg_color,...
        'Position',InputSelect{ch_idx}.Position,...
        'SelectedObject',[],...
        'SelectionChangeFcn',@InputSelectCallback,...
        'OldSelectedObject',[]);
    
118
    position =  [0 0 button_width button_height];
119 120 121 122 123 124 125 126 127
    for button_idx = 1:nButtons
        InputSelect{ch_idx}.hButton(button_idx) = uicontrol(...
            'Parent',InputSelect{ch_idx}.h,...
            'Units','characters',...
            'FontSize',10,...
            'Position',position,...
            'String',nameStr{button_idx},...
            'UserData',userdata,...
            'Style','togglebutton',...
128
            'Value',strcmpi(nameStr{button_idx},oldSettings.ch(ch_idx).inputselect),...
129
            'Tag','togglebuttonNorm');
130
        position = position + [0 button_height 0 0];
131 132 133 134 135 136 137
    end
    
    %% INPUT RANGE
    inputRange_vec = -34:10:56;
    nameStr = cellstr(num2str(inputRange_vec'));
    nButtons = length(nameStr);
    
138
    InputRange{ch_idx}.Size = [button_width+1 (nButtons+1) * (button_height)];
139 140 141 142 143 144 145 146 147 148 149 150 151 152
    InputRange{ch_idx}.Position = [InputSelect{ch_idx}.Position(1)  InputSelect{ch_idx}.Position(2)+ InputSelect{ch_idx}.Position(4)+ver_space InputRange{ch_idx}.Size];
    InputRange{ch_idx}.h = uibuttongroup(...
        'Parent',hFigure,...
        'Units','characters',...
        'FontSize',10,...
        'Title',['Range ch' num2str(ch_idx)],...
        'Tag','Mode',...
        'BackgroundColor',gui_bg_color,...
        'Clipping','on',...
        'Position',InputRange{ch_idx}.Position,...
        'SelectedObject',[],...
        'SelectionChangeFcn',@InputRangeCallback,...
        'OldSelectedObject',[]);
    
153
    position =  [0 0 button_width button_height];
154 155 156 157 158 159 160 161 162 163
    for button_idx = 1:nButtons
        InputRange{ch_idx}.hButton(button_idx) = uicontrol(...
            'Parent',InputRange{ch_idx}.h,...
            'Units','characters',...
            'FontSize',10,...
            'Position',[position],...
            'String',nameStr{button_idx},...
            'BackgroundColor',[0.1 0.9 0.1],...
            'UserData',userdata,...
            'Style','togglebutton',...
164
            'Value',oldSettings.ch(ch_idx).inputrange == inputRange_vec(button_idx),...
165
            'Tag','togglebuttonNorm');
166
        position = position + [0 button_height 0 0];
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
    end
    
    hor_start = hor_start + button_width + hor_space;
    
end

%% right column
nameStr = {};
argCell = {};
ele = 1;
nameStr{ele} = {'AmpRef'};
argCell{ele} = {'mode','ampref'};
ele = ele + 1;
nameStr{ele} = {'LineRef'};
argCell{ele} = {'mode','lineref'};
ele = ele + 1;
nameStr{ele} = {'ImpRef'};
argCell{ele} = {'mode','impref'};
ele = ele + 1;
nameStr{ele} = {'Imp'};
argCell{ele} = {'mode','imp'};
ele = ele + 1;
nameStr{ele} = {'Norm'};
argCell{ele} = {'mode','norm'};

%% generate modebuttons
InputFeed = InputFeed(1);
nButtons = length(nameStr);
195
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)];
196 197 198 199 200 201 202 203 204 205 206
InputFeed{1}.Position = [hor_start+1 ver_start InputFeed{1}.Size];
InputFeed{1}.h = uibuttongroup(...
    'Parent',hFigure,...
    'Units','characters',...
    'FontSize',10,...
    'Title','Mode',...
    'Tag','Mode',...
    'Clipping','on',...
    'Position',InputFeed{1}.Position,...
    'BackgroundColor',gui_bg_color,...
    'SelectedObject',[],...
207
    'OldSelectedObject',[]);
208
ch_idx = 1;
209
position =  [0 0 button_width button_height];
210 211 212 213 214 215 216 217
for button_idx = 1:nButtons
    userdata = argCell{button_idx};
    ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
        'Parent',InputFeed{ch_idx}.h,...
        'Units','characters',...
        'FontSize',10,...
        'Position',position,...
        'String',nameStr{button_idx},...
218 219
        'Style','pushbutton',...
        'Callback',@modePushButtonCallback,...
220
        'UserData',userdata,...
221
        'Value',0,...
222
        'Tag','');
223
    position = position + [0 button_height 0 0];
224 225 226 227 228 229 230 231 232 233 234 235 236
end


%% davolume
nameStr = {};
argCell = {};
ele = 1;
nameStr{ele} = {'Init'};
argCell{ele} = {'init'};
% ele = ele + 1;
% nameStr{ele} = {['Reset']};
% argCell{ele} = {'Reset'};
ele = ele + 1;
237
nameStr{ele} = {'Amplifier'};
238 239
argCell{ele} = {'Amplifier'};
ele = ele + 1;
240 241 242 243
nameStr{ele} = {'NoAmplifier'};
argCell{ele} = {'NoAmplifier'};
ele = ele + 1;
nameStr{ele} = {'Amp26dBu'};
244 245
argCell{ele} = {'Amp26dBu'};
ele = ele + 1;
246 247 248
nameStr{ele} = {'Amp06dBu'};
argCell{ele} = {'Amp06dBu'};
ele = ele + 1;
249 250 251
nameStr{ele} = {'AmpHighPower'};
argCell{ele} = {'AmpHighPower'};
ele = ele + 1;
252 253 254
nameStr{ele} = {'AmpLowPower'};
argCell{ele} = {'AmpLowPower'};
ele = ele + 1;
255
nameStr{ele} = {'GroundLift'};
256 257 258 259
argCell{ele} = {'GroundLift'};
ele = ele + 1;
nameStr{ele} = {'NoGroundLift'};
argCell{ele} = {'NoGroundLift'};
260 261 262 263 264


%% controlbuttons (push)
nButtons = length(nameStr);

265
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)];
266 267 268 269 270 271 272 273 274 275 276 277 278
InputFeed{1}.Position = [InputFeed{1}.Position(1)  InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size];
%     InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(...
    'Parent',hFigure,...
    'Units','characters',...
    'FontSize',10,...
    'Title','Control',...
    'Tag','Mode',...
    'Clipping','on',...
    'Position',InputFeed{ch_idx}.Position,...
    'BackgroundColor',gui_bg_color);


279 280
position =  [0 0 button_width button_height];
for button_idx = 1:length(nameStr)
281 282 283 284 285 286 287
    userdata = argCell{button_idx};
    ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
        'Units','characters',...
        'Parent',InputFeed{1}.h,...
        'FontSize',10,...
        'Position',[position],...
        'String',nameStr{button_idx},...
288 289
        'Style','pushbutton',...
        'Callback',@controlPushButtonCallback,...
290
        'UserData',userdata,...
291 292 293
        'Value',0,...
        'Tag','');
    position = position + [0 button_height 0 0];
294 295 296 297 298 299 300
end


%% sampling rate
nameStr = {};
argCell = {};
ele = 1;
301 302
nameStr{ele} = {'96000'};
argCell{ele} = {96000};
303 304 305 306
ele = ele + 1;
nameStr{ele} = {'88200'};
argCell{ele} = {88200};
ele = ele + 1;
307 308
nameStr{ele} = {'48000'};
argCell{ele} = {48000};
309
ele = ele + 1;
310 311
nameStr{ele} = {'44100'};
argCell{ele} = {44100};
312 313 314


%% controlbuttons (push)
315
nButtons = length(nameStr);
316

317
InputFeed{1}.Size = [button_width+1 (nButtons+1) * (button_height)];
318 319 320 321 322 323 324 325 326
InputFeed{1}.Position = [InputFeed{1}.Position(1)  InputFeed{1}.Position(2)+ InputFeed{1}.Position(4)+ver_space InputFeed{1}.Size];
%     InputFeed{ch_idx}.Position = [hor_start ver_start InputFeed{ch_idx}.Size];
InputFeed{1}.h = uipanel(...
    'Parent',hFigure,...
    'Units','characters',...
    'FontSize',10,...
    'Title','SamplingRate',...
    'Tag','Mode',...
    'Clipping','on',...
327
    'Position',InputFeed{ch_idx}.Position,...
328 329 330
    'BackgroundColor',gui_bg_color);


331 332 333 334
position =  [0 0 button_width button_height];
for button_idx = 1:length(nameStr)
    userdata = argCell{button_idx};
    ControlButton{ch_idx}.hButton(button_idx) = uicontrol(...
335 336 337
        'Units','characters',...
        'Parent',InputFeed{1}.h,...
        'FontSize',10,...
338 339
        'Position',position,...
        'String',nameStr{button_idx},...
340
        'Style','pushbutton',...
341
        'Callback',@samplingRateButtonCallback,...
342
        'UserData',userdata,...
343
        'Value',0,...
344
        'Tag','');
345
    position = position + [0 button_height 0 0];
346 347 348 349 350 351
end


%% callback functions

    function modePushButtonCallback(h,event)
352
        userdata = getfield(get(h),'UserData');
353 354
        argCell = userdata;
        if ~isempty(argCell)
355 356
            ita_aurelio_control(argCell{:});
            ita_aureliocontrol_gui('init');
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
        end
    end


    function controlPushButtonCallback(h,event)
        argCell = getfield(get(h),'UserData');
        if ~isempty(argCell)
            if strfind(argCell{1},'davolume')
                a = ita_modulita_control('getSettings');
                davolume = a.davolume;
                if strfind(argCell{1},'--')
                    davolume = davolume - 1;
                else
                    davolume = davolume + 1;
                end
372
                ita_aurelio_control('davolume',davolume);
373 374
                %                 set(event.NewValue,'UserData',argCell);
            else
375 376
                ita_aurelio_control(argCell{:});
                ita_aureliocontrol_gui('init');
377 378 379 380 381 382
            end
        end
    end


    function samplingRateButtonCallback(h,event)
383
        argCell = getfield(get(h),'UserData');
384
        if ~isempty(argCell)
385
            ita_aurelio_control('samplingRate',argCell{1});
386 387 388 389 390 391 392
        end
    end


    function InputSelectCallback(h,event)
        userdata = getfield(get(event.NewValue),'UserData');
        inputselect = getfield(get(event.NewValue),'String');
393
        ita_aurelio_control('channel',userdata.ch,'input',inputselect);
394 395 396 397 398 399
    end


    function InputFeedCallback(h,event)
        userdata = getfield(get(event.NewValue),'UserData');
        inputfeed = getfield(get(event.NewValue),'String');
400
        ita_aurelio_control('channel',userdata.ch,'feed',inputfeed);
401 402 403 404 405 406 407
    end


    function InputRangeCallback(h,event)
        userdata = getfield(get(event.NewValue),'UserData');
        value = getfield(get(event.NewValue),'String');
        inputrange = str2num(value); %#ok<ST2NM>
408
        ita_aurelio_control('channel',userdata.ch,'inputrange',inputrange);
409 410 411
    end

end