📄 fm_dirset.m
字号:
fm_choice('Filter for PET data format has not been implemeted yet',2) break case 19, % Flowdemo.net format fm_choice('Filter for Flowdemo.net data format has not been implemeted yet',2) break case 20, % GE EPC format fm_choice('Filter for GE EPC data format has not been implemeted yet',2) break case 21, % All files fm_disp('Select a Data Format for running the conversion.') end if ~check & ~isempty(lasterr), fm_disp(lasterr), end end %================================================================== case 'fileinit' % IEEE Common Data Format is used as default format a = dir; numfile = find([a.isdir] == 0); jfile = 1; cfile = []; for i = 1:length(numfile) nomefile = a(numfile(i)).name; lfile = length(nomefile); extent = nomefile(max(1,lfile-2):lfile); extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat') | strcmpi(extent,'txt') | strcmpi(extent,'.cf'), if isfile(nomefile,'BUS DATA FOLLOW',20) cfile{jfile,1} = a(numfile(i)).name; jfile = jfile + 1; end end end if isempty(cfile), cfile = {'empty'}; else, cfile = sort(cfile); end set(gcbo,'String',cfile,'Value',1); %================================================================== 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 '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)a = 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 1 % IEEE Common Data Format 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 2 % CYME Format 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 3 % MatPower Format extent = nomefile(lfile); if strcmpi(extent,'m') if isfile(nomefile,'baseMVA',5), add_file = 1; end end case 4 % PSAT Format extent = nomefile(lfile); if strcmpi(extent,'m') & strcmp(nomefile(1),'d') if isfile(nomefile,'Bus.con',15), add_file = 1; end end case 5 % PST Format extent = nomefile(lfile); if strcmpi(extent,'m') & strcmp(nomefile(1),'d') if isfile(nomefile,'bus = [',50), add_file = 1; end end case 6 % WSCC Format 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; end end case 7 % PTI Format 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 8 % PSAP Format 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 9 % Eurostag Format extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), if isfile(nomefile,'HEADER ',20), add_file = 1; end end case 10 % BPA Format extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), if isfile(nomefile,'/NETWORK_DATA\',20), add_file = 1; end end case 11 % TH Format 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 12 extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'dat'), if isfile(nomefile,'VNOM',25), add_file = 1; end end case 13 extent = nomefile(max(1,lfile-7):lfile); if strcmpi(extent,'_vst.dat'), add_file = 1; end case 14 extent = nomefile(max(1,lfile-6):lfile); if strcmpi(extent,'.optpow') | strcmpi(extent,'.dynpow') add_file = 1; end case 15 extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.ndt'), add_file = 1; end case 16 extent = nomefile(max(1,lfile-2):lfile); if strcmpi(extent,'.dz'), add_file = 1; end case 17 extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.aux'), add_file = 1; end case 18 % Pet extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.pet'), add_file = 1; end case 19 % Flowdemo.net extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.fdn'), add_file = 1; end case 20 % GE EPC extent = nomefile(max(1,lfile-3):lfile); if strcmpi(extent,'.epc'), add_file = 1; end otherwise % All files add_file = 1; 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,pres_fm)global Settings Pathif Settings.hostver < 6.5 if strcmp(program_name,'IEEE CDF') check = fm_cdf(file_name,pwd,pres_fm); else fm_choice(['Filter for ',program_name, ... ' data format not available for' ... 'Matlab version ',Settings.hostver,'.'],2) endelse results = perl([Path.filters,filter_name],file_name); % split line of result string idx = [0,findstr(results,char(10))]; out = cell(length(idx)-1,1); for i = 2:length(idx) out{i-1,1} = results([idx(i-1)+1:idx(i)-1]); end fm_disp(out) if ~isempty(findstr(results,'completed')), check = 1; else check = 0; endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -