⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_main.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
📖 第 1 页 / 共 3 页
字号:
function fig = fm_main(varargin)
% FM_MAIN create the main GUI for PSAT
%
% HDL = FM_MAIN()
%
%see general purpose structures for settings
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Update:    10-Feb-2003
%Update:    27-Feb-2003
%Update:    29-Jul-2003
%Version:   1.0.3
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano
%
% Copyright (C) 2002-2006 Federico Milano

global Settings Path File History
global Hdl Theme Fig

if exist('simulink') ~= 5
  fmlib = 'fm_choice(''Simulink is not available on this system'',2)';
else
  fmlib = 'fm_lib';
end

if nargin
  if ~exist('Fig'), Fig.main = 0, end
  if ~Fig.main
    Fig.main = findobj(get(0,'Children'),'FileName','fm_main');
  end
  switch varargin{1}

   case 'buttondown'

    pos = get(Fig.main,'CurrentPoint');
    if pos(1) > 0.04064 & pos(2) > 0.1152 & pos(1) < 0.2943 & pos(2) < 0.3395
      if ~exist('Hdl'), return, end
      if Hdl.status ~= 0,
        delete(Hdl.status)
        Hdl.status = 0;
      elseif strcmp(get(Fig.main,'SelectionType'),'open')
        fm_about
      end
    elseif pos(1) > 0.0406404 & pos(2) > 0.0358255 & pos(1) < 0.9618 & pos(2) < 0.0794
      if strcmp(get(Fig.main,'SelectionType'),'open'), fm_hist, end
    elseif pos(1) > 0.098522 & pos(2) > 0.7180 & pos(1) <  0.5751 & pos(2) < 0.7569
      if strcmp(get(Fig.main,'SelectionType'),'open'),
        fm_set setpert,
      end
    elseif pos(1) > 0.098522 & pos(2) > 0.8317 & pos(1) < 0.5751 & pos(2) < 0.8706
      if strcmp(get(Fig.main,'SelectionType'),'open'),
        fm_set setdata,
      end
    end

   case 'buttonmotion'

    pos = get(Fig.main,'CurrentPoint');
    if pos(1) > 0.04064 & pos(2) > 0.1152 & pos(1) < 0.2943 & pos(2) < 0.3395
      set(Fig.main,'Pointer','custom');
    elseif pos(1) > 0.0406404 & pos(2) > 0.0358255 & pos(1) < 0.9618 & pos(2) < 0.0794
      set(Fig.main,'Pointer','custom');
    elseif pos(1) > 0.098522 & pos(2) > 0.7180 & pos(1) <  0.5751 & pos(2) < 0.7569
      set(Fig.main,'Pointer','custom');
    elseif pos(1) > 0.098522 & pos(2) > 0.8317 & pos(1) < 0.5751 & pos(2) < 0.8706
      set(Fig.main,'Pointer','custom');
    else
      set(Fig.main,'Pointer','ibeam'); % this solves a bug with Red
                                       % Hat 9 and Gnome 2
      set(Fig.main,'Pointer','arrow');
    end

  end
  return
end

if Fig.main
  figure(Fig.main)
  return
end
load finger

simversion = '5.1 (R13SP1)';
allowsimconv = 1;

h0 = figure('Color',Theme.color01, ...
            'Units','normalized', ...
            'CreateFcn','Fig.main = gcf;', ...
            'DeleteFcn','fm_set delete', ...
            'FileName','fm_main', ...
            'KeyPressFcn','fm_set keypress', ...
            'MenuBar','none', ...
            'MinColormap', 256, ...
            'Name',['PSAT ',Settings.version], ...
            'NumberTitle','off', ...
            'PaperPosition',[18 180 576 432], ...
            'PaperType','A4', ...
            'PaperUnits','points', ...
            'PointerShapeCData',finger, ...
            'Position',sizefig(0.6348,0.6276), ...
            'RendererMode','manual', ...
            'Resize','on', ...
            'ShareColors', 'on', ...
            'Tag','Settings', ...
            'ToolBar','none', ...
            'UserData', 1, ...
            'WindowButtonDownFcn','fm_main buttondown', ...
            'WindowButtonMotionFcn','fm_main buttonmotion');
fm_set colormap

% Menu File/Open
h1 = uimenu('Parent',h0, ...
            'Label','File', ...
            'Tag','MenuFile');

h2 = uimenu('Parent',h1, ...
            'Label', 'Open', ...
            'Tag','FileOpen');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set setdata', ...
            'Label', 'Data File', ...
            'Tag','OpenData', ...
            'Accelerator','d');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set setpert', ...
            'Label', 'Perturbation File', ...
            'Tag','OpenPert', ...
            'Accelerator','j');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set opensys', ...
            'Label', 'Saved System', ...
            'Tag','OpenLF', ...
            'Accelerator','y');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_simrep(''ViewModel'',0,0)', ...
            'Label', 'Current Simulink model', ...
            'Tag','OpenSimModel', ...
            'Accelerator','0');

% Menu File/Save
h2 = uimenu('Parent',h1, ...
            'Label', 'Save', ...
            'Tag','FileSave');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set savesys', ...
            'Label', 'Current System', ...
            'Tag','SaveLF', ...
            'Accelerator','a');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set savedata', ...
            'Label', 'Restore Data File', ...
            'Tag','SaveD', ...
            'Accelerator','r');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set appendV', ...
            'Label', 'Append Voltages', ...
            'Tag','SaveV');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_set savesettings', ...
            'Label', 'Settings', ...
            'Tag','SaveS');
