-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfm_busfig.m
288 lines (256 loc) · 7.54 KB
/
fm_busfig.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
function h1 = fm_busfig(varargin)
% FM_BUSFIG graphical user interface for custom bus selections
%
%see also the function FM_EQUIV and FM_EQUIVFIG
%
%Author: Federico Milano
%Update: 02-Apr-2008
%Version: 0.1
%
%E-mail: [email protected]
%Web-site: faraday1.ucd.ie/psat.html
%
% Copyright (C) 2002-2019 Federico Milano
global Theme EQUIV Bus Areas Regions File Path
switch nargin
case 0, flag = 'null';
case 1, flag = varargin{1};
end
switch flag
case 'writelist'
hdl_bus = findobj(gcf,'Tag','BusList');
idx = get(hdl_bus,'Value');
EQUIV.buslist = idx;
listfile = [strrep(File.data,'(mdl)',''),'.lst'];
[fid,message] = fopen([Path.data,listfile],'wt');
if fid == -1
fm_disp(message)
return
end
for i = 1:length(idx)
count = fprintf(fid,'%s\n',Bus.names{idx(i)});
end
fclose(fid);
fm_disp(['File <',listfile,'> written in data folder.'])
close(gcf)
return
case 'area'
hdl_area = findobj(gcf,'Tag','PopUpArea');
hdl_vol = findobj(gcf,'Tag','PopUpVoltage');
hdl_bus = findobj(gcf,'Tag','BusList');
busdata = get(hdl_bus,'UserData');
value = get(hdl_area,'Value');
idx = [];
for i = 1:length(value)
idx = [idx; find(getarea(Bus,0,0) == value(i))];
end
set(hdl_bus,'Value',unique(idx),'ListboxTop',idx(1));
set(hdl_vol,'Value',[])
return
case 'region'
hdl_region = findobj(gcf,'Tag','PopUpRegion');
hdl_vol = findobj(gcf,'Tag','PopUpVoltage');
hdl_bus = findobj(gcf,'Tag','BusList');
busdata = get(hdl_bus,'UserData');
value = get(hdl_region,'Value');
idx = [];
for i = 1:length(value)
idx = [idx; find(getregion(Bus,0,0) == value(i))];
end
set(hdl_bus,'Value',unique(idx),'ListboxTop',idx(1));
set(hdl_vol,'Value',[])
return
case 'voltage'
hdl_vol = findobj(gcf,'Tag','PopUpVoltage');
hdl_bus = findobj(gcf,'Tag','BusList');
hdl_area = findobj(gcf,'Tag','PopUpArea');
busdata = get(hdl_bus,'UserData');
voltages = get(hdl_vol,'String');
value = get(hdl_vol,'Value');
idx = [];
for i = 1:length(value)
idx = [idx; find(getkv(Bus,0,0) == str2num(voltages{value(i)}))];
end
set(hdl_bus,'Value',unique(idx),'ListboxTop',idx(1));
set(hdl_area,'Value',[])
return
end
h1 = figure(...
'Units','normalized',...
'Color',Theme.color01, ...
'Colormap',[], ...
'MenuBar','none',...
'Name','Bus Selection',...
'NumberTitle','off',...
'PaperPosition',[18 180 576 432], ...
'Position',sizefig(0.525,0.55),...
'Resize','on',...
'WindowStyle','modal', ...
'FileName','fm_busfig',...
'CreateFcn','Fig.bus = gcf;', ...
'DeleteFcn','Fig.bus = -1;');
fm_set colormap
% Menu File/Open
hm = uimenu('Parent',h1, ...
'Label','File', ...
'Tag','MenuFile');
hs = uimenu('Parent',hm, ...
'Callback','close(gcf)', ...
'Label', 'Exit', ...
'Tag','OpenLF', ...
'Separator','on', ...
'Accelerator','q');
h2 = uipanel(...
'Parent',h1,...
'Units','normalized',...
'FontSize',10,...
'BackgroundColor', Theme.color01, ...
'Title',{ 'Bus Selection' },...
'Tag','uipanel1',...
'Clipping','on',...
'Position',[0.1 0.1 0.35 0.8]);
h8 = uibuttongroup(...
'Parent',h1,...
'Units','normalized',...
'FontSize',10,...
'BackgroundColor', Theme.color01, ...
'Title',{ 'Advanced Settings' },...
'Tag','uipanel2',...
'Clipping','on',...
'Position',[0.55 0.1 0.35 0.8]);
ht = uicontrol( ...
'Parent',h2, ...
'Units','normalized', ...
'BackgroundColor', Theme.color01, ...
'Enable', 'inactive', ...
'HorizontalAlignment','left', ...
'Position',[0.1 0.95 0.8 0.05], ...
'String','Bus Names', ...
'Style','text', ...
'Tag','TextBus');
ht = uicontrol( ...
'Parent',h2, ...
'Units','normalized', ...
'BackgroundColor',Theme.color04, ...
'ForegroundColor',Theme.color05, ...
'HorizontalAlignment','left', ...
'Position',[0.1 0.45 0.8 0.5], ...
'Max',20, ...
'String',Bus.names, ...
'Style','listbox', ...
'Value',[], ...
'Tag','BusList');
% -----------------------------------------------------------------
% Voltage Rate
% -----------------------------------------------------------------
ht = uicontrol( ...
'Parent',h2, ...
'Units','normalized', ...
'BackgroundColor', Theme.color01, ...
'Enable', 'inactive', ...
'HorizontalAlignment','left', ...
'Position',[0.1 0.35 0.8 0.05], ...
'String','Select Voltage Rate', ...
'Style','text', ...
'Tag','TextVoltage');
voltages = unique(getkv(Bus,0,0));
volnames = cell(length(voltages),1);
for i = 1:length(voltages)
volnames{i} = num2str(voltages(i));
end
h13 = uicontrol(...
'Parent',h2,...
'Units','normalized',...
'HorizontalAlignment','center', ...
'BackgroundColor',Theme.color04, ...
'ForegroundColor',Theme.color05, ...
'FontName','Curier', ...
'Callback','fm_busfig voltage',...
'FontSize',10,...
'Position',[0.1 0.05 0.8 0.3],...
'String',volnames,...
'Max',20,...
'Style','listbox',...
'Value',[], ...
'Tag','PopUpVoltage');
% -----------------------------------------------------------------
% Area
% -----------------------------------------------------------------
ht = uicontrol( ...
'Parent',h8, ...
'Units','normalized', ...
'BackgroundColor', Theme.color01, ...
'Enable', 'inactive', ...
'HorizontalAlignment','left', ...
'Position',[0.1 0.9 0.8 0.05], ...
'String','Select Area', ...
'Style','text', ...
'Tag','TextArea');
h13 = uicontrol(...
'Parent',h8,...
'Units','normalized',...
'HorizontalAlignment','center', ...
'BackgroundColor',Theme.color04, ...
'ForegroundColor',Theme.color05, ...
'FontName','Curier', ...
'Callback','fm_busfig area',...
'FontSize',10,...
'Position',[0.1 0.6 0.8 0.3],...
'String',Areas.names,...
'Max',20,...
'Style','listbox',...
'Tag','PopUpArea',...
'Value',[]);
% -----------------------------------------------------------------
% Region
% -----------------------------------------------------------------
ht = uicontrol( ...
'Parent',h8, ...
'Units','normalized', ...
'BackgroundColor', Theme.color01, ...
'Enable', 'inactive', ...
'HorizontalAlignment','left', ...
'Position',[0.1 0.5 0.8 0.05], ...
'String','Select Region', ...
'Style','text', ...
'Tag','TextRegion');
h13 = uicontrol(...
'Parent',h8,...
'Units','normalized',...
'HorizontalAlignment','center', ...
'BackgroundColor',Theme.color04, ...
'ForegroundColor',Theme.color05, ...
'FontName','Curier', ...
'Callback','fm_busfig region',...
'FontSize',10,...
'Position',[0.1 0.2 0.8 0.3],...
'String',Regions.names,...
'Max',20,...
'Style','listbox',...
'Tag','PopUpRegion',...
'Value',[]);
% -----------------------------------------------------------------
% Buttons
% -----------------------------------------------------------------
h13 = uicontrol(...
'Parent',h8,...
'Units','normalized',...
'HorizontalAlignment','center', ...
'BackgroundColor',Theme.color01,...
'FontName','Curier', ...
'Callback','fm_busfig writelist',...
'FontSize',10,...
'Position',[0.1 0.05 0.35 0.1],...
'String','Save',...
'Tag','ButtonList');
h13 = uicontrol(...
'Parent',h8,...
'Units','normalized',...
'HorizontalAlignment','center', ...
'BackgroundColor',Theme.color01,...
'FontName','Curier', ...
'Callback','close(gcf)',...
'FontSize',10,...
'Position',[0.55 0.05 0.35 0.1],...
'String','Cancel',...
'Tag','ButtonClose');