Home > matpower6.0 > run_userfcn.m

run_userfcn

PURPOSE ^

RUN_USERFCN Runs the userfcn callbacks for a given stage.

SYNOPSIS ^

function rv = run_userfcn(userfcn, stage, varargin)

DESCRIPTION ^

RUN_USERFCN   Runs the userfcn callbacks for a given stage.
   RV = RUN_USERFCN(USERFCN, STAGE, VARARGIN)

   USERFCN : the 'userfcn' field of mpc, populated by ADD_USERFCN
   STAGE   : the name of the callback stage begin executed
   (additional arguments) some stages require additional arguments.

   Example:
       mpc = get_mpc(om);
       om = run_userfcn(mpc.userfcn, 'formulation', om);

   See also ADD_USERFCN, REMOVE_USERFCN, TOGGLE_RESERVES, TOGGLE_IFLIMS,
   RUNOPF_W_RES.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function rv = run_userfcn(userfcn, stage, varargin)
0002 %RUN_USERFCN   Runs the userfcn callbacks for a given stage.
0003 %   RV = RUN_USERFCN(USERFCN, STAGE, VARARGIN)
0004 %
0005 %   USERFCN : the 'userfcn' field of mpc, populated by ADD_USERFCN
0006 %   STAGE   : the name of the callback stage begin executed
0007 %   (additional arguments) some stages require additional arguments.
0008 %
0009 %   Example:
0010 %       mpc = get_mpc(om);
0011 %       om = run_userfcn(mpc.userfcn, 'formulation', om);
0012 %
0013 %   See also ADD_USERFCN, REMOVE_USERFCN, TOGGLE_RESERVES, TOGGLE_IFLIMS,
0014 %   RUNOPF_W_RES.
0015 
0016 %   MATPOWER
0017 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0018 %   by Ray Zimmerman, PSERC Cornell
0019 %
0020 %   This file is part of MATPOWER.
0021 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0022 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0023 
0024 rv = varargin{1};
0025 if ~isempty(userfcn) && isfield(userfcn, stage)
0026     for k = 1:length(userfcn.(stage))
0027         if isfield(userfcn.(stage)(k), 'args')
0028             args = userfcn.(stage)(k).args;
0029         else
0030             args = [];
0031         end
0032         switch stage
0033             case {'ext2int', 'formulation', 'int2ext'}
0034                 % mpc     = userfcn_*_ext2int(mpc, args);
0035                 % om      = userfcn_*_formulation(om, args);
0036                 % results = userfcn_*_int2ext(results, args);
0037                 rv = feval(userfcn.(stage)(k).fcn, rv, args);
0038             case {'printpf', 'savecase'}
0039                 % results = userfcn_*_printpf(results, fd, mpopt, args);
0040                 % mpc     = userfcn_*_savecase(mpc, fd, prefix, args);
0041                 rv = feval(userfcn.(stage)(k).fcn, rv, varargin{2}, varargin{3}, args);
0042         end
0043     end
0044 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005