h3 = uimenu('Parent',h2, ...
            'Callback','fm_simsave(''fm_lib.mdl'',Path.psat)', ...
            'Label', ['Library as Simulink ', simversion], ...
            'Tag','SaveS');
if ~allowsimconv, set(h3,'Enable','off'), end
h3 = uimenu('Parent',h2, ...
            'Callback','fm_simsave', ...
            'Label',['Save model as Simulink ',simversion], ...
            'Tag','ToolsSIMMOD');
if ~allowsimconv, set(h3,'Enable','off'), end
h3 = uimenu('Parent',h2, ...
            'Callback','fm_simsave(''all'')', ...
            'Label',['Save all models in folder as Sim. ',simversion], ...
            'Tag','ToolsALLSIM');
if ~allowsimconv, set(h3,'Enable','off'), end
h2 = uimenu('Parent',h1, ...
            'Callback','fm_set closepert', ...
            'Label','Discard Perturbation File', ...
            'Tag','PertClose', ...
            'Separator','on');

h2 = uimenu('Parent',h1, ...
            'Callback','close(gcf)', ...
            'Label','Close', ...
            'Tag','FileClose', ...
            'Separator','on', ...
            'Accelerator','q');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_set exit', ...
            'Label','Exit', ...
            'Tag','NetSett', ...
            'Accelerator','x');

% Menu Edit
h1 = uimenu('Parent',h0, ...
            'Label','Edit', ...
            'Tag','MenuEdit');
h2 = uimenu('Parent',h1, ...
            'Callback',fmlib, ...
            'Label', 'Simulink Library', ...
            'Tag','NetEdit', ...
            'Accelerator','s');
a = dir([Path.psat,filesep,'*.mdl']);
a = {a.name}';
idx = strmatch('fm_xlib',a);
for i = 2:length(idx)
  h2 = uimenu('Parent',h1, ...
	      'Callback',strrep(a{idx(i)},'.mdl',''), ...
	      'Label',['Extra Library #',num2str(i-1)], ...
	      'Tag',['NetEdit',num2str(i)]);
end
h2 = uimenu('Parent',h1, ...
            'Callback','fm_simset', ...
            'Label','Simulink Model Settings', ...
            'Tag','NetSett');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_setting', ...
            'Label','General Settings', ...
            'Tag','ToolSett', ...
            'Separator','on', ...
            'Accelerator','k');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_plotsel', ...
            'Label','Select Plot Variables', ...
            'Tag','PlotSetVar');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_snbfig', ...
            'Label','SNB Settings', ...
            'Tag','ToolSNBSett', ...
            'Accelerator','g');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_libfig', ...
            'Label', 'LIB Settings', ...
            'Tag','ToolLIBSett', ...
            'Accelerator','l');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_cpffig', ...
            'Label','CPF Settings', ...
            'Tag','ToolOPFSett', ...
            'Accelerator','i');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_opffig', ...
            'Label','OPF Settings', ...
            'Tag','ToolCPFSett', ...
            'Accelerator','z');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_set setdefault', ...
            'Label','Set Default', ...
            'Tag','ToolDef');

% Menu Run
h1 = uimenu('Parent',h0, ...
            'Label','Run', ...
            'Tag','MenuRun');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_set lf', ...
            'Label','Power Flow', ...
            'Tag','RunPF', ...
            'Accelerator','p');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_snb', ...
            'Label','Saddle-Node Bifurcation', ...
            'Tag','ViewSNB');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_limit', ...
            'Label','Limit-Induced Bifurcation', ...
            'Tag','ViewLIB');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_cpf(''cpf'');', ...
            'Label','Continuation Power Flow', ...
            'Tag','ViewCPF', ...
            'Accelerator','c');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_set opf', ...
            'Label','Optimal Power Flow', ...
            'Tag','ViewOPF', ...
            'Accelerator','o');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_n1cont', ...
            'Label','N-1 Contingency Analysis', ...
            'Tag','ViewN1C');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_eigfig', ...
            'Label','Eigenvalue Analysis', ...
            'Tag','ViewEIG', ...
            'Separator','on', ...
            'Accelerator','e');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_int', ...
            'Label','Time Simulation', ...
            'Tag','RunTime', ...
            'Accelerator','t');

% Menu Tools
h1 = uimenu('Parent',h0, ...
            'Label','Tools', ...
            'Tag','Tool');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_dir(0)', ...
            'Label','Data Format Conversion', ...
            'Tag','ToolDir', ...
            'Accelerator','f');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_comp copen', ...
            'Label','Component Browser', ...
            'Tag','ToolComp', ...
            'Accelerator','b');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_snap', ...
            'Label','Snapshots', ...
            'Tag','ToolSnap', ...
            'Accelerator','n');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_pmufig', ...
            'Label','PMU placement', ...
            'Tag','ToolsPMU', ...
            'Accelerator','u');
%h2 = uimenu('Parent',h1, ...
%            'Callback','fm_pcode', ...
%            'Label','Archive (p-code)', ...
%            'Tag','ToolsPCODE', ...
%            'Separator','on');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_laprint', ...
            'Label','LaTeX Print', ...
            'Tag','ToolsLaPrint', ...
            'Separator','on');

% Menu Interfaces
h1 = uimenu('Parent',h0, ...
            'Label','Interfaces', ...
            'Tag','Interface');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_gamsfig', ...
            'Label','GAMS', ...
            'Accelerator', '1', ...
            'Tag','InterGams');
h2 = uimenu('Parent',h1, ...
            'Callback','fm_uwfig', ...
            'Label','UWPFLOW', ...
            'Accelerator','2', ...
            'Tag','InterGams');

% Menu View
h1 = uimenu('Parent',h0, ...
            'Label','View', ...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -