Home > matpower7.0 > lib > 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 being executed
   (additional arguments) some stages require additional arguments.

   Example:
       mpc = om.get_mpc();
       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 being executed
0007 %   (additional arguments) some stages require additional arguments.
0008 %
0009 %   Example:
0010 %       mpc = om.get_mpc();
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 https://matpower.org 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         rv = feval(userfcn.(stage)(k).fcn, rv, varargin{2:end}, args);
0033         % mpc     = userfcn_*_ext2int(mpc, mpopt, args);
0034         % om      = userfcn_*_formulation(om, mpopt, args);
0035         % results = userfcn_*_int2ext(results, mpopt, args);
0036         % results = userfcn_*_printpf(results, fd, mpopt, args);
0037         % mpc     = userfcn_*_savecase(mpc, fd, prefix, args);
0038     end
0039 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005