📄 fm_dirset.m
字号:
fm_choice('Filter for PET data format has not been implemeted yet',2) break case FLOWDEMO check = fm_perl('FlowDemo.net','flowdemo2psat',filename); case GEEPC check = fm_perl('GE','ge2psat',filename); case CHAPMAN check = fm_perl('Chapman','chapman2psat',filename); case UCTE check = fm_perl('UCTE','ucte2psat',filename); case PCFLO check = fm_perl('PCFLO','pcflo2psat',filename); case WEBFLOW check = fm_perl('WebFlow','webflow2psat',filename); case VITRUVIO % All files fm_disp('Select a Data Format for running the conversion.') end if ~check & ~isempty(lasterr), fm_disp(lasterr), end end if nargout, varargout{1} = check; end %================================================================== case 'openfile' global File Path.temp = 0; File.temp = ''; hdl = findobj(Fig.dir,'Tag','Listbox2'); numfile = get(hdl,'Value'); nomefile = get(hdl,'String'); if ~iscell(nomefile), nomefile = cellstr(nomefile); end if numfile == 1 & strcmp(nomefile{1},'empty') fm_disp('Current folder does not contain files in the selected data format.',2) cd(Path.local) close(Fig.dir) return end hdl = findobj(Fig.dir,'Tag','PopupMenu1'); type = get(hdl,'Value'); if type == PSAT | type == PSATPERT check = 1; else cd(Path.local) check = fm_dirset('convert'); end if ~check fm_disp('Data conversion failed.',2) return end % determine file name namefile = nomefile{numfile}; switch type case {PSAT,PSATPERT,PSATMDL} % nothing to do! case PCFLO namefile = regexprep([namefile,'.m'],'^bdat\.','','ignorecase'); namefile = regexprep(['d_',namefile],'^d*_*','d_'); namefile = regexprep(namefile,'[^\w\.]','_'); otherwise namefile = regexprep(['d_',namefile],'^d*_*','d_'); namefile = regexprep(namefile,'^d_d','d_'); namefile = regexprep(namefile,'[^\w\.]','_'); namefile = regexprep(namefile,'\..+$','.m'); end Path.temp = get(Fig.dir,'UserData'); if ~strcmp(Path.temp(end),filesep) Path.temp = [Path.temp,filesep]; end File.temp = namefile; close(Fig.dir) %================================================================== case 'cancel' Path.temp = 0; File.temp = ''; close(Fig.dir) %================================================================== case 'view' hdl = findobj(Fig.dir,'Tag','Listbox2'); numfile = get(hdl,'Value'); nomefile = get(hdl,'String'); if ~iscell(nomefile), nomefile = cellstr(nomefile); end if strcmp(nomefile{1},'empty') fm_disp('Folder is empty or does not contain files in the selected data format',2) cd(Path.local) return end for i = 1:length(numfile) ext = lower(nomefile{numfile(i),1}(end-2:end)); idx = findstr(ext,'.'); if ~isempty(idx) ext = ext(idx(end)+1:end); end file = nomefile{numfile(i),1}; try switch ext case 'mdl' open_system(file) case 'pdf', switch computer case 'GLNX86', eval(['! xpdf ',file, ' &']), case 'PCWIN', eval(['! acroread ',file, ' &']) otherwise 'SOL2', eval(['! acroread ',file, ' &']) end case '.ps' switch computer case 'GLNX86', eval(['! gsview ',file, ' &']), case 'PCWIN', eval(['! gsview ',file, ' &']) otherwise, eval(['! ghostview ',file, ' &']) end case 'eps' switch computer case 'GLNX86', eval(['! gsview ',file, ' &']), case 'PCWIN', eval(['! gsview ',file, ' &']) otherwise, eval(['! ghostview ',file, ' &']) end case 'doc' switch computer case 'GLNX86', eval(['! AbiWord ',file, ' &']), case 'PCWIN', eval(['! WINWORD ',file, ' &']) otherwise, fm_disp('Unknown viewer on this platform for file "',file,'"') end case 'ppt' switch computer case 'GLNX86', eval(['! AbiWord ',file, ' &']), case 'PCWIN', eval(['! POWERPNT ',file, ' &']) otherwise, fm_disp('Unknown viewer on this platform for file "',file,'"') end case 'dvi' switch computer case 'GLNX86', eval(['! xdvi ',file, ' &']), case 'PCWIN', fm_disp('Unknown viewer on this platform for file "',file,'"') otherwise, eval(['! xdvi ',file, ' &']) end case 'jpg', fm_iview(file) case 'tif', fm_iview(file) case 'gif', fm_iview(file) case 'bmp', fm_iview(file) case 'png', fm_iview(file) case 'hdf', fm_iview(file) case 'pcx', fm_iview(file) case 'xwd', fm_iview(file) case 'ico', fm_iview(file) case 'cur', fm_iview(file) otherwise, fm_text(13,file) end catch fm_disp(['Error in opeining file "',file,'": ',lasterr]) end endendcd(Path.local)%===================================================================function cfile = uform(formato)% codesIEEE = 1;PSAT = 2;PSATPERT = 3;PSATMDL = 4;CYME = 5;MATPOWER = 6;PST = 7;EPRI = 8;PSSE = 9;PSAP = 10;EUROSTAG = 11;TH = 12;CESI = 13;VST = 14;SIMPOW = 15;NEPLAN = 16;DIGSILENT = 17;POWERWORLD = 18;PET = 19;FLOWDEMO = 20;GEEPC = 21;CHAPMAN = 22;UCTE = 23;PCFLO = 24;WEBFLOW = 25;VITRUVIO = 26; % all filesa = dir;numfile = find([a.isdir] == 0);jfile = 1;cfile = [];for i = 1:length(numfile) nomefile = a(numfile(i)).name; lfile = length(nomefile); add_file = 0; switch formato case IEEE extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat') | strcmpi(extent,'txt') | ... strcmpi(extent,'.cf'), if isfile(nomefile,'BUS DATA FOLLOW',20) add_file = 1; end end case CYME extent1 = nomefile(max(1,lfile-3):lfile); extent2 = nomefile(max(1,lfile-2):lfile); if strcmpi(extent1,'.nnd') | strcmpi(extent2,'.sf') add_file = 1; end case MATPOWER extent = nomefile(lfile); if strcmpi(extent,'m') if isfile(nomefile,'baseMVA',5), add_file = 1; end end case PSAT extent = nomefile(lfile); if strcmpi(extent,'m') & strcmp(nomefile(1),'d') if isfile(nomefile,'Bus.con',15), add_file = 1; end end case PSATPERT extent = nomefile(lfile); if strcmpi(extent,'m') & strcmp(nomefile(1),'p') if isfile(nomefile,'(t)',5), add_file = 1; end end case PSATMDL extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'mdl') & strcmp(nomefile(1),'d') add_file = 1; end case PST extent = nomefile(lfile); if strcmpi(extent,'m') & strcmp(nomefile(1),'d') if isfile(nomefile,'bus = [',50), add_file = 1; end end case EPRI extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'wsc') | strcmpi(extent,'txt') | ... strcmpi(extent,'dat') if isfile(nomefile,'HDG',15) add_file = 1; elseif isfile(nomefile,'/NETWORK_DATA\',20) add_file = 1; end end case PSSE extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'raw'), fid = fopen(nomefile, 'rt'); sline = fgets(fid); out = 0; if isempty(sline), sline = ' 2'; end if sline == -1; sline = ' 2'; end if length(sline) == 1; sline = [sline,' ']; end if isempty(str2num(sline(1:4))), sline = ' 2'; end if str2num(sline(1:2)) == 0 | str2num(sline(1:2)) == 1 out = 1; end if strcmp(sline(1:3),'001'), out = 0; end count = fclose(fid); if out, add_file = 1; end end case PSAP extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), fid = fopen(nomefile, 'rt'); sline = fgets(fid); out = 0; if isempty(sline), sline = ' 2'; end if sline == -1; sline = ' 2'; end warning off if isempty(str2num(sline)), sline = ' 2'; end if str2num(sline) == 1, out = 1; end warning on count = fclose(fid); if out, add_file = 1; end end case EUROSTAG extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), if isfile(nomefile,'HEADER ',20), add_file = 1; end end case TH extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), if isfile(nomefile,'SYSBASE',50) | ... isfile(nomefile,'THLINE',50) add_file = 1; end end case CESI extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), if isfile(nomefile,'VNOM',25), add_file = 1; end end case VST extent = nomefile(max(1,lfile-7):lfile); if strcmpi(extent,'_vst.dat'), add_file = 1; end case SIMPOW extent = nomefile(max(1,lfile-6):lfile); if strcmpi(extent,'.optpow') | strcmpi(extent,'.dynpow') add_file = 1; end case NEPLAN extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.ndt'), add_file = 1; end case DIGSILENT extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.dgs'), add_file = 1; end case POWERWORLD extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.aux'), add_file = 1; end case PET extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.pet'), add_file = 1; end case FLOWDEMO extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.fdn'), add_file = 1; end case CHAPMAN if isempty(findstr(nomefile,'.')), if isfile(nomefile,'SYSTEM',10), add_file = 1; end end case UCTE extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.uct'), add_file = 1; end case PCFLO if strmatch('bdat.',lower(nomefile)), add_file = 1; end case WEBFLOW extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.txt') if isfile(nomefile,'BQ',10) add_file = 1; end end case GEEPC extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'epc'), add_file = 1; end otherwise % all files % add only files that noe begins with a dot that are % hidden files on UNIX systems if ~strcmp(nomefile(1),'.') & isunix add_file = 1; end end if add_file, cfile{jfile,1} = a(numfile(i)).name; jfile = jfile + 1; endend%============================================================================function out = isfile(file,stringa,nrow)% check of the first nrow for figuring out the data formatout = 0;[fid, message] = fopen(file, 'rt');if ~isempty(message) fm_disp(['While inspecting the current folder, ', ... 'error found in file "',file,'". ',message]) returnendn_row = 0;while 1 sline = fgets(fid); n_row = n_row + 1; if ~isempty(sline), if sline == -1, break; end, end vec = findstr(sline,stringa); if ~isempty(vec), out = 1; break, end if n_row == nrow, break, endendcount = fclose(fid);%============================================================================function devices = getdevicesif isunix devices = {'/'};else devices = {'a:\'}; ndev = 1; for i='c':'z' device_name = [i,':\']; %if exist(device_name) == 7 if ~isempty(dir(device_name)) ndev = ndev + 1; devices{ndev,1} = device_name; end endend%============================================================================function check = fm_perl(program_name,filter_name,file_name)global Path[results,status] = perl([Path.filters,filter_name],file_name);fm_disp(results)check = ~status;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -