classdef SCDclass_wrapper < SCDclass_component
  % Wrapper class containing algos
  methods
    function obj = SCDclass_wrapper(name,dt)
      if nargin<2, dt=1e-3; end % default wrapper period
      
      obj.name    = name;
      obj.algos   = [];
      obj.ddname  = [name,'.sldd'];
      obj.mdlname = [name,'.slx'];
      obj.timing  = struct('dt',dt);
      assert(~isempty(which(obj.mdlname)),...
        'could not find %s for SCD component %s',obj.mdlname,obj.name);
    end
    
    function updatetemplatetp(obj)
      % update node algos tunable parameters
      for ii=1:numel(obj.algos)
        if isempty(obj.algos(ii)), continue; end
        obj.algos(ii).updatetemplatetp;
      end
    end
    
    function printinfo(obj)
      fprintf('%s, dt=%5.3f[ms]\n',obj.name,obj.timing.dt*1e3);
      fprintf('   Algos:');
      if isempty(obj.algos), fprintf('  none'); end
      fprintf('\n');
      for ii=1:numel(obj.algos)
        myalgo = obj.algos(ii);
        fprintf('  %9s%s\n','',myalgo.getname);
      end
    end
    
    function init(obj)
        for ii=1:numel(obj.algos)
            obj.algos(ii).init;
        end
    end
    
    function setup(obj)
        for ii=1:numel(obj.algos)
            obj.algos(ii).setup;
        end
    end
    
    
  end
end