classdef fluidstep < handle
    properties
        name % collect flush flow, etc
        duration
        pumpspeed
        av
        % pause % TODO: It'd be convenient to pause in the middle of, say,
        % injecting a solution and wait for user input (e.g. Yes, sample is
        % injected, or switching to continuous flow at the end of an experiment)
    end
    
    methods
        
        function obj = fluidstep(name, duration, pumpspeed, av)% , pause)
            obj.name = name;
            obj.duration = duration;
            obj.pumpspeed = pumpspeed;
            obj.av = av;
            % obj.pause = pause;
        end
                
        function str = getfluidstepstring(obj)
            str = obj.name + ' ' + obj.duration + ' ' + obj.pumpspeed + ' ' + obj.av;
        end
        
        function data = getcommanddata(obj)
            data = commanddata();
            data.Name = obj.name;
            data.Duration = obj.duration;
            data.Pumpspeed = obj.pumpspeed;
            data.AV = obj.av;
        end
        
        function data = addcommanddata(obj, data)
            data.Name = obj.name;
            data.Duration = obj.duration;
            data.Pumpspeed = obj.pumpspeed;
            data.AV = obj.av;
        end
    end
    
    methods (Static)
        function obj = setfromcommanddata(data)
            nm = lower(data.Name);
            dur = data.Duration;
            speed = data.Pumpspeed;
            a_v = data.AV;
            obj = fluidstep(nm, dur, speed, a_v);
        end
        
        function obj = setfromstring(str)
            obj = setfromcells(textscan(str, '%s %u %u %s'));
        end
        
        function obj = setfromcells(cells)
            name = cells{1};
            duration = cells{2};
            pumpspeed = cells{3};
            av = cells{4};
            obj = fluidstep(name, duration, pumpspeed, av);
        end
        
        function obj = copy(cp)
            name = cp.name;
            duration = cp.duration;
            pumpspeed = cp.pumpspeed;
            av = cp.av;
            obj = fluidstep(name, duration, pumpspeed, av);
        end
        
    end
end