-
Notifications
You must be signed in to change notification settings - Fork 3
/
Control_Panel.m
127 lines (95 loc) · 4.8 KB
/
Control_Panel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function [state, dpd_st, adapt_st] = Control_Panel(state, par, dpd_st, adapt_st, sa_st)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
if isempty(fieldnames(state))
% control panel figure
state.ctrl1_fn = 101;
state.ctrl1_fh = findobj(allchild(groot), 'flat', 'type', 'figure', 'number', state.ctrl1_fn);
if ~isempty(state.ctrl1_fh); clf(state.ctrl1_fh); end
state.ctrl1_fh = figure(state.ctrl1_fn);
bgcolor = state.ctrl1_fh.Color;
% add sliders
state.k_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.9,0.7,0.05], ...
'value', 0.39, 'min', 0, 'max', 2);
state.l_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.8,0.7,0.05], ...
'value', 1, 'min', 0, 'max', 5);
state.d_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.7,0.7,0.05], ...
'value', 0.39, 'min', 0, 'max', 2);
state.f_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.6,0.7,0.05], ...
'value', 18, 'min', 10, 'max', 30); % 2.3
state.k_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.9,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.l_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.8,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.d_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.7,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.f_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.6,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
% add monitors
state.mchpwr_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.5,0.7,0.05], ...
'value', -30, 'min', -30, 'max', 0);
state.dpd_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.4,0.7,0.05], ...
'value', 0, 'min', 0, 'max', 2);
state.dpd2_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.3,0.7,0.05], ...
'value', 0, 'min', 0, 'max', 2);
state.adapt1_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.2,0.7,0.05], ...
'value', 0, 'min', 0, 'max', 2);
state.adapt2_sl = uicontrol('Parent',state.ctrl1_fh, 'Style','slider', ...
'Units','normal', 'Position',[0.25,0.1,0.7,0.05], ...
'value', 0, 'min', 0, 'max', 2);
state.mchpwr_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.5,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.dpd_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.4,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.dpd2_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.3,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.adapt1_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.2,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
state.adapt2_tx = uicontrol('Parent',state.ctrl1_fh, 'Style','text', ...
'Units','normal', 'Position',[0,0.1,0.25,0.05],...
'String', 'k','BackgroundColor',bgcolor);
end
% update texts
state.k_tx.String = sprintf('k=%.2f', state.k_sl.Value);
state.l_tx.String = sprintf('l=%.2f', state.l_sl.Value);
state.d_tx.String = sprintf('d=%.2f', state.d_sl.Value);
state.f_tx.String = sprintf('f=%.2f', state.f_sl.Value);
% update values for DPD and adaptation
for i = 1:length(par)
dpd_st{i}.in_scaler = state.k_sl.Value;
dpd_st{i}.out_scaler = state.l_sl.Value;
adapt_st{i}.in_scaler = state.d_sl.Value;
adapt_st{i}.out_scaler = state.f_sl.Value;
end
% update monitors
mchpwr = sa_st.mchpwr(1,sa_st.iter);
z_max = dpd_st{1}.z_max;
x_max = dpd_st{1}.x_max;
u_max = adapt_st{1}.z_max;
y_max = adapt_st{1}.y_max;
state.mchpwr_tx.String = sprintf('mchpwr=%.2f', mchpwr);
state.dpd_tx.String = sprintf('z_max=%.2f', z_max);
state.dpd2_tx.String = sprintf('x_max=%.2f', x_max);
state.adapt1_tx.String = sprintf('z_max=%.2f', u_max);
state.adapt2_tx.String = sprintf('y_max=%.2f', y_max);
state.mchpwr_sl.Value = mchpwr;
state.dpd_sl.Value = z_max;
state.dpd2_sl.Value = x_max;
state.adapt1_sl.Value = u_max;
state.adapt2_sl.Value = y_max;