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

📄 fm_setting.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
📖 第 1 页 / 共 2 页
字号:
function fig = fm_setting(varargin)
% FM_SETTING create GUI for general settings
%
% HDL = FM_SETTING()
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Version:   1.0.0
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano
%
% Copyright (C) 2002-2006 Federico Milano

global Settings Theme Fig

if nargin
  switch varargin{1}
   case 'tstep'

    if isempty(str2num(get(gcbo,'String')))
      set(gcbo,'String',num2str(Settings.tstep));
      fm_disp('Time step cannot be empty.',2)
    else
      oldtstep = Settings.tstep;
      Settings.tstep = str2num(get(gcbo,'String'));
      if Settings.tstep == 0
        Settings.tstep = oldtstep;
        set(gcbo,'String',num2str(Settings.tstep));
        fm_disp('Time step cannot be zero.',2)
      elseif Settings.tstep < 0
        Settings.tstep = oldtstep;
        set(gcbo,'String',num2str(Settings.tstep));
        fm_disp('Time step cannot be negative.',2)
      end
      fm_disp(['Time step set to ',num2str(Settings.tstep),' s'])
    end

   case 'deltadelta'

    if isempty(str2num(get(gcbo,'String')))
      set(gcbo,'String',num2str(Settings.deltadelta));
      fm_disp('Max delta diff. cannot be empty.',2)
    else
      olddiff = Settings.deltadelta;
      Settings.deltadelta = str2num(get(gcbo,'String'));
      if Settings.deltadelta == 0
        Settings.deltadelta = olddiff;
        set(gcbo,'String',num2str(Settings.deltadelta));
        fm_disp('Max delta diff. cannot be zero.',2)
      elseif Settings.deltadelta < 0
        Settings.deltadelta = olddiff;
        set(gcbo,'String',num2str(Settings.deltadelta));
        fm_disp('Max delta diff. cannot be negative.',2)
      end
      fm_disp(['Max delta diff. set to ',num2str(Settings.deltadelta),' s'])
    end

   case 'checkdelta'

    Settings.checkdelta = get(gcbo,'Value');
    hdl = findobj(gcf,'Tag','EditTextDelta');
    if Settings.checkdelta
      set(hdl,'Enable','on');
    else
      set(hdl,'Enable','off');
    end

   case 'simulink'

    Settings.simtd = get(gcbo,'Value');
    hdl = findobj(gcf,'Tag','EditTextDelta');
    if Settings.simtd
      set(hdl,'Enable','on');
    else
      set(hdl,'Enable','off');
    end

   case 'fixt'

    Settings.fixt = get(gcbo,'Value');
    hdl = findobj(gcf,'Tag','EditTextTimeStep');
    if Settings.fixt
      set(hdl,'Enable','on');
    else
      set(hdl,'Enable','off');
    end

   case 'setplot'

    Settings.plot = get(gcbo,'Value');
    hdlvar = findobj(gcbf,'Tag','PopupMenu2');
    if Settings.plot
      set(hdlvar,'Enable','on');
      set(hdlvar,'Value',1);
      Settings.plottype = 1;
    else
      set(hdlvar,'Enable','off');
    end

   case 'setvscomp'

    % This is for enforce the computation of trajectories
    % during time domain simulations.
    % This option is currently undocumented.

    Settings.vs = get(gcbo,'Value');
    hdlvar = findobj(gcbf,'Tag','PopupMenu2');
    aaa = get(hdlvar,'Value');
    if Settings.vs == 0 & aaa == 6
      set(hdlvar,'Value',1);
      Settings.plottype = 1;
    end

   case 'setplotvar'

    Settings.plottype = get(gcbo,'Value');
    if Settings.plottype == 6 & Settings.vs == 0
      fm_disp(['You can plot voltage stability indices only if you ' ...
               'select Voltage Stability Computations'],2)
      set(gcbo,'Value',1);
      Settings.plottype = 1;
    end

  end
end

if Fig.setting, figure(Fig.setting), return, end

methods = {'Forward Euler'; ...
           'Trapezoidal Rule'};
plottype = {'State Variables'; ...
            'Node Voltages'; ...
            'Node Phases'; ...
            'Active Power'; ...
            'Reactive Power'; ...
            'Voltage Stability Indices'};
pfsolver = {'NR method', ...
            'XB FDPF', ...
            'BX FDPF'};

N = 10.75;
D = (N+3)*0.039+0.0244;
d1 = 1.1*1/(2*N+3);
d2 = 1.2*d1;

h0 = figure('Color',Theme.color01, ...
            'Units', 'normalized', ...
            'ColorMap', [], ...
            'CreateFcn','Fig.setting = gcf;', ...
            'DeleteFcn','Fig.setting = 0;', ...
            'FileName','fm_setting', ...
            'MenuBar','none', ...
            'Name','General Settings', ...
            'NumberTitle','off', ...
            'PaperPosition',[18 180 576 432], ...
            'PaperType','A4', ...
            'PaperUnits','points', ...
            'Position',sizefig(0.3906,D), ...
            'RendererMode','manual', ...
            'Tag','Settings', ...
            'ToolBar','none', ...
            'UserData',Settings);

% Menu File
h1 = uimenu('Parent',h0, ...
            'Label','File', ...
            'Tag','MenuFile');
h2 = uimenu('Parent',h1, ...
            'Callback','close(gcf);', ...
            'Label','Save and Exit', ...
            'Tag','OTV', ...
            'Accelerator','s');
h2 = uimenu('Parent',h1, ...
            'Callback','Settings = get(gcf,''UserData''); close(gcf);', ...
            'Label','Discard and Exit', ...
            'Tag','NetSett', ...
            'Accelerator','x', ...
            'Separator','on');

h1 = uicontrol('Parent',h0, ...
               'Units', 'normalized', ...
               'BackgroundColor',Theme.color02, ...
               'ForegroundColor',Theme.color03, ...
               'Position',[0.038 d1 0.92 1-2*d1], ...
               'Style','frame', ...
               'Tag','Frame1');

% Left-hand checkboxes
h1 = uicontrol('Parent',h0, ...
               'Units', 'normalized', ...
               'BackgroundColor',Theme.color02, ...
               'Callback','Settings.distrsw = get(gcbo,''Value'');', ...
               'Position',[0.078  5*d1   0.43    d2], ...
               'String','Use Distributed Slack Bus', ...
               'Style','checkbox', ...
               'Tag','Checkbox6', ...
               'Value',Settings.distrsw);
h1 = uicontrol('Parent',h0, ...
               'Units', 'normalized', ...
               'BackgroundColor',Theme.color02, ...
               'Callback','Settings.static = get(gcbo,''Value'');', ...
               'Position',[0.078     6.5*d1   0.43   d2], ...
               'String','Discard Dynamic Comp.', ...
               'Style','checkbox', ...
               'Tag','Checkbox5', ...
               'Value',Settings.static);
h1 = uicontrol('Parent',h0, ...
               'Units', 'normalized', ...
               'BackgroundColor',Theme.color02, ...
               'Callback','fm_setting checkdelta', ...
               'Position',[0.078   18*d1   0.43  d2], ...
               'String','Stop TDs at max delta', ...
               'Style','checkbox', ...
               'Tag','Checkbox5', ...
               'Value',Settings.checkdelta);
h1 = uicontrol('Parent',h0, ...
               'Units', 'normalized', ...
               'BackgroundColor',Theme.color02, ...
               'Callback','Settings.showlf = get(gcbo,''Value'');', ...
               'Position',[0.078  11*d1   0.43   d2], ...
               'String','Show Power Flow Results', ...
               'Style','checkbox', ...

⌨️ 快捷键说明

